@agent-native/core 0.69.0 → 0.70.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/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +48 -0
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/changelog/parse.ts +245 -0
- package/corpus/core/src/cli/changelog.ts +199 -0
- package/corpus/core/src/cli/index.ts +19 -0
- package/corpus/core/src/cli/recap.ts +24 -1
- package/corpus/core/src/cli/skills.ts +72 -45
- package/corpus/core/src/client/CommandMenu.tsx +183 -75
- package/corpus/core/src/client/agent-chat-adapter.ts +44 -7
- package/corpus/core/src/client/analytics.ts +181 -0
- package/corpus/core/src/client/changelog/Changelog.tsx +321 -0
- package/corpus/core/src/client/index.ts +11 -0
- package/corpus/core/src/client/mcp-apps/McpAppRenderer.tsx +54 -0
- package/corpus/core/src/client/settings/useBuilderStatus.ts +82 -20
- package/corpus/core/src/mcp/build-server.ts +1 -1
- package/corpus/core/src/mcp/embed-app.ts +112 -6
- package/corpus/core/src/server/attribution.ts +211 -0
- package/corpus/core/src/server/auth.ts +6 -0
- package/corpus/core/src/server/better-auth-instance.ts +49 -5
- package/corpus/core/src/server/builder-browser.ts +27 -1
- package/corpus/core/src/server/core-routes-plugin.ts +58 -0
- package/corpus/core/src/server/google-oauth.ts +19 -6
- package/corpus/core/src/shared/mcp-embed-headers.ts +1 -1
- package/corpus/core/src/styles/agent-conversation.css +21 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/changelog/SKILL.md +111 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/tracking/SKILL.md +46 -14
- package/corpus/templates/analytics/CHANGELOG.md +10 -0
- package/corpus/templates/analytics/actions/install-dashboard-template.ts +2 -2
- package/corpus/templates/analytics/actions/open-traffic-dashboard.ts +1 -1
- package/corpus/templates/analytics/actions/update-dashboard.ts +5 -3
- package/corpus/templates/analytics/app/components/layout/CommandPalette.tsx +180 -144
- package/corpus/templates/analytics/app/components/layout/Header.tsx +2 -2
- package/corpus/templates/analytics/app/components/layout/Layout.tsx +7 -5
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +221 -213
- package/corpus/templates/analytics/app/hooks/use-navigation-state.ts +6 -3
- package/corpus/templates/analytics/app/lib/demo-dashboard-path.ts +1 -1
- package/corpus/templates/analytics/app/lib/last-opened.ts +2 -1
- package/corpus/templates/analytics/app/pages/Settings.tsx +4 -0
- package/corpus/templates/analytics/app/pages/adhoc/explorer-dashboard/index.tsx +3 -3
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/DashboardFilterBar.tsx +2 -2
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/index.tsx +101 -99
- package/corpus/templates/analytics/app/pages/overview/OverviewPage.tsx +1 -1
- package/corpus/templates/analytics/app/routes/adhoc.$id.tsx +18 -5
- package/corpus/templates/analytics/app/routes/catalog.tsx +1 -1
- package/corpus/templates/analytics/app/routes/dashboards.$id.tsx +9 -0
- package/corpus/templates/analytics/app/routes/traffic.tsx +1 -1
- package/corpus/templates/analytics/changelog/2026-06-23-the-dashboards-and-analyses-sidebar-settings-buttons-now-sta.md +6 -0
- package/corpus/templates/analytics/seeds/dashboards/agent-native-templates-first-party.json +145 -0
- package/corpus/templates/analytics/server/db/index.ts +1 -1
- package/corpus/templates/analytics/server/lib/dashboard-catalog.ts +9 -2
- package/corpus/templates/analytics/server/lib/demo-dashboards.ts +1 -1
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +2 -2
- package/corpus/templates/analytics/server/plugins/core-routes.ts +6 -6
- package/corpus/templates/assets/CHANGELOG.md +10 -0
- package/corpus/templates/assets/app/root.tsx +7 -1
- package/corpus/templates/assets/app/routes/settings.tsx +6 -0
- package/corpus/templates/brain/CHANGELOG.md +10 -0
- package/corpus/templates/brain/app/root.tsx +7 -1
- package/corpus/templates/brain/app/routes/settings.tsx +8 -1
- package/corpus/templates/calendar/CHANGELOG.md +10 -0
- package/corpus/templates/calendar/app/pages/Settings.tsx +4 -0
- package/corpus/templates/calendar/app/root.tsx +7 -1
- package/corpus/templates/chat/CHANGELOG.md +10 -0
- package/corpus/templates/chat/app/root.tsx +7 -1
- package/corpus/templates/clips/CHANGELOG.md +10 -0
- package/corpus/templates/clips/app/components/player/share-dialog.tsx +33 -7
- package/corpus/templates/clips/app/components/player/sign-in-prompt-dialog.tsx +8 -0
- package/corpus/templates/clips/app/components/player/video-player.tsx +150 -20
- package/corpus/templates/clips/app/components/recorder/pre-record-panel.tsx +7 -11
- package/corpus/templates/clips/app/components/recorder/recorder-engine.ts +31 -0
- package/corpus/templates/clips/app/components/sharing/slack-share-hint.tsx +71 -0
- package/corpus/templates/clips/app/root.tsx +7 -1
- package/corpus/templates/clips/app/routes/_app.settings._index.tsx +15 -1
- package/corpus/templates/clips/app/routes/record.tsx +78 -5
- package/corpus/templates/clips/app/routes/share.$shareId.tsx +86 -5
- package/corpus/templates/clips/changelog/2026-06-23-clips-shared-in-slack-no-longer-show-a-could-not-start-playb.md +6 -0
- package/corpus/templates/clips/changelog/2026-06-23-made-the-play-button-on-shared-and-embedded-clips-scale-with.md +6 -0
- package/corpus/templates/clips/changelog/2026-06-23-public-clip-share-links-now-show-whether-they-ll-play-inline.md +6 -0
- package/corpus/templates/clips/changelog/2026-06-23-screen-camera-recordings-now-keep-the-presenter-s-face-in-th.md +6 -0
- package/corpus/templates/clips/desktop/src/lib/recorder.ts +20 -0
- package/corpus/templates/clips/desktop/src/main.tsx +3 -0
- package/corpus/templates/clips/desktop/src/overlays/region-record-border.tsx +76 -0
- package/corpus/templates/clips/desktop/src/styles.css +49 -0
- package/corpus/templates/clips/desktop/src-tauri/capabilities/default.json +2 -1
- package/corpus/templates/clips/desktop/src-tauri/src/clips/mod.rs +67 -1
- package/corpus/templates/clips/desktop/src-tauri/src/lib.rs +2 -0
- package/corpus/templates/clips/desktop/src-tauri/src/util.rs +4 -1
- package/corpus/templates/clips/server/routes/api/video/[recordingId].get.ts +51 -1
- package/corpus/templates/clips/shared/share-attribution.ts +79 -0
- package/corpus/templates/content/CHANGELOG.md +10 -0
- package/corpus/templates/content/app/root.tsx +7 -1
- package/corpus/templates/design/CHANGELOG.md +10 -0
- package/corpus/templates/design/actions/generate-design.ts +4 -0
- package/corpus/templates/design/app/root.tsx +7 -1
- package/corpus/templates/design/app/routes/settings.tsx +10 -2
- package/corpus/templates/dispatch/CHANGELOG.md +10 -0
- package/corpus/templates/dispatch/app/root.tsx +7 -1
- package/corpus/templates/forms/CHANGELOG.md +10 -0
- package/corpus/templates/forms/app/root.tsx +7 -1
- package/corpus/templates/macros/CHANGELOG.md +10 -0
- package/corpus/templates/macros/app/root.tsx +7 -1
- package/corpus/templates/mail/CHANGELOG.md +10 -0
- package/corpus/templates/mail/app/components/layout/CommandPalette.tsx +3 -0
- package/corpus/templates/mail/app/pages/SettingsPage.tsx +27 -0
- package/corpus/templates/plan/.agents/skills/visual-plan/SKILL.md +31 -17
- package/corpus/templates/plan/.agents/skills/visual-plan/references/wireframe.md +7 -4
- package/corpus/templates/plan/.agents/skills/visual-recap/SKILL.md +34 -24
- package/corpus/templates/plan/.agents/skills/visual-recap/references/wireframe.md +7 -4
- package/corpus/templates/plan/AGENTS.md +4 -0
- package/corpus/templates/plan/CHANGELOG.md +10 -0
- package/corpus/templates/plan/actions/view-screen.ts +5 -0
- package/corpus/templates/plan/app/components/layout/Sidebar.tsx +98 -1
- package/corpus/templates/plan/app/pages/PlansPage.tsx +107 -7
- package/corpus/templates/plan/app/root.tsx +7 -1
- package/corpus/templates/plan/shared/share-attribution.ts +72 -0
- package/corpus/templates/slides/CHANGELOG.md +10 -0
- package/corpus/templates/slides/app/root.tsx +7 -1
- package/corpus/templates/videos/CHANGELOG.md +4 -151
- package/corpus/templates/videos/app/root.tsx +7 -1
- package/dist/changelog/parse.d.ts +70 -0
- package/dist/changelog/parse.d.ts.map +1 -0
- package/dist/changelog/parse.js +200 -0
- package/dist/changelog/parse.js.map +1 -0
- package/dist/cli/changelog.d.ts +4 -0
- package/dist/cli/changelog.d.ts.map +1 -0
- package/dist/cli/changelog.js +166 -0
- package/dist/cli/changelog.js.map +1 -0
- package/dist/cli/index.js +18 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/recap.d.ts.map +1 -1
- package/dist/cli/recap.js +22 -1
- package/dist/cli/recap.js.map +1 -1
- package/dist/cli/skills.d.ts +3 -3
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +72 -45
- package/dist/cli/skills.js.map +1 -1
- package/dist/client/CommandMenu.d.ts +17 -1
- package/dist/client/CommandMenu.d.ts.map +1 -1
- package/dist/client/CommandMenu.js +49 -13
- package/dist/client/CommandMenu.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +43 -6
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/analytics.d.ts +18 -0
- package/dist/client/analytics.d.ts.map +1 -1
- package/dist/client/analytics.js +177 -0
- package/dist/client/analytics.js.map +1 -1
- package/dist/client/changelog/Changelog.d.ts +47 -0
- package/dist/client/changelog/Changelog.d.ts.map +1 -0
- package/dist/client/changelog/Changelog.js +138 -0
- package/dist/client/changelog/Changelog.js.map +1 -0
- package/dist/client/index.d.ts +2 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +2 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/mcp-apps/McpAppRenderer.d.ts +1 -0
- package/dist/client/mcp-apps/McpAppRenderer.d.ts.map +1 -1
- package/dist/client/mcp-apps/McpAppRenderer.js +42 -1
- package/dist/client/mcp-apps/McpAppRenderer.js.map +1 -1
- package/dist/client/settings/useBuilderStatus.d.ts +2 -0
- package/dist/client/settings/useBuilderStatus.d.ts.map +1 -1
- package/dist/client/settings/useBuilderStatus.js +58 -10
- package/dist/client/settings/useBuilderStatus.js.map +1 -1
- package/dist/mcp/build-server.js +1 -1
- package/dist/mcp/build-server.js.map +1 -1
- package/dist/mcp/embed-app.d.ts.map +1 -1
- package/dist/mcp/embed-app.js +112 -6
- package/dist/mcp/embed-app.js.map +1 -1
- package/dist/server/attribution.d.ts +83 -0
- package/dist/server/attribution.d.ts.map +1 -0
- package/dist/server/attribution.js +178 -0
- package/dist/server/attribution.js.map +1 -0
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +7 -0
- package/dist/server/auth.js.map +1 -1
- package/dist/server/better-auth-instance.d.ts +9 -1
- package/dist/server/better-auth-instance.d.ts.map +1 -1
- package/dist/server/better-auth-instance.js +32 -2
- package/dist/server/better-auth-instance.js.map +1 -1
- package/dist/server/builder-browser.d.ts +4 -0
- package/dist/server/builder-browser.d.ts.map +1 -1
- package/dist/server/builder-browser.js +20 -1
- package/dist/server/builder-browser.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts +25 -0
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +38 -0
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/google-oauth.d.ts.map +1 -1
- package/dist/server/google-oauth.js +16 -2
- package/dist/server/google-oauth.js.map +1 -1
- package/dist/shared/mcp-embed-headers.js +1 -1
- package/dist/shared/mcp-embed-headers.js.map +1 -1
- package/dist/styles/agent-conversation.css +21 -0
- package/dist/templates/workspace-core/.agents/skills/changelog/SKILL.md +111 -0
- package/dist/templates/workspace-core/.agents/skills/tracking/SKILL.md +46 -14
- package/package.json +1 -1
- package/src/templates/workspace-core/.agents/skills/changelog/SKILL.md +111 -0
- package/src/templates/workspace-core/.agents/skills/tracking/SKILL.md +46 -14
- /package/corpus/templates/analytics/app/routes/{dashboards.tsx → dashboards._index.tsx} +0 -0
|
@@ -14,6 +14,24 @@ type SentryUser = {
|
|
|
14
14
|
email?: string;
|
|
15
15
|
username?: string;
|
|
16
16
|
};
|
|
17
|
+
export interface FirstTouchAttribution {
|
|
18
|
+
ref?: string;
|
|
19
|
+
via?: string;
|
|
20
|
+
utm_source?: string;
|
|
21
|
+
utm_medium?: string;
|
|
22
|
+
utm_campaign?: string;
|
|
23
|
+
utm_content?: string;
|
|
24
|
+
utm_term?: string;
|
|
25
|
+
landing_path?: string;
|
|
26
|
+
landing_referrer?: string;
|
|
27
|
+
landed_at?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Return the parsed first-touch referral attribution captured for this
|
|
31
|
+
* visitor, or `null` when none is stored. Reads from `localStorage`
|
|
32
|
+
* (`an_attribution`). SSR-safe and defensive.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getFirstTouchAttribution(): FirstTouchAttribution | null;
|
|
17
35
|
/**
|
|
18
36
|
* Attach the current user to Sentry events from the browser. Pass `null` to
|
|
19
37
|
* clear (e.g. on logout). If Sentry isn't initialized yet, the value is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../src/client/analytics.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,CAAC;QAChC,uBAAuB,CAAC,EAAE;YACxB,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;SAC5B,CAAC;KACH;CACF;AAED,KAAK,eAAe,GAAG,CACrB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAChC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAO7B,KAAK,UAAU,GAAG;IAChB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;
|
|
1
|
+
{"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../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,MAAM,WAAW,oBAAoB;IACnC,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;IAC1C;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACpD;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,oBAAyB,GACjC,MAAM,GAAG,SAAS,CAyBpB;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,OAAO,EACd,OAAO,GAAE,oBAAyB,GACjC,MAAM,GAAG,SAAS,CAEpB;AAeD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IACzC,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC,GAAG,IAAI,CAWP;AAgKD,wBAAgB,UAAU,CACxB,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC/B,IAAI,CASN;AAED,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAE1D"}
|
package/dist/client/analytics.js
CHANGED
|
@@ -25,6 +25,29 @@ const LLM_CONNECTION_CACHE_TTL_MS = 5 * 60 * 1000;
|
|
|
25
25
|
// overnight starts a new session in the morning rather than stretching one
|
|
26
26
|
// session over multiple visits.
|
|
27
27
|
const SESSION_IDLE_TIMEOUT_MS = 30 * 60 * 1000;
|
|
28
|
+
// First-touch referral attribution (viral attribution). Captured once on the
|
|
29
|
+
// visitor's first page load and persisted across the signup boundary so the
|
|
30
|
+
// server-side `signup` event can record where the user came from. First-write
|
|
31
|
+
// wins — an existing value is never overwritten.
|
|
32
|
+
const FIRST_TOUCH_STORAGE_KEY = "an_attribution";
|
|
33
|
+
const FIRST_TOUCH_COOKIE_NAME = "an_ft";
|
|
34
|
+
// 30 days, matching the session cookie lifetime — long enough to bridge a
|
|
35
|
+
// "land today, sign up next week" path without retaining attribution forever.
|
|
36
|
+
const FIRST_TOUCH_COOKIE_MAX_AGE_SECONDS = 2592000;
|
|
37
|
+
const FIRST_TOUCH_MAX_FIELD_LENGTH = 120;
|
|
38
|
+
// Keep the serialized cookie well under the ~4KB browser cap; we bail rather
|
|
39
|
+
// than write a runaway cookie if some field combination blows past this.
|
|
40
|
+
const FIRST_TOUCH_MAX_COOKIE_BYTES = 1500;
|
|
41
|
+
const FIRST_TOUCH_QUERY_FIELDS = [
|
|
42
|
+
"ref",
|
|
43
|
+
"via",
|
|
44
|
+
"utm_source",
|
|
45
|
+
"utm_medium",
|
|
46
|
+
"utm_campaign",
|
|
47
|
+
"utm_content",
|
|
48
|
+
"utm_term",
|
|
49
|
+
];
|
|
50
|
+
let _firstTouchCaptured = false;
|
|
28
51
|
function generateVisitorId() {
|
|
29
52
|
try {
|
|
30
53
|
if (typeof crypto !== "undefined" &&
|
|
@@ -168,6 +191,159 @@ function getOrCreateSessionId() {
|
|
|
168
191
|
safeStorageSet(SESSION_LAST_ACTIVITY_STORAGE_KEY, String(now));
|
|
169
192
|
return id;
|
|
170
193
|
}
|
|
194
|
+
function truncateFirstTouchField(value) {
|
|
195
|
+
if (!value)
|
|
196
|
+
return "";
|
|
197
|
+
const trimmed = value.trim();
|
|
198
|
+
if (!trimmed)
|
|
199
|
+
return "";
|
|
200
|
+
return trimmed.slice(0, FIRST_TOUCH_MAX_FIELD_LENGTH);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Extract just the host of a referrer URL — never the full URL or query
|
|
204
|
+
* string (those can carry tokens). Returns "" when there's no usable host or
|
|
205
|
+
* the referrer is same-origin (a same-site navigation isn't a referral).
|
|
206
|
+
*/
|
|
207
|
+
function scrubReferrerHost(referrer) {
|
|
208
|
+
if (!referrer)
|
|
209
|
+
return "";
|
|
210
|
+
try {
|
|
211
|
+
const url = new URL(referrer);
|
|
212
|
+
const host = url.host;
|
|
213
|
+
if (!host)
|
|
214
|
+
return "";
|
|
215
|
+
if (typeof window !== "undefined" &&
|
|
216
|
+
host.toLowerCase() === window.location.host.toLowerCase()) {
|
|
217
|
+
return "";
|
|
218
|
+
}
|
|
219
|
+
return truncateFirstTouchField(host);
|
|
220
|
+
}
|
|
221
|
+
catch {
|
|
222
|
+
return "";
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
function buildFirstTouchAttribution() {
|
|
226
|
+
const attribution = {};
|
|
227
|
+
let params = null;
|
|
228
|
+
try {
|
|
229
|
+
params = new URLSearchParams(window.location.search);
|
|
230
|
+
}
|
|
231
|
+
catch {
|
|
232
|
+
params = null;
|
|
233
|
+
}
|
|
234
|
+
if (params) {
|
|
235
|
+
for (const field of FIRST_TOUCH_QUERY_FIELDS) {
|
|
236
|
+
const value = truncateFirstTouchField(params.get(field));
|
|
237
|
+
if (value)
|
|
238
|
+
attribution[field] = value;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
const landingPath = truncateFirstTouchField(window.location.pathname);
|
|
242
|
+
if (landingPath)
|
|
243
|
+
attribution.landing_path = landingPath;
|
|
244
|
+
const landingReferrer = typeof document !== "undefined" ? scrubReferrerHost(document.referrer) : "";
|
|
245
|
+
if (landingReferrer)
|
|
246
|
+
attribution.landing_referrer = landingReferrer;
|
|
247
|
+
attribution.landed_at = new Date().toISOString();
|
|
248
|
+
return attribution;
|
|
249
|
+
}
|
|
250
|
+
function readFirstTouchCookie() {
|
|
251
|
+
if (typeof document === "undefined")
|
|
252
|
+
return null;
|
|
253
|
+
try {
|
|
254
|
+
const cookies = document.cookie ? document.cookie.split(";") : [];
|
|
255
|
+
for (const part of cookies) {
|
|
256
|
+
const eq = part.indexOf("=");
|
|
257
|
+
if (eq === -1)
|
|
258
|
+
continue;
|
|
259
|
+
const name = part.slice(0, eq).trim();
|
|
260
|
+
if (name === FIRST_TOUCH_COOKIE_NAME) {
|
|
261
|
+
return part.slice(eq + 1).trim();
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
catch {
|
|
266
|
+
// document.cookie can throw in sandboxed iframes — best-effort.
|
|
267
|
+
}
|
|
268
|
+
return null;
|
|
269
|
+
}
|
|
270
|
+
function writeFirstTouchCookie(encodedValue) {
|
|
271
|
+
if (typeof document === "undefined")
|
|
272
|
+
return;
|
|
273
|
+
// Non-sensitive, written by client JS, so no HttpOnly. SameSite=Lax keeps it
|
|
274
|
+
// on top-level navigations (which is how share links arrive) without leaking
|
|
275
|
+
// it to cross-site subresource requests.
|
|
276
|
+
const cookie = `${FIRST_TOUCH_COOKIE_NAME}=${encodedValue}; path=/; ` +
|
|
277
|
+
`max-age=${FIRST_TOUCH_COOKIE_MAX_AGE_SECONDS}; SameSite=Lax`;
|
|
278
|
+
if (cookie.length > FIRST_TOUCH_MAX_COOKIE_BYTES)
|
|
279
|
+
return;
|
|
280
|
+
try {
|
|
281
|
+
document.cookie = cookie;
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
// best-effort
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Capture the visitor's first-touch referral attribution exactly once. Reads
|
|
289
|
+
* the current URL query params + landing info and, IF no attribution is
|
|
290
|
+
* already stored (first-write-wins), persists it to both `localStorage`
|
|
291
|
+
* (`an_attribution`) and the first-party `an_ft` cookie. Fully defensive and
|
|
292
|
+
* SSR-safe — any failure is swallowed so it can never break app boot.
|
|
293
|
+
*/
|
|
294
|
+
function captureFirstTouchAttribution() {
|
|
295
|
+
if (_firstTouchCaptured)
|
|
296
|
+
return;
|
|
297
|
+
_firstTouchCaptured = true;
|
|
298
|
+
if (typeof window === "undefined")
|
|
299
|
+
return;
|
|
300
|
+
try {
|
|
301
|
+
const existing = safeStorageGet(FIRST_TOUCH_STORAGE_KEY);
|
|
302
|
+
if (existing) {
|
|
303
|
+
// Already captured in a prior visit. Backfill the cookie if it expired
|
|
304
|
+
// or was cleared so the signup boundary still sees first-touch data, but
|
|
305
|
+
// never overwrite the stored value itself (first-write-wins).
|
|
306
|
+
if (!readFirstTouchCookie()) {
|
|
307
|
+
try {
|
|
308
|
+
writeFirstTouchCookie(encodeURIComponent(existing));
|
|
309
|
+
}
|
|
310
|
+
catch {
|
|
311
|
+
// ignore
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
const attribution = buildFirstTouchAttribution();
|
|
317
|
+
const json = JSON.stringify(attribution);
|
|
318
|
+
safeStorageSet(FIRST_TOUCH_STORAGE_KEY, json);
|
|
319
|
+
writeFirstTouchCookie(encodeURIComponent(json));
|
|
320
|
+
}
|
|
321
|
+
catch {
|
|
322
|
+
// Attribution is best-effort telemetry; never let it break boot.
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Return the parsed first-touch referral attribution captured for this
|
|
327
|
+
* visitor, or `null` when none is stored. Reads from `localStorage`
|
|
328
|
+
* (`an_attribution`). SSR-safe and defensive.
|
|
329
|
+
*/
|
|
330
|
+
export function getFirstTouchAttribution() {
|
|
331
|
+
if (typeof window === "undefined")
|
|
332
|
+
return null;
|
|
333
|
+
try {
|
|
334
|
+
const raw = safeStorageGet(FIRST_TOUCH_STORAGE_KEY);
|
|
335
|
+
if (!raw)
|
|
336
|
+
return null;
|
|
337
|
+
const parsed = JSON.parse(raw);
|
|
338
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
339
|
+
return null;
|
|
340
|
+
}
|
|
341
|
+
return parsed;
|
|
342
|
+
}
|
|
343
|
+
catch {
|
|
344
|
+
return null;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
171
347
|
function isLocalAnalyticsHostname(hostname) {
|
|
172
348
|
const h = (hostname || "").toLowerCase();
|
|
173
349
|
return (h === "localhost" ||
|
|
@@ -431,6 +607,7 @@ export function configureTracking(options) {
|
|
|
431
607
|
if (typeof window !== "undefined") {
|
|
432
608
|
ensureSentry();
|
|
433
609
|
ensureAmplitude();
|
|
610
|
+
captureFirstTouchAttribution();
|
|
434
611
|
installLlmConnectionRefresh();
|
|
435
612
|
installPageviewTracking();
|
|
436
613
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../src/client/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,8BAA8B,CAAC;AAC1D,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACL,+BAA+B,GAEhC,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AA4B1C,IAAI,gBAAgB,GAA2B,IAAI,CAAC;AACpD,IAAI,qBAAqB,GAAG,KAAK,CAAC;AAClC,IAAI,kBAAkB,GAAG,KAAK,CAAC;AAC/B,IAAI,oBAAoB,GAA+B,IAAI,CAAC;AAC5D,IAAI,qBAAqB,GAAyB,IAAI,CAAC;AACvD,IAAI,8BAA8B,GAAG,KAAK,CAAC;AAC3C,qEAAqE;AACrE,uEAAuE;AACvE,IAAI,kBAAkB,GAAkC,SAAS,CAAC;AAClE,IAAI,mBAAmB,GAA8B,SAAS,CAAC;AAE/D,MAAM,uCAAuC,GAC3C,0CAA0C,CAAC;AAC7C,MAAM,2BAA2B,GAAG,MAAM,CAAC,GAAG,CAC5C,sCAAsC,CACvC,CAAC;AAEF,MAAM,wBAAwB,GAAG,2BAA2B,CAAC;AAC7D,MAAM,sBAAsB,GAAG,yBAAyB,CAAC;AACzD,MAAM,iCAAiC,GAAG,oCAAoC,CAAC;AAC/E,MAAM,0BAA0B,GA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,CAAC,CAAC;IACzC,MAAM,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;IACzD,IAAI,eAAe,EAAE,EAAE,CAAC;QACtB,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;IACD,wBAAwB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,QAAiB;IAClD,UAAU,CAAC,gBAAgB,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import * as amplitude from \"@amplitude/analytics-browser\";\nimport * as Sentry from \"@sentry/browser\";\nimport { agentNativePath } from \"./api-path.js\";\nimport {\n llmConnectionTrackingProperties,\n type LlmConnectionStatus,\n} from \"../shared/llm-connection.js\";\nimport { scrubUrl } from \"./url-scrub.js\";\nexport { scrubUrl } from \"./url-scrub.js\";\n\ndeclare global {\n interface Window {\n gtag?: (...args: any[]) => void;\n __AGENT_NATIVE_CONFIG__?: {\n sentryDsn?: string;\n sentryEnvironment?: string;\n };\n }\n}\n\ntype GetDefaultProps = (\n name: string,\n properties: Record<string, unknown>,\n) => Record<string, unknown>;\n\ntype PageviewTrackingState = {\n installed: boolean;\n lastPageviewKey: string | null;\n};\n\ntype SentryUser = {\n id?: string;\n email?: string;\n username?: string;\n};\n\nlet _getDefaultProps: GetDefaultProps | null = null;\nlet _amplitudeInitialized = false;\nlet _sentryInitialized = false;\nlet _llmConnectionStatus: LlmConnectionStatus | null = null;\nlet _llmConnectionRefresh: Promise<void> | null = null;\nlet _llmConnectionRefreshInstalled = false;\n// Buffer for setSentryUser calls made before Sentry has initialized.\n// `undefined` means \"no pending update\"; `null` means \"pending clear\".\nlet _pendingSentryUser: SentryUser | null | undefined = undefined;\nlet _pendingSentryOrgId: string | null | undefined = undefined;\n\nconst AGENT_NATIVE_ANALYTICS_DEFAULT_ENDPOINT =\n \"https://analytics.agent-native.com/track\";\nconst PAGEVIEW_TRACKING_STATE_KEY = Symbol.for(\n \"agent-native.client.pageviewTracking\",\n);\n\nconst ANONYMOUS_ID_STORAGE_KEY = \"agent-native.anonymous_id\";\nconst SESSION_ID_STORAGE_KEY = \"agent-native.session_id\";\nconst SESSION_LAST_ACTIVITY_STORAGE_KEY = \"agent-native.session_last_activity\";\nconst LLM_CONNECTION_STORAGE_KEY = \"agent-native.llm_connection_status\";\nconst LLM_CONNECTION_CACHE_TTL_MS = 5 * 60 * 1000;\n// 30-minute idle timeout matches GA4 / Mixpanel defaults — a tab left open\n// overnight starts a new session in the morning rather than stretching one\n// session over multiple visits.\nconst SESSION_IDLE_TIMEOUT_MS = 30 * 60 * 1000;\n\nfunction generateVisitorId(): string {\n try {\n if (\n typeof crypto !== \"undefined\" &&\n typeof crypto.randomUUID === \"function\"\n ) {\n return crypto.randomUUID();\n }\n } catch {\n // fall through to Math.random\n }\n return (\n Date.now().toString(36) +\n Math.random().toString(36).slice(2) +\n Math.random().toString(36).slice(2)\n );\n}\n\nfunction safeStorageGet(key: string): string | null {\n try {\n return window.localStorage.getItem(key);\n } catch {\n return null;\n }\n}\n\nfunction safeStorageSet(key: string, value: string): void {\n try {\n window.localStorage.setItem(key, value);\n } catch {\n // private browsing / storage disabled — best-effort\n }\n}\n\nfunction readCachedLlmConnectionStatus(): LlmConnectionStatus | null {\n if (typeof window === \"undefined\") return null;\n const raw = safeStorageGet(LLM_CONNECTION_STORAGE_KEY);\n if (!raw) return null;\n try {\n const parsed = JSON.parse(raw) as LlmConnectionStatus & {\n cachedAt?: number;\n };\n if (\n typeof parsed.cachedAt !== \"number\" ||\n Date.now() - parsed.cachedAt > LLM_CONNECTION_CACHE_TTL_MS\n ) {\n return null;\n }\n return {\n configured: parsed.configured,\n engine: parsed.engine,\n model: parsed.model,\n source: parsed.source,\n envVar: parsed.envVar,\n };\n } catch {\n return null;\n }\n}\n\nfunction cacheLlmConnectionStatus(status: LlmConnectionStatus): void {\n if (typeof window === \"undefined\") return;\n safeStorageSet(\n LLM_CONNECTION_STORAGE_KEY,\n JSON.stringify({ ...status, cachedAt: Date.now() }),\n );\n}\n\nfunction normalizeAgentEngineStatus(data: unknown): LlmConnectionStatus {\n const value = data as Record<string, unknown> | null;\n if (!value || value.configured !== true) {\n return { configured: false };\n }\n return {\n configured: true,\n engine: typeof value.engine === \"string\" ? value.engine : null,\n model: typeof value.model === \"string\" ? value.model : null,\n source: typeof value.source === \"string\" ? value.source : null,\n envVar: typeof value.envVar === \"string\" ? value.envVar : null,\n };\n}\n\nfunction refreshLlmConnectionStatus(): Promise<void> {\n if (typeof window === \"undefined\" || typeof fetch !== \"function\") {\n return Promise.resolve();\n }\n if (_llmConnectionRefresh) return _llmConnectionRefresh;\n let request: Promise<Response>;\n try {\n request = fetch(agentNativePath(\"/_agent-native/agent-engine/status\"));\n } catch {\n return Promise.resolve();\n }\n _llmConnectionRefresh = request\n .then((res) => (res.ok ? res.json() : null))\n .then((data) => {\n _llmConnectionStatus = normalizeAgentEngineStatus(data);\n cacheLlmConnectionStatus(_llmConnectionStatus);\n })\n .catch(() => {\n if (!_llmConnectionStatus) {\n _llmConnectionStatus = readCachedLlmConnectionStatus();\n }\n })\n .finally(() => {\n _llmConnectionRefresh = null;\n });\n return _llmConnectionRefresh;\n}\n\nfunction installLlmConnectionRefresh(): void {\n if (typeof window === \"undefined\" || _llmConnectionRefreshInstalled) return;\n _llmConnectionRefreshInstalled = true;\n _llmConnectionStatus = readCachedLlmConnectionStatus();\n void refreshLlmConnectionStatus();\n window.addEventListener(\"focus\", () => {\n void refreshLlmConnectionStatus();\n });\n window.addEventListener(\"agent-engine:configured-changed\", () => {\n void refreshLlmConnectionStatus();\n });\n}\n\nfunction getOrCreateAnonymousId(): string | undefined {\n if (typeof window === \"undefined\") return undefined;\n let id = safeStorageGet(ANONYMOUS_ID_STORAGE_KEY);\n if (!id) {\n id = generateVisitorId();\n safeStorageSet(ANONYMOUS_ID_STORAGE_KEY, id);\n }\n return id;\n}\n\nfunction getOrCreateSessionId(): string | undefined {\n if (typeof window === \"undefined\") return undefined;\n const now = Date.now();\n const lastActivityRaw = safeStorageGet(SESSION_LAST_ACTIVITY_STORAGE_KEY);\n const lastActivity = lastActivityRaw\n ? Number.parseInt(lastActivityRaw, 10)\n : 0;\n let id = safeStorageGet(SESSION_ID_STORAGE_KEY);\n const expired =\n !lastActivity ||\n Number.isNaN(lastActivity) ||\n now - lastActivity > SESSION_IDLE_TIMEOUT_MS;\n if (!id || expired) {\n id = generateVisitorId();\n safeStorageSet(SESSION_ID_STORAGE_KEY, id);\n }\n safeStorageSet(SESSION_LAST_ACTIVITY_STORAGE_KEY, String(now));\n return id;\n}\n\nfunction isLocalAnalyticsHostname(hostname: string | undefined): boolean {\n const h = (hostname || \"\").toLowerCase();\n return (\n h === \"localhost\" ||\n h === \"127.0.0.1\" ||\n h === \"::1\" ||\n h === \"[::1]\" ||\n h.endsWith(\".localhost\") ||\n h.endsWith(\".local\")\n );\n}\n\nfunction ensureAmplitude(): boolean {\n if (_amplitudeInitialized) return true;\n const key = (import.meta.env as Record<string, string | undefined>)\n ?.VITE_AMPLITUDE_API_KEY;\n if (!key) return false;\n amplitude.init(key, { autocapture: true });\n _amplitudeInitialized = true;\n return true;\n}\n\nfunction shouldDropBrowserSentryNoise(event: Sentry.Event): boolean {\n const exceptionValues = event.exception?.values ?? [];\n // AgentAutoContinueSignal is a control-flow sentinel thrown to bubble\n // out of the SSE stream parser when the agent run needs to be\n // auto-continued. It's caught by the chat adapter and is never a real\n // error. Drop it unconditionally — capturing it as a Sentry exception\n // pollutes the issue list with sentinels that have no actionable stack.\n if (\n exceptionValues.some((value) => value.type === \"AgentAutoContinueSignal\")\n ) {\n return true;\n }\n // Browser-side access control rejections usually mean a tab outlived the\n // session or hit a protected route while signed out. The server Sentry setup\n // already drops these bare auth errors; mirror that here for client-captured\n // route/query failures.\n if (\n exceptionValues.some((value) => {\n const exceptionType = String(value.type ?? \"\")\n .trim()\n .toLowerCase();\n const exceptionValue = String(value.value ?? \"\")\n .trim()\n .toLowerCase();\n return (\n exceptionType === \"unauthorizederror\" ||\n exceptionType === \"unauthenticatederror\" ||\n exceptionValue === \"unauthorized\" ||\n exceptionValue === \"unauthenticated\"\n );\n })\n ) {\n return true;\n }\n // Safari occasionally reports a source-less global `EmptyRanges` reference\n // error while browsing public pages. There is no script URL or function to\n // map back to our bundle, so keep the filter narrow and only drop it when\n // every frame is missing/undefined.\n if (\n exceptionValues.some((value) => {\n const exceptionType = String(value.type ?? \"\")\n .trim()\n .toLowerCase();\n const exceptionValue = String(value.value ?? \"\")\n .trim()\n .toLowerCase();\n if (\n exceptionType !== \"referenceerror\" ||\n !exceptionValue.includes(\"emptyranges\")\n ) {\n return false;\n }\n const frames = value.stacktrace?.frames ?? [];\n return (\n frames.length === 0 ||\n frames.every((frame) => {\n const filename = String(frame.filename ?? frame.abs_path ?? \"\")\n .trim()\n .toLowerCase();\n const functionName = String(frame.function ?? \"\").trim();\n return (\n !functionName &&\n (!filename ||\n filename === \"undefined\" ||\n filename === \"<anonymous>\")\n );\n })\n );\n })\n ) {\n return true;\n }\n // Exact user/navigation aborts are expected browser behavior. Keep other\n // AbortError shapes visible unless they match this common non-bug message.\n if (\n exceptionValues.some((value) => {\n const exceptionType = String(value.type ?? \"\")\n .trim()\n .toLowerCase();\n const exceptionValue = String(value.value ?? \"\")\n .trim()\n .toLowerCase();\n return (\n exceptionValue === \"the user aborted a request.\" ||\n exceptionValue === \"aborterror: the user aborted a request.\" ||\n (exceptionType === \"aborterror\" &&\n exceptionValue.includes(\"the user aborted a request\"))\n );\n })\n ) {\n return true;\n }\n const exceptionText = exceptionValues\n .map((value) => `${value.type ?? \"\"} ${value.value ?? \"\"}`)\n .join(\" \")\n .toLowerCase();\n const requestUrl = event.request?.url?.toLowerCase() ?? \"\";\n const breadcrumbText = (event.breadcrumbs ?? [])\n .map((crumb) => {\n const data = crumb.data as Record<string, unknown> | undefined;\n return [\n crumb.category,\n crumb.message,\n typeof data?.url === \"string\" ? data.url : \"\",\n ].join(\" \");\n })\n .join(\" \")\n .toLowerCase();\n const combined = `${exceptionText} ${requestUrl} ${breadcrumbText}`;\n return (\n combined.includes(\"api2.amplitude.com\") &&\n (combined.includes(\"failed to fetch\") ||\n combined.includes(\"networkerror\") ||\n combined.includes(\"load failed\"))\n );\n}\n\nfunction getClientSentryDsn(): string | undefined {\n const env = (import.meta.env as Record<string, string | undefined>) ?? {};\n return (\n env.VITE_SENTRY_CLIENT_DSN ||\n env.VITE_SENTRY_DSN ||\n window.__AGENT_NATIVE_CONFIG__?.sentryDsn\n );\n}\n\nfunction ensureSentry(): void {\n if (_sentryInitialized) return;\n const dsn = getClientSentryDsn();\n if (!dsn) return;\n Sentry.init({\n dsn,\n environment:\n window.__AGENT_NATIVE_CONFIG__?.sentryEnvironment ||\n (import.meta.env as Record<string, string | undefined>)?.MODE ||\n \"production\",\n beforeSend(event) {\n if (shouldDropBrowserSentryNoise(event)) {\n return null;\n }\n // Strip sensitive query params from the request URL. React Router\n // history can include share tokens, ?signin=1, password reset codes,\n // public-share password params (audit F-07), etc.\n if (event.request?.url) {\n event.request.url = scrubUrl(event.request.url);\n }\n // Clean the same params from breadcrumb URLs (Sentry captures\n // history.pushState breadcrumbs by default).\n if (Array.isArray(event.breadcrumbs)) {\n for (const crumb of event.breadcrumbs) {\n if (crumb && typeof crumb === \"object\" && \"data\" in crumb) {\n const data = crumb.data as Record<string, unknown> | undefined;\n if (data && typeof data.url === \"string\") {\n data.url = scrubUrl(data.url);\n }\n if (data && typeof data.from === \"string\") {\n data.from = scrubUrl(data.from);\n }\n if (data && typeof data.to === \"string\") {\n data.to = scrubUrl(data.to);\n }\n }\n }\n }\n return event;\n },\n });\n Sentry.setTag(\"runtime\", \"browser\");\n _sentryInitialized = true;\n // Flush any user/tag that was set before init.\n if (_pendingSentryUser !== undefined) {\n Sentry.setUser(_pendingSentryUser);\n _pendingSentryUser = undefined;\n }\n if (_pendingSentryOrgId !== undefined) {\n Sentry.setTag(\"orgId\", _pendingSentryOrgId);\n _pendingSentryOrgId = undefined;\n }\n}\n\n/**\n * Attach the current user to Sentry events from the browser. Pass `null` to\n * clear (e.g. on logout). If Sentry isn't initialized yet, the value is\n * buffered and applied once `ensureSentry()` runs.\n *\n * Pass `orgId` to also tag events with the active organization ID — useful\n * for filtering Sentry by tenant.\n */\nexport function setSentryUser(\n user: SentryUser | null,\n orgId?: string | null,\n): void {\n if (_sentryInitialized) {\n Sentry.setUser(user);\n if (orgId !== undefined) {\n Sentry.setTag(\"orgId\", orgId ?? null);\n }\n return;\n }\n _pendingSentryUser = user;\n if (orgId !== undefined) {\n _pendingSentryOrgId = orgId ?? null;\n }\n}\n\nexport interface ClientCaptureContext {\n /** Searchable Sentry tags (low-cardinality strings only). */\n tags?: Record<string, string | undefined>;\n /**\n * High-cardinality / structured payload — not searchable but visible in\n * the Sentry event detail (file sizes, request URLs, response body\n * tails, etc.).\n */\n extra?: Record<string, unknown>;\n /**\n * Grouped contexts shown as separate cards in the Sentry event UI.\n */\n contexts?: Record<string, Record<string, unknown>>;\n}\n\n/**\n * Capture an exception to Sentry from browser code without forcing the\n * caller to depend on `@sentry/browser` directly.\n *\n * Templates can route a thrown Error through here on a known failure path\n * (chunk-upload 500, thumbnail upload, etc.) to attach searchable tags and\n * structured extra context. No-ops gracefully when Sentry isn't\n * initialized — never throws back into the caller, so a Sentry hiccup\n * can't mask the original error.\n */\nexport function captureClientException(\n error: unknown,\n context: ClientCaptureContext = {},\n): string | undefined {\n if (typeof window === \"undefined\") return undefined;\n try {\n ensureSentry();\n return Sentry.withScope((scope) => {\n if (context.tags) {\n for (const [k, v] of Object.entries(context.tags)) {\n if (typeof v === \"string\") scope.setTag(k, v);\n }\n }\n if (context.extra) {\n for (const [k, v] of Object.entries(context.extra)) {\n if (v !== undefined) scope.setExtra(k, v);\n }\n }\n if (context.contexts) {\n for (const [k, v] of Object.entries(context.contexts)) {\n scope.setContext(k, v);\n }\n }\n return Sentry.captureException(error);\n });\n } catch {\n return undefined;\n }\n}\n\n/**\n * Public browser-side error capture utility, mirroring `trackEvent()`:\n * templates can call `captureError(err, { tags, extra, contexts })` without\n * depending on Sentry directly. Sentry receives the event when a browser DSN\n * is configured; otherwise this is a quiet no-op.\n */\nexport function captureError(\n error: unknown,\n context: ClientCaptureContext = {},\n): string | undefined {\n return captureClientException(error, context);\n}\n\nfunction getPageviewTrackingState(): PageviewTrackingState {\n const g = globalThis as typeof globalThis & {\n [PAGEVIEW_TRACKING_STATE_KEY]?: PageviewTrackingState;\n };\n if (!g[PAGEVIEW_TRACKING_STATE_KEY]) {\n g[PAGEVIEW_TRACKING_STATE_KEY] = {\n installed: false,\n lastPageviewKey: null,\n };\n }\n return g[PAGEVIEW_TRACKING_STATE_KEY];\n}\n\nexport function configureTracking(options: {\n getDefaultProps?: GetDefaultProps;\n}): void {\n if (options.getDefaultProps) {\n _getDefaultProps = options.getDefaultProps;\n }\n if (typeof window !== \"undefined\") {\n ensureSentry();\n ensureAmplitude();\n installLlmConnectionRefresh();\n installPageviewTracking();\n }\n}\n\nfunction inferTemplateName(properties: Record<string, unknown>): string | null {\n const envTemplate =\n (import.meta.env as Record<string, string | undefined>)\n ?.VITE_AGENT_NATIVE_TEMPLATE ||\n (import.meta.env as Record<string, string | undefined>)?.VITE_APP_TEMPLATE;\n if (envTemplate) return envTemplate;\n\n const app = typeof properties.app === \"string\" ? properties.app.trim() : \"\";\n if (!app || app === \"localhost\") return null;\n if (app.startsWith(\"agent-native-\")) {\n return app.slice(\"agent-native-\".length);\n }\n return app;\n}\n\nfunction resolveProps(\n name: string,\n params?: Record<string, unknown>,\n): Record<string, unknown> {\n if (typeof window === \"undefined\") return { ...params };\n const base: Record<string, unknown> = {\n url: window.location.origin + window.location.pathname,\n app: window.location.hostname.split(\".\")[0] || \"localhost\",\n ...params,\n };\n const props = _getDefaultProps ? _getDefaultProps(name, base) : base;\n let withTemplate = props;\n if (withTemplate.template === undefined) {\n const template = inferTemplateName(props);\n if (template) {\n withTemplate = { ...props, template };\n }\n }\n const llmProps = llmConnectionTrackingProperties(_llmConnectionStatus);\n const enriched = { ...withTemplate };\n for (const [key, value] of Object.entries(llmProps)) {\n if (enriched[key] === undefined) enriched[key] = value;\n }\n return enriched;\n}\n\nfunction pageviewKey(): string {\n return window.location.href;\n}\n\nfunction pageviewProperties(reason: string): Record<string, unknown> {\n const properties: Record<string, unknown> = {\n url: scrubUrl(window.location.href),\n path: window.location.pathname,\n hostname: window.location.hostname,\n navigation_type: reason,\n };\n if (window.location.search) {\n properties.search = scrubUrl(window.location.search);\n }\n if (typeof document !== \"undefined\") {\n if (document.referrer) {\n properties.referrer = scrubUrl(document.referrer);\n }\n if (document.title) {\n properties.title = document.title;\n }\n }\n return properties;\n}\n\nfunction emitPageview(reason: string): void {\n if (isLocalAnalyticsHostname(window.location.hostname)) return;\n const state = getPageviewTrackingState();\n const key = pageviewKey();\n if (state.lastPageviewKey === key) return;\n state.lastPageviewKey = key;\n trackEvent(\"pageview\", pageviewProperties(reason));\n}\n\nfunction schedulePageview(reason: string): void {\n const run = () => emitPageview(reason);\n if (_llmConnectionRefresh && !_llmConnectionStatus) {\n const timeout = new Promise<void>((resolve) =>\n window.setTimeout(resolve, 250),\n );\n Promise.race([_llmConnectionRefresh, timeout]).finally(run);\n return;\n }\n if (typeof queueMicrotask === \"function\") {\n queueMicrotask(run);\n return;\n }\n window.setTimeout(run, 0);\n}\n\nfunction installPageviewTracking(): void {\n const state = getPageviewTrackingState();\n if (state.installed) return;\n state.installed = true;\n\n schedulePageview(\"load\");\n\n const originalPushState = window.history.pushState;\n const originalReplaceState = window.history.replaceState;\n\n window.history.pushState = function pushState(...args) {\n const result = originalPushState.apply(this, args);\n schedulePageview(\"pushState\");\n return result;\n };\n\n window.history.replaceState = function replaceState(...args) {\n const result = originalReplaceState.apply(this, args);\n schedulePageview(\"replaceState\");\n return result;\n };\n\n window.addEventListener(\"popstate\", () => schedulePageview(\"popstate\"));\n}\n\nfunction sendAgentNativeAnalytics(\n name: string,\n properties: Record<string, unknown>,\n): void {\n if (isLocalAnalyticsHostname(window.location.hostname)) return;\n\n const publicKey = (import.meta.env as Record<string, string | undefined>)\n ?.VITE_AGENT_NATIVE_ANALYTICS_PUBLIC_KEY;\n if (!publicKey) return;\n\n const endpoint =\n (import.meta.env as Record<string, string | undefined>)\n ?.VITE_AGENT_NATIVE_ANALYTICS_ENDPOINT ||\n AGENT_NATIVE_ANALYTICS_DEFAULT_ENDPOINT;\n const userId =\n typeof properties.userId === \"string\" ? properties.userId : undefined;\n const body = JSON.stringify({\n publicKey,\n event: name,\n properties,\n userId,\n anonymousId: getOrCreateAnonymousId(),\n sessionId: getOrCreateSessionId(),\n timestamp: new Date().toISOString(),\n });\n\n try {\n if (navigator.sendBeacon) {\n const sent = navigator.sendBeacon(endpoint, body);\n if (sent) return;\n }\n fetch(endpoint, {\n method: \"POST\",\n body,\n keepalive: true,\n headers: { \"Content-Type\": \"text/plain;charset=UTF-8\" },\n }).catch(() => {});\n } catch {\n // best-effort\n }\n}\n\nexport function trackEvent(\n name: string,\n params?: Record<string, unknown>,\n): void {\n if (typeof window === \"undefined\") return;\n ensureSentry();\n const props = resolveProps(name, params);\n window.gtag?.(\"event\", name.replace(/\\s+/g, \"_\"), props);\n if (ensureAmplitude()) {\n amplitude.track(name, props);\n }\n sendAgentNativeAnalytics(name, props);\n}\n\nexport function trackSessionStatus(signedIn: boolean): void {\n trackEvent(\"session status\", { signed_in: signedIn });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../src/client/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,8BAA8B,CAAC;AAC1D,OAAO,KAAK,MAAM,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,EACL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QACH,IAAI,SAAS,CAAC,UAAU,EAAE,CAAC;YACzB,MAAM,IAAI,GAAG,SAAS,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YAClD,IAAI,IAAI;gBAAE,OAAO;QACnB,CAAC;QACD,KAAK,CAAC,QAAQ,EAAE;YACd,MAAM,EAAE,MAAM;YACd,IAAI;YACJ,SAAS,EAAE,IAAI;YACf,OAAO,EAAE,EAAE,cAAc,EAAE,0BAA0B,EAAE;SACxD,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;IACrB,CAAC;IAAC,MAAM,CAAC;QACP,cAAc;IAChB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU,CACxB,IAAY,EACZ,MAAgC;IAEhC,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,OAAO;IAC1C,YAAY,EAAE,CAAC;IACf,MAAM,KAAK,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACzC,MAAM,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;IACzD,IAAI,eAAe,EAAE,EAAE,CAAC;QACtB,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/B,CAAC;IACD,wBAAwB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,QAAiB;IAClD,UAAU,CAAC,gBAAgB,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC;AACxD,CAAC","sourcesContent":["import * as amplitude from \"@amplitude/analytics-browser\";\nimport * as Sentry from \"@sentry/browser\";\nimport { agentNativePath } from \"./api-path.js\";\nimport {\n llmConnectionTrackingProperties,\n type LlmConnectionStatus,\n} from \"../shared/llm-connection.js\";\nimport { scrubUrl } from \"./url-scrub.js\";\nexport { scrubUrl } from \"./url-scrub.js\";\n\ndeclare global {\n interface Window {\n gtag?: (...args: any[]) => void;\n __AGENT_NATIVE_CONFIG__?: {\n sentryDsn?: string;\n sentryEnvironment?: string;\n };\n }\n}\n\ntype GetDefaultProps = (\n name: string,\n properties: Record<string, unknown>,\n) => Record<string, unknown>;\n\ntype PageviewTrackingState = {\n installed: boolean;\n lastPageviewKey: string | null;\n};\n\ntype SentryUser = {\n id?: string;\n email?: string;\n username?: string;\n};\n\nlet _getDefaultProps: GetDefaultProps | null = null;\nlet _amplitudeInitialized = false;\nlet _sentryInitialized = false;\nlet _llmConnectionStatus: LlmConnectionStatus | null = null;\nlet _llmConnectionRefresh: Promise<void> | null = null;\nlet _llmConnectionRefreshInstalled = false;\n// Buffer for setSentryUser calls made before Sentry has initialized.\n// `undefined` means \"no pending update\"; `null` means \"pending clear\".\nlet _pendingSentryUser: SentryUser | null | undefined = undefined;\nlet _pendingSentryOrgId: string | null | undefined = undefined;\n\nconst AGENT_NATIVE_ANALYTICS_DEFAULT_ENDPOINT =\n \"https://analytics.agent-native.com/track\";\nconst PAGEVIEW_TRACKING_STATE_KEY = Symbol.for(\n \"agent-native.client.pageviewTracking\",\n);\n\nconst ANONYMOUS_ID_STORAGE_KEY = \"agent-native.anonymous_id\";\nconst SESSION_ID_STORAGE_KEY = \"agent-native.session_id\";\nconst SESSION_LAST_ACTIVITY_STORAGE_KEY = \"agent-native.session_last_activity\";\nconst LLM_CONNECTION_STORAGE_KEY = \"agent-native.llm_connection_status\";\nconst LLM_CONNECTION_CACHE_TTL_MS = 5 * 60 * 1000;\n// 30-minute idle timeout matches GA4 / Mixpanel defaults — a tab left open\n// overnight starts a new session in the morning rather than stretching one\n// session over multiple visits.\nconst SESSION_IDLE_TIMEOUT_MS = 30 * 60 * 1000;\n\n// First-touch referral attribution (viral attribution). Captured once on the\n// visitor's first page load and persisted across the signup boundary so the\n// server-side `signup` event can record where the user came from. First-write\n// wins — an existing value is never overwritten.\nconst FIRST_TOUCH_STORAGE_KEY = \"an_attribution\";\nconst FIRST_TOUCH_COOKIE_NAME = \"an_ft\";\n// 30 days, matching the session cookie lifetime — long enough to bridge a\n// \"land today, sign up next week\" path without retaining attribution forever.\nconst FIRST_TOUCH_COOKIE_MAX_AGE_SECONDS = 2592000;\nconst FIRST_TOUCH_MAX_FIELD_LENGTH = 120;\n// Keep the serialized cookie well under the ~4KB browser cap; we bail rather\n// than write a runaway cookie if some field combination blows past this.\nconst FIRST_TOUCH_MAX_COOKIE_BYTES = 1500;\nconst FIRST_TOUCH_QUERY_FIELDS = [\n \"ref\",\n \"via\",\n \"utm_source\",\n \"utm_medium\",\n \"utm_campaign\",\n \"utm_content\",\n \"utm_term\",\n] as const;\n\nlet _firstTouchCaptured = false;\n\nexport interface FirstTouchAttribution {\n ref?: string;\n via?: string;\n utm_source?: string;\n utm_medium?: string;\n utm_campaign?: string;\n utm_content?: string;\n utm_term?: string;\n landing_path?: string;\n landing_referrer?: string;\n landed_at?: string;\n}\n\nfunction generateVisitorId(): string {\n try {\n if (\n typeof crypto !== \"undefined\" &&\n typeof crypto.randomUUID === \"function\"\n ) {\n return crypto.randomUUID();\n }\n } catch {\n // fall through to Math.random\n }\n return (\n Date.now().toString(36) +\n Math.random().toString(36).slice(2) +\n Math.random().toString(36).slice(2)\n );\n}\n\nfunction safeStorageGet(key: string): string | null {\n try {\n return window.localStorage.getItem(key);\n } catch {\n return null;\n }\n}\n\nfunction safeStorageSet(key: string, value: string): void {\n try {\n window.localStorage.setItem(key, value);\n } catch {\n // private browsing / storage disabled — best-effort\n }\n}\n\nfunction readCachedLlmConnectionStatus(): LlmConnectionStatus | null {\n if (typeof window === \"undefined\") return null;\n const raw = safeStorageGet(LLM_CONNECTION_STORAGE_KEY);\n if (!raw) return null;\n try {\n const parsed = JSON.parse(raw) as LlmConnectionStatus & {\n cachedAt?: number;\n };\n if (\n typeof parsed.cachedAt !== \"number\" ||\n Date.now() - parsed.cachedAt > LLM_CONNECTION_CACHE_TTL_MS\n ) {\n return null;\n }\n return {\n configured: parsed.configured,\n engine: parsed.engine,\n model: parsed.model,\n source: parsed.source,\n envVar: parsed.envVar,\n };\n } catch {\n return null;\n }\n}\n\nfunction cacheLlmConnectionStatus(status: LlmConnectionStatus): void {\n if (typeof window === \"undefined\") return;\n safeStorageSet(\n LLM_CONNECTION_STORAGE_KEY,\n JSON.stringify({ ...status, cachedAt: Date.now() }),\n );\n}\n\nfunction normalizeAgentEngineStatus(data: unknown): LlmConnectionStatus {\n const value = data as Record<string, unknown> | null;\n if (!value || value.configured !== true) {\n return { configured: false };\n }\n return {\n configured: true,\n engine: typeof value.engine === \"string\" ? value.engine : null,\n model: typeof value.model === \"string\" ? value.model : null,\n source: typeof value.source === \"string\" ? value.source : null,\n envVar: typeof value.envVar === \"string\" ? value.envVar : null,\n };\n}\n\nfunction refreshLlmConnectionStatus(): Promise<void> {\n if (typeof window === \"undefined\" || typeof fetch !== \"function\") {\n return Promise.resolve();\n }\n if (_llmConnectionRefresh) return _llmConnectionRefresh;\n let request: Promise<Response>;\n try {\n request = fetch(agentNativePath(\"/_agent-native/agent-engine/status\"));\n } catch {\n return Promise.resolve();\n }\n _llmConnectionRefresh = request\n .then((res) => (res.ok ? res.json() : null))\n .then((data) => {\n _llmConnectionStatus = normalizeAgentEngineStatus(data);\n cacheLlmConnectionStatus(_llmConnectionStatus);\n })\n .catch(() => {\n if (!_llmConnectionStatus) {\n _llmConnectionStatus = readCachedLlmConnectionStatus();\n }\n })\n .finally(() => {\n _llmConnectionRefresh = null;\n });\n return _llmConnectionRefresh;\n}\n\nfunction installLlmConnectionRefresh(): void {\n if (typeof window === \"undefined\" || _llmConnectionRefreshInstalled) return;\n _llmConnectionRefreshInstalled = true;\n _llmConnectionStatus = readCachedLlmConnectionStatus();\n void refreshLlmConnectionStatus();\n window.addEventListener(\"focus\", () => {\n void refreshLlmConnectionStatus();\n });\n window.addEventListener(\"agent-engine:configured-changed\", () => {\n void refreshLlmConnectionStatus();\n });\n}\n\nfunction getOrCreateAnonymousId(): string | undefined {\n if (typeof window === \"undefined\") return undefined;\n let id = safeStorageGet(ANONYMOUS_ID_STORAGE_KEY);\n if (!id) {\n id = generateVisitorId();\n safeStorageSet(ANONYMOUS_ID_STORAGE_KEY, id);\n }\n return id;\n}\n\nfunction getOrCreateSessionId(): string | undefined {\n if (typeof window === \"undefined\") return undefined;\n const now = Date.now();\n const lastActivityRaw = safeStorageGet(SESSION_LAST_ACTIVITY_STORAGE_KEY);\n const lastActivity = lastActivityRaw\n ? Number.parseInt(lastActivityRaw, 10)\n : 0;\n let id = safeStorageGet(SESSION_ID_STORAGE_KEY);\n const expired =\n !lastActivity ||\n Number.isNaN(lastActivity) ||\n now - lastActivity > SESSION_IDLE_TIMEOUT_MS;\n if (!id || expired) {\n id = generateVisitorId();\n safeStorageSet(SESSION_ID_STORAGE_KEY, id);\n }\n safeStorageSet(SESSION_LAST_ACTIVITY_STORAGE_KEY, String(now));\n return id;\n}\n\nfunction truncateFirstTouchField(value: string | null | undefined): string {\n if (!value) return \"\";\n const trimmed = value.trim();\n if (!trimmed) return \"\";\n return trimmed.slice(0, FIRST_TOUCH_MAX_FIELD_LENGTH);\n}\n\n/**\n * Extract just the host of a referrer URL — never the full URL or query\n * string (those can carry tokens). Returns \"\" when there's no usable host or\n * the referrer is same-origin (a same-site navigation isn't a referral).\n */\nfunction scrubReferrerHost(referrer: string | undefined): string {\n if (!referrer) return \"\";\n try {\n const url = new URL(referrer);\n const host = url.host;\n if (!host) return \"\";\n if (\n typeof window !== \"undefined\" &&\n host.toLowerCase() === window.location.host.toLowerCase()\n ) {\n return \"\";\n }\n return truncateFirstTouchField(host);\n } catch {\n return \"\";\n }\n}\n\nfunction buildFirstTouchAttribution(): FirstTouchAttribution {\n const attribution: FirstTouchAttribution = {};\n let params: URLSearchParams | null = null;\n try {\n params = new URLSearchParams(window.location.search);\n } catch {\n params = null;\n }\n if (params) {\n for (const field of FIRST_TOUCH_QUERY_FIELDS) {\n const value = truncateFirstTouchField(params.get(field));\n if (value) attribution[field] = value;\n }\n }\n const landingPath = truncateFirstTouchField(window.location.pathname);\n if (landingPath) attribution.landing_path = landingPath;\n const landingReferrer =\n typeof document !== \"undefined\" ? scrubReferrerHost(document.referrer) : \"\";\n if (landingReferrer) attribution.landing_referrer = landingReferrer;\n attribution.landed_at = new Date().toISOString();\n return attribution;\n}\n\nfunction readFirstTouchCookie(): string | null {\n if (typeof document === \"undefined\") return null;\n try {\n const cookies = document.cookie ? document.cookie.split(\";\") : [];\n for (const part of cookies) {\n const eq = part.indexOf(\"=\");\n if (eq === -1) continue;\n const name = part.slice(0, eq).trim();\n if (name === FIRST_TOUCH_COOKIE_NAME) {\n return part.slice(eq + 1).trim();\n }\n }\n } catch {\n // document.cookie can throw in sandboxed iframes — best-effort.\n }\n return null;\n}\n\nfunction writeFirstTouchCookie(encodedValue: string): void {\n if (typeof document === \"undefined\") return;\n // Non-sensitive, written by client JS, so no HttpOnly. SameSite=Lax keeps it\n // on top-level navigations (which is how share links arrive) without leaking\n // it to cross-site subresource requests.\n const cookie =\n `${FIRST_TOUCH_COOKIE_NAME}=${encodedValue}; path=/; ` +\n `max-age=${FIRST_TOUCH_COOKIE_MAX_AGE_SECONDS}; SameSite=Lax`;\n if (cookie.length > FIRST_TOUCH_MAX_COOKIE_BYTES) return;\n try {\n document.cookie = cookie;\n } catch {\n // best-effort\n }\n}\n\n/**\n * Capture the visitor's first-touch referral attribution exactly once. Reads\n * the current URL query params + landing info and, IF no attribution is\n * already stored (first-write-wins), persists it to both `localStorage`\n * (`an_attribution`) and the first-party `an_ft` cookie. Fully defensive and\n * SSR-safe — any failure is swallowed so it can never break app boot.\n */\nfunction captureFirstTouchAttribution(): void {\n if (_firstTouchCaptured) return;\n _firstTouchCaptured = true;\n if (typeof window === \"undefined\") return;\n try {\n const existing = safeStorageGet(FIRST_TOUCH_STORAGE_KEY);\n if (existing) {\n // Already captured in a prior visit. Backfill the cookie if it expired\n // or was cleared so the signup boundary still sees first-touch data, but\n // never overwrite the stored value itself (first-write-wins).\n if (!readFirstTouchCookie()) {\n try {\n writeFirstTouchCookie(encodeURIComponent(existing));\n } catch {\n // ignore\n }\n }\n return;\n }\n const attribution = buildFirstTouchAttribution();\n const json = JSON.stringify(attribution);\n safeStorageSet(FIRST_TOUCH_STORAGE_KEY, json);\n writeFirstTouchCookie(encodeURIComponent(json));\n } catch {\n // Attribution is best-effort telemetry; never let it break boot.\n }\n}\n\n/**\n * Return the parsed first-touch referral attribution captured for this\n * visitor, or `null` when none is stored. Reads from `localStorage`\n * (`an_attribution`). SSR-safe and defensive.\n */\nexport function getFirstTouchAttribution(): FirstTouchAttribution | null {\n if (typeof window === \"undefined\") return null;\n try {\n const raw = safeStorageGet(FIRST_TOUCH_STORAGE_KEY);\n if (!raw) return null;\n const parsed = JSON.parse(raw) as unknown;\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n return null;\n }\n return parsed as FirstTouchAttribution;\n } catch {\n return null;\n }\n}\n\nfunction isLocalAnalyticsHostname(hostname: string | undefined): boolean {\n const h = (hostname || \"\").toLowerCase();\n return (\n h === \"localhost\" ||\n h === \"127.0.0.1\" ||\n h === \"::1\" ||\n h === \"[::1]\" ||\n h.endsWith(\".localhost\") ||\n h.endsWith(\".local\")\n );\n}\n\nfunction ensureAmplitude(): boolean {\n if (_amplitudeInitialized) return true;\n const key = (import.meta.env as Record<string, string | undefined>)\n ?.VITE_AMPLITUDE_API_KEY;\n if (!key) return false;\n amplitude.init(key, { autocapture: true });\n _amplitudeInitialized = true;\n return true;\n}\n\nfunction shouldDropBrowserSentryNoise(event: Sentry.Event): boolean {\n const exceptionValues = event.exception?.values ?? [];\n // AgentAutoContinueSignal is a control-flow sentinel thrown to bubble\n // out of the SSE stream parser when the agent run needs to be\n // auto-continued. It's caught by the chat adapter and is never a real\n // error. Drop it unconditionally — capturing it as a Sentry exception\n // pollutes the issue list with sentinels that have no actionable stack.\n if (\n exceptionValues.some((value) => value.type === \"AgentAutoContinueSignal\")\n ) {\n return true;\n }\n // Browser-side access control rejections usually mean a tab outlived the\n // session or hit a protected route while signed out. The server Sentry setup\n // already drops these bare auth errors; mirror that here for client-captured\n // route/query failures.\n if (\n exceptionValues.some((value) => {\n const exceptionType = String(value.type ?? \"\")\n .trim()\n .toLowerCase();\n const exceptionValue = String(value.value ?? \"\")\n .trim()\n .toLowerCase();\n return (\n exceptionType === \"unauthorizederror\" ||\n exceptionType === \"unauthenticatederror\" ||\n exceptionValue === \"unauthorized\" ||\n exceptionValue === \"unauthenticated\"\n );\n })\n ) {\n return true;\n }\n // Safari occasionally reports a source-less global `EmptyRanges` reference\n // error while browsing public pages. There is no script URL or function to\n // map back to our bundle, so keep the filter narrow and only drop it when\n // every frame is missing/undefined.\n if (\n exceptionValues.some((value) => {\n const exceptionType = String(value.type ?? \"\")\n .trim()\n .toLowerCase();\n const exceptionValue = String(value.value ?? \"\")\n .trim()\n .toLowerCase();\n if (\n exceptionType !== \"referenceerror\" ||\n !exceptionValue.includes(\"emptyranges\")\n ) {\n return false;\n }\n const frames = value.stacktrace?.frames ?? [];\n return (\n frames.length === 0 ||\n frames.every((frame) => {\n const filename = String(frame.filename ?? frame.abs_path ?? \"\")\n .trim()\n .toLowerCase();\n const functionName = String(frame.function ?? \"\").trim();\n return (\n !functionName &&\n (!filename ||\n filename === \"undefined\" ||\n filename === \"<anonymous>\")\n );\n })\n );\n })\n ) {\n return true;\n }\n // Exact user/navigation aborts are expected browser behavior. Keep other\n // AbortError shapes visible unless they match this common non-bug message.\n if (\n exceptionValues.some((value) => {\n const exceptionType = String(value.type ?? \"\")\n .trim()\n .toLowerCase();\n const exceptionValue = String(value.value ?? \"\")\n .trim()\n .toLowerCase();\n return (\n exceptionValue === \"the user aborted a request.\" ||\n exceptionValue === \"aborterror: the user aborted a request.\" ||\n (exceptionType === \"aborterror\" &&\n exceptionValue.includes(\"the user aborted a request\"))\n );\n })\n ) {\n return true;\n }\n const exceptionText = exceptionValues\n .map((value) => `${value.type ?? \"\"} ${value.value ?? \"\"}`)\n .join(\" \")\n .toLowerCase();\n const requestUrl = event.request?.url?.toLowerCase() ?? \"\";\n const breadcrumbText = (event.breadcrumbs ?? [])\n .map((crumb) => {\n const data = crumb.data as Record<string, unknown> | undefined;\n return [\n crumb.category,\n crumb.message,\n typeof data?.url === \"string\" ? data.url : \"\",\n ].join(\" \");\n })\n .join(\" \")\n .toLowerCase();\n const combined = `${exceptionText} ${requestUrl} ${breadcrumbText}`;\n return (\n combined.includes(\"api2.amplitude.com\") &&\n (combined.includes(\"failed to fetch\") ||\n combined.includes(\"networkerror\") ||\n combined.includes(\"load failed\"))\n );\n}\n\nfunction getClientSentryDsn(): string | undefined {\n const env = (import.meta.env as Record<string, string | undefined>) ?? {};\n return (\n env.VITE_SENTRY_CLIENT_DSN ||\n env.VITE_SENTRY_DSN ||\n window.__AGENT_NATIVE_CONFIG__?.sentryDsn\n );\n}\n\nfunction ensureSentry(): void {\n if (_sentryInitialized) return;\n const dsn = getClientSentryDsn();\n if (!dsn) return;\n Sentry.init({\n dsn,\n environment:\n window.__AGENT_NATIVE_CONFIG__?.sentryEnvironment ||\n (import.meta.env as Record<string, string | undefined>)?.MODE ||\n \"production\",\n beforeSend(event) {\n if (shouldDropBrowserSentryNoise(event)) {\n return null;\n }\n // Strip sensitive query params from the request URL. React Router\n // history can include share tokens, ?signin=1, password reset codes,\n // public-share password params (audit F-07), etc.\n if (event.request?.url) {\n event.request.url = scrubUrl(event.request.url);\n }\n // Clean the same params from breadcrumb URLs (Sentry captures\n // history.pushState breadcrumbs by default).\n if (Array.isArray(event.breadcrumbs)) {\n for (const crumb of event.breadcrumbs) {\n if (crumb && typeof crumb === \"object\" && \"data\" in crumb) {\n const data = crumb.data as Record<string, unknown> | undefined;\n if (data && typeof data.url === \"string\") {\n data.url = scrubUrl(data.url);\n }\n if (data && typeof data.from === \"string\") {\n data.from = scrubUrl(data.from);\n }\n if (data && typeof data.to === \"string\") {\n data.to = scrubUrl(data.to);\n }\n }\n }\n }\n return event;\n },\n });\n Sentry.setTag(\"runtime\", \"browser\");\n _sentryInitialized = true;\n // Flush any user/tag that was set before init.\n if (_pendingSentryUser !== undefined) {\n Sentry.setUser(_pendingSentryUser);\n _pendingSentryUser = undefined;\n }\n if (_pendingSentryOrgId !== undefined) {\n Sentry.setTag(\"orgId\", _pendingSentryOrgId);\n _pendingSentryOrgId = undefined;\n }\n}\n\n/**\n * Attach the current user to Sentry events from the browser. Pass `null` to\n * clear (e.g. on logout). If Sentry isn't initialized yet, the value is\n * buffered and applied once `ensureSentry()` runs.\n *\n * Pass `orgId` to also tag events with the active organization ID — useful\n * for filtering Sentry by tenant.\n */\nexport function setSentryUser(\n user: SentryUser | null,\n orgId?: string | null,\n): void {\n if (_sentryInitialized) {\n Sentry.setUser(user);\n if (orgId !== undefined) {\n Sentry.setTag(\"orgId\", orgId ?? null);\n }\n return;\n }\n _pendingSentryUser = user;\n if (orgId !== undefined) {\n _pendingSentryOrgId = orgId ?? null;\n }\n}\n\nexport interface ClientCaptureContext {\n /** Searchable Sentry tags (low-cardinality strings only). */\n tags?: Record<string, string | undefined>;\n /**\n * High-cardinality / structured payload — not searchable but visible in\n * the Sentry event detail (file sizes, request URLs, response body\n * tails, etc.).\n */\n extra?: Record<string, unknown>;\n /**\n * Grouped contexts shown as separate cards in the Sentry event UI.\n */\n contexts?: Record<string, Record<string, unknown>>;\n}\n\n/**\n * Capture an exception to Sentry from browser code without forcing the\n * caller to depend on `@sentry/browser` directly.\n *\n * Templates can route a thrown Error through here on a known failure path\n * (chunk-upload 500, thumbnail upload, etc.) to attach searchable tags and\n * structured extra context. No-ops gracefully when Sentry isn't\n * initialized — never throws back into the caller, so a Sentry hiccup\n * can't mask the original error.\n */\nexport function captureClientException(\n error: unknown,\n context: ClientCaptureContext = {},\n): string | undefined {\n if (typeof window === \"undefined\") return undefined;\n try {\n ensureSentry();\n return Sentry.withScope((scope) => {\n if (context.tags) {\n for (const [k, v] of Object.entries(context.tags)) {\n if (typeof v === \"string\") scope.setTag(k, v);\n }\n }\n if (context.extra) {\n for (const [k, v] of Object.entries(context.extra)) {\n if (v !== undefined) scope.setExtra(k, v);\n }\n }\n if (context.contexts) {\n for (const [k, v] of Object.entries(context.contexts)) {\n scope.setContext(k, v);\n }\n }\n return Sentry.captureException(error);\n });\n } catch {\n return undefined;\n }\n}\n\n/**\n * Public browser-side error capture utility, mirroring `trackEvent()`:\n * templates can call `captureError(err, { tags, extra, contexts })` without\n * depending on Sentry directly. Sentry receives the event when a browser DSN\n * is configured; otherwise this is a quiet no-op.\n */\nexport function captureError(\n error: unknown,\n context: ClientCaptureContext = {},\n): string | undefined {\n return captureClientException(error, context);\n}\n\nfunction getPageviewTrackingState(): PageviewTrackingState {\n const g = globalThis as typeof globalThis & {\n [PAGEVIEW_TRACKING_STATE_KEY]?: PageviewTrackingState;\n };\n if (!g[PAGEVIEW_TRACKING_STATE_KEY]) {\n g[PAGEVIEW_TRACKING_STATE_KEY] = {\n installed: false,\n lastPageviewKey: null,\n };\n }\n return g[PAGEVIEW_TRACKING_STATE_KEY];\n}\n\nexport function configureTracking(options: {\n getDefaultProps?: GetDefaultProps;\n}): void {\n if (options.getDefaultProps) {\n _getDefaultProps = options.getDefaultProps;\n }\n if (typeof window !== \"undefined\") {\n ensureSentry();\n ensureAmplitude();\n captureFirstTouchAttribution();\n installLlmConnectionRefresh();\n installPageviewTracking();\n }\n}\n\nfunction inferTemplateName(properties: Record<string, unknown>): string | null {\n const envTemplate =\n (import.meta.env as Record<string, string | undefined>)\n ?.VITE_AGENT_NATIVE_TEMPLATE ||\n (import.meta.env as Record<string, string | undefined>)?.VITE_APP_TEMPLATE;\n if (envTemplate) return envTemplate;\n\n const app = typeof properties.app === \"string\" ? properties.app.trim() : \"\";\n if (!app || app === \"localhost\") return null;\n if (app.startsWith(\"agent-native-\")) {\n return app.slice(\"agent-native-\".length);\n }\n return app;\n}\n\nfunction resolveProps(\n name: string,\n params?: Record<string, unknown>,\n): Record<string, unknown> {\n if (typeof window === \"undefined\") return { ...params };\n const base: Record<string, unknown> = {\n url: window.location.origin + window.location.pathname,\n app: window.location.hostname.split(\".\")[0] || \"localhost\",\n ...params,\n };\n const props = _getDefaultProps ? _getDefaultProps(name, base) : base;\n let withTemplate = props;\n if (withTemplate.template === undefined) {\n const template = inferTemplateName(props);\n if (template) {\n withTemplate = { ...props, template };\n }\n }\n const llmProps = llmConnectionTrackingProperties(_llmConnectionStatus);\n const enriched = { ...withTemplate };\n for (const [key, value] of Object.entries(llmProps)) {\n if (enriched[key] === undefined) enriched[key] = value;\n }\n return enriched;\n}\n\nfunction pageviewKey(): string {\n return window.location.href;\n}\n\nfunction pageviewProperties(reason: string): Record<string, unknown> {\n const properties: Record<string, unknown> = {\n url: scrubUrl(window.location.href),\n path: window.location.pathname,\n hostname: window.location.hostname,\n navigation_type: reason,\n };\n if (window.location.search) {\n properties.search = scrubUrl(window.location.search);\n }\n if (typeof document !== \"undefined\") {\n if (document.referrer) {\n properties.referrer = scrubUrl(document.referrer);\n }\n if (document.title) {\n properties.title = document.title;\n }\n }\n return properties;\n}\n\nfunction emitPageview(reason: string): void {\n if (isLocalAnalyticsHostname(window.location.hostname)) return;\n const state = getPageviewTrackingState();\n const key = pageviewKey();\n if (state.lastPageviewKey === key) return;\n state.lastPageviewKey = key;\n trackEvent(\"pageview\", pageviewProperties(reason));\n}\n\nfunction schedulePageview(reason: string): void {\n const run = () => emitPageview(reason);\n if (_llmConnectionRefresh && !_llmConnectionStatus) {\n const timeout = new Promise<void>((resolve) =>\n window.setTimeout(resolve, 250),\n );\n Promise.race([_llmConnectionRefresh, timeout]).finally(run);\n return;\n }\n if (typeof queueMicrotask === \"function\") {\n queueMicrotask(run);\n return;\n }\n window.setTimeout(run, 0);\n}\n\nfunction installPageviewTracking(): void {\n const state = getPageviewTrackingState();\n if (state.installed) return;\n state.installed = true;\n\n schedulePageview(\"load\");\n\n const originalPushState = window.history.pushState;\n const originalReplaceState = window.history.replaceState;\n\n window.history.pushState = function pushState(...args) {\n const result = originalPushState.apply(this, args);\n schedulePageview(\"pushState\");\n return result;\n };\n\n window.history.replaceState = function replaceState(...args) {\n const result = originalReplaceState.apply(this, args);\n schedulePageview(\"replaceState\");\n return result;\n };\n\n window.addEventListener(\"popstate\", () => schedulePageview(\"popstate\"));\n}\n\nfunction sendAgentNativeAnalytics(\n name: string,\n properties: Record<string, unknown>,\n): void {\n if (isLocalAnalyticsHostname(window.location.hostname)) return;\n\n const publicKey = (import.meta.env as Record<string, string | undefined>)\n ?.VITE_AGENT_NATIVE_ANALYTICS_PUBLIC_KEY;\n if (!publicKey) return;\n\n const endpoint =\n (import.meta.env as Record<string, string | undefined>)\n ?.VITE_AGENT_NATIVE_ANALYTICS_ENDPOINT ||\n AGENT_NATIVE_ANALYTICS_DEFAULT_ENDPOINT;\n const userId =\n typeof properties.userId === \"string\" ? properties.userId : undefined;\n const body = JSON.stringify({\n publicKey,\n event: name,\n properties,\n userId,\n anonymousId: getOrCreateAnonymousId(),\n sessionId: getOrCreateSessionId(),\n timestamp: new Date().toISOString(),\n });\n\n try {\n if (navigator.sendBeacon) {\n const sent = navigator.sendBeacon(endpoint, body);\n if (sent) return;\n }\n fetch(endpoint, {\n method: \"POST\",\n body,\n keepalive: true,\n headers: { \"Content-Type\": \"text/plain;charset=UTF-8\" },\n }).catch(() => {});\n } catch {\n // best-effort\n }\n}\n\nexport function trackEvent(\n name: string,\n params?: Record<string, unknown>,\n): void {\n if (typeof window === \"undefined\") return;\n ensureSentry();\n const props = resolveProps(name, params);\n window.gtag?.(\"event\", name.replace(/\\s+/g, \"_\"), props);\n if (ensureAmplitude()) {\n amplitude.track(name, props);\n }\n sendAgentNativeAnalytics(name, props);\n}\n\nexport function trackSessionStatus(signedIn: boolean): void {\n trackEvent(\"session status\", { signed_in: signedIn });\n}\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Changelog UI — renders an app's CHANGELOG.md as an in-app "What's new"
|
|
3
|
+
* surface. Core owns all of this; a template just passes its own
|
|
4
|
+
* `CHANGELOG.md?raw` content in (Vite inlines it at build time, so this works
|
|
5
|
+
* on every host with no runtime file access or server route).
|
|
6
|
+
*
|
|
7
|
+
* Surfaces:
|
|
8
|
+
* - <ChangelogDialog> a self-contained modal listing every release.
|
|
9
|
+
* - <ChangelogSettingsCard> a settings-page card with the latest updates.
|
|
10
|
+
* - useChangelogSeen() tracks the last release a user has seen (so the
|
|
11
|
+
* command menu can show an "unseen" dot).
|
|
12
|
+
*
|
|
13
|
+
* The command menu's built-in `changelog` prop (see CommandMenu.tsx) wires the
|
|
14
|
+
* dialog automatically — most templates never touch these directly.
|
|
15
|
+
*/
|
|
16
|
+
import { parseChangelog, type ChangelogEntry } from "../../changelog/parse.js";
|
|
17
|
+
/**
|
|
18
|
+
* Tracks the latest release a user has already seen (per browser, via
|
|
19
|
+
* localStorage). Returns whether there's an unseen release and a `markSeen`
|
|
20
|
+
* callback to clear the indicator once the changelog is opened.
|
|
21
|
+
*/
|
|
22
|
+
export declare function useChangelogSeen(appKey: string, latestId: string | undefined): {
|
|
23
|
+
unseen: boolean;
|
|
24
|
+
markSeen: () => void;
|
|
25
|
+
};
|
|
26
|
+
export interface ChangelogDialogProps {
|
|
27
|
+
open: boolean;
|
|
28
|
+
onOpenChange: (open: boolean) => void;
|
|
29
|
+
/** Raw CHANGELOG.md contents (e.g. `import md from "../CHANGELOG.md?raw"`). */
|
|
30
|
+
markdown: string;
|
|
31
|
+
/** Dialog heading. Default: "What's new". */
|
|
32
|
+
title?: string;
|
|
33
|
+
}
|
|
34
|
+
export declare function ChangelogDialog({ open, onOpenChange, markdown, title, }: ChangelogDialogProps): import("react/jsx-runtime").JSX.Element | null;
|
|
35
|
+
export interface ChangelogSettingsCardProps {
|
|
36
|
+
/** Raw CHANGELOG.md contents (e.g. `import md from "../CHANGELOG.md?raw"`). */
|
|
37
|
+
markdown: string;
|
|
38
|
+
/** How many recent releases to show inline before "View all". Default: 2. */
|
|
39
|
+
limit?: number;
|
|
40
|
+
/** Card heading. Default: "What's new". */
|
|
41
|
+
title?: string;
|
|
42
|
+
className?: string;
|
|
43
|
+
}
|
|
44
|
+
export declare function ChangelogSettingsCard({ markdown, limit, title, className, }: ChangelogSettingsCardProps): import("react/jsx-runtime").JSX.Element | null;
|
|
45
|
+
export { parseChangelog };
|
|
46
|
+
export type { ChangelogEntry };
|
|
47
|
+
//# sourceMappingURL=Changelog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Changelog.d.ts","sourceRoot":"","sources":["../../../src/client/changelog/Changelog.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAwG/E;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GAAG,SAAS,GAC3B;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,MAAM,IAAI,CAAA;CAAE,CA8B3C;AA8BD,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,CAAC;IACjB,6CAA6C;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,KAAoB,GACrB,EAAE,oBAAoB,kDAqDtB;AAID,MAAM,WAAW,0BAA0B;IACzC,+EAA+E;IAC/E,QAAQ,EAAE,MAAM,CAAC;IACjB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2CAA2C;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,qBAAqB,CAAC,EACpC,QAAQ,EACR,KAAS,EACT,KAAoB,EACpB,SAAS,GACV,EAAE,0BAA0B,kDAwC5B;AAED,OAAO,EAAE,cAAc,EAAE,CAAC;AAC1B,YAAY,EAAE,cAAc,EAAE,CAAC"}
|