@erdoai/cli 0.28.0 → 0.30.0
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 +76 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -209,6 +209,12 @@ var ErdoClient = class {
|
|
|
209
209
|
setAutonomyMode(mode) {
|
|
210
210
|
return this.request("PUT", "/v1/autonomy-mode", { mode });
|
|
211
211
|
}
|
|
212
|
+
// Run a read-only HogQL query against the org's page-analytics events. Rows are
|
|
213
|
+
// positional per columns; enabled:false means page analytics is off for the org
|
|
214
|
+
// (not zero traffic). A rejected query surfaces PostHog's message as the error.
|
|
215
|
+
queryPageAnalytics(query) {
|
|
216
|
+
return this.request("POST", "/v1/page-analytics/query", { query });
|
|
217
|
+
}
|
|
212
218
|
listEvalSuites() {
|
|
213
219
|
return this.request("GET", "/v1/evals/suites");
|
|
214
220
|
}
|
|
@@ -690,6 +696,14 @@ var ErdoClient = class {
|
|
|
690
696
|
deployPage(input) {
|
|
691
697
|
return this.request("POST", "/v1/pages", input);
|
|
692
698
|
}
|
|
699
|
+
// Start a review of external page URLs with the real landing critic; returns a
|
|
700
|
+
// review id immediately (poll getPageReview for the typed findings).
|
|
701
|
+
reviewPages(urls) {
|
|
702
|
+
return this.request("POST", "/v1/page-reviews", { urls });
|
|
703
|
+
}
|
|
704
|
+
getPageReview(id) {
|
|
705
|
+
return this.request("GET", `/v1/page-reviews/${encodeURIComponent(id)}`);
|
|
706
|
+
}
|
|
693
707
|
updatePage(pageID, input) {
|
|
694
708
|
return this.request("PUT", `/v1/pages/${encodeURIComponent(pageID)}`, input);
|
|
695
709
|
}
|
|
@@ -2235,6 +2249,41 @@ pagesCmd.command("get <id>").description("Show an artifact").action(async (id) =
|
|
|
2235
2249
|
fail(e);
|
|
2236
2250
|
}
|
|
2237
2251
|
});
|
|
2252
|
+
pagesCmd.command("review <url...>").description(
|
|
2253
|
+
"Review external landing page URLs with Erdo's real conversion critic \u2014 typed defects (severity, issue, why it costs conversions, evidence, fix) plus strengths, judged from fold + full-page captures on desktop and mobile. Returns a review id; use --wait to poll and print the findings."
|
|
2254
|
+
).option("--wait", "poll until the review is ready, then print the findings").action(async (urls, opts) => {
|
|
2255
|
+
try {
|
|
2256
|
+
const client = new ErdoClient();
|
|
2257
|
+
const started = await client.reviewPages(urls);
|
|
2258
|
+
if (!opts.wait) {
|
|
2259
|
+
print(started);
|
|
2260
|
+
return;
|
|
2261
|
+
}
|
|
2262
|
+
const deadline = Date.now() + 15 * 60 * 1e3;
|
|
2263
|
+
process.stderr.write("reviewing");
|
|
2264
|
+
while (Date.now() < deadline) {
|
|
2265
|
+
const res = await client.getPageReview(started.id);
|
|
2266
|
+
if (res.status === "ready" || res.status === "failed") {
|
|
2267
|
+
process.stderr.write("\n");
|
|
2268
|
+
print(res);
|
|
2269
|
+
return;
|
|
2270
|
+
}
|
|
2271
|
+
process.stderr.write(".");
|
|
2272
|
+
await sleep2(5e3);
|
|
2273
|
+
}
|
|
2274
|
+
process.stderr.write("\n");
|
|
2275
|
+
print(await client.getPageReview(started.id));
|
|
2276
|
+
} catch (e) {
|
|
2277
|
+
fail(e);
|
|
2278
|
+
}
|
|
2279
|
+
});
|
|
2280
|
+
pagesCmd.command("review-result <id>").description("Read a page review by id \u2014 its status and, once ready, the typed per-page findings").action(async (id) => {
|
|
2281
|
+
try {
|
|
2282
|
+
print(await new ErdoClient().getPageReview(id));
|
|
2283
|
+
} catch (e) {
|
|
2284
|
+
fail(e);
|
|
2285
|
+
}
|
|
2286
|
+
});
|
|
2238
2287
|
var datasetsCmd = program.command("datasets").description("Datasets");
|
|
2239
2288
|
datasetsCmd.command("list").description("List datasets").action(async () => {
|
|
2240
2289
|
try {
|
|
@@ -2311,6 +2360,33 @@ datasetsCmd.command("from-integration <app>").description("Create a dataset back
|
|
|
2311
2360
|
fail(e);
|
|
2312
2361
|
}
|
|
2313
2362
|
});
|
|
2363
|
+
function printAnalyticsTable(columns, rows) {
|
|
2364
|
+
const cell = (v) => v === null || v === void 0 ? "" : typeof v === "object" ? JSON.stringify(v) : String(v);
|
|
2365
|
+
const widths = columns.map((c, i) => Math.max(c.length, ...rows.map((r) => cell(r[i]).length), 0));
|
|
2366
|
+
const line = (cells) => cells.map((c, i) => c.padEnd(widths[i])).join(" ").trimEnd();
|
|
2367
|
+
console.log(line(columns));
|
|
2368
|
+
console.log(widths.map((w) => "-".repeat(w)).join(" "));
|
|
2369
|
+
for (const r of rows) console.log(line(columns.map((_, i) => cell(r[i]))));
|
|
2370
|
+
}
|
|
2371
|
+
var analytics = program.command("analytics").description("Query page analytics (how published pages perform with real visitors)");
|
|
2372
|
+
analytics.command("query <hogql>").description("Run a read-only HogQL query against this org's page-analytics events").option("--json", "print the raw JSON result instead of a table").action(async (hogql, opts) => {
|
|
2373
|
+
try {
|
|
2374
|
+
const res = await new ErdoClient().queryPageAnalytics(hogql);
|
|
2375
|
+
if (opts.json) {
|
|
2376
|
+
print(res);
|
|
2377
|
+
return;
|
|
2378
|
+
}
|
|
2379
|
+
if (!res.enabled) {
|
|
2380
|
+
console.log("Page analytics is not enabled for this organization \u2014 turn it on in the Erdo app, then query real traffic here.");
|
|
2381
|
+
return;
|
|
2382
|
+
}
|
|
2383
|
+
printAnalyticsTable(res.columns, res.rows);
|
|
2384
|
+
if (res.truncated) console.log(`
|
|
2385
|
+
(rows truncated at the cap \u2014 aggregate further or add a tighter filter/LIMIT)`);
|
|
2386
|
+
} catch (e) {
|
|
2387
|
+
fail(e);
|
|
2388
|
+
}
|
|
2389
|
+
});
|
|
2314
2390
|
var OPERATORS = ["equals", "not_equals", "greater_than", "less_than", "contains", "between"];
|
|
2315
2391
|
function parseCondition(s) {
|
|
2316
2392
|
const m = s.trim().match(/^(\S+)\s+(\S+)\s+([\s\S]+)$/);
|