@erdoai/cli 0.205.1 → 0.207.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.
Files changed (2) hide show
  1. package/dist/index.js +41 -20
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -691,11 +691,14 @@ var ErdoClient = class {
691
691
  }
692
692
  // Daily paid-media and lead performance for one organization, or for every
693
693
  // client org this account manages when organization_slug is omitted.
694
+ // page_event_series entries are "metric=event"; omitted, the server counts
695
+ // visits=pageview, form_starts=form_start, leads_on_page=generate_lead.
694
696
  managerPerformance(params) {
695
697
  const qs = new URLSearchParams();
696
698
  if (params.organization_slug) qs.set("organization_slug", params.organization_slug);
697
699
  if (params.from) qs.set("from", params.from);
698
700
  if (params.to) qs.set("to", params.to);
701
+ for (const entry of params.page_event_series ?? []) qs.append("page_event_series", entry);
699
702
  const q = qs.toString();
700
703
  return this.request(
701
704
  "GET",
@@ -1679,8 +1682,9 @@ var ErdoClient = class {
1679
1682
  `/v1/provider-lead-sources${qs ? `?${qs}` : ""}`
1680
1683
  );
1681
1684
  }
1682
- listProviderLeadSourceForms(connectionId, accountId) {
1685
+ listProviderLeadSourceForms(connectionId, accountId, provider) {
1683
1686
  const q = new URLSearchParams({ connection_id: connectionId, account_id: accountId });
1687
+ if (provider) q.set("provider", provider);
1684
1688
  return this.request(
1685
1689
  "GET",
1686
1690
  `/v1/provider-lead-sources/forms?${q.toString()}`
@@ -4005,13 +4009,19 @@ This key operates every org you manage; target one with X-Organization-ID (or \`
4005
4009
  });
4006
4010
  managed.command("performance").description(
4007
4011
  "Daily spend, traffic and captured leads for the client orgs you manage \u2014 one organization with --organization, otherwise every client. Each advertising source prints its as-of time and the provider day it runs through. A metric whose source dataset is missing or unreadable prints as '-' and is explained under coverage; it is never reported as zero."
4008
- ).option("--organization <slug>", "read one organization instead of every client org").option("--from <YYYY-MM-DD>", "first day to include (inclusive); defaults to 89 days before --to").option("--to <YYYY-MM-DD>", "last day to include (inclusive); defaults to today (UTC)").option("--daily", "one row per organization per day instead of window totals").option("--json", "print the raw JSON result instead of a table").action(
4012
+ ).option("--organization <slug>", "read one organization instead of every client org").option("--from <YYYY-MM-DD>", "first day to include (inclusive); defaults to 89 days before --to").option("--to <YYYY-MM-DD>", "last day to include (inclusive); defaults to today (UTC)").option(
4013
+ "--page-event <metric=event>",
4014
+ "count page events named <event> as <metric> (repeatable); replaces the default visits=pageview, form_starts=form_start, leads_on_page=generate_lead columns",
4015
+ collect,
4016
+ []
4017
+ ).option("--daily", "one row per organization per day instead of window totals").option("--json", "print the raw JSON result instead of a table").action(
4009
4018
  async (opts) => {
4010
4019
  try {
4011
4020
  const res = await new ErdoClient().managerPerformance({
4012
4021
  organization_slug: opts.organization,
4013
4022
  from: opts.from,
4014
- to: opts.to
4023
+ to: opts.to,
4024
+ page_event_series: opts.pageEvent.length > 0 ? opts.pageEvent : void 0
4015
4025
  });
4016
4026
  if (opts.json) {
4017
4027
  print(res);
@@ -4031,6 +4041,14 @@ managed.command("performance").description(
4031
4041
  }
4032
4042
  return sum;
4033
4043
  };
4044
+ const pageColumns = opts.pageEvent.length > 0 ? opts.pageEvent.map((entry) => {
4045
+ const metric = entry.split("=")[0].trim();
4046
+ return { header: metric, pick: (d) => d.page_events?.[metric] ?? null };
4047
+ }) : [
4048
+ { header: "visits", pick: (d) => d.visits },
4049
+ { header: "form starts", pick: (d) => d.form_starts },
4050
+ { header: "page leads", pick: (d) => d.leads_on_page }
4051
+ ];
4034
4052
  if (opts.daily) {
4035
4053
  const rows = [];
4036
4054
  for (const org2 of res.organizations) {
@@ -4040,20 +4058,25 @@ managed.command("performance").description(
4040
4058
  day2.date,
4041
4059
  cell(day2.spend, 2),
4042
4060
  cell(day2.clicks),
4043
- cell(day2.visits),
4044
- cell(day2.form_starts),
4045
- cell(day2.leads_on_page),
4061
+ ...pageColumns.map((column) => cell(column.pick(day2))),
4046
4062
  cell(day2.leads_captured)
4047
4063
  ]);
4048
4064
  }
4049
4065
  }
4050
4066
  printAlignedTable(
4051
- ["organization", "date", "spend", "clicks", "visits", "form starts", "page leads", "leads"],
4067
+ ["organization", "date", "spend", "clicks", ...pageColumns.map((column) => column.header), "leads"],
4052
4068
  rows
4053
4069
  );
4054
4070
  } else {
4055
4071
  printAlignedTable(
4056
- ["organization", "spend", "clicks", "visits", "form starts", "page leads", "leads", "cost/lead"],
4072
+ [
4073
+ "organization",
4074
+ "spend",
4075
+ "clicks",
4076
+ ...pageColumns.map((column) => column.header),
4077
+ "leads",
4078
+ "cost/lead"
4079
+ ],
4057
4080
  res.organizations.map((org2) => {
4058
4081
  const spend = total(org2.days, (d) => d.spend);
4059
4082
  const leads = total(org2.days, (d) => d.leads_captured);
@@ -4062,9 +4085,7 @@ managed.command("performance").description(
4062
4085
  org2.organization_slug,
4063
4086
  cell(spend, 2),
4064
4087
  cell(total(org2.days, (d) => d.clicks)),
4065
- cell(total(org2.days, (d) => d.visits)),
4066
- cell(total(org2.days, (d) => d.form_starts)),
4067
- cell(total(org2.days, (d) => d.leads_on_page)),
4088
+ ...pageColumns.map((column) => cell(total(org2.days, column.pick))),
4068
4089
  cell(leads, 0),
4069
4090
  cell(costPerLead, 2)
4070
4091
  ];
@@ -8426,7 +8447,7 @@ voiceWidgetsCmd.command("realtime-model <widget> <model>").description("Choose t
8426
8447
  }
8427
8448
  });
8428
8449
  var datasetsCmd = program.command("datasets").description("Datasets");
8429
- var providerLeadSourcesCmd = program.command("provider-lead-sources").description("Manage lead sources: LinkedIn lead forms, Google Sheets, webhooks and imports written into a lead dataset");
8450
+ var providerLeadSourcesCmd = program.command("provider-lead-sources").description("Manage lead sources: LinkedIn and Meta lead forms, Google Sheets, webhooks and imports written into a lead dataset");
8430
8451
  providerLeadSourcesCmd.command("list").description("List lead source declarations").option("--provider <provider>", "filter by ad platform provider").option("--account-id <id>", "filter by provider ad account id").action(async (opts) => {
8431
8452
  try {
8432
8453
  print(await new ErdoClient().listProviderLeadSources({ provider: opts.provider, account_id: opts.accountId }));
@@ -8434,16 +8455,16 @@ providerLeadSourcesCmd.command("list").description("List lead source declaration
8434
8455
  fail(e);
8435
8456
  }
8436
8457
  });
8437
- providerLeadSourcesCmd.command("forms").description("List LinkedIn lead forms available on a connected ad account").requiredOption("--connection-id <id>", "native integration id from erdo integrations status linkedin_ads_sync or GET /v1/integrations").requiredOption("--account-id <id>", "numeric LinkedIn ad account id").action(async (opts) => {
8458
+ providerLeadSourcesCmd.command("forms").description("List the lead forms a connected ad account can declare: LinkedIn Lead Gen Forms, or with --provider meta_ads the Instant Forms on the Pages a Meta ad account promotes").option("--provider <provider>", "linkedin_ads (default) or meta_ads").requiredOption("--connection-id <id>", "native integration id from erdo integrations status linkedin_ads_sync (or meta_ads) or GET /v1/integrations").requiredOption("--account-id <id>", "numeric ad account id (a Meta id with or without act_)").action(async (opts) => {
8438
8459
  try {
8439
- print(await new ErdoClient().listProviderLeadSourceForms(opts.connectionId, opts.accountId));
8460
+ print(await new ErdoClient().listProviderLeadSourceForms(opts.connectionId, opts.accountId, opts.provider));
8440
8461
  } catch (e) {
8441
8462
  fail(e);
8442
8463
  }
8443
8464
  });
8444
8465
  providerLeadSourcesCmd.command("set").description(
8445
- "Save a lead source from JSON or flags. A LinkedIn source names a connection, ad account and forms; a google_sheets, webhook or import source names itself and carries a column mapping (use --file). --dry-run previews what it would write and saves nothing."
8446
- ).option("-f, --file <path>", "one JSON declaration object; use - to read from stdin").option("--dataset <slug>", "lead dataset slug").option("--provider <provider>", "linkedin_ads, google_sheets, webhook or import", "linkedin_ads").option("--connection-id <id>", "native integration id from erdo integrations status linkedin_ads_sync or GET /v1/integrations").option("--account-id <id>", "numeric LinkedIn ad account id").option("--form <id>", "LinkedIn lead gen form id (repeatable)", collect, []).option("--name <name>", "a google_sheets, webhook or import source's name").option("--sheet-url <url>", "a google_sheets source's tab, as its address in the browser (open to anyone with the link)").option("--dry-run", "preview what the source would write; save nothing").option("--rotate-secret", "issue a webhook source a new secret").option("--disabled", "save the declaration disabled").option("--create-only", "refuse the save if a source with this name already exists").action(async (opts) => {
8466
+ "Save a lead source from JSON or flags. A LinkedIn or Meta (meta_ads) source names a connection, ad account and forms; a google_sheets, webhook or import source names itself and carries a column mapping (use --file). --dry-run previews what it would write and saves nothing."
8467
+ ).option("-f, --file <path>", "one JSON declaration object; use - to read from stdin").option("--dataset <slug>", "lead dataset slug").option("--provider <provider>", "linkedin_ads, meta_ads, google_sheets, webhook or import", "linkedin_ads").option("--connection-id <id>", "native integration id from erdo integrations status linkedin_ads_sync (or meta_ads) or GET /v1/integrations").option("--account-id <id>", "numeric ad account id (a Meta id with or without act_)").option("--form <id>", "LinkedIn lead gen form or Meta Instant Form id (repeatable)", collect, []).option("--name <name>", "a google_sheets, webhook or import source's name").option("--sheet-url <url>", "a google_sheets source's tab, as its address in the browser (open to anyone with the link)").option("--dry-run", "preview what the source would write; save nothing").option("--rotate-secret", "issue a webhook source a new secret").option("--disabled", "save the declaration disabled").option("--create-only", "refuse the save if a source with this name already exists").action(async (opts) => {
8447
8468
  try {
8448
8469
  let input;
8449
8470
  if (opts.file) {
@@ -8467,18 +8488,18 @@ providerLeadSourcesCmd.command("set").description(
8467
8488
  const provider = typeof input.provider === "string" ? input.provider.trim() : "";
8468
8489
  if (!dataset) throw new Error("dataset must be a non-empty string");
8469
8490
  if (!provider) throw new Error("provider must be a non-empty string");
8470
- if (provider === "linkedin_ads") {
8491
+ if (provider === "linkedin_ads" || provider === "meta_ads") {
8471
8492
  const connectionID = typeof input.connection_id === "string" ? input.connection_id.trim() : "";
8472
8493
  const accountID = typeof input.account_id === "string" ? input.account_id.trim() : "";
8473
8494
  const forms = Array.isArray(input.forms) ? input.forms.filter((form) => typeof form === "string" && form.trim().length > 0) : [];
8474
8495
  if (!connectionID) throw new Error("connection_id must be a non-empty string");
8475
8496
  if (!accountID) throw new Error("account_id must be a non-empty string");
8476
8497
  if (forms.length === 0) throw new Error("forms must contain at least one form");
8477
- print(await new ErdoClient().setProviderLeadSource({ ...input, dataset, provider: "linkedin_ads", connection_id: connectionID, account_id: accountID, forms }));
8498
+ print(await new ErdoClient().setProviderLeadSource({ ...input, dataset, provider, connection_id: connectionID, account_id: accountID, forms }));
8478
8499
  return;
8479
8500
  }
8480
8501
  if (provider !== "google_sheets" && provider !== "webhook" && provider !== "import") {
8481
- throw new Error("provider must be linkedin_ads, google_sheets, webhook or import");
8502
+ throw new Error("provider must be linkedin_ads, meta_ads, google_sheets, webhook or import");
8482
8503
  }
8483
8504
  const name = typeof input.name === "string" ? input.name.trim() : "";
8484
8505
  if (!name) throw new Error("name must be a non-empty string");
@@ -8578,7 +8599,7 @@ providerLeadSourcesCmd.command("import <name> <file>").description(
8578
8599
  fail(e);
8579
8600
  }
8580
8601
  });
8581
- providerLeadSourcesCmd.command("delete").description("Delete a lead source, by --name or by --provider and --account-id. Leads already written stay").option("--name <name>", "a google_sheets, webhook or import source's name").option("--provider <provider>", "ad platform provider", "linkedin_ads").option("--account-id <id>", "numeric provider ad account id").option("--if-updated-at <time>", "delete only the source with this updated_at from list").action(async (opts) => {
8602
+ providerLeadSourcesCmd.command("delete").description("Delete a lead source, by --name or by --provider and --account-id. Leads already written stay").option("--name <name>", "a google_sheets, webhook or import source's name").option("--provider <provider>", "ad platform provider: linkedin_ads or meta_ads", "linkedin_ads").option("--account-id <id>", "numeric provider ad account id").option("--if-updated-at <time>", "delete only the source with this updated_at from list").action(async (opts) => {
8582
8603
  try {
8583
8604
  if (opts.name) {
8584
8605
  print(await new ErdoClient().deleteProviderLeadSource({ name: opts.name, ifUpdatedAt: opts.ifUpdatedAt }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.205.1",
3
+ "version": "0.207.0",
4
4
  "description": "Erdo CLI \u2014 drive datasets, pages, and evals from the terminal or CI",
5
5
  "type": "module",
6
6
  "bin": {