@canonry/canonry 7.55.0 → 7.56.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/README.md +18 -6
- package/assets/agent-workspace/skills/canonry/references/canonry-cli.md +7 -1
- package/assets/assets/{AgentSetupPage-Dr7UsGcq.js → AgentSetupPage-BkKw_in_.js} +3 -3
- package/assets/assets/{AuditHistoryPanel-Dg9ZNNQw.js → AuditHistoryPanel-UtRnS-sh.js} +1 -1
- package/assets/assets/{BacklinksPage-DSgwyFCi.js → BacklinksPage-DCSmuAOQ.js} +1 -1
- package/assets/assets/{ChartPrimitives-DIEeZdrs.js → ChartPrimitives-BgY3tqbD.js} +1 -1
- package/assets/assets/{Hint-Cn4lh0Do.js → Hint-BsfMSR5e.js} +1 -1
- package/assets/assets/{HistoryPage-DaX20IWP.js → HistoryPage-DzpqCNJM.js} +1 -1
- package/assets/assets/{InfoTooltip-TIx9qM5h.js → InfoTooltip-COkeQYiP.js} +1 -1
- package/assets/assets/MeasurementPropertyPage-Dh0BJw_f.js +4 -0
- package/assets/assets/ProjectPage-D-9IeFap.js +7 -0
- package/assets/assets/{RunsPage-D06GJ47B.js → RunsPage-DtllYN3I.js} +1 -1
- package/assets/assets/{SettingsPage-MSgC8Zrc.js → SettingsPage-_p15s-OC.js} +1 -1
- package/assets/assets/SiteHealthSection-BEpXTW3G.js +2 -0
- package/assets/assets/ToneBadge-nxe12_3b.js +60 -0
- package/assets/assets/{TrafficPage-DikPWmaU.js → TrafficPage-wru6cQPP.js} +2 -2
- package/assets/assets/{TrafficSourceDetailPage-C1hfimWW.js → TrafficSourceDetailPage-_XKbd-aS.js} +1 -1
- package/assets/assets/{account-context-CHtJm4fz.js → account-context-BekDho6K.js} +1 -1
- package/assets/assets/{card-BO6dtEV9.js → card-By9JlCCv.js} +1 -1
- package/assets/assets/{extract-error-message-Q9pkEqUE.js → extract-error-message-SMPhaAkr.js} +1 -1
- package/assets/assets/{format-helpers-Gj1ekh6p.js → format-helpers-CVjOUs0j.js} +1 -1
- package/assets/assets/index-BMD46UDb.css +1 -0
- package/assets/assets/index-el2M4tYf.js +56 -0
- package/assets/assets/{query-client-C22j0Z7h.js → query-client-8RITTP1A.js} +1 -1
- package/assets/assets/react-query-BXwc1UHc.js +1 -0
- package/assets/assets/{react-sigma_core.esm.min-j5DWE8Rk.js → react-sigma_core.esm.min-CM12VcoB.js} +1 -1
- package/assets/assets/{service-2DEngBCR.js → service-B0wkGxvy.js} +1 -1
- package/assets/assets/vendor-lucide-CPeGWK5C.js +1 -0
- package/assets/assets/{vendor-markdown-DWjffpgb.js → vendor-markdown-Bdsu1JLE.js} +1 -1
- package/assets/assets/{vendor-radix-BU76HM0G.js → vendor-radix-3k2C0Ly9.js} +1 -1
- package/assets/assets/{vendor-recharts-CsHBXoK8.js → vendor-recharts-CFnqWvWF.js} +1 -1
- package/assets/assets/{vendor-tanstack-QhOrDhIL.js → vendor-tanstack-CXaF1vMI.js} +1 -1
- package/assets/index.html +15 -15
- package/dist/{ads-A5S2NQBZ.js → ads-SPXNKDEW.js} +3 -3
- package/dist/{agent-BV7G7QN7.js → agent-THPYOGXD.js} +7 -7
- package/dist/{agent-ask-5ALAHZ6T.js → agent-ask-VHRA5RVU.js} +3 -3
- package/dist/{agent-conversations-MJPQCJYR.js → agent-conversations-5HXXVMZV.js} +3 -3
- package/dist/{agent-memory-Z3VPA5KH.js → agent-memory-SKBUFHGV.js} +3 -3
- package/dist/{agent-providers-FP3LAZPG.js → agent-providers-TOIA75C6.js} +3 -3
- package/dist/{agent-transcript-4GXCOC73.js → agent-transcript-DFE2PDTS.js} +3 -3
- package/dist/{analytics-TOLSUYSN.js → analytics-JJHPK2TK.js} +3 -3
- package/dist/{apply-EU5JAFVZ.js → apply-AC36NXPF.js} +3 -3
- package/dist/{backfill-3263IYJH.js → backfill-HMP43HMJ.js} +9 -9
- package/dist/{backlinks-XQ5JTN6W.js → backlinks-EKSQJXMS.js} +3 -3
- package/dist/{bing-LYHRD7BF.js → bing-XZQ6CQM4.js} +3 -3
- package/dist/{bootstrap-AKWTIMMH.js → bootstrap-GJUT3AVH.js} +10 -10
- package/dist/{cdp-N4PQJWGQ.js → cdp-QROXKBXS.js} +7 -7
- package/dist/{chunk-75CFTTBF.js → chunk-2Z7FALTN.js} +2 -2
- package/dist/{chunk-GFRIXUDK.js → chunk-37YB52NM.js} +84 -1
- package/dist/{chunk-K5MBEK4S.js → chunk-3BHGEP3O.js} +8 -8
- package/dist/{chunk-VCTP2RG6.js → chunk-3HZZ2XZD.js} +5 -5
- package/dist/{chunk-QFKDFU73.js → chunk-4QRF7TNW.js} +2 -2
- package/dist/{chunk-D234NBWI.js → chunk-ADCVXKSD.js} +1 -1
- package/dist/{chunk-EIG2V6UI.js → chunk-AOBMI5UM.js} +1 -1
- package/dist/{chunk-F5XONXGH.js → chunk-BALZYIFH.js} +4 -4
- package/dist/{chunk-XJVCTI2N.js → chunk-C5LD76KR.js} +3 -3
- package/dist/{chunk-LCTYTGSE.js → chunk-CFGQOIXW.js} +3 -3
- package/dist/{chunk-VB47PTY7.js → chunk-DDM6PVXJ.js} +3 -3
- package/dist/{chunk-PRNO5TLE.js → chunk-DOP5QNPM.js} +375 -40
- package/dist/{chunk-ZA7D7CCN.js → chunk-F5DLOQ3B.js} +2 -2
- package/dist/{chunk-6WTSWWP6.js → chunk-NSE55FZE.js} +2 -2
- package/dist/{chunk-H6EQMYGT.js → chunk-NZ6KZLTM.js} +2 -1
- package/dist/{chunk-YOZ35ZTT.js → chunk-P2OVWQKT.js} +1 -1
- package/dist/{chunk-BQKKAPMW.js → chunk-PUTJ6LPE.js} +1 -1
- package/dist/{chunk-VF7XGX2I.js → chunk-Q5ZRUA57.js} +1 -1
- package/dist/{chunk-OMXWBR2R.js → chunk-QAGZQ2DY.js} +165 -2
- package/dist/{chunk-R4AFXPM4.js → chunk-RCCZ6VGK.js} +1 -1
- package/dist/{chunk-SKZVEZZK.js → chunk-RELKG6XH.js} +2 -2
- package/dist/{chunk-2OB7YQEZ.js → chunk-RWYKUCPF.js} +338 -325
- package/dist/{chunk-RHO7UNXA.js → chunk-S4H7KMIH.js} +20 -20
- package/dist/{chunk-Y2YBRLSS.js → chunk-SJLCALSV.js} +3 -3
- package/dist/{chunk-WDJMIIY2.js → chunk-SVLNIJS2.js} +1 -1
- package/dist/{chunk-4LVJFSPH.js → chunk-T7A46CVU.js} +5 -5
- package/dist/{chunk-OHVXKFQI.js → chunk-TPCXTUL5.js} +1 -1
- package/dist/{chunk-RHCDUPD6.js → chunk-V4V7WOHY.js} +16 -2
- package/dist/{chunk-B37SDIGU.js → chunk-VZURJP3T.js} +1 -1
- package/dist/{chunk-VMCVLESK.js → chunk-W5FAL4LJ.js} +4 -4
- package/dist/{chunk-J7VN3FZ3.js → chunk-WRYVESRH.js} +1 -1
- package/dist/{chunk-MARVEIWH.js → chunk-XUW5SU24.js} +4 -4
- package/dist/{chunk-T63KVDWY.js → chunk-ZNAAZHNT.js} +26 -6
- package/dist/{chunk-ZILJZNMQ.js → chunk-ZOVL5NAP.js} +1 -1
- package/dist/{citations-JK3ZMAR7.js → citations-5ARZ6M42.js} +3 -3
- package/dist/{cli-catalog-P2I6IYNI.js → cli-catalog-XD7VY3ES.js} +3 -3
- package/dist/{cli-commands-U6NDGGK2.js → cli-commands-KGTXEDAZ.js} +7 -7
- package/dist/cli.js +13 -13
- package/dist/{competitor-5CJPM36M.js → competitor-XWTEIVZL.js} +3 -3
- package/dist/{content-5FEDXNHR.js → content-4EVGV32G.js} +3 -3
- package/dist/{dashboard-ME7MBJTX.js → dashboard-YEYFINMF.js} +6 -6
- package/dist/{demo-J3QCDV43.js → demo-RK5OKZIY.js} +1 -1
- package/dist/{demo-server-FJLSYQXZ.js → demo-server-JL4JLKMG.js} +113 -12
- package/dist/{discover-EAISVTA6.js → discover-VQYJ4UOL.js} +3 -3
- package/dist/{discover-eval-JIBKK44Q.js → discover-eval-FMEMPSM3.js} +3 -3
- package/dist/{doctor-HSQYOZ4C.js → doctor-VYES5HCM.js} +3 -3
- package/dist/{evidence-PSYAWKPP.js → evidence-BG45EBS3.js} +3 -3
- package/dist/{export-cmd-MWJN6H7W.js → export-cmd-PQZCMR7C.js} +3 -3
- package/dist/{ga-WSQWECYY.js → ga-ZQL2LHQA.js} +42 -4
- package/dist/{gbp-OD26AEPF.js → gbp-KNWDBHFM.js} +3 -3
- package/dist/{google-FMJ7IWAF.js → google-GOKE6J5E.js} +4 -4
- package/dist/{google-marketing-66JL4V24.js → google-marketing-7DYEKRHS.js} +1 -1
- package/dist/{health-cmd-2RO5LAI4.js → health-cmd-4OZ7EYWI.js} +3 -3
- package/dist/{history-X6CNPW7G.js → history-U2W77DIY.js} +3 -3
- package/dist/index.d.ts +493 -18
- package/dist/index.js +24 -24
- package/dist/{init-EDSKLFUY.js → init-WTLTEYSB.js} +11 -11
- package/dist/{insights-6IWWA6JU.js → insights-LWMDBEYC.js} +3 -3
- package/dist/intelligence-service-PY6QR36M.js +15 -0
- package/dist/{keys-ABXAPISY.js → keys-RSKVNMJI.js} +3 -3
- package/dist/{keyword-LERAVMI3.js → keyword-IM4GUM5U.js} +3 -3
- package/dist/{logs-BTAB5SNZ.js → logs-B35V2RPE.js} +3 -3
- package/dist/{mcp-5E42RT6R.js → mcp-UFMKQFGP.js} +2 -2
- package/dist/mcp.js +9 -9
- package/dist/{measurement-plan-MRZRNBJG.js → measurement-plan-BOHLLJD5.js} +5 -5
- package/dist/{notify-YQYGC5UZ.js → notify-RQIQP5ZF.js} +3 -3
- package/dist/{organic-evidence-6QT4YT3K.js → organic-evidence-C3OZR7UY.js} +3 -3
- package/dist/{overview-EHZ3FTS2.js → overview-OVIPKMAY.js} +4 -4
- package/dist/{project-RNLV2ARE.js → project-QBUTYR6J.js} +3 -3
- package/dist/{query-IM2RXI4L.js → query-KCGET5FS.js} +3 -3
- package/dist/{research-4FALR336.js → research-HTURJWRL.js} +3 -3
- package/dist/{results-export-4ETSRUGO.js → results-export-GJNXEXV4.js} +3 -3
- package/dist/{run-QL7226N7.js → run-ZNTT7W5M.js} +4 -4
- package/dist/{schedule-GJE634VO.js → schedule-S2ODDXFB.js} +3 -3
- package/dist/{search-7OQL67R6.js → search-UW56VG5B.js} +3 -3
- package/dist/{serve-VJ3M7FAT.js → serve-BIWTUO6A.js} +25 -25
- package/dist/{session-5M54TVY5.js → session-T4Q6NH3K.js} +12 -12
- package/dist/{settings-2QOL7YBM.js → settings-TGSORPVW.js} +3 -3
- package/dist/{skills-GPLAAU3I.js → skills-SBZZLY4T.js} +2 -2
- package/dist/{snapshot-5YMJFRJS.js → snapshot-OMS33CN4.js} +3 -3
- package/dist/{src-YF3JLURF.js → src-LKNW35M6.js} +4 -2
- package/dist/{status-WGWC6FLN.js → status-7D7NUW7M.js} +4 -4
- package/dist/{technical-aeo-RNMLD7OL.js → technical-aeo-UFDHAV7G.js} +3 -3
- package/dist/{telemetry-7U3ZICU4.js → telemetry-ZPVJITHJ.js} +4 -4
- package/dist/{tools-CSKTZTKT.js → tools-PDV6BJ5Y.js} +11 -11
- package/dist/{traffic-QIAXLW6J.js → traffic-T6YAKUY5.js} +5 -5
- package/dist/{users-I6X5P5AO.js → users-6N2YMWAP.js} +3 -3
- package/dist/{visibility-stats-33OUKQQL.js → visibility-stats-GODBRQVG.js} +3 -3
- package/dist/{wordpress-3IO3O27D.js → wordpress-ISFI67TH.js} +3 -3
- package/package.json +1 -1
- package/assets/assets/MeasurementPropertyPage-FGhKdZAP.js +0 -4
- package/assets/assets/ProjectPage-BTJYS9gc.js +0 -7
- package/assets/assets/SiteHealthSection-4PXTNjon.js +0 -2
- package/assets/assets/ToneBadge-AoUA_EpE.js +0 -60
- package/assets/assets/index-B8W65ejO.css +0 -1
- package/assets/assets/index-BBfEsbxI.js +0 -56
- package/assets/assets/react-query-BLKqSvlU.js +0 -1
- package/assets/assets/vendor-lucide-BjvO55Hk.js +0 -1
- package/dist/intelligence-service-N334P6FH.js +0 -15
|
@@ -6,14 +6,14 @@ import {
|
|
|
6
6
|
isSelfTraffic,
|
|
7
7
|
normalizeCloudflareWorkerEvent,
|
|
8
8
|
verifyRequestSignature
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-P2OVWQKT.js";
|
|
10
10
|
import {
|
|
11
11
|
currentOutcomeAttribution,
|
|
12
12
|
getRequestContext,
|
|
13
13
|
registerRequestContext,
|
|
14
14
|
requestAuditIdentity,
|
|
15
15
|
sanitizeRequestContext
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-AOBMI5UM.js";
|
|
17
17
|
import {
|
|
18
18
|
SentimentIdempotencyConflict,
|
|
19
19
|
SentimentRepository,
|
|
@@ -62,6 +62,7 @@ import {
|
|
|
62
62
|
gaTrafficSnapshots,
|
|
63
63
|
gaTrafficSummaries,
|
|
64
64
|
gaTrafficWindowSummaries,
|
|
65
|
+
gaWindowMetrics,
|
|
65
66
|
gbpAttributesSnapshots,
|
|
66
67
|
gbpDailyMetrics,
|
|
67
68
|
gbpKeywordImpressions,
|
|
@@ -142,7 +143,7 @@ import {
|
|
|
142
143
|
userSessions,
|
|
143
144
|
users,
|
|
144
145
|
writeNegativeReviewMaxStars
|
|
145
|
-
} from "./chunk-
|
|
146
|
+
} from "./chunk-37YB52NM.js";
|
|
146
147
|
import {
|
|
147
148
|
ADS_ACTIVATE_SCOPE,
|
|
148
149
|
ADS_ACTIVATION_ABSOLUTE_MAX_ENTITIES,
|
|
@@ -221,6 +222,8 @@ import {
|
|
|
221
222
|
DiscoverySessionStatuses,
|
|
222
223
|
FeatureNames,
|
|
223
224
|
GA4_AI_ASSISTANT_CHANNEL_GROUP,
|
|
225
|
+
GA_OVERVIEW_HISTORY_DAYS,
|
|
226
|
+
GA_OVERVIEW_METRIC_ORDER,
|
|
224
227
|
GA_SEARCH_LANDING_DEFAULT_LIMIT,
|
|
225
228
|
GA_SEARCH_LANDING_DEFAULT_WINDOW,
|
|
226
229
|
GA_SEARCH_LANDING_MAX_LIMIT,
|
|
@@ -232,6 +235,7 @@ import {
|
|
|
232
235
|
GOOGLE_MARKETING_WRITE_SCOPE,
|
|
233
236
|
GaAcquisitionDimensions,
|
|
234
237
|
GaMoverChangeBases,
|
|
238
|
+
GaOverviewPeriods,
|
|
235
239
|
GoogleAdsCampaignStatuses,
|
|
236
240
|
GoogleAdsConnectionStates,
|
|
237
241
|
GoogleAdsGoalConfigurationLevels,
|
|
@@ -239,6 +243,7 @@ import {
|
|
|
239
243
|
GoogleMarketingProviders,
|
|
240
244
|
GtmConnectionStates,
|
|
241
245
|
GtmSnapshotKinds,
|
|
246
|
+
InsightActionGroups,
|
|
242
247
|
LATEST_RUN_ID,
|
|
243
248
|
LOCATION_REDIRECT_STATUSES,
|
|
244
249
|
LOGIN_FAILED_MESSAGE,
|
|
@@ -600,6 +605,9 @@ import {
|
|
|
600
605
|
gaAttributionTrendResponseSchema,
|
|
601
606
|
gaMeasurementAnalysisDtoSchema,
|
|
602
607
|
gaMeasurementHostScopeSchema,
|
|
608
|
+
gaOverviewComparisonDaysAgo,
|
|
609
|
+
gaOverviewComparisonRanges,
|
|
610
|
+
gaOverviewResponseSchema,
|
|
603
611
|
gaSearchLandingPagesResponseSchema,
|
|
604
612
|
gaSearchLandingWindowSchema,
|
|
605
613
|
gaSocialReferralTrendResponseSchema,
|
|
@@ -667,6 +675,7 @@ import {
|
|
|
667
675
|
hostOf,
|
|
668
676
|
inclusiveDayCount,
|
|
669
677
|
indexingRequestResponseDtoSchema,
|
|
678
|
+
insightActionGroupByType,
|
|
670
679
|
instanceStatusDtoSchema,
|
|
671
680
|
integrationSettingsSummaryDtoSchema,
|
|
672
681
|
internalError,
|
|
@@ -675,6 +684,7 @@ import {
|
|
|
675
684
|
isEligibleFor,
|
|
676
685
|
isFetchTransportError,
|
|
677
686
|
isGa4AiAssistantChannel,
|
|
687
|
+
isGaOverviewWindow,
|
|
678
688
|
isListingMarketplace,
|
|
679
689
|
isLocationRedirectStatus,
|
|
680
690
|
isNegativeReviewRating,
|
|
@@ -1074,7 +1084,7 @@ import {
|
|
|
1074
1084
|
wordpressSchemaDeployResultDtoSchema,
|
|
1075
1085
|
wordpressSchemaStatusResultDtoSchema,
|
|
1076
1086
|
wordpressStatusDtoSchema
|
|
1077
|
-
} from "./chunk-
|
|
1087
|
+
} from "./chunk-QAGZQ2DY.js";
|
|
1078
1088
|
|
|
1079
1089
|
// ../api-routes/src/user-session.ts
|
|
1080
1090
|
import crypto2 from "crypto";
|
|
@@ -27815,6 +27825,12 @@ function severitiesAtOrAbove(min2) {
|
|
|
27815
27825
|
}
|
|
27816
27826
|
return Object.keys(SEVERITY_RANK).filter((s) => SEVERITY_RANK[s] >= floor);
|
|
27817
27827
|
}
|
|
27828
|
+
function compareInsightsForTriage(a, b) {
|
|
27829
|
+
return b.createdAt.localeCompare(a.createdAt) || monitorRank(a) - monitorRank(b) || SEVERITY_RANK[b.severity] - SEVERITY_RANK[a.severity];
|
|
27830
|
+
}
|
|
27831
|
+
function monitorRank(insight) {
|
|
27832
|
+
return insightActionGroupByType[insight.type] === InsightActionGroups.monitor ? 1 : 0;
|
|
27833
|
+
}
|
|
27818
27834
|
function emptyHealthSnapshot(projectId) {
|
|
27819
27835
|
return {
|
|
27820
27836
|
id: `no-data:${projectId}`,
|
|
@@ -27948,7 +27964,7 @@ async function intelligenceRoutes(app) {
|
|
|
27948
27964
|
}
|
|
27949
27965
|
const rows = app.db.select().from(insights).where(conditions.length === 1 ? conditions[0] : and37(...conditions)).orderBy(desc19(insights.createdAt)).all();
|
|
27950
27966
|
const showDismissed = request.query.dismissed === "true";
|
|
27951
|
-
let result = rows.filter((r) => showDismissed || !r.dismissed).map(mapInsightRow);
|
|
27967
|
+
let result = rows.filter((r) => showDismissed || !r.dismissed).map(mapInsightRow).sort(compareInsightsForTriage);
|
|
27952
27968
|
if (limit !== void 0) result = result.slice(0, limit);
|
|
27953
27969
|
return reply.send(result);
|
|
27954
27970
|
});
|
|
@@ -31068,7 +31084,7 @@ async function compositeRoutes(app, options) {
|
|
|
31068
31084
|
const healthRow = app.db.select().from(healthSnapshots).where(eq55(healthSnapshots.projectId, project.id)).orderBy(desc25(healthSnapshots.createdAt)).limit(1).get();
|
|
31069
31085
|
const health = healthRow ? mapHealthRow2(healthRow) : null;
|
|
31070
31086
|
const insightRows = app.db.select().from(insights).where(eq55(insights.projectId, project.id)).orderBy(desc25(insights.createdAt)).all();
|
|
31071
|
-
const topInsights = insightRows.filter((row) => !row.dismissed).slice(0, TOP_INSIGHT_LIMIT)
|
|
31087
|
+
const topInsights = insightRows.filter((row) => !row.dismissed).map(mapInsightRow2).sort(compareInsightsForTriage).slice(0, TOP_INSIGHT_LIMIT);
|
|
31072
31088
|
const sparklineRunIds = visibilityRuns.slice(0, DEFAULT_RUN_HISTORY_LIMIT).map((r) => r.id);
|
|
31073
31089
|
const snapshotRunIds = new Set(sparklineRunIds);
|
|
31074
31090
|
for (const run of latestVisRunGroup) snapshotRunIds.add(run.id);
|
|
@@ -32701,6 +32717,7 @@ var SCHEMA_TABLE = {
|
|
|
32701
32717
|
GA4AiReferralHistoryEntry: ga4AiReferralHistoryEntrySchema,
|
|
32702
32718
|
GA4MeasurementAnalysisDto: gaMeasurementAnalysisDtoSchema,
|
|
32703
32719
|
GA4SessionHistoryEntry: ga4SessionHistoryEntrySchema,
|
|
32720
|
+
GaOverviewResponse: gaOverviewResponseSchema,
|
|
32704
32721
|
GA4SocialReferralHistoryEntry: ga4SocialReferralHistoryEntrySchema,
|
|
32705
32722
|
GA4PropertiesDto: ga4PropertiesDtoSchema,
|
|
32706
32723
|
GA4StatusDto: ga4StatusDtoSchema,
|
|
@@ -33319,6 +33336,12 @@ var analyticsWindowParameter = {
|
|
|
33319
33336
|
description: "Time window for analytics queries. An unrecognised value is rejected with 400; it is never widened to the full history.",
|
|
33320
33337
|
schema: { type: "string", enum: ["7d", "30d", "90d", "all"] }
|
|
33321
33338
|
};
|
|
33339
|
+
var gaOverviewWindowParameter = {
|
|
33340
|
+
name: "window",
|
|
33341
|
+
in: "query",
|
|
33342
|
+
description: 'Overview window: the complete days ending yesterday, as GA4 counts "Last 30 days". Defaults to 30d. Any other value is rejected with 400.',
|
|
33343
|
+
schema: { type: "string", enum: ["7d", "30d", "90d"] }
|
|
33344
|
+
};
|
|
33322
33345
|
var competitorLandscapeGroupKeyParameter = {
|
|
33323
33346
|
name: "groupKey",
|
|
33324
33347
|
in: "query",
|
|
@@ -39131,6 +39154,18 @@ var routeCatalog = [
|
|
|
39131
39154
|
404: errorResponse("Project not found.")
|
|
39132
39155
|
}
|
|
39133
39156
|
},
|
|
39157
|
+
{
|
|
39158
|
+
method: "get",
|
|
39159
|
+
path: "/api/v1/projects/{name}/ga/overview",
|
|
39160
|
+
summary: "Get the GA4 overview: totals, change against the previous period, and both periods by day",
|
|
39161
|
+
tags: ["ga4"],
|
|
39162
|
+
parameters: [nameParameter, gaOverviewWindowParameter],
|
|
39163
|
+
responses: {
|
|
39164
|
+
200: jsonResponse("GA4 overview returned.", "GaOverviewResponse"),
|
|
39165
|
+
400: errorResponse("GA4 is not connected, or the window is not 7d, 30d or 90d."),
|
|
39166
|
+
404: errorResponse("Project not found.")
|
|
39167
|
+
}
|
|
39168
|
+
},
|
|
39134
39169
|
{
|
|
39135
39170
|
method: "get",
|
|
39136
39171
|
path: "/api/v1/projects/{name}/ga/session-history",
|
|
@@ -39168,7 +39203,7 @@ var routeCatalog = [
|
|
|
39168
39203
|
{ name: "runId", in: "query", description: "Filter by run ID.", schema: stringSchema },
|
|
39169
39204
|
{ name: "type", in: "query", description: "Filter by insight type. Exact match, or a trailing `*` for a prefix (e.g. `gbp-*`).", schema: stringSchema },
|
|
39170
39205
|
{ name: "severity", in: "query", description: "Minimum severity (low|medium|high|critical); e.g. `high` returns high + critical.", schema: stringSchema },
|
|
39171
|
-
{ name: "limit", in: "query", description: "
|
|
39206
|
+
{ name: "limit", in: "query", description: "Keep the first N insights. Order: newest analysis first; within one analysis, insights that need action before wins, then most severe first.", schema: stringSchema }
|
|
39172
39207
|
],
|
|
39173
39208
|
responses: {
|
|
39174
39209
|
// TODO: Add `InsightDto` Zod schema in contracts.
|
|
@@ -42263,6 +42298,17 @@ var GA4_METRICS = {
|
|
|
42263
42298
|
* sessions did not (captured live, 2026-10-08).
|
|
42264
42299
|
*/
|
|
42265
42300
|
activeUsers: "activeUsers",
|
|
42301
|
+
/** GA4's "Views": web pages and app screens viewed. */
|
|
42302
|
+
screenPageViews: "screenPageViews",
|
|
42303
|
+
/** GA4's "Key events" (named "conversions" until 2024). */
|
|
42304
|
+
keyEvents: "keyEvents",
|
|
42305
|
+
/**
|
|
42306
|
+
* Engaged time in seconds, summed. GA4's "Average engagement time" is this
|
|
42307
|
+
* divided by `activeUsers` over the same span.
|
|
42308
|
+
*/
|
|
42309
|
+
userEngagementDuration: "userEngagementDuration",
|
|
42310
|
+
/** Share of sessions that were not engaged (0-1), GA4's own figure. */
|
|
42311
|
+
bounceRate: "bounceRate",
|
|
42266
42312
|
/**
|
|
42267
42313
|
* Search Console metrics a GA4 property exposes once it is linked to Search
|
|
42268
42314
|
* Console. Compatible only with the landing page, device and country
|
|
@@ -42570,6 +42616,18 @@ async function batchRunReports(accessToken, propertyId, requests) {
|
|
|
42570
42616
|
function formatDate(d) {
|
|
42571
42617
|
return d.toISOString().slice(0, 10);
|
|
42572
42618
|
}
|
|
42619
|
+
function ga4RelativeDate(daysAgo) {
|
|
42620
|
+
if (daysAgo === 0) return "today";
|
|
42621
|
+
if (daysAgo === 1) return "yesterday";
|
|
42622
|
+
return `${daysAgo}daysAgo`;
|
|
42623
|
+
}
|
|
42624
|
+
function reportTimeZone(...responses) {
|
|
42625
|
+
for (const res of responses) {
|
|
42626
|
+
const zone = res?.metadata?.timeZone?.trim();
|
|
42627
|
+
if (zone) return zone;
|
|
42628
|
+
}
|
|
42629
|
+
return null;
|
|
42630
|
+
}
|
|
42573
42631
|
function measurementDateRange(days) {
|
|
42574
42632
|
const { effectiveDays: syncDays } = resolveGa4SyncDays(days);
|
|
42575
42633
|
const endDate = /* @__PURE__ */ new Date();
|
|
@@ -42979,38 +43037,75 @@ function parseOptionalCountMetric(value) {
|
|
|
42979
43037
|
const parsed = parseOptionalMetric(value);
|
|
42980
43038
|
return parsed === null ? null : Math.round(parsed);
|
|
42981
43039
|
}
|
|
42982
|
-
async function fetchDailyTotals(accessToken, propertyId, days) {
|
|
43040
|
+
async function fetchDailyTotals(accessToken, propertyId, days = GA_OVERVIEW_HISTORY_DAYS, options = {}) {
|
|
42983
43041
|
validateAccessToken2(accessToken);
|
|
42984
43042
|
validatePropertyId(propertyId);
|
|
42985
|
-
const
|
|
42986
|
-
const
|
|
42987
|
-
const
|
|
42988
|
-
|
|
42989
|
-
|
|
42990
|
-
|
|
42991
|
-
|
|
42992
|
-
|
|
42993
|
-
|
|
42994
|
-
|
|
42995
|
-
|
|
42996
|
-
|
|
42997
|
-
|
|
42998
|
-
|
|
42999
|
-
|
|
43000
|
-
|
|
43001
|
-
|
|
43002
|
-
|
|
43003
|
-
|
|
43043
|
+
const historyDays = Math.min(Math.max(1, Number.isFinite(days) ? Math.trunc(days) : GA_OVERVIEW_HISTORY_DAYS), GA_OVERVIEW_HISTORY_DAYS);
|
|
43044
|
+
const requestedAt = (options.now ?? /* @__PURE__ */ new Date()).toISOString();
|
|
43045
|
+
const dateRange = { startDate: ga4RelativeDate(historyDays), endDate: ga4RelativeDate(0) };
|
|
43046
|
+
ga4Log("info", "fetch-daily-totals.start", { propertyId, days: historyDays });
|
|
43047
|
+
const [totalsRes, organicRes] = await batchRunReports(accessToken, propertyId, [
|
|
43048
|
+
{
|
|
43049
|
+
dateRanges: [dateRange],
|
|
43050
|
+
dimensions: [{ name: GA4_DIMENSIONS.date }],
|
|
43051
|
+
metrics: [
|
|
43052
|
+
{ name: GA4_METRICS.sessions },
|
|
43053
|
+
{ name: GA4_METRICS.totalUsers },
|
|
43054
|
+
{ name: GA4_METRICS.engagementRate },
|
|
43055
|
+
{ name: GA4_METRICS.newUsers },
|
|
43056
|
+
{ name: GA4_METRICS.activeUsers },
|
|
43057
|
+
{ name: GA4_METRICS.screenPageViews },
|
|
43058
|
+
{ name: GA4_METRICS.eventCount },
|
|
43059
|
+
{ name: GA4_METRICS.keyEvents },
|
|
43060
|
+
{ name: GA4_METRICS.userEngagementDuration },
|
|
43061
|
+
{ name: GA4_METRICS.bounceRate }
|
|
43062
|
+
],
|
|
43063
|
+
limit: historyDays + 1
|
|
43064
|
+
},
|
|
43065
|
+
{
|
|
43066
|
+
dateRanges: [dateRange],
|
|
43067
|
+
dimensions: [{ name: GA4_DIMENSIONS.date }],
|
|
43068
|
+
metrics: [{ name: GA4_METRICS.sessions }],
|
|
43069
|
+
dimensionFilter: {
|
|
43070
|
+
filter: {
|
|
43071
|
+
fieldName: GA4_DIMENSIONS.sessionDefaultChannelGrouping,
|
|
43072
|
+
stringFilter: { matchType: "EXACT", value: "Organic Search" }
|
|
43073
|
+
}
|
|
43074
|
+
},
|
|
43075
|
+
limit: historyDays + 1
|
|
43076
|
+
}
|
|
43077
|
+
]);
|
|
43078
|
+
const organicByDate = /* @__PURE__ */ new Map();
|
|
43079
|
+
for (const row of organicRes?.rows ?? []) {
|
|
43080
|
+
const date = compactDateToIso(row.dimensionValues[0]?.value ?? "");
|
|
43081
|
+
if (date) organicByDate.set(date, parseOptionalCountMetric(row.metricValues[0]?.value) ?? 0);
|
|
43082
|
+
}
|
|
43083
|
+
const rows = (totalsRes?.rows ?? []).map((row) => {
|
|
43084
|
+
const date = compactDateToIso(row.dimensionValues[0]?.value ?? "");
|
|
43085
|
+
const metric2 = (index) => parseOptionalMetric(row.metricValues[index]?.value);
|
|
43086
|
+
const count9 = (index) => parseOptionalCountMetric(row.metricValues[index]?.value);
|
|
43004
43087
|
return {
|
|
43005
|
-
date
|
|
43088
|
+
date,
|
|
43006
43089
|
sessions: parseInt(row.metricValues[0]?.value ?? "0", 10) || 0,
|
|
43007
|
-
users:
|
|
43008
|
-
engagementRate: parseBoundedRate(
|
|
43009
|
-
newUsers
|
|
43090
|
+
users: parseInt(row.metricValues[1]?.value ?? "0", 10) || 0,
|
|
43091
|
+
engagementRate: parseBoundedRate(metric2(2)),
|
|
43092
|
+
newUsers: count9(3),
|
|
43093
|
+
activeUsers: count9(4),
|
|
43094
|
+
organicSessions: organicRes ? organicByDate.get(date) ?? 0 : null,
|
|
43095
|
+
views: count9(5),
|
|
43096
|
+
eventCount: count9(6),
|
|
43097
|
+
keyEvents: metric2(7),
|
|
43098
|
+
engagementSeconds: metric2(8),
|
|
43099
|
+
bounceRate: parseBoundedRate(metric2(9))
|
|
43010
43100
|
};
|
|
43011
43101
|
}).filter((row) => row.date.length > 0);
|
|
43012
|
-
|
|
43013
|
-
|
|
43102
|
+
const timeZone = reportTimeZone(totalsRes, organicRes) ?? "UTC";
|
|
43103
|
+
ga4Log("info", "fetch-daily-totals.done", { propertyId, days: historyDays, timeZone, rows: rows.length });
|
|
43104
|
+
return {
|
|
43105
|
+
startDate: isoDateDaysBeforeInTimeZone(requestedAt, historyDays, timeZone),
|
|
43106
|
+
endDate: isoDateDaysBeforeInTimeZone(requestedAt, 0, timeZone),
|
|
43107
|
+
rows
|
|
43108
|
+
};
|
|
43014
43109
|
}
|
|
43015
43110
|
var WINDOW_DAYS2 = { "7d": 7, "30d": 30, "90d": 90 };
|
|
43016
43111
|
async function fetchWindowSummary(accessToken, propertyId, windowKey) {
|
|
@@ -43072,6 +43167,84 @@ async function fetchWindowSummary(accessToken, propertyId, windowKey) {
|
|
|
43072
43167
|
ga4Log("info", "fetch-window-summary.done", { propertyId, ...summary3 });
|
|
43073
43168
|
return summary3;
|
|
43074
43169
|
}
|
|
43170
|
+
var COMPARISON_RANGE_NAMES = { current: "current", previous: "previous" };
|
|
43171
|
+
async function fetchWindowMetrics(accessToken, propertyId, windowKey, options = {}) {
|
|
43172
|
+
validateAccessToken2(accessToken);
|
|
43173
|
+
validatePropertyId(propertyId);
|
|
43174
|
+
const requestedAt = options.now ?? /* @__PURE__ */ new Date();
|
|
43175
|
+
const daysAgo = gaOverviewComparisonDaysAgo(windowKey);
|
|
43176
|
+
const dateRanges = [
|
|
43177
|
+
{ startDate: ga4RelativeDate(daysAgo.current.start), endDate: ga4RelativeDate(daysAgo.current.end), name: COMPARISON_RANGE_NAMES.current },
|
|
43178
|
+
{ startDate: ga4RelativeDate(daysAgo.previous.start), endDate: ga4RelativeDate(daysAgo.previous.end), name: COMPARISON_RANGE_NAMES.previous }
|
|
43179
|
+
];
|
|
43180
|
+
ga4Log("info", "fetch-window-metrics.start", { propertyId, windowKey });
|
|
43181
|
+
const [totalsRes, organicRes] = await batchRunReports(accessToken, propertyId, [
|
|
43182
|
+
{
|
|
43183
|
+
dateRanges,
|
|
43184
|
+
dimensions: [],
|
|
43185
|
+
metrics: [
|
|
43186
|
+
{ name: GA4_METRICS.activeUsers },
|
|
43187
|
+
{ name: GA4_METRICS.newUsers },
|
|
43188
|
+
{ name: GA4_METRICS.totalUsers },
|
|
43189
|
+
{ name: GA4_METRICS.sessions },
|
|
43190
|
+
{ name: GA4_METRICS.screenPageViews },
|
|
43191
|
+
{ name: GA4_METRICS.eventCount },
|
|
43192
|
+
{ name: GA4_METRICS.keyEvents },
|
|
43193
|
+
{ name: GA4_METRICS.engagementRate },
|
|
43194
|
+
{ name: GA4_METRICS.bounceRate },
|
|
43195
|
+
{ name: GA4_METRICS.userEngagementDuration }
|
|
43196
|
+
],
|
|
43197
|
+
limit: dateRanges.length
|
|
43198
|
+
},
|
|
43199
|
+
{
|
|
43200
|
+
dateRanges,
|
|
43201
|
+
dimensions: [],
|
|
43202
|
+
metrics: [{ name: GA4_METRICS.sessions }],
|
|
43203
|
+
dimensionFilter: {
|
|
43204
|
+
filter: {
|
|
43205
|
+
fieldName: GA4_DIMENSIONS.sessionDefaultChannelGrouping,
|
|
43206
|
+
stringFilter: { matchType: "EXACT", value: "Organic Search" }
|
|
43207
|
+
}
|
|
43208
|
+
},
|
|
43209
|
+
limit: dateRanges.length
|
|
43210
|
+
}
|
|
43211
|
+
]);
|
|
43212
|
+
const rowFor = (res, name) => {
|
|
43213
|
+
const index = Math.max(0, (res?.dimensionHeaders ?? []).findIndex((header2) => header2.name === "dateRange"));
|
|
43214
|
+
return res?.rows?.find((row) => row.dimensionValues[index]?.value === name);
|
|
43215
|
+
};
|
|
43216
|
+
const period2 = (name, range) => {
|
|
43217
|
+
const totals = rowFor(totalsRes, name);
|
|
43218
|
+
const organic = rowFor(organicRes, name);
|
|
43219
|
+
const metric2 = (index) => parseOptionalMetric(totals?.metricValues[index]?.value);
|
|
43220
|
+
const count9 = (index) => parseOptionalCountMetric(totals?.metricValues[index]?.value);
|
|
43221
|
+
return {
|
|
43222
|
+
...range,
|
|
43223
|
+
activeUsers: count9(0),
|
|
43224
|
+
newUsers: count9(1),
|
|
43225
|
+
totalUsers: count9(2),
|
|
43226
|
+
sessions: count9(3),
|
|
43227
|
+
views: count9(4),
|
|
43228
|
+
eventCount: count9(5),
|
|
43229
|
+
keyEvents: metric2(6),
|
|
43230
|
+
engagementRate: parseBoundedRate(metric2(7)),
|
|
43231
|
+
bounceRate: parseBoundedRate(metric2(8)),
|
|
43232
|
+
engagementSeconds: metric2(9),
|
|
43233
|
+
// A period with sessions but no Organic Search row had none; a period
|
|
43234
|
+
// GA4 sent nothing for stays unknown.
|
|
43235
|
+
organicSessions: organic ? parseOptionalCountMetric(organic.metricValues[0]?.value) : totals ? 0 : null
|
|
43236
|
+
};
|
|
43237
|
+
};
|
|
43238
|
+
const timeZone = reportTimeZone(totalsRes, organicRes) ?? "UTC";
|
|
43239
|
+
const ranges = gaOverviewComparisonRanges(windowKey, requestedAt, timeZone);
|
|
43240
|
+
const result = {
|
|
43241
|
+
windowKey,
|
|
43242
|
+
current: period2(COMPARISON_RANGE_NAMES.current, ranges.current),
|
|
43243
|
+
previous: period2(COMPARISON_RANGE_NAMES.previous, ranges.previous)
|
|
43244
|
+
};
|
|
43245
|
+
ga4Log("info", "fetch-window-metrics.done", { propertyId, windowKey, timeZone });
|
|
43246
|
+
return result;
|
|
43247
|
+
}
|
|
43075
43248
|
async function fetchAiReferrals(accessToken, propertyId, days) {
|
|
43076
43249
|
validateAccessToken2(accessToken);
|
|
43077
43250
|
validatePropertyId(propertyId);
|
|
@@ -53434,6 +53607,111 @@ function buildSessionHistory(landingPageDays, dailyTotals) {
|
|
|
53434
53607
|
});
|
|
53435
53608
|
}
|
|
53436
53609
|
|
|
53610
|
+
// ../api-routes/src/ga-overview.ts
|
|
53611
|
+
function parseGaOverviewWindow(value) {
|
|
53612
|
+
if (value === void 0 || value === "") return "30d";
|
|
53613
|
+
if (!isGaOverviewWindow(value)) throw validationError(`Invalid window "${value}": the GA4 overview supports 7d, 30d or 90d.`);
|
|
53614
|
+
return value;
|
|
53615
|
+
}
|
|
53616
|
+
var NO_VALUES = {
|
|
53617
|
+
activeUsers: null,
|
|
53618
|
+
newUsers: null,
|
|
53619
|
+
totalUsers: null,
|
|
53620
|
+
sessions: null,
|
|
53621
|
+
organicSessions: null,
|
|
53622
|
+
views: null,
|
|
53623
|
+
eventCount: null,
|
|
53624
|
+
keyEvents: null,
|
|
53625
|
+
engagementRate: null,
|
|
53626
|
+
bounceRate: null,
|
|
53627
|
+
averageEngagementTimeSeconds: null
|
|
53628
|
+
};
|
|
53629
|
+
var NO_TRAFFIC_DAY = {
|
|
53630
|
+
...NO_VALUES,
|
|
53631
|
+
activeUsers: 0,
|
|
53632
|
+
newUsers: 0,
|
|
53633
|
+
totalUsers: 0,
|
|
53634
|
+
sessions: 0,
|
|
53635
|
+
organicSessions: 0,
|
|
53636
|
+
views: 0,
|
|
53637
|
+
eventCount: 0,
|
|
53638
|
+
keyEvents: 0
|
|
53639
|
+
};
|
|
53640
|
+
function averageEngagementSeconds(engagementSeconds, activeUsers) {
|
|
53641
|
+
if (engagementSeconds === null || activeUsers === null || activeUsers <= 0) return null;
|
|
53642
|
+
return engagementSeconds / activeUsers;
|
|
53643
|
+
}
|
|
53644
|
+
function periodValues(row) {
|
|
53645
|
+
if (!row) return NO_VALUES;
|
|
53646
|
+
return {
|
|
53647
|
+
activeUsers: row.activeUsers,
|
|
53648
|
+
newUsers: row.newUsers,
|
|
53649
|
+
totalUsers: row.totalUsers,
|
|
53650
|
+
sessions: row.sessions,
|
|
53651
|
+
organicSessions: row.organicSessions,
|
|
53652
|
+
views: row.views,
|
|
53653
|
+
eventCount: row.eventCount,
|
|
53654
|
+
keyEvents: row.keyEvents,
|
|
53655
|
+
engagementRate: row.engagementRate,
|
|
53656
|
+
bounceRate: row.bounceRate,
|
|
53657
|
+
averageEngagementTimeSeconds: averageEngagementSeconds(row.engagementSeconds, row.activeUsers)
|
|
53658
|
+
};
|
|
53659
|
+
}
|
|
53660
|
+
function dayValues(row) {
|
|
53661
|
+
return {
|
|
53662
|
+
activeUsers: row.activeUsers,
|
|
53663
|
+
newUsers: row.newUsers,
|
|
53664
|
+
totalUsers: row.users,
|
|
53665
|
+
sessions: row.sessions,
|
|
53666
|
+
organicSessions: row.organicSessions,
|
|
53667
|
+
views: row.views,
|
|
53668
|
+
eventCount: row.eventCount,
|
|
53669
|
+
keyEvents: row.keyEvents,
|
|
53670
|
+
engagementRate: row.engagementRate,
|
|
53671
|
+
bounceRate: row.bounceRate,
|
|
53672
|
+
averageEngagementTimeSeconds: averageEngagementSeconds(row.engagementSeconds, row.activeUsers)
|
|
53673
|
+
};
|
|
53674
|
+
}
|
|
53675
|
+
function changeOf(totals, previous) {
|
|
53676
|
+
const change = {};
|
|
53677
|
+
for (const key of GA_OVERVIEW_METRIC_ORDER) {
|
|
53678
|
+
const current = totals[key];
|
|
53679
|
+
const prior = previous[key];
|
|
53680
|
+
change[key] = current === null || prior === null ? null : deltaPercent(current, prior);
|
|
53681
|
+
}
|
|
53682
|
+
return change;
|
|
53683
|
+
}
|
|
53684
|
+
function buildGaOverview(input) {
|
|
53685
|
+
const current = input.current ?? input.fallback.current;
|
|
53686
|
+
const previous = input.previous ?? input.fallback.previous;
|
|
53687
|
+
const synced = input.current !== null && input.previous !== null;
|
|
53688
|
+
const byDate = new Map(input.daily.map((row) => [row.date, row]));
|
|
53689
|
+
const valuesOn = (date) => {
|
|
53690
|
+
const row = byDate.get(date);
|
|
53691
|
+
if (row) return dayValues(row);
|
|
53692
|
+
return synced ? NO_TRAFFIC_DAY : NO_VALUES;
|
|
53693
|
+
};
|
|
53694
|
+
const dayCount = inclusiveDayCount(current.startDate, current.endDate) ?? 0;
|
|
53695
|
+
const days = [];
|
|
53696
|
+
for (let index = 0; index < dayCount; index++) {
|
|
53697
|
+
const date = shiftIsoCalendarDate(current.startDate, index);
|
|
53698
|
+
const previousDate = shiftIsoCalendarDate(previous.startDate, index);
|
|
53699
|
+
days.push({ date, previousDate, values: valuesOn(date), previousValues: valuesOn(previousDate) });
|
|
53700
|
+
}
|
|
53701
|
+
const totals = periodValues(input.current);
|
|
53702
|
+
const previousTotals = periodValues(input.previous);
|
|
53703
|
+
return {
|
|
53704
|
+
window: input.window,
|
|
53705
|
+
current: { startDate: current.startDate, endDate: current.endDate },
|
|
53706
|
+
previous: { startDate: previous.startDate, endDate: previous.endDate },
|
|
53707
|
+
totals,
|
|
53708
|
+
previousTotals,
|
|
53709
|
+
changePct: changeOf(totals, previousTotals),
|
|
53710
|
+
days,
|
|
53711
|
+
syncedAt: input.current?.syncedAt ?? null
|
|
53712
|
+
};
|
|
53713
|
+
}
|
|
53714
|
+
|
|
53437
53715
|
// ../api-routes/src/ga-source-mover.ts
|
|
53438
53716
|
function moverChangeBasis(prior) {
|
|
53439
53717
|
if (prior <= 0) return GaMoverChangeBases.new;
|
|
@@ -54098,6 +54376,8 @@ async function ga4Routes(app, opts) {
|
|
|
54098
54376
|
}
|
|
54099
54377
|
app.db.delete(gaTrafficSnapshots).where(eq69(gaTrafficSnapshots.projectId, project.id)).run();
|
|
54100
54378
|
app.db.delete(gaTrafficSummaries).where(eq69(gaTrafficSummaries.projectId, project.id)).run();
|
|
54379
|
+
app.db.delete(gaTrafficWindowSummaries).where(eq69(gaTrafficWindowSummaries.projectId, project.id)).run();
|
|
54380
|
+
app.db.delete(gaWindowMetrics).where(eq69(gaWindowMetrics.projectId, project.id)).run();
|
|
54101
54381
|
app.db.delete(gaDailyTotals).where(eq69(gaDailyTotals.projectId, project.id)).run();
|
|
54102
54382
|
app.db.delete(gaAiReferrals).where(eq69(gaAiReferrals.projectId, project.id)).run();
|
|
54103
54383
|
app.db.delete(gaSocialReferrals).where(eq69(gaSocialReferrals.projectId, project.id)).run();
|
|
@@ -54200,7 +54480,8 @@ async function ga4Routes(app, opts) {
|
|
|
54200
54480
|
const fetches = [
|
|
54201
54481
|
fetchAggregateSummary(accessToken, propertyId, days),
|
|
54202
54482
|
...WINDOW_KEYS.map((w) => fetchWindowSummary(accessToken, propertyId, w)),
|
|
54203
|
-
fetchDailyTotals(accessToken, propertyId,
|
|
54483
|
+
fetchDailyTotals(accessToken, propertyId),
|
|
54484
|
+
...WINDOW_KEYS.map((w) => fetchWindowMetrics(accessToken, propertyId, w))
|
|
54204
54485
|
];
|
|
54205
54486
|
if (syncTraffic) fetches.push(fetchTrafficByLandingPage(accessToken, propertyId, days));
|
|
54206
54487
|
if (syncAi) fetches.push(fetchAiReferrals(accessToken, propertyId, days));
|
|
@@ -54215,7 +54496,8 @@ async function ga4Routes(app, opts) {
|
|
|
54215
54496
|
const summary3 = results[0];
|
|
54216
54497
|
const windowSummaries = results.slice(1, 1 + WINDOW_KEYS.length);
|
|
54217
54498
|
const dailyTotals = results[1 + WINDOW_KEYS.length];
|
|
54218
|
-
|
|
54499
|
+
const windowMetrics = results.slice(2 + WINDOW_KEYS.length, 2 + 2 * WINDOW_KEYS.length);
|
|
54500
|
+
let idx = 2 + 2 * WINDOW_KEYS.length;
|
|
54219
54501
|
if (syncTraffic) {
|
|
54220
54502
|
rows = results[idx++];
|
|
54221
54503
|
}
|
|
@@ -54254,11 +54536,11 @@ async function ga4Routes(app, opts) {
|
|
|
54254
54536
|
tx.delete(gaDailyTotals).where(
|
|
54255
54537
|
and58(
|
|
54256
54538
|
eq69(gaDailyTotals.projectId, project.id),
|
|
54257
|
-
sql23`${gaDailyTotals.date} >= ${
|
|
54258
|
-
sql23`${gaDailyTotals.date} <= ${
|
|
54539
|
+
sql23`${gaDailyTotals.date} >= ${dailyTotals.startDate}`,
|
|
54540
|
+
sql23`${gaDailyTotals.date} <= ${dailyTotals.endDate}`
|
|
54259
54541
|
)
|
|
54260
54542
|
).run();
|
|
54261
|
-
for (const row of dailyTotals) {
|
|
54543
|
+
for (const row of dailyTotals.rows) {
|
|
54262
54544
|
tx.insert(gaDailyTotals).values({
|
|
54263
54545
|
id: crypto45.randomUUID(),
|
|
54264
54546
|
projectId: project.id,
|
|
@@ -54271,11 +54553,47 @@ async function ga4Routes(app, opts) {
|
|
|
54271
54553
|
// row keeps only what GA4 actually reported.
|
|
54272
54554
|
engagementRate: row.engagementRate,
|
|
54273
54555
|
newUsers: row.newUsers,
|
|
54556
|
+
activeUsers: row.activeUsers,
|
|
54557
|
+
organicSessions: row.organicSessions,
|
|
54558
|
+
views: row.views,
|
|
54559
|
+
eventCount: row.eventCount,
|
|
54560
|
+
keyEvents: row.keyEvents,
|
|
54561
|
+
engagementSeconds: row.engagementSeconds,
|
|
54562
|
+
bounceRate: row.bounceRate,
|
|
54274
54563
|
syncedAt: now,
|
|
54275
54564
|
syncRunId: runId,
|
|
54276
54565
|
createdAt: now
|
|
54277
54566
|
}).run();
|
|
54278
54567
|
}
|
|
54568
|
+
tx.delete(gaWindowMetrics).where(eq69(gaWindowMetrics.projectId, project.id)).run();
|
|
54569
|
+
for (const windowMetric of windowMetrics) {
|
|
54570
|
+
for (const [period2, totals] of [
|
|
54571
|
+
[GaOverviewPeriods.current, windowMetric.current],
|
|
54572
|
+
[GaOverviewPeriods.previous, windowMetric.previous]
|
|
54573
|
+
]) {
|
|
54574
|
+
tx.insert(gaWindowMetrics).values({
|
|
54575
|
+
id: crypto45.randomUUID(),
|
|
54576
|
+
projectId: project.id,
|
|
54577
|
+
windowKey: windowMetric.windowKey,
|
|
54578
|
+
period: period2,
|
|
54579
|
+
startDate: totals.startDate,
|
|
54580
|
+
endDate: totals.endDate,
|
|
54581
|
+
activeUsers: totals.activeUsers,
|
|
54582
|
+
newUsers: totals.newUsers,
|
|
54583
|
+
totalUsers: totals.totalUsers,
|
|
54584
|
+
sessions: totals.sessions,
|
|
54585
|
+
organicSessions: totals.organicSessions,
|
|
54586
|
+
views: totals.views,
|
|
54587
|
+
eventCount: totals.eventCount,
|
|
54588
|
+
keyEvents: totals.keyEvents,
|
|
54589
|
+
engagementRate: totals.engagementRate,
|
|
54590
|
+
bounceRate: totals.bounceRate,
|
|
54591
|
+
engagementSeconds: totals.engagementSeconds,
|
|
54592
|
+
syncedAt: now,
|
|
54593
|
+
syncRunId: runId
|
|
54594
|
+
}).run();
|
|
54595
|
+
}
|
|
54596
|
+
}
|
|
54279
54597
|
if (syncAi) {
|
|
54280
54598
|
tx.delete(gaAiReferrals).where(
|
|
54281
54599
|
and58(
|
|
@@ -54490,10 +54808,10 @@ async function ga4Routes(app, opts) {
|
|
|
54490
54808
|
totalUsers: summary3.totalUsers,
|
|
54491
54809
|
...only ? { only } : {}
|
|
54492
54810
|
});
|
|
54493
|
-
const counts2 = { rows: rows.length + dailyTotals.length + aiReferrals.length + socialReferrals.length };
|
|
54811
|
+
const counts2 = { rows: rows.length + dailyTotals.rows.length + aiReferrals.length + socialReferrals.length };
|
|
54494
54812
|
if (componentFailure) {
|
|
54495
54813
|
outcome2.report({ status: OutcomeStatuses.partial, ...classifyOutcomeError(componentFailure.error), counts: counts2 });
|
|
54496
|
-
} else if (rows.length === 0 && dailyTotals.length === 0) {
|
|
54814
|
+
} else if (rows.length === 0 && dailyTotals.rows.length === 0) {
|
|
54497
54815
|
outcome2.report({ status: OutcomeStatuses.skipped, reasonCode: OutcomeReasonCodes.NO_DATA, counts: counts2 });
|
|
54498
54816
|
} else {
|
|
54499
54817
|
outcome2.report({ status: OutcomeStatuses.succeeded, counts: counts2 });
|
|
@@ -54919,6 +55237,23 @@ async function ga4Routes(app, opts) {
|
|
|
54919
55237
|
};
|
|
54920
55238
|
return response;
|
|
54921
55239
|
});
|
|
55240
|
+
app.get("/projects/:name/ga/overview", async (request, _reply) => {
|
|
55241
|
+
const project = resolveProject(app.db, request.params.name);
|
|
55242
|
+
requireGa4Connection(opts, project.name, project.canonicalDomain);
|
|
55243
|
+
const window = parseGaOverviewWindow(request.query.window);
|
|
55244
|
+
const periodRows = app.db.select().from(gaWindowMetrics).where(and58(eq69(gaWindowMetrics.projectId, project.id), eq69(gaWindowMetrics.windowKey, window))).all();
|
|
55245
|
+
const current = periodRows.find((row) => row.period === GaOverviewPeriods.current) ?? null;
|
|
55246
|
+
const previous = periodRows.find((row) => row.period === GaOverviewPeriods.previous) ?? null;
|
|
55247
|
+
const fallback = gaOverviewComparisonRanges(window);
|
|
55248
|
+
const from = previous?.startDate ?? fallback.previous.startDate;
|
|
55249
|
+
const to = current?.endDate ?? fallback.current.endDate;
|
|
55250
|
+
const daily = app.db.select().from(gaDailyTotals).where(and58(
|
|
55251
|
+
eq69(gaDailyTotals.projectId, project.id),
|
|
55252
|
+
sql23`${gaDailyTotals.date} >= ${from}`,
|
|
55253
|
+
sql23`${gaDailyTotals.date} <= ${to}`
|
|
55254
|
+
)).all();
|
|
55255
|
+
return buildGaOverview({ window, current, previous, daily, fallback });
|
|
55256
|
+
});
|
|
54922
55257
|
app.get("/projects/:name/ga/session-history", async (request, _reply) => {
|
|
54923
55258
|
const project = resolveProject(app.db, request.params.name);
|
|
54924
55259
|
requireGa4Connection(opts, project.name, project.canonicalDomain);
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
siteCrawlGraphNodes,
|
|
6
6
|
siteCrawlPages,
|
|
7
7
|
siteCrawlSnapshots
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-37YB52NM.js";
|
|
9
9
|
import {
|
|
10
10
|
SITE_CRAWL_GRAPH_MAX_EDGES,
|
|
11
11
|
SITE_CRAWL_GRAPH_MAX_NODES,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
factorStatusFromDistribution,
|
|
16
16
|
factorStatusFromScore,
|
|
17
17
|
roundPreservingTotal
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-QAGZQ2DY.js";
|
|
19
19
|
|
|
20
20
|
// src/site-audit-factors.ts
|
|
21
21
|
function recordedSharePct(factor) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createApiClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-V4V7WOHY.js";
|
|
4
4
|
import {
|
|
5
5
|
emitJsonl
|
|
6
6
|
} from "./chunk-Z7IUAJOF.js";
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
formatMicros,
|
|
20
20
|
formatRunErrorOneLine,
|
|
21
21
|
resolveProviderInput
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-QAGZQ2DY.js";
|
|
23
23
|
|
|
24
24
|
// src/commands/run.ts
|
|
25
25
|
function getClient() {
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
AppError,
|
|
6
6
|
parseWindowIn,
|
|
7
7
|
resolveDateRange
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-QAGZQ2DY.js";
|
|
9
9
|
|
|
10
10
|
// src/cli-access.ts
|
|
11
11
|
var CLI_ACCESS_BY_ID = Object.freeze({
|
|
@@ -149,6 +149,7 @@ var CLI_ACCESS_BY_ID = Object.freeze({
|
|
|
149
149
|
"ga.measurement-analysis": "stored",
|
|
150
150
|
"ga.properties": "live",
|
|
151
151
|
"ga.search-landing-pages": "stored",
|
|
152
|
+
"ga.overview": "stored",
|
|
152
153
|
"ga.session-history": "stored",
|
|
153
154
|
"ga.social-referral-history": "stored",
|
|
154
155
|
"ga.social-referral-summary": "stored",
|