@akson/cortex-analytics 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ var require_package = __commonJS({
8
8
  "package.json"(exports, module) {
9
9
  module.exports = {
10
10
  name: "@akson/cortex-analytics",
11
- version: "0.9.0",
11
+ version: "0.9.1",
12
12
  description: "Unified CLI for Cortex analytics operations across all platforms",
13
13
  type: "module",
14
14
  main: "dist/index.js",
@@ -25,9 +25,9 @@ var require_package = __commonJS({
25
25
  "type-check": "tsc --noEmit"
26
26
  },
27
27
  dependencies: {
28
- "@akson/cortex-gsc": "workspace:*",
29
- "@akson/cortex-gtm": "workspace:*",
30
- "@akson/cortex-posthog": "workspace:*",
28
+ "@akson/cortex-gsc": "^0.5.0",
29
+ "@akson/cortex-gtm": "^3.1.0",
30
+ "@akson/cortex-posthog": "^0.5.0",
31
31
  chalk: "^5.5.0",
32
32
  commander: "^14.0.0",
33
33
  inquirer: "^13.1.0",
@@ -82,8 +82,10 @@ var require_package = __commonJS({
82
82
  });
83
83
 
84
84
  // src/analytics-manager.ts
85
+ import { spawn } from "child_process";
85
86
  import crypto from "crypto";
86
87
  import fs from "fs/promises";
88
+ import { platform } from "os";
87
89
  import {
88
90
  GoogleAdsClient,
89
91
  HistoricalAnalyzer,
@@ -243,13 +245,13 @@ var AnalyticsManager = class {
243
245
  const tableData = [
244
246
  ["Platform", "Status", verbose ? "Message" : ""].filter(Boolean)
245
247
  ];
246
- for (const platform of health) {
247
- const statusColor = platform.status === "healthy" ? chalk.green : chalk.red;
248
- const statusText = platform.status === "healthy" ? "\u2705 Healthy" : "\u274C Error";
248
+ for (const platform2 of health) {
249
+ const statusColor = platform2.status === "healthy" ? chalk.green : chalk.red;
250
+ const statusText = platform2.status === "healthy" ? "\u2705 Healthy" : "\u274C Error";
249
251
  const row = [
250
- platform.platform,
252
+ platform2.platform,
251
253
  statusColor(statusText),
252
- verbose ? platform.message || "" : ""
254
+ verbose ? platform2.message || "" : ""
253
255
  ].filter(Boolean);
254
256
  tableData.push(row);
255
257
  }
@@ -434,8 +436,8 @@ var AnalyticsManager = class {
434
436
  platform_mappings: options.target ? {
435
437
  [options.target]: PLATFORM_MAPPINGS[options.target.toUpperCase()]?.LEAD_GENERATION
436
438
  } : Object.fromEntries(
437
- Object.entries(PLATFORM_MAPPINGS).map(([platform, mapping]) => [
438
- platform.toLowerCase(),
439
+ Object.entries(PLATFORM_MAPPINGS).map(([platform2, mapping]) => [
440
+ platform2.toLowerCase(),
439
441
  mapping.LEAD_GENERATION
440
442
  ])
441
443
  )
@@ -446,8 +448,8 @@ var AnalyticsManager = class {
446
448
  platform_mappings: options.target ? {
447
449
  [options.target]: PLATFORM_MAPPINGS[options.target.toUpperCase()]?.ECOMMERCE
448
450
  } : Object.fromEntries(
449
- Object.entries(PLATFORM_MAPPINGS).map(([platform, mapping]) => [
450
- platform.toLowerCase(),
451
+ Object.entries(PLATFORM_MAPPINGS).map(([platform2, mapping]) => [
452
+ platform2.toLowerCase(),
451
453
  mapping.ECOMMERCE
452
454
  ])
453
455
  )
@@ -1297,9 +1299,9 @@ Total: ${result.data.length} flags`));
1297
1299
  const spinner = ora("Running cross-platform analysis...").start();
1298
1300
  try {
1299
1301
  const results = {};
1300
- for (const platform of options.platforms) {
1301
- spinner.text = `Analyzing ${platform}...`;
1302
- switch (platform) {
1302
+ for (const platform2 of options.platforms) {
1303
+ spinner.text = `Analyzing ${platform2}...`;
1304
+ switch (platform2) {
1303
1305
  case "posthog": {
1304
1306
  if (!this.clients.postHog) {
1305
1307
  const config = loadPostHogConfig();
@@ -1941,6 +1943,21 @@ Applying changes: ${plan.changes.length} operations
1941
1943
  console.log(
1942
1944
  chalk.yellow(" 2. Use GTM UI to publish workspace to production")
1943
1945
  );
1946
+ if (options.open !== false && this.clients.gtm) {
1947
+ try {
1948
+ const gtmConfig = loadGTMConfig();
1949
+ const workspaceId = this.clients.gtm.getCurrentWorkspaceId?.() || options.workspace || "64";
1950
+ const gtmUrl = `https://tagmanager.google.com/#/container/accounts/${gtmConfig.accountId}/containers/${gtmConfig.containerId}/workspaces/${workspaceId}`;
1951
+ console.log(chalk.cyan("\n\u{1F310} Opening GTM workspace in browser..."));
1952
+ console.log(chalk.dim(` ${gtmUrl}`));
1953
+ this.openBrowser(gtmUrl);
1954
+ } catch (browserError) {
1955
+ console.warn(
1956
+ chalk.yellow("\n\u26A0\uFE0F Could not open browser automatically.")
1957
+ );
1958
+ console.log(chalk.dim(" Open GTM manually: https://tagmanager.google.com"));
1959
+ }
1960
+ }
1944
1961
  } catch (error) {
1945
1962
  spinner.fail("Apply failed");
1946
1963
  console.error(
@@ -5232,6 +5249,29 @@ Report template saved to ${options.output}`));
5232
5249
  ...keywordRows
5233
5250
  ].join("\n");
5234
5251
  }
5252
+ /**
5253
+ * Open a URL in the default browser
5254
+ * Cross-platform support for macOS, Windows, and Linux
5255
+ */
5256
+ openBrowser(url) {
5257
+ const os = platform();
5258
+ let command;
5259
+ let args;
5260
+ switch (os) {
5261
+ case "darwin":
5262
+ command = "open";
5263
+ args = [url];
5264
+ break;
5265
+ case "win32":
5266
+ command = "cmd";
5267
+ args = ["/c", "start", url];
5268
+ break;
5269
+ default:
5270
+ command = "xdg-open";
5271
+ args = [url];
5272
+ }
5273
+ spawn(command, args, { stdio: "ignore", detached: true }).unref();
5274
+ }
5235
5275
  };
5236
5276
 
5237
5277
  // src/cli.ts
@@ -5878,7 +5918,7 @@ gtmCmd.command("plan").description("Show changes that would be applied to GTM").
5878
5918
  gtmCmd.command("apply").description("Apply GTM configuration changes").option("-c, --config <path>", "Configuration file path", "gtm.config.yaml").option("-p, --plan <path>", "Apply from saved plan file").option(
5879
5919
  "-w, --workspace <id>",
5880
5920
  "Workspace ID to use (defaults to Default Workspace)"
5881
- ).option("-y, --yes", "Auto-approve changes").option("-v, --verbose", "Enable verbose logging for detailed debugging").action(async (options) => {
5921
+ ).option("-y, --yes", "Auto-approve changes").option("-v, --verbose", "Enable verbose logging for detailed debugging").option("--no-open", "Skip opening GTM workspace in browser after apply").action(async (options) => {
5882
5922
  const manager = new AnalyticsManager();
5883
5923
  await manager.gtmTerraformApply(options);
5884
5924
  });