@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/cli.js +57 -17
- package/dist/cli.js.map +1 -1
- package/dist/index.js +57 -17
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/cli.js
CHANGED
|
@@ -9,7 +9,7 @@ var require_package = __commonJS({
|
|
|
9
9
|
"package.json"(exports, module) {
|
|
10
10
|
module.exports = {
|
|
11
11
|
name: "@akson/cortex-analytics",
|
|
12
|
-
version: "0.9.
|
|
12
|
+
version: "0.9.1",
|
|
13
13
|
description: "Unified CLI for Cortex analytics operations across all platforms",
|
|
14
14
|
type: "module",
|
|
15
15
|
main: "dist/index.js",
|
|
@@ -26,9 +26,9 @@ var require_package = __commonJS({
|
|
|
26
26
|
"type-check": "tsc --noEmit"
|
|
27
27
|
},
|
|
28
28
|
dependencies: {
|
|
29
|
-
"@akson/cortex-gsc": "
|
|
30
|
-
"@akson/cortex-gtm": "
|
|
31
|
-
"@akson/cortex-posthog": "
|
|
29
|
+
"@akson/cortex-gsc": "^0.5.0",
|
|
30
|
+
"@akson/cortex-gtm": "^3.1.0",
|
|
31
|
+
"@akson/cortex-posthog": "^0.5.0",
|
|
32
32
|
chalk: "^5.5.0",
|
|
33
33
|
commander: "^14.0.0",
|
|
34
34
|
inquirer: "^13.1.0",
|
|
@@ -87,8 +87,10 @@ import chalk3 from "chalk";
|
|
|
87
87
|
import { Command } from "commander";
|
|
88
88
|
|
|
89
89
|
// src/analytics-manager.ts
|
|
90
|
+
import { spawn } from "child_process";
|
|
90
91
|
import crypto from "crypto";
|
|
91
92
|
import fs from "fs/promises";
|
|
93
|
+
import { platform } from "os";
|
|
92
94
|
import {
|
|
93
95
|
GoogleAdsClient,
|
|
94
96
|
HistoricalAnalyzer,
|
|
@@ -248,13 +250,13 @@ var AnalyticsManager = class {
|
|
|
248
250
|
const tableData = [
|
|
249
251
|
["Platform", "Status", verbose ? "Message" : ""].filter(Boolean)
|
|
250
252
|
];
|
|
251
|
-
for (const
|
|
252
|
-
const statusColor =
|
|
253
|
-
const statusText =
|
|
253
|
+
for (const platform2 of health) {
|
|
254
|
+
const statusColor = platform2.status === "healthy" ? chalk.green : chalk.red;
|
|
255
|
+
const statusText = platform2.status === "healthy" ? "\u2705 Healthy" : "\u274C Error";
|
|
254
256
|
const row = [
|
|
255
|
-
|
|
257
|
+
platform2.platform,
|
|
256
258
|
statusColor(statusText),
|
|
257
|
-
verbose ?
|
|
259
|
+
verbose ? platform2.message || "" : ""
|
|
258
260
|
].filter(Boolean);
|
|
259
261
|
tableData.push(row);
|
|
260
262
|
}
|
|
@@ -439,8 +441,8 @@ var AnalyticsManager = class {
|
|
|
439
441
|
platform_mappings: options.target ? {
|
|
440
442
|
[options.target]: PLATFORM_MAPPINGS[options.target.toUpperCase()]?.LEAD_GENERATION
|
|
441
443
|
} : Object.fromEntries(
|
|
442
|
-
Object.entries(PLATFORM_MAPPINGS).map(([
|
|
443
|
-
|
|
444
|
+
Object.entries(PLATFORM_MAPPINGS).map(([platform2, mapping]) => [
|
|
445
|
+
platform2.toLowerCase(),
|
|
444
446
|
mapping.LEAD_GENERATION
|
|
445
447
|
])
|
|
446
448
|
)
|
|
@@ -451,8 +453,8 @@ var AnalyticsManager = class {
|
|
|
451
453
|
platform_mappings: options.target ? {
|
|
452
454
|
[options.target]: PLATFORM_MAPPINGS[options.target.toUpperCase()]?.ECOMMERCE
|
|
453
455
|
} : Object.fromEntries(
|
|
454
|
-
Object.entries(PLATFORM_MAPPINGS).map(([
|
|
455
|
-
|
|
456
|
+
Object.entries(PLATFORM_MAPPINGS).map(([platform2, mapping]) => [
|
|
457
|
+
platform2.toLowerCase(),
|
|
456
458
|
mapping.ECOMMERCE
|
|
457
459
|
])
|
|
458
460
|
)
|
|
@@ -1302,9 +1304,9 @@ Total: ${result.data.length} flags`));
|
|
|
1302
1304
|
const spinner = ora("Running cross-platform analysis...").start();
|
|
1303
1305
|
try {
|
|
1304
1306
|
const results = {};
|
|
1305
|
-
for (const
|
|
1306
|
-
spinner.text = `Analyzing ${
|
|
1307
|
-
switch (
|
|
1307
|
+
for (const platform2 of options.platforms) {
|
|
1308
|
+
spinner.text = `Analyzing ${platform2}...`;
|
|
1309
|
+
switch (platform2) {
|
|
1308
1310
|
case "posthog": {
|
|
1309
1311
|
if (!this.clients.postHog) {
|
|
1310
1312
|
const config = loadPostHogConfig();
|
|
@@ -1946,6 +1948,21 @@ Applying changes: ${plan.changes.length} operations
|
|
|
1946
1948
|
console.log(
|
|
1947
1949
|
chalk.yellow(" 2. Use GTM UI to publish workspace to production")
|
|
1948
1950
|
);
|
|
1951
|
+
if (options.open !== false && this.clients.gtm) {
|
|
1952
|
+
try {
|
|
1953
|
+
const gtmConfig = loadGTMConfig();
|
|
1954
|
+
const workspaceId = this.clients.gtm.getCurrentWorkspaceId?.() || options.workspace || "64";
|
|
1955
|
+
const gtmUrl = `https://tagmanager.google.com/#/container/accounts/${gtmConfig.accountId}/containers/${gtmConfig.containerId}/workspaces/${workspaceId}`;
|
|
1956
|
+
console.log(chalk.cyan("\n\u{1F310} Opening GTM workspace in browser..."));
|
|
1957
|
+
console.log(chalk.dim(` ${gtmUrl}`));
|
|
1958
|
+
this.openBrowser(gtmUrl);
|
|
1959
|
+
} catch (browserError) {
|
|
1960
|
+
console.warn(
|
|
1961
|
+
chalk.yellow("\n\u26A0\uFE0F Could not open browser automatically.")
|
|
1962
|
+
);
|
|
1963
|
+
console.log(chalk.dim(" Open GTM manually: https://tagmanager.google.com"));
|
|
1964
|
+
}
|
|
1965
|
+
}
|
|
1949
1966
|
} catch (error) {
|
|
1950
1967
|
spinner.fail("Apply failed");
|
|
1951
1968
|
console.error(
|
|
@@ -5237,6 +5254,29 @@ Report template saved to ${options.output}`));
|
|
|
5237
5254
|
...keywordRows
|
|
5238
5255
|
].join("\n");
|
|
5239
5256
|
}
|
|
5257
|
+
/**
|
|
5258
|
+
* Open a URL in the default browser
|
|
5259
|
+
* Cross-platform support for macOS, Windows, and Linux
|
|
5260
|
+
*/
|
|
5261
|
+
openBrowser(url) {
|
|
5262
|
+
const os = platform();
|
|
5263
|
+
let command;
|
|
5264
|
+
let args;
|
|
5265
|
+
switch (os) {
|
|
5266
|
+
case "darwin":
|
|
5267
|
+
command = "open";
|
|
5268
|
+
args = [url];
|
|
5269
|
+
break;
|
|
5270
|
+
case "win32":
|
|
5271
|
+
command = "cmd";
|
|
5272
|
+
args = ["/c", "start", url];
|
|
5273
|
+
break;
|
|
5274
|
+
default:
|
|
5275
|
+
command = "xdg-open";
|
|
5276
|
+
args = [url];
|
|
5277
|
+
}
|
|
5278
|
+
spawn(command, args, { stdio: "ignore", detached: true }).unref();
|
|
5279
|
+
}
|
|
5240
5280
|
};
|
|
5241
5281
|
|
|
5242
5282
|
// src/help.ts
|
|
@@ -5879,7 +5919,7 @@ gtmCmd.command("plan").description("Show changes that would be applied to GTM").
|
|
|
5879
5919
|
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(
|
|
5880
5920
|
"-w, --workspace <id>",
|
|
5881
5921
|
"Workspace ID to use (defaults to Default Workspace)"
|
|
5882
|
-
).option("-y, --yes", "Auto-approve changes").option("-v, --verbose", "Enable verbose logging for detailed debugging").action(async (options) => {
|
|
5922
|
+
).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) => {
|
|
5883
5923
|
const manager = new AnalyticsManager();
|
|
5884
5924
|
await manager.gtmTerraformApply(options);
|
|
5885
5925
|
});
|