@canonry/canonry 7.104.0 → 7.104.1

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.
@@ -10,8 +10,8 @@ import {
10
10
  backfillSnapshotAttributionCommand,
11
11
  backfillTrafficClassificationCommand,
12
12
  replayQueryAuditLog
13
- } from "./chunk-T3G44DHS.js";
14
- import "./chunk-FUERP5PU.js";
13
+ } from "./chunk-FYRNKI3A.js";
14
+ import "./chunk-IHY4Q74C.js";
15
15
  import "./chunk-HPFT4IKN.js";
16
16
  import "./chunk-HGMYEDAQ.js";
17
17
  import "./chunk-CJ55MGWI.js";
@@ -19,7 +19,7 @@ import "./chunk-WQQ4TNIY.js";
19
19
  import {
20
20
  backfillProjectAnswerMentions,
21
21
  backfillProjectAnswerMentionsInChunks
22
- } from "./chunk-PL76V2DY.js";
22
+ } from "./chunk-NGGMSNF6.js";
23
23
  import "./chunk-K32GU473.js";
24
24
  import "./chunk-TCXITSDO.js";
25
25
  import "./chunk-BYYP43Q3.js";
@@ -17,7 +17,7 @@ import {
17
17
  mergeGscQueryTotalsWithFallback,
18
18
  readGscQueryDailyRows,
19
19
  readLatestGscDataDate
20
- } from "./chunk-PL76V2DY.js";
20
+ } from "./chunk-NGGMSNF6.js";
21
21
  import {
22
22
  competitors,
23
23
  gbpDailyMetrics,
@@ -47,7 +47,7 @@ function queueServeHandoff() {
47
47
  async function runPendingServeHandoff(format) {
48
48
  if (!pendingServeHandoff) return;
49
49
  pendingServeHandoff = false;
50
- const { serveCommand } = await import("./serve-WDUJ36KJ.js");
50
+ const { serveCommand } = await import("./serve-UHEE443J.js");
51
51
  await serveCommand(format);
52
52
  }
53
53
 
@@ -11,7 +11,7 @@ import {
11
11
  } from "./chunk-HGMYEDAQ.js";
12
12
  import {
13
13
  buildOpenApiDocument
14
- } from "./chunk-PL76V2DY.js";
14
+ } from "./chunk-NGGMSNF6.js";
15
15
  import {
16
16
  DEFAULT_COMPETITOR_AUTO_ALIAS_MODE,
17
17
  MeasurementPortfolioLists,
@@ -732,7 +732,7 @@ var DEMO_CLI_COMMANDS = [{
732
732
  options: { host: stringOption(), port: stringOption(), "trust-proxy": multiStringOption() },
733
733
  allowPositionals: false,
734
734
  run: async (input) => {
735
- const { demoCommand } = await import("./demo-63JTCWN5.js");
735
+ const { demoCommand } = await import("./demo-NKCOCN6Z.js");
736
736
  await demoCommand({
737
737
  host: getString(input.values, "host"),
738
738
  port: getString(input.values, "port"),
@@ -753,7 +753,7 @@ var BACKFILL_CLI_COMMANDS = [
753
753
  allowPositionals: false,
754
754
  supportsDryRun: true,
755
755
  run: async (input) => {
756
- const { backfillAnswerVisibilityCommand } = await import("./backfill-KR2NSPSE.js");
756
+ const { backfillAnswerVisibilityCommand } = await import("./backfill-QD3I5MYX.js");
757
757
  await backfillAnswerVisibilityCommand({
758
758
  project: getString(input.values, "project"),
759
759
  dryRun: input.dryRun,
@@ -770,7 +770,7 @@ var BACKFILL_CLI_COMMANDS = [
770
770
  allowPositionals: false,
771
771
  supportsDryRun: true,
772
772
  run: async (input) => {
773
- const { backfillAnswerMentionsCommand } = await import("./backfill-KR2NSPSE.js");
773
+ const { backfillAnswerMentionsCommand } = await import("./backfill-QD3I5MYX.js");
774
774
  await backfillAnswerMentionsCommand({
775
775
  project: getString(input.values, "project"),
776
776
  dryRun: input.dryRun,
@@ -788,7 +788,7 @@ var BACKFILL_CLI_COMMANDS = [
788
788
  },
789
789
  supportsDryRun: true,
790
790
  run: async (input) => {
791
- const { backfillInsightsCommand } = await import("./backfill-KR2NSPSE.js");
791
+ const { backfillInsightsCommand } = await import("./backfill-QD3I5MYX.js");
792
792
  const usage = "canonry backfill insights <project> [--from-run <id>] [--to-run <id>] [--since <date>] [--dry-run] [--format json]";
793
793
  const project3 = requireProject(input, "backfill insights", usage);
794
794
  await backfillInsightsCommand(project3, {
@@ -808,7 +808,7 @@ var BACKFILL_CLI_COMMANDS = [
808
808
  },
809
809
  allowPositionals: false,
810
810
  run: async (input) => {
811
- const { backfillNormalizedPathsCommand } = await import("./backfill-KR2NSPSE.js");
811
+ const { backfillNormalizedPathsCommand } = await import("./backfill-QD3I5MYX.js");
812
812
  await backfillNormalizedPathsCommand({
813
813
  project: getString(input.values, "project"),
814
814
  format: input.format
@@ -823,7 +823,7 @@ var BACKFILL_CLI_COMMANDS = [
823
823
  },
824
824
  allowPositionals: false,
825
825
  run: async (input) => {
826
- const { backfillAiReferralPathsCommand } = await import("./backfill-KR2NSPSE.js");
826
+ const { backfillAiReferralPathsCommand } = await import("./backfill-QD3I5MYX.js");
827
827
  await backfillAiReferralPathsCommand({
828
828
  project: getString(input.values, "project"),
829
829
  format: input.format
@@ -835,7 +835,7 @@ var BACKFILL_CLI_COMMANDS = [
835
835
  usage: "canonry backfill snapshot-attribution <project> [--dry-run] [--format json]",
836
836
  supportsDryRun: true,
837
837
  run: async (input) => {
838
- const { backfillSnapshotAttributionCommand } = await import("./backfill-KR2NSPSE.js");
838
+ const { backfillSnapshotAttributionCommand } = await import("./backfill-QD3I5MYX.js");
839
839
  const usage = "canonry backfill snapshot-attribution <project> [--dry-run] [--format json]";
840
840
  const project3 = requireProject(input, "backfill snapshot-attribution", usage);
841
841
  await backfillSnapshotAttributionCommand({
@@ -854,7 +854,7 @@ var BACKFILL_CLI_COMMANDS = [
854
854
  allowPositionals: false,
855
855
  supportsDryRun: true,
856
856
  run: async (input) => {
857
- const { backfillTrafficClassificationCommand } = await import("./backfill-KR2NSPSE.js");
857
+ const { backfillTrafficClassificationCommand } = await import("./backfill-QD3I5MYX.js");
858
858
  await backfillTrafficClassificationCommand({
859
859
  project: getString(input.values, "project"),
860
860
  dryRun: input.dryRun,
@@ -1498,7 +1498,7 @@ var DASHBOARD_CLI_COMMANDS = [
1498
1498
  usage: "canonry dashboard reset-password [--format json]",
1499
1499
  help: "Clears the dashboard password from config.yaml, so the dashboard asks for a new one after a restart.\nLocal only: it edits the config file under CANONRY_CONFIG_DIR and does not call the server.",
1500
1500
  run: async (input) => {
1501
- const { resetDashboardPassword } = await import("./dashboard-4GWISEMI.js");
1501
+ const { resetDashboardPassword } = await import("./dashboard-4KP7KKMY.js");
1502
1502
  await resetDashboardPassword({ format: input.format });
1503
1503
  }
1504
1504
  },
@@ -7294,7 +7294,7 @@ var SYSTEM_CLI_COMMANDS = [
7294
7294
  options: { access: stringOption() },
7295
7295
  run: async (input) => {
7296
7296
  if (input.positionals.length > 1) throw usageError("Expected at most one command group");
7297
- const [{ printCliCatalog }, { REGISTERED_CLI_COMMANDS: REGISTERED_CLI_COMMANDS2 }] = await Promise.all([import("./cli-catalog-6B2O2JQE.js"), import("./cli-commands-RJX2UC5L.js")]);
7297
+ const [{ printCliCatalog }, { REGISTERED_CLI_COMMANDS: REGISTERED_CLI_COMMANDS2 }] = await Promise.all([import("./cli-catalog-6B2O2JQE.js"), import("./cli-commands-O46WFSHZ.js")]);
7298
7298
  printCliCatalog(REGISTERED_CLI_COMMANDS2, input.format, input.positionals[0], getString(input.values, "access"));
7299
7299
  }
7300
7300
  },
@@ -7343,7 +7343,7 @@ var SYSTEM_CLI_COMMANDS = [
7343
7343
  },
7344
7344
  allowPositionals: false,
7345
7345
  run: async (input) => {
7346
- const { initCommand } = await import("./init-CLSFH5OL.js");
7346
+ const { initCommand } = await import("./init-WDRQTCKK.js");
7347
7347
  await initCommand({
7348
7348
  force: getBoolean(input.values, "force"),
7349
7349
  ref: getString(input.values, "ref"),
@@ -7398,7 +7398,7 @@ var SYSTEM_CLI_COMMANDS = [
7398
7398
  allowPositionals: false,
7399
7399
  run: async (input) => {
7400
7400
  applyServerEnv(input.values);
7401
- const { serveCommand } = await import("./serve-WDUJ36KJ.js");
7401
+ const { serveCommand } = await import("./serve-UHEE443J.js");
7402
7402
  await serveCommand(input.format);
7403
7403
  }
7404
7404
  },
@@ -8772,8 +8772,8 @@ var AGENT_CLI_COMMANDS = [
8772
8772
  "timeout-ms": stringOption()
8773
8773
  },
8774
8774
  run: async (input) => {
8775
- const { coerceAgentProvider } = await import("./session-M66S3VTK.js");
8776
- const { AERO_TOOL_PROFILES, isAeroToolProfile } = await import("./tools-W63YOE6T.js");
8775
+ const { coerceAgentProvider } = await import("./session-AS2VQ7VL.js");
8776
+ const { AERO_TOOL_PROFILES, isAeroToolProfile } = await import("./tools-YGKVGB5M.js");
8777
8777
  const { agentAsk } = await import("./agent-ask-TF2WTRTO.js");
8778
8778
  const usage = `canonry agent ask <project> "<prompt>" [--provider ${AGENT_PROVIDER_IDS.join("|")}] [--model <id>] [--scope all|read-only] [--profile default|ads-operator] [--context <json>] [--conversation <id>] [--max-tool-calls <n>] [--timeout-ms <ms>] [--format json]`;
8779
8779
  const project3 = requireProject(input, "agent.ask", usage);
@@ -8,7 +8,7 @@ import {
8
8
  reparseStoredResult4,
9
9
  reparseStoredResult5,
10
10
  resolveStoredApiResponse
11
- } from "./chunk-FUERP5PU.js";
11
+ } from "./chunk-IHY4Q74C.js";
12
12
  import {
13
13
  loadConfig
14
14
  } from "./chunk-HPFT4IKN.js";
@@ -25,7 +25,7 @@ import {
25
25
  createRunCompetitorResolver,
26
26
  readMarketCompetitorNames,
27
27
  refreshSnapshotMentionIdentity
28
- } from "./chunk-PL76V2DY.js";
28
+ } from "./chunk-NGGMSNF6.js";
29
29
  import {
30
30
  RawEventSampleEventTypes,
31
31
  auditLog,
@@ -430,7 +430,7 @@ No DB writes performed. Re-run without --dry-run to apply.`);
430
430
  }
431
431
  }
432
432
  async function backfillInsightsCommand(project, opts) {
433
- const { IntelligenceService } = await import("./intelligence-service-TTDFQ2TB.js");
433
+ const { IntelligenceService } = await import("./intelligence-service-DAUXHAOP.js");
434
434
  const config = loadConfig();
435
435
  const db = createClient(config.database);
436
436
  migrate(db);
@@ -7,7 +7,7 @@ import {
7
7
  mergeSplitJourneyVisitors,
8
8
  repairAiReferralArrivalsOnStartup,
9
9
  writeUnrecognizedAgentBuckets
10
- } from "./chunk-PL76V2DY.js";
10
+ } from "./chunk-NGGMSNF6.js";
11
11
  import {
12
12
  AGENT_TRUST_RULES_VERSION,
13
13
  BROWSER_AGENT_BOT_IDS,
@@ -53639,20 +53639,40 @@ function measurementDateRange(days, requestedRange, maxDays = GA4_MAX_SYNC_DAYS)
53639
53639
  startDate.setUTCDate(startDate.getUTCDate() - syncDays);
53640
53640
  return { syncDays, dateRange: { startDate: formatDate(startDate), endDate: formatDate(endDate) } };
53641
53641
  }
53642
+ var GA4_PAGED_READ_ATTEMPTS = 3;
53643
+ function orderByEveryDimension(dimensions) {
53644
+ return dimensions.map(({ name }) => ({ dimension: { dimensionName: name, orderType: "ALPHANUMERIC" } }));
53645
+ }
53642
53646
  async function fetchPagedReport(accessToken, propertyId, baseRequest, pageSize = 1e4) {
53647
+ const request = baseRequest.orderBys?.length ? baseRequest : { ...baseRequest, orderBys: orderByEveryDimension(baseRequest.dimensions) };
53648
+ for (let attempt = 1; attempt <= GA4_PAGED_READ_ATTEMPTS; attempt++) {
53649
+ const rows = await readReportPages(accessToken, propertyId, request, pageSize);
53650
+ if (rows) return rows;
53651
+ ga4Log("info", "paged-report.rows-moved", { propertyId, attempt, attempts: GA4_PAGED_READ_ATTEMPTS });
53652
+ }
53653
+ throw new GA4ApiError(
53654
+ `GA4 report rows moved between pages on ${GA4_PAGED_READ_ATTEMPTS} reads in a row, so no consistent copy could be read. The next sync will try again.`,
53655
+ 502
53656
+ );
53657
+ }
53658
+ async function readReportPages(accessToken, propertyId, request, pageSize) {
53643
53659
  const rows = [];
53660
+ const seen2 = /* @__PURE__ */ new Set();
53644
53661
  let offset = 0;
53645
53662
  for (let page2 = 0; page2 < GA4_MAX_PAGES; page2++) {
53646
- const response = await runReport(accessToken, propertyId, { ...baseRequest, limit: pageSize, offset });
53663
+ const response = await runReport(accessToken, propertyId, { ...request, limit: pageSize, offset });
53664
+ if (!response) throw new GA4ApiError("GA4 returned an empty report response", 502);
53647
53665
  const pageRows = response.rows ?? [];
53666
+ for (const row of pageRows) {
53667
+ const key = JSON.stringify(row.dimensionValues.map(({ value }) => value));
53668
+ if (seen2.has(key)) return null;
53669
+ seen2.add(key);
53670
+ }
53648
53671
  rows.push(...pageRows);
53649
53672
  offset += pageRows.length;
53650
- if (pageRows.length < pageSize || response.rowCount !== void 0 && offset >= response.rowCount) break;
53651
- if (page2 === GA4_MAX_PAGES - 1) {
53652
- throw new Error(`GA4 report truncated: page limit (${GA4_MAX_PAGES}) reached before all rows were fetched`);
53653
- }
53673
+ if (pageRows.length < pageSize || response.rowCount !== void 0 && offset >= response.rowCount) return rows;
53654
53674
  }
53655
- return rows;
53675
+ throw new Error(`GA4 report truncated: page limit (${GA4_MAX_PAGES}) reached before all rows were fetched`);
53656
53676
  }
53657
53677
  async function fetchPagedReportWithTotals(accessToken, propertyId, baseRequest, options) {
53658
53678
  const pageSize = Math.max(1, Math.trunc(options.pageSize));
@@ -53796,106 +53816,50 @@ var AI_REFERRAL_PASSES = [
53796
53816
  function isInvalidGa4Request(error) {
53797
53817
  return error instanceof GA4ApiError && error.status === 400;
53798
53818
  }
53819
+ async function fetchSessionsByDateAndPage(accessToken, propertyId, dateRange, channelGroup) {
53820
+ const rows = await fetchPagedReport(accessToken, propertyId, {
53821
+ dateRanges: [dateRange],
53822
+ dimensions: [{ name: GA4_DIMENSIONS.date }, { name: GA4_DIMENSIONS.landingPagePlusQueryString }],
53823
+ metrics: [{ name: GA4_METRICS.sessions }],
53824
+ dimensionFilter: {
53825
+ filter: {
53826
+ fieldName: GA4_DIMENSIONS.sessionDefaultChannelGrouping,
53827
+ stringFilter: { matchType: "EXACT", value: channelGroup }
53828
+ }
53829
+ }
53830
+ });
53831
+ return new Map(rows.map((row) => [
53832
+ `${row.dimensionValues[0].value}::${row.dimensionValues[1].value}`,
53833
+ parseInt(row.metricValues[0].value, 10) || 0
53834
+ ]));
53835
+ }
53799
53836
  async function fetchTrafficByLandingPage(accessToken, propertyId, days, dateRangeOverride) {
53800
53837
  validateAccessToken2(accessToken);
53801
53838
  validatePropertyId(propertyId);
53802
53839
  const { syncDays, dateRange } = measurementDateRange(days, dateRangeOverride);
53803
53840
  ga4Log("info", "fetch-traffic.start", { propertyId, days: syncDays });
53804
- const PAGE_SIZE = 1e4;
53805
- const rows = [];
53806
- let offset = 0;
53807
- let pageCount = 0;
53808
- while (pageCount < GA4_MAX_PAGES) {
53809
- pageCount++;
53810
- const request = {
53811
- dateRanges: [dateRange],
53812
- dimensions: [
53813
- { name: GA4_DIMENSIONS.date },
53814
- { name: GA4_DIMENSIONS.landingPagePlusQueryString }
53815
- ],
53816
- metrics: [
53817
- { name: GA4_METRICS.sessions },
53818
- { name: GA4_METRICS.totalUsers }
53819
- ],
53820
- limit: PAGE_SIZE,
53821
- offset
53822
- };
53823
- const response = await runReport(accessToken, propertyId, request);
53824
- if (!response) break;
53825
- const pageRows = (response.rows ?? []).map((row) => ({
53826
- date: row.dimensionValues[0].value,
53827
- landingPage: row.dimensionValues[1].value,
53828
- sessions: parseInt(row.metricValues[0].value, 10) || 0,
53829
- organicSessions: 0,
53830
- // populated by organic-only pass below
53831
- directSessions: 0,
53832
- // populated by direct-only pass below
53833
- users: parseInt(row.metricValues[1].value, 10) || 0
53834
- }));
53835
- rows.push(...pageRows);
53836
- const totalRows = response.rowCount;
53837
- offset += pageRows.length;
53838
- if (pageRows.length < PAGE_SIZE || totalRows !== void 0 && offset >= totalRows) break;
53839
- if (pageCount >= GA4_MAX_PAGES) throw new GA4ApiError("GA4 report truncated at the page limit", 502);
53840
- }
53841
- const organicMap = /* @__PURE__ */ new Map();
53842
- let organicOffset = 0;
53843
- let organicPageCount = 0;
53844
- while (organicPageCount < GA4_MAX_PAGES) {
53845
- organicPageCount++;
53846
- const organicRequest = {
53847
- dateRanges: [dateRange],
53848
- dimensions: [{ name: GA4_DIMENSIONS.date }, { name: GA4_DIMENSIONS.landingPagePlusQueryString }],
53849
- metrics: [{ name: GA4_METRICS.sessions }],
53850
- dimensionFilter: {
53851
- filter: {
53852
- fieldName: GA4_DIMENSIONS.sessionDefaultChannelGrouping,
53853
- stringFilter: { matchType: "EXACT", value: "Organic Search" }
53854
- }
53855
- },
53856
- limit: 1e4,
53857
- offset: organicOffset
53858
- };
53859
- const organicResponse = await runReport(accessToken, propertyId, organicRequest);
53860
- if (!organicResponse) break;
53861
- for (const row of organicResponse.rows ?? []) {
53862
- const key = `${row.dimensionValues[0].value}::${row.dimensionValues[1].value}`;
53863
- organicMap.set(key, parseInt(row.metricValues[0].value, 10) || 0);
53864
- }
53865
- const total = organicResponse.rowCount;
53866
- organicOffset += (organicResponse.rows ?? []).length;
53867
- if ((organicResponse.rows ?? []).length < 1e4 || total !== void 0 && organicOffset >= total) break;
53868
- if (organicPageCount >= GA4_MAX_PAGES) throw new GA4ApiError("GA4 organic report truncated at the page limit", 502);
53869
- }
53870
- const directMap = /* @__PURE__ */ new Map();
53871
- let directOffset = 0;
53872
- let directPageCount = 0;
53873
- while (directPageCount < GA4_MAX_PAGES) {
53874
- directPageCount++;
53875
- const directRequest = {
53876
- dateRanges: [dateRange],
53877
- dimensions: [{ name: GA4_DIMENSIONS.date }, { name: GA4_DIMENSIONS.landingPagePlusQueryString }],
53878
- metrics: [{ name: GA4_METRICS.sessions }],
53879
- dimensionFilter: {
53880
- filter: {
53881
- fieldName: GA4_DIMENSIONS.sessionDefaultChannelGrouping,
53882
- stringFilter: { matchType: "EXACT", value: "Direct" }
53883
- }
53884
- },
53885
- limit: 1e4,
53886
- offset: directOffset
53887
- };
53888
- const directResponse = await runReport(accessToken, propertyId, directRequest);
53889
- if (!directResponse) break;
53890
- for (const row of directResponse.rows ?? []) {
53891
- const key = `${row.dimensionValues[0].value}::${row.dimensionValues[1].value}`;
53892
- directMap.set(key, parseInt(row.metricValues[0].value, 10) || 0);
53893
- }
53894
- const total = directResponse.rowCount;
53895
- directOffset += (directResponse.rows ?? []).length;
53896
- if ((directResponse.rows ?? []).length < 1e4 || total !== void 0 && directOffset >= total) break;
53897
- if (directPageCount >= GA4_MAX_PAGES) throw new GA4ApiError("GA4 direct report truncated at the page limit", 502);
53898
- }
53841
+ const rows = (await fetchPagedReport(accessToken, propertyId, {
53842
+ dateRanges: [dateRange],
53843
+ dimensions: [
53844
+ { name: GA4_DIMENSIONS.date },
53845
+ { name: GA4_DIMENSIONS.landingPagePlusQueryString }
53846
+ ],
53847
+ metrics: [
53848
+ { name: GA4_METRICS.sessions },
53849
+ { name: GA4_METRICS.totalUsers }
53850
+ ]
53851
+ })).map((row) => ({
53852
+ date: row.dimensionValues[0].value,
53853
+ landingPage: row.dimensionValues[1].value,
53854
+ sessions: parseInt(row.metricValues[0].value, 10) || 0,
53855
+ organicSessions: 0,
53856
+ // populated by organic-only pass below
53857
+ directSessions: 0,
53858
+ // populated by direct-only pass below
53859
+ users: parseInt(row.metricValues[1].value, 10) || 0
53860
+ }));
53861
+ const organicMap = await fetchSessionsByDateAndPage(accessToken, propertyId, dateRange, "Organic Search");
53862
+ const directMap = await fetchSessionsByDateAndPage(accessToken, propertyId, dateRange, "Direct");
53899
53863
  for (const row of rows) {
53900
53864
  const key = `${row.date}::${row.landingPage}`;
53901
53865
  row.organicSessions = organicMap.get(key) ?? 0;
@@ -54323,54 +54287,38 @@ async function fetchAiReferralPass(accessToken, propertyId, dateRange, pass, cha
54323
54287
  }
54324
54288
  });
54325
54289
  }
54326
- const rows = [];
54327
- let offset = 0;
54328
- let pageCount = 0;
54329
- while (pageCount < GA4_MAX_PAGES) {
54330
- pageCount++;
54331
- const request = {
54332
- dateRanges: [dateRange],
54333
- dimensions: [
54334
- { name: GA4_DIMENSIONS.date },
54335
- { name: pass.sourceDimension },
54336
- { name: pass.mediumDimension },
54337
- { name: GA4_DIMENSIONS.sessionDefaultChannelGrouping },
54338
- { name: GA4_DIMENSIONS.landingPagePlusQueryString }
54339
- ],
54340
- metrics: [
54341
- { name: GA4_METRICS.sessions },
54342
- { name: GA4_METRICS.totalUsers }
54343
- ],
54344
- dimensionFilter: { orGroup: { expressions } },
54345
- limit: PAGE_SIZE,
54346
- offset
54290
+ const rawRows = await fetchPagedReport(accessToken, propertyId, {
54291
+ dateRanges: [dateRange],
54292
+ dimensions: [
54293
+ { name: GA4_DIMENSIONS.date },
54294
+ { name: pass.sourceDimension },
54295
+ { name: pass.mediumDimension },
54296
+ { name: GA4_DIMENSIONS.sessionDefaultChannelGrouping },
54297
+ { name: GA4_DIMENSIONS.landingPagePlusQueryString }
54298
+ ],
54299
+ metrics: [
54300
+ { name: GA4_METRICS.sessions },
54301
+ { name: GA4_METRICS.totalUsers }
54302
+ ],
54303
+ dimensionFilter: { orGroup: { expressions } }
54304
+ }, PAGE_SIZE);
54305
+ return rawRows.map((row) => {
54306
+ const source = row.dimensionValues[1].value;
54307
+ const medium = row.dimensionValues[2].value;
54308
+ const channelGroup = row.dimensionValues[3]?.value ?? "(not set)";
54309
+ const landingPage = row.dimensionValues[4]?.value ?? "(not set)";
54310
+ return {
54311
+ date: row.dimensionValues[0].value,
54312
+ source,
54313
+ medium,
54314
+ trafficClass: classifyAiReferralTrafficClass({ source, medium, channelGroup, landingPage }),
54315
+ channelGroup,
54316
+ landingPage,
54317
+ sessions: parseInt(row.metricValues[0].value, 10) || 0,
54318
+ users: parseInt(row.metricValues[1].value, 10) || 0,
54319
+ sourceDimension: pass.label
54347
54320
  };
54348
- const response = await runReport(accessToken, propertyId, request);
54349
- if (!response) break;
54350
- const pageRows = (response.rows ?? []).map((row) => {
54351
- const source = row.dimensionValues[1].value;
54352
- const medium = row.dimensionValues[2].value;
54353
- const channelGroup = row.dimensionValues[3]?.value ?? "(not set)";
54354
- const landingPage = row.dimensionValues[4]?.value ?? "(not set)";
54355
- return {
54356
- date: row.dimensionValues[0].value,
54357
- source,
54358
- medium,
54359
- trafficClass: classifyAiReferralTrafficClass({ source, medium, channelGroup, landingPage }),
54360
- channelGroup,
54361
- landingPage,
54362
- sessions: parseInt(row.metricValues[0].value, 10) || 0,
54363
- users: parseInt(row.metricValues[1].value, 10) || 0,
54364
- sourceDimension: pass.label
54365
- };
54366
- });
54367
- rows.push(...pageRows);
54368
- const totalRows = response.rowCount;
54369
- offset += pageRows.length;
54370
- if (pageRows.length < PAGE_SIZE || totalRows !== void 0 && offset >= totalRows) break;
54371
- if (pageCount >= GA4_MAX_PAGES) throw new GA4ApiError("GA4 report truncated at the page limit", 502);
54372
- }
54373
- return rows;
54321
+ });
54374
54322
  }
54375
54323
  var SOCIAL_CHANNEL_GROUPS = ["Organic Social", "Paid Social"];
54376
54324
  async function fetchSocialReferrals(accessToken, propertyId, days, dateRangeOverride) {
@@ -54378,56 +54326,37 @@ async function fetchSocialReferrals(accessToken, propertyId, days, dateRangeOver
54378
54326
  validatePropertyId(propertyId);
54379
54327
  const { syncDays, dateRange } = measurementDateRange(days, dateRangeOverride);
54380
54328
  ga4Log("info", "fetch-social-referrals.start", { propertyId, days: syncDays });
54381
- const PAGE_SIZE = 1e3;
54382
- const rows = [];
54383
- let offset = 0;
54384
- let pageCount = 0;
54385
- while (pageCount < GA4_MAX_PAGES) {
54386
- const request = {
54387
- dateRanges: [dateRange],
54388
- dimensions: [
54389
- { name: GA4_DIMENSIONS.date },
54390
- { name: GA4_DIMENSIONS.sessionSource },
54391
- { name: GA4_DIMENSIONS.sessionMedium },
54392
- { name: GA4_DIMENSIONS.sessionDefaultChannelGroup }
54393
- ],
54394
- metrics: [
54395
- { name: GA4_METRICS.sessions },
54396
- { name: GA4_METRICS.totalUsers }
54397
- ],
54398
- dimensionFilter: {
54399
- orGroup: {
54400
- expressions: SOCIAL_CHANNEL_GROUPS.map((value) => ({
54401
- filter: {
54402
- fieldName: GA4_DIMENSIONS.sessionDefaultChannelGroup,
54403
- stringFilter: { matchType: "EXACT", value }
54404
- }
54405
- }))
54406
- }
54407
- },
54408
- limit: PAGE_SIZE,
54409
- offset
54410
- };
54411
- const response = await runReport(accessToken, propertyId, request);
54412
- if (!response) break;
54413
- const pageRows = (response.rows ?? []).map((row) => ({
54414
- date: row.dimensionValues[0].value,
54415
- source: row.dimensionValues[1].value,
54416
- medium: row.dimensionValues[2].value,
54417
- sessions: parseInt(row.metricValues[0].value, 10) || 0,
54418
- users: parseInt(row.metricValues[1].value, 10) || 0,
54419
- channelGroup: row.dimensionValues[3].value
54420
- }));
54421
- rows.push(...pageRows);
54422
- const totalRows = response.rowCount;
54423
- offset += pageRows.length;
54424
- pageCount += 1;
54425
- if (pageRows.length < PAGE_SIZE || totalRows !== void 0 && offset >= totalRows) break;
54426
- if (pageCount >= GA4_MAX_PAGES) throw new GA4ApiError("GA4 report truncated at the page limit", 502);
54427
- }
54428
- for (const row of rows) {
54429
- row.date = compactDateToIso(row.date);
54430
- }
54329
+ const rawRows = await fetchPagedReport(accessToken, propertyId, {
54330
+ dateRanges: [dateRange],
54331
+ dimensions: [
54332
+ { name: GA4_DIMENSIONS.date },
54333
+ { name: GA4_DIMENSIONS.sessionSource },
54334
+ { name: GA4_DIMENSIONS.sessionMedium },
54335
+ { name: GA4_DIMENSIONS.sessionDefaultChannelGroup }
54336
+ ],
54337
+ metrics: [
54338
+ { name: GA4_METRICS.sessions },
54339
+ { name: GA4_METRICS.totalUsers }
54340
+ ],
54341
+ dimensionFilter: {
54342
+ orGroup: {
54343
+ expressions: SOCIAL_CHANNEL_GROUPS.map((value) => ({
54344
+ filter: {
54345
+ fieldName: GA4_DIMENSIONS.sessionDefaultChannelGroup,
54346
+ stringFilter: { matchType: "EXACT", value }
54347
+ }
54348
+ }))
54349
+ }
54350
+ }
54351
+ }, 1e3);
54352
+ const rows = rawRows.map((row) => ({
54353
+ date: compactDateToIso(row.dimensionValues[0].value),
54354
+ source: row.dimensionValues[1].value,
54355
+ medium: row.dimensionValues[2].value,
54356
+ sessions: parseInt(row.metricValues[0].value, 10) || 0,
54357
+ users: parseInt(row.metricValues[1].value, 10) || 0,
54358
+ channelGroup: row.dimensionValues[3].value
54359
+ }));
54431
54360
  ga4Log("info", "fetch-social-referrals.done", { propertyId, rowCount: rows.length });
54432
54361
  return rows;
54433
54362
  }
@@ -23,7 +23,7 @@ import {
23
23
  resolveConfiguredAgentProvider,
24
24
  resolveSessionProviderAndModel,
25
25
  setAeroSystemPrompt
26
- } from "./chunk-MT2LENZA.js";
26
+ } from "./chunk-PU5OA57Z.js";
27
27
  import {
28
28
  answerServiceAdapters,
29
29
  answerServiceDescriptors
@@ -34,7 +34,7 @@ import {
34
34
  buildAeroStateTools,
35
35
  isAeroToolProfile,
36
36
  truncateToolResult
37
- } from "./chunk-SFLSZXLO.js";
37
+ } from "./chunk-756RPVYB.js";
38
38
  import {
39
39
  getGoogleAuthConfig,
40
40
  getGoogleConnection,
@@ -65,7 +65,7 @@ import {
65
65
  openrouterAdapter,
66
66
  perplexityAdapter,
67
67
  startTrafficReclassification
68
- } from "./chunk-FUERP5PU.js";
68
+ } from "./chunk-IHY4Q74C.js";
69
69
  import {
70
70
  classifyUsageSurface,
71
71
  createApiUsageTelemetry,
@@ -165,7 +165,7 @@ import {
165
165
  } from "./chunk-HGMYEDAQ.js";
166
166
  import {
167
167
  IntelligenceService
168
- } from "./chunk-2QWG6HWM.js";
168
+ } from "./chunk-47QPY6Y3.js";
169
169
  import {
170
170
  computeCitedCompetitorDomains,
171
171
  determineCitationState
@@ -322,7 +322,7 @@ import {
322
322
  webhookResponseReason,
323
323
  webhookTargetRefusalReason,
324
324
  writeAuditLog
325
- } from "./chunk-PL76V2DY.js";
325
+ } from "./chunk-NGGMSNF6.js";
326
326
  import {
327
327
  OperationalLogStore,
328
328
  SentimentIdempotencyConflict,
@@ -6453,7 +6453,7 @@ function nonBlank(value) {
6453
6453
  return trimmed ? trimmed : void 0;
6454
6454
  }
6455
6455
  function resolveBuildCommit(env = process.env) {
6456
- const embedded = true ? "bae4b8576b5f9846afcc71da4ea2b4756855b14e" : void 0;
6456
+ const embedded = true ? "ee6935865de0ce3cf161b0ad07289a187633c0e6" : void 0;
6457
6457
  return nonBlank(embedded) ?? nonBlank(env.CANONRY_COMMIT);
6458
6458
  }
6459
6459
  function resolveInstanceIdentity(env = process.env) {
@@ -5,7 +5,7 @@ import {
5
5
  isStoredPageReadTool,
6
6
  isStoredReadTool,
7
7
  truncateToolResult
8
- } from "./chunk-SFLSZXLO.js";
8
+ } from "./chunk-756RPVYB.js";
9
9
  import {
10
10
  CANONRY_MCP_TOOLKITS,
11
11
  resolveAeroSkillDir
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  REGISTERED_CLI_COMMANDS
3
- } from "./chunk-RBAK7RQX.js";
3
+ } from "./chunk-7XJG2OTB.js";
4
4
  import "./chunk-6GO5VVAC.js";
5
5
  import "./chunk-VJWDBFSL.js";
6
6
  import "./chunk-MDRAKMCV.js";
package/dist/cli.js CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node --import tsx
2
2
  import {
3
3
  REGISTERED_CLI_COMMANDS
4
- } from "./chunk-RBAK7RQX.js";
4
+ } from "./chunk-7XJG2OTB.js";
5
5
  import "./chunk-6GO5VVAC.js";
6
6
  import {
7
7
  buildSetupState,
8
8
  runPendingServeHandoff
9
- } from "./chunk-C6RWAAF6.js";
9
+ } from "./chunk-5UHNDYUH.js";
10
10
  import "./chunk-VJWDBFSL.js";
11
11
  import "./chunk-MDRAKMCV.js";
12
12
  import "./chunk-TSENU4GG.js";