@erdoai/cli 0.206.0 → 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 +30 -10
  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",
@@ -4006,13 +4009,19 @@ This key operates every org you manage; target one with X-Organization-ID (or \`
4006
4009
  });
4007
4010
  managed.command("performance").description(
4008
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."
4009
- ).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(
4010
4018
  async (opts) => {
4011
4019
  try {
4012
4020
  const res = await new ErdoClient().managerPerformance({
4013
4021
  organization_slug: opts.organization,
4014
4022
  from: opts.from,
4015
- to: opts.to
4023
+ to: opts.to,
4024
+ page_event_series: opts.pageEvent.length > 0 ? opts.pageEvent : void 0
4016
4025
  });
4017
4026
  if (opts.json) {
4018
4027
  print(res);
@@ -4032,6 +4041,14 @@ managed.command("performance").description(
4032
4041
  }
4033
4042
  return sum;
4034
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
+ ];
4035
4052
  if (opts.daily) {
4036
4053
  const rows = [];
4037
4054
  for (const org2 of res.organizations) {
@@ -4041,20 +4058,25 @@ managed.command("performance").description(
4041
4058
  day2.date,
4042
4059
  cell(day2.spend, 2),
4043
4060
  cell(day2.clicks),
4044
- cell(day2.visits),
4045
- cell(day2.form_starts),
4046
- cell(day2.leads_on_page),
4061
+ ...pageColumns.map((column) => cell(column.pick(day2))),
4047
4062
  cell(day2.leads_captured)
4048
4063
  ]);
4049
4064
  }
4050
4065
  }
4051
4066
  printAlignedTable(
4052
- ["organization", "date", "spend", "clicks", "visits", "form starts", "page leads", "leads"],
4067
+ ["organization", "date", "spend", "clicks", ...pageColumns.map((column) => column.header), "leads"],
4053
4068
  rows
4054
4069
  );
4055
4070
  } else {
4056
4071
  printAlignedTable(
4057
- ["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
+ ],
4058
4080
  res.organizations.map((org2) => {
4059
4081
  const spend = total(org2.days, (d) => d.spend);
4060
4082
  const leads = total(org2.days, (d) => d.leads_captured);
@@ -4063,9 +4085,7 @@ managed.command("performance").description(
4063
4085
  org2.organization_slug,
4064
4086
  cell(spend, 2),
4065
4087
  cell(total(org2.days, (d) => d.clicks)),
4066
- cell(total(org2.days, (d) => d.visits)),
4067
- cell(total(org2.days, (d) => d.form_starts)),
4068
- cell(total(org2.days, (d) => d.leads_on_page)),
4088
+ ...pageColumns.map((column) => cell(total(org2.days, column.pick))),
4069
4089
  cell(leads, 0),
4070
4090
  cell(costPerLead, 2)
4071
4091
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@erdoai/cli",
3
- "version": "0.206.0",
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": {