@agent-native/core 0.68.3 → 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 +54 -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/extensions/web-search-tool.ts +45 -4
- package/corpus/core/src/mcp/build-server.ts +1 -1
- package/corpus/core/src/mcp/embed-app.ts +112 -6
- package/corpus/core/src/secrets/register-framework-secrets.ts +7 -0
- 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 +72 -20
- package/corpus/templates/clips/app/components/recorder/recorder-engine.ts +69 -2
- package/corpus/templates/clips/app/components/sharing/slack-share-hint.tsx +71 -0
- package/corpus/templates/clips/app/lib/recorder-preferences.ts +67 -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/_app.trash.tsx +21 -0
- package/corpus/templates/clips/app/routes/record.tsx +92 -8
- 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/content/vitest.config.ts +3 -0
- 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/extensions/web-search-tool.d.ts +5 -3
- package/dist/extensions/web-search-tool.d.ts.map +1 -1
- package/dist/extensions/web-search-tool.js +36 -4
- package/dist/extensions/web-search-tool.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/secrets/register-framework-secrets.d.ts.map +1 -1
- package/dist/secrets/register-framework-secrets.js +6 -0
- package/dist/secrets/register-framework-secrets.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
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: changelog
|
|
3
|
+
description: >-
|
|
4
|
+
How to keep each app's user-facing changelog. Use when you ship a change a
|
|
5
|
+
user would notice (a new feature, a visible improvement, a bug fix), when
|
|
6
|
+
wiring the in-app "What's new" surface into a template, or when releasing
|
|
7
|
+
pending changelog entries.
|
|
8
|
+
scope: dev
|
|
9
|
+
metadata:
|
|
10
|
+
internal: true
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
# Changelog — user-facing "What's new"
|
|
14
|
+
|
|
15
|
+
Every template app keeps a `CHANGELOG.md` of **user-facing** changes that
|
|
16
|
+
renders in-app via the command menu (Cmd+K → "What's new") and on the settings
|
|
17
|
+
page. The flow mirrors changesets so it survives many agents working in
|
|
18
|
+
parallel: each change drops a small **pending entry file**, and a later
|
|
19
|
+
**release** rolls all pending files into a dated `CHANGELOG.md` section.
|
|
20
|
+
|
|
21
|
+
## When to add an entry
|
|
22
|
+
|
|
23
|
+
Add an entry whenever you ship something a user of that app would notice:
|
|
24
|
+
|
|
25
|
+
- a new capability or surface,
|
|
26
|
+
- a visible improvement (speed, layout, copy, defaults),
|
|
27
|
+
- a bug fix that affects behavior they'd see.
|
|
28
|
+
|
|
29
|
+
Do **not** add entries for refactors, internal tooling, tests, dependency
|
|
30
|
+
bumps, or anything invisible to the end user. The changelog is product notes,
|
|
31
|
+
not a commit log — write it the way you'd describe the change to a customer.
|
|
32
|
+
|
|
33
|
+
## How to add an entry
|
|
34
|
+
|
|
35
|
+
From the app directory (the template you changed):
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
agent-native changelog add "Recordings can be trimmed before sharing" --type added
|
|
39
|
+
agent-native changelog add "Faster transcript search" --type improved
|
|
40
|
+
agent-native changelog add "Fixed a crash when opening an empty folder" --type fixed
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`--type` is one of `added`, `improved`, `fixed`, `changed`, `removed`,
|
|
44
|
+
`security` (aliases like `feature`, `bugfix`, `enhancement` are accepted). This
|
|
45
|
+
writes `changelog/<date>-<slug>.md` — one file per change, so parallel work
|
|
46
|
+
never conflicts. You can also hand-write that file; the frontmatter is just:
|
|
47
|
+
|
|
48
|
+
```md
|
|
49
|
+
---
|
|
50
|
+
type: added
|
|
51
|
+
date: 2026-06-23
|
|
52
|
+
---
|
|
53
|
+
Recordings can be trimmed before sharing.
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Writing good entries
|
|
57
|
+
|
|
58
|
+
- One user-facing sentence, present tense, no internal jargon or file names.
|
|
59
|
+
- Lead with the benefit ("Recordings can be trimmed…"), not the mechanism.
|
|
60
|
+
- Markdown is allowed (bold, links) but keep it short — it renders as a bullet.
|
|
61
|
+
|
|
62
|
+
## Releasing
|
|
63
|
+
|
|
64
|
+
`release` stamps every pending entry into `CHANGELOG.md` under a dated
|
|
65
|
+
`## <date>` section (grouped by type) and deletes the pending files:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
agent-native changelog release # uses today's date
|
|
69
|
+
agent-native changelog list # preview pending + released
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Releasing is usually done at deploy/merge time. The in-app surface reads
|
|
73
|
+
`CHANGELOG.md`, so only released entries are visible to users — pending entries
|
|
74
|
+
stay invisible until rolled up.
|
|
75
|
+
|
|
76
|
+
## Wiring the in-app surface (once per template)
|
|
77
|
+
|
|
78
|
+
Templates already get the rendering for free from `@agent-native/core`. To
|
|
79
|
+
expose it in an app:
|
|
80
|
+
|
|
81
|
+
1. **Command menu** — pass the app's own changelog to `CommandMenu`:
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
import changelog from "../CHANGELOG.md?raw";
|
|
85
|
+
// ...
|
|
86
|
+
<CommandMenu open={cmdkOpen} onOpenChange={setCmdkOpen} changelog={changelog}>
|
|
87
|
+
{/* existing groups */}
|
|
88
|
+
</CommandMenu>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
This adds a "What's new" entry with an unseen-release dot and an in-app
|
|
92
|
+
dialog — no other wiring needed.
|
|
93
|
+
|
|
94
|
+
2. **Settings** (optional) — drop the card on the settings page:
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
import { ChangelogSettingsCard } from "@agent-native/core/client";
|
|
98
|
+
import changelog from "../CHANGELOG.md?raw";
|
|
99
|
+
// ...
|
|
100
|
+
<ChangelogSettingsCard markdown={changelog} />
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
`CHANGELOG.md?raw` is inlined by Vite at build time, so this works on every
|
|
104
|
+
host with no server route or runtime file access.
|
|
105
|
+
|
|
106
|
+
## Checklist
|
|
107
|
+
|
|
108
|
+
- [ ] Shipped a user-visible change? Run `agent-native changelog add "…"`.
|
|
109
|
+
- [ ] New template UI? Pass `changelog` to its `CommandMenu` and seed a
|
|
110
|
+
`CHANGELOG.md`.
|
|
111
|
+
- [ ] Releasing/deploying? `agent-native changelog release` rolls pending → dated.
|
|
@@ -31,7 +31,11 @@ Fire an analytics event.
|
|
|
31
31
|
```ts
|
|
32
32
|
import { track } from "@agent-native/core/tracking";
|
|
33
33
|
|
|
34
|
-
track(
|
|
34
|
+
track(
|
|
35
|
+
"meal.logged",
|
|
36
|
+
{ mealName: "Salad", calories: 350 },
|
|
37
|
+
{ userId: "user@example.com" },
|
|
38
|
+
);
|
|
35
39
|
```
|
|
36
40
|
|
|
37
41
|
### `identify(userId, traits?)`
|
|
@@ -73,13 +77,13 @@ Flush all providers (call before process exit).
|
|
|
73
77
|
|
|
74
78
|
Set the env var and the provider auto-registers at startup. No SDK dependencies -- all providers use raw HTTP.
|
|
75
79
|
|
|
76
|
-
| Provider
|
|
77
|
-
|
|
|
78
|
-
| PostHog
|
|
79
|
-
| Mixpanel
|
|
80
|
-
| Amplitude
|
|
80
|
+
| Provider | Env vars |
|
|
81
|
+
| ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
82
|
+
| PostHog | `POSTHOG_API_KEY` (required), `POSTHOG_HOST` (optional, defaults to `https://us.i.posthog.com`) |
|
|
83
|
+
| Mixpanel | `MIXPANEL_TOKEN` |
|
|
84
|
+
| Amplitude | `AMPLITUDE_API_KEY` |
|
|
81
85
|
| Agent Native Analytics | `AGENT_NATIVE_ANALYTICS_PUBLIC_KEY` (server), `AGENT_NATIVE_ANALYTICS_ENDPOINT` (optional, defaults to `https://analytics.agent-native.com/track`) |
|
|
82
|
-
| Webhook
|
|
86
|
+
| Webhook | `TRACKING_WEBHOOK_URL` (required), `TRACKING_WEBHOOK_AUTH` (optional, sent as `Authorization` header) |
|
|
83
87
|
|
|
84
88
|
Multiple providers can be active simultaneously. All receive every event.
|
|
85
89
|
|
|
@@ -106,10 +110,35 @@ Every browser-side `trackEvent()` POST to the Agent Native Analytics `/track` en
|
|
|
106
110
|
|
|
107
111
|
These fields land in the `analytics_events.anonymous_id`, `analytics_events.session_id`, and `analytics_events.user_id` columns in the analytics template. Storage access is wrapped in try/catch — private-browsing / blocked-storage clients silently degrade to NULL rather than crashing the page.
|
|
108
112
|
|
|
113
|
+
### Referral / viral attribution (first-touch)
|
|
114
|
+
|
|
115
|
+
`configureTracking()` also captures an anonymous visitor's **first-touch** referral context once, on first page load, and persists it across the signup boundary so the server-side `signup` event records where the user came from. This powers virality metrics for every template (Clips share links, Plans public pages, etc.).
|
|
116
|
+
|
|
117
|
+
**Share-link params** (set by whatever generates the link; read client-side only):
|
|
118
|
+
|
|
119
|
+
- `ref` — referral source bucket, e.g. `clip_share`, `plan_share`
|
|
120
|
+
- `via` — the referrer's stable user id (the clip/plan owner)
|
|
121
|
+
- `utm_source`, `utm_medium`, `utm_campaign`, `utm_content`, `utm_term`
|
|
122
|
+
|
|
123
|
+
**Client persistence** (first-write-wins — an existing value is never overwritten):
|
|
124
|
+
|
|
125
|
+
- `localStorage` key `an_attribution` and first-party cookie `an_ft` (`path=/; max-age=2592000; SameSite=Lax`, not HttpOnly — non-sensitive, written by client JS).
|
|
126
|
+
- Both store the same URL-encoded compact JSON (empty fields omitted, each value capped at 120 chars): `{ ref, via, utm_source, utm_medium, utm_campaign, utm_content, utm_term, landing_path, landing_referrer, landed_at }`. `landing_referrer` is the **host only** of `document.referrer` (scrubbed; same-origin referrers are dropped).
|
|
127
|
+
- `getFirstTouchAttribution()` (from `@agent-native/core/client`) returns the parsed object or `null`.
|
|
128
|
+
|
|
129
|
+
**Signup event enrichment** (server-side, from the `an_ft` cookie on the signup/OAuth-callback request, derived in `packages/core/src/server/attribution.ts`):
|
|
130
|
+
|
|
131
|
+
- `referral_source` — `ref` if present, else derived: `/share/…` → `clip_share`; a plan public path (`/p/`, `/plan/`, `/share-plan/`) → `plan_share`; a non-empty external referring host → `external`; otherwise `direct`.
|
|
132
|
+
- `referrer_user` (= `via`), `referral_medium` (= `utm_medium`), `referral_campaign` (= `utm_campaign`)
|
|
133
|
+
- `utm_source`, `utm_medium`, `utm_campaign`, `utm_content`, `utm_term` (raw passthrough)
|
|
134
|
+
- `first_touch_path` (= `landing_path`), `landing_referrer`
|
|
135
|
+
|
|
136
|
+
Attribution parsing is fully defensive and never blocks signup — a missing/malformed cookie falls back to `referral_source: "direct"`.
|
|
137
|
+
|
|
109
138
|
Other framework-level baseline events:
|
|
110
139
|
|
|
111
140
|
- `session status` from `useSession()`, with `signed_in`
|
|
112
|
-
- `signup` from Better Auth user creation, with `auth_provider` and `
|
|
141
|
+
- `signup` from Better Auth user creation, with `auth_provider`, `auth_user_id`, and first-touch referral attribution (`referral_source`, `referrer_user`, `referral_medium`, `referral_campaign`, `utm_*`, `first_touch_path`, `landing_referrer` — see "Referral / viral attribution" above)
|
|
113
142
|
- `builder connect clicked` and `builder connect popup blocked` from browser Connect Builder CTAs
|
|
114
143
|
- `builder connect started`, `builder connect succeeded`, `builder connect failed`, `builder disconnect succeeded`, and `builder disconnect failed` from the Builder connection routes, with LLM connection context when resolvable
|
|
115
144
|
|
|
@@ -121,7 +150,10 @@ For new lifecycle events, call `track()` server-side when the server is the sour
|
|
|
121
150
|
interface TrackingProvider {
|
|
122
151
|
name: string;
|
|
123
152
|
track(event: TrackingEvent): void | Promise<void>;
|
|
124
|
-
identify?(
|
|
153
|
+
identify?(
|
|
154
|
+
userId: string,
|
|
155
|
+
traits?: Record<string, unknown>,
|
|
156
|
+
): void | Promise<void>;
|
|
125
157
|
flush?(): void | Promise<void>;
|
|
126
158
|
}
|
|
127
159
|
|
|
@@ -142,11 +174,11 @@ interface TrackingEvent {
|
|
|
142
174
|
|
|
143
175
|
## Key Files
|
|
144
176
|
|
|
145
|
-
| File
|
|
146
|
-
|
|
|
147
|
-
| `packages/core/src/tracking/registry.ts`
|
|
148
|
-
| `packages/core/src/tracking/providers.ts`
|
|
149
|
-
| `packages/core/src/tracking/types.ts`
|
|
177
|
+
| File | Purpose |
|
|
178
|
+
| ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
|
|
179
|
+
| `packages/core/src/tracking/registry.ts` | `track()`, `identify()`, `registerTrackingProvider()`, `flushTracking()` |
|
|
180
|
+
| `packages/core/src/tracking/providers.ts` | Built-in providers (PostHog, Mixpanel, Amplitude, Agent Native Analytics, Webhook) and `registerBuiltinProviders()` |
|
|
181
|
+
| `packages/core/src/tracking/types.ts` | `TrackingEvent` and `TrackingProvider` interfaces |
|
|
150
182
|
|
|
151
183
|
## Related Skills
|
|
152
184
|
|
|
File without changes
|