@vllnt/convex-analytics 0.1.0 → 0.1.1-canary.879bde1
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/CHANGELOG.md +125 -0
- package/README.md +99 -38
- package/dist/component/crons.js +1 -1
- package/dist/component/crons.js.map +1 -1
- package/dist/component/http.d.ts +5 -0
- package/dist/component/http.d.ts.map +1 -1
- package/dist/component/http.js +76 -21
- package/dist/component/http.js.map +1 -1
- package/dist/component/internal_mutations.js +4 -4
- package/dist/component/internal_mutations.js.map +1 -1
- package/dist/component/mutations.d.ts.map +1 -1
- package/dist/component/mutations.js +28 -13
- package/dist/component/mutations.js.map +1 -1
- package/dist/component/queries.d.ts.map +1 -1
- package/dist/component/queries.js +57 -58
- package/dist/component/queries.js.map +1 -1
- package/dist/component/schema.d.ts +2 -4
- package/dist/component/schema.js +10 -5
- package/dist/component/schema.js.map +1 -1
- package/dist/component/validators.d.ts +27 -0
- package/dist/component/validators.d.ts.map +1 -1
- package/dist/component/validators.js +54 -1
- package/dist/component/validators.js.map +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.js +1 -1
- package/dist/test.d.ts +2 -4
- package/dist/web/index.d.ts +2 -2
- package/dist/web/index.js +2 -2
- package/docs/api-reference.md +132 -0
- package/docs/architecture.md +70 -0
- package/docs/client-sdk.md +249 -0
- package/docs/multi-product.md +69 -0
- package/docs/quick-start.md +115 -0
- package/docs/schema.md +135 -0
- package/docs/web-preset.md +104 -0
- package/llms.txt +37 -0
- package/package.json +39 -27
- package/src/component/crons.ts +1 -1
- package/src/component/http.ts +78 -21
- package/src/component/internal_mutations.ts +5 -5
- package/src/component/mutations.ts +37 -15
- package/src/component/queries.ts +83 -64
- package/src/component/schema.ts +10 -5
- package/src/component/validators.ts +80 -1
- package/src/react/index.tsx +1 -1
- package/src/web/index.ts +2 -2
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.1.1] - Unreleased
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- The npm package now ships the user docs (`docs/*.md`), `llms.txt` and `CHANGELOG.md`, so
|
|
13
|
+
`node_modules/@vllnt/convex-analytics/` holds docs that match the installed version.
|
|
14
|
+
`llms.txt` links to them with relative paths. `pnpm test:package` (run in CI) installs the
|
|
15
|
+
packed tarball and fails when a required file is missing, an internal file ships, or a
|
|
16
|
+
relative link does not resolve.
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- Reject clearly invalid input with typed `ConvexError` codes (`EMPTY_STRING`,
|
|
21
|
+
`INVALID_TIMESTAMP`, `INVALID_SAMPLE_RATE`, `INVALID_PROP_VALUE`, `INVALID_PROP_KEY`,
|
|
22
|
+
`INVALID_COUNT`, `INVALID_CURSOR`, `INVALID_BUCKETS`, `INVALID_CONFIG`): `NaN` or infinite
|
|
23
|
+
`ts`, range bounds, `sampleRate` and number props; empty `scope`, `name`, `subjectRef`,
|
|
24
|
+
`sessionRef`, `dedupeKey`, dimensions and config keys; non-scalar props; non-positive or
|
|
25
|
+
non-integer `limit`, `periods` and `numItems`; and non-numeric `list` cursors. A negative
|
|
26
|
+
`top` limit used to return all but the last rows; non-finite timestamps used to create `NaN`
|
|
27
|
+
rollup buckets.
|
|
28
|
+
- `configure` rejects non-positive `retentionDays` and `sessionIdleMs`, which would otherwise
|
|
29
|
+
make `prune` delete every event.
|
|
30
|
+
- Inherited keys such as `constructor` are no longer rolled up as dimensions.
|
|
31
|
+
- The REST routes return `400 { error, code }` for typed input errors, including nested `props`
|
|
32
|
+
values and non-numeric `from`, `to` or `limit` (blank or malformed values used to widen the
|
|
33
|
+
range silently), and `400 { error }` for non-object bodies and malformed `dimensions` /
|
|
34
|
+
`granularities` / `props`; a malformed stored `apiKeys` value returns `500` with a clear
|
|
35
|
+
message instead of an unhandled exception.
|
|
36
|
+
- `metric`, `top` and `timeseries` read only the rollup buckets in the requested range, and
|
|
37
|
+
`uniques` reads only subjects active in range through a new `by_scope_lastSeen` index.
|
|
38
|
+
- Add `.js` extensions to every relative import in `src/` so `@vllnt/convex-analytics/test`
|
|
39
|
+
type-checks under `moduleResolution: nodenext`.
|
|
40
|
+
- `convex` is declared only as a (now required) peer dependency, no longer also as a runtime
|
|
41
|
+
dependency, so a host on `convex` 1.45 to 1.47 no longer gets a second, nested `convex` copy.
|
|
42
|
+
- Export `./convex.config.js` (same target as `./convex.config`), which the Convex Components
|
|
43
|
+
Directory preflight requires alongside `./_generated/component.js`.
|
|
44
|
+
|
|
45
|
+
### Changed
|
|
46
|
+
|
|
47
|
+
- `track` no longer writes to the `@convex-dev/aggregate` child: no query read it. One fewer
|
|
48
|
+
component call and B-tree write per tracked event. The child stays mounted.
|
|
49
|
+
- Drop the unused `events.by_scope_subject_ts`, `events.by_scope_session_ts` and
|
|
50
|
+
`sessions.by_scope_lastTs` indexes (2 fewer index writes per event, 1 fewer per session write).
|
|
51
|
+
- Replace `rollups.by_scope_name_dim_val` with `by_scope_name_gran_dim_val_bucket`. `metric` and
|
|
52
|
+
`timeseries` now read only the requested series instead of every dimension value in the range.
|
|
53
|
+
- Release flow: stable versions publish only from a pushed `vX.Y.Z` tag on `main` through
|
|
54
|
+
`.github/workflows/publish.yml` (npm trusted publishing with provenance); actions are pinned
|
|
55
|
+
to commit SHAs. The changelog now lives in `packages/convex-analytics/`.
|
|
56
|
+
- Tooling: pnpm 10 with a release-age gate and blocked install scripts; trimmed dependency
|
|
57
|
+
overrides.
|
|
58
|
+
- Docs: input-error table, PII guidance, and an explicit statement that the component never
|
|
59
|
+
logs event data.
|
|
60
|
+
- Docs match the source: the `scopes` table is documented (six tables, not five), the sharded
|
|
61
|
+
counter is keyed by `(scope, name)`, `convex` is a required peer dependency, and web-preset
|
|
62
|
+
examples spread the readonly `webDimensions` tuple (`dimensions: [...webDimensions]`) so
|
|
63
|
+
they type-check.
|
|
64
|
+
- Package metadata: `homepage` is https://oss.vllnt.com/packages/convex-analytics. README adds
|
|
65
|
+
"For coding agents" and "Related packages" sections.
|
|
66
|
+
- Release flow: canary publishes on every qualifying push to `main` without a repository-variable
|
|
67
|
+
gate, and a change to the shipped docs, `llms.txt`, README, LICENSE or changelog alone now
|
|
68
|
+
triggers it.
|
|
69
|
+
|
|
70
|
+
## [0.1.0] - 2026-09-01
|
|
71
|
+
|
|
72
|
+
First stable release (the earlier `0.1.0-canary.*` builds were published from June 2026).
|
|
73
|
+
The component is a **generic, domain-neutral** analytics core —
|
|
74
|
+
the earlier web-locked draft was replaced before any public release, so the generic rebuild
|
|
75
|
+
is folded into this single `0.1.0` entry.
|
|
76
|
+
|
|
77
|
+
### Added
|
|
78
|
+
|
|
79
|
+
- **Generic core** — free-string event `name`, opaque `subjectRef` / `sessionRef`, host-typed
|
|
80
|
+
scalar `props` (no `v.any()`), and host-declared `dimensions`. Zero hardcoded domain.
|
|
81
|
+
- **Rollup-on-write** — counts are incremented as events land, so `metric` / `top` /
|
|
82
|
+
`timeseries` read in O(1) (backed by `@convex-dev/aggregate` + `@convex-dev/sharded-counter`).
|
|
83
|
+
- **Verb set** — `track`, `metric`, `top`, `timeseries`, `uniques`, `funnel`, `retention`,
|
|
84
|
+
`distribution`, `list`, `configure`; all generic across any event / dimension / domain.
|
|
85
|
+
- **Distribution** — `distribution(name, measure, { buckets })` is a histogram over a numeric
|
|
86
|
+
`props` measure (declared upper-bound bins + overflow, with `count` / `sum`), computed from
|
|
87
|
+
raw events in range (index-backed, bounded).
|
|
88
|
+
- **Granularities** — `minute` / `hour` / `day` rollup buckets (`minute` opt-in for short live
|
|
89
|
+
windows), end-to-end through `track`, the read verbs, and the REST routes.
|
|
90
|
+
- **Config surface** — `scope`, `dimensions`, `granularities`, `retentionDays`, `sampleRate`,
|
|
91
|
+
`sessionIdleMs`, `propsValidator`; sensible defaults, zero config required. Config is
|
|
92
|
+
applied (not ignored) — `dimensions` / `granularities` / `sampleRate` per call, retention /
|
|
93
|
+
sampling / idle persisted for the crons via `configure`.
|
|
94
|
+
- **Opaque `scope` partition** on every table, mutation, and query for multi-tenant isolation.
|
|
95
|
+
- **Per-session rate limiting, dedupe, and sampling** built into `track`.
|
|
96
|
+
- **Schema** — five sandboxed tables (events, rollups, subjects, sessions, config); raw events
|
|
97
|
+
TTL-pruned, rollups kept forever.
|
|
98
|
+
- **Crons** — daily `prune` (raw-event TTL) and `closeSessions` (idle close), idempotent;
|
|
99
|
+
plus a `backfill` mutation to re-derive rollups.
|
|
100
|
+
- **Web preset** — opt-in `@vllnt/convex-analytics/web`: `webDimensions`, `parseUserAgent`,
|
|
101
|
+
`geoFromHeaders`, `trackPageview`. The generic core carries no web fields.
|
|
102
|
+
- **React hooks** — optional `@vllnt/convex-analytics/react`: `useMetric`, `useTop`,
|
|
103
|
+
`useTimeseries`, `useUniques` over the host's re-exported aggregate query refs.
|
|
104
|
+
- **REST API** — five generic `x-api-key`-authed routes (/track, /metric, /top, /timeseries,
|
|
105
|
+
/uniques), timing-safe key comparison.
|
|
106
|
+
- **Testing** — `@vllnt/convex-analytics/test` export for convex-test, registering the child
|
|
107
|
+
components so `track` is exercised end-to-end.
|
|
108
|
+
|
|
109
|
+
### Fixed (since the first canary)
|
|
110
|
+
|
|
111
|
+
- Register automatic session-closing and event-retention cron jobs, including zero-config scopes.
|
|
112
|
+
- Seek expired events by `(scope, ts)`, page scope discovery, and bound/reschedule maintenance at
|
|
113
|
+
500 rows per transaction.
|
|
114
|
+
- Preserve valid rollups when backfill input exceeds its supported 50,000-event bound instead of
|
|
115
|
+
deleting them and silently rebuilding from truncated input.
|
|
116
|
+
- Count funnel subjects through later valid repeated steps, isolate rate limits and counters with
|
|
117
|
+
collision-safe tuple keys, and reopen sessions without moving `lastTs` backward.
|
|
118
|
+
|
|
119
|
+
### Changed (since the first canary)
|
|
120
|
+
|
|
121
|
+
- Treat Convex `_generated` output as CLI-owned, exclude it from formatting, and expose a
|
|
122
|
+
dedicated codegen script.
|
|
123
|
+
- Adopt the stable v2 vllnt toolchain, TypeScript 7 validation, Convex 1.45,
|
|
124
|
+
`convex-test` 0.0.56, and the latest compatible direct dependencies.
|
|
125
|
+
- Use explicit table names for Convex database patch/delete operations.
|
package/README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<!-- Badges -->
|
|
2
|
+
|
|
2
3
|
[](https://www.convex.dev/components)
|
|
3
4
|
[](https://www.npmjs.com/package/@vllnt/convex-analytics)
|
|
4
5
|
[](https://github.com/vllnt/convex-analytics/actions/workflows/ci.yml)
|
|
@@ -7,7 +8,7 @@
|
|
|
7
8
|
# @vllnt/convex-analytics
|
|
8
9
|
|
|
9
10
|
A generic, configurable, embedded analytics component for Convex — any event,
|
|
10
|
-
any dimension, any domain — with rollup-on-write
|
|
11
|
+
any dimension, any domain — with rollup-on-write for reactive aggregate reads.
|
|
11
12
|
|
|
12
13
|
```ts
|
|
13
14
|
import { AnalyticsClient } from "@vllnt/convex-analytics";
|
|
@@ -17,7 +18,10 @@ const analytics = new AnalyticsClient(components.analytics, {
|
|
|
17
18
|
dimensions: ["plan", "country"], // prop keys to roll up on
|
|
18
19
|
});
|
|
19
20
|
|
|
20
|
-
await analytics.track(ctx, "signup", {
|
|
21
|
+
await analytics.track(ctx, "signup", {
|
|
22
|
+
subjectRef: userId,
|
|
23
|
+
props: { plan: "pro", country: "FR" },
|
|
24
|
+
});
|
|
21
25
|
const byPlan = await analytics.top(ctx, "signup", "plan"); // [{ value: "pro", count: 1 }]
|
|
22
26
|
```
|
|
23
27
|
|
|
@@ -25,9 +29,9 @@ const byPlan = await analytics.top(ctx, "signup", "plan"); // [{ value: "pro", c
|
|
|
25
29
|
|
|
26
30
|
- **Generic events** — free-string event name, opaque `subjectRef` / `sessionRef`, host-typed `props`.
|
|
27
31
|
- **Host-declared dimensions** — you pass the prop keys to roll up on; nothing is hardcoded.
|
|
28
|
-
- **Rollup-on-write** — counts are incremented as events land
|
|
32
|
+
- **Rollup-on-write** — counts are incremented as events land. Unfiltered lifetime `metric` reads a fixed-shard counter; ranged/filtered metrics, breakdowns, and time series scan matching rollup rows, not constant-time results.
|
|
29
33
|
- **Rich verb set** — `metric`, `top`, `timeseries`, `uniques`, `funnel`, `retention`, `distribution`, plus paginated raw `list`.
|
|
30
|
-
- **Configurable** — `scope`, `dimensions`, `granularities`, `retentionDays`, `sampleRate
|
|
34
|
+
- **Configurable** — `scope`, `dimensions`, `granularities`, `retentionDays`, `sampleRate`; sensible defaults, zero config required.
|
|
31
35
|
- **Per-session rate limiting + dedupe + sampling** built into `track`.
|
|
32
36
|
- **Opt-in web preset** — `@vllnt/convex-analytics/web` adds web dimensions + UA/geo helpers when you want them.
|
|
33
37
|
- **Optional React hooks** — `@vllnt/convex-analytics/react` for reactive aggregate reads.
|
|
@@ -48,6 +52,9 @@ fields. See [docs/web-preset.md](docs/web-preset.md).
|
|
|
48
52
|
npm install @vllnt/convex-analytics
|
|
49
53
|
```
|
|
50
54
|
|
|
55
|
+
Requires `convex@^1.45.0` as a peer dependency; React is optional. The command installs
|
|
56
|
+
the latest stable release; `@canary` follows `main`.
|
|
57
|
+
|
|
51
58
|
## Usage
|
|
52
59
|
|
|
53
60
|
```ts
|
|
@@ -72,7 +79,10 @@ const analytics = new AnalyticsClient<MyProps>(components.analytics, {
|
|
|
72
79
|
granularities: ["day"],
|
|
73
80
|
});
|
|
74
81
|
|
|
75
|
-
await analytics.track(ctx, "signup", {
|
|
82
|
+
await analytics.track(ctx, "signup", {
|
|
83
|
+
subjectRef: userId,
|
|
84
|
+
props: { plan: "pro" },
|
|
85
|
+
});
|
|
76
86
|
const total = await analytics.metric(ctx, "signup");
|
|
77
87
|
```
|
|
78
88
|
|
|
@@ -80,45 +90,76 @@ const total = await analytics.metric(ctx, "signup");
|
|
|
80
90
|
|
|
81
91
|
Passed to the `AnalyticsClient` constructor. All optional — the defaults work with zero config.
|
|
82
92
|
|
|
83
|
-
| Option
|
|
84
|
-
|
|
85
|
-
| `scope`
|
|
86
|
-
| `dimensions`
|
|
87
|
-
| `granularities` | `("minute" \| "hour" \| "day")[]` | `["day"]`
|
|
88
|
-
| `retentionDays` | `number`
|
|
89
|
-
| `sampleRate`
|
|
90
|
-
| `sessionIdleMs` | `number`
|
|
91
|
-
| `propsValidator` | Convex validator | typed scalar record | Optional host validator narrowing `props` at the boundary. |
|
|
93
|
+
| Option | Type | Default | Purpose |
|
|
94
|
+
| --------------- | --------------------------------- | ----------- | ----------------------------------------------------------------------------------- |
|
|
95
|
+
| `scope` | `string` | `"default"` | Multi-tenant partition; isolates one tenant's data. |
|
|
96
|
+
| `dimensions` | `string[]` | `[]` | Prop keys to roll up on (drives rollup-on-write). Empty = count by event name only. |
|
|
97
|
+
| `granularities` | `("minute" \| "hour" \| "day")[]` | `["day"]` | Rollup bucket sizes (`minute` for short live windows). Keep `"day"`: see below. |
|
|
98
|
+
| `retentionDays` | `number` | `90` | Raw-event TTL in days (rollups are kept forever). Applied via `configure`. |
|
|
99
|
+
| `sampleRate` | `number` | `1` | Fraction `0..1` of events to keep at ingest. |
|
|
100
|
+
| `sessionIdleMs` | `number` | `1800000` | Idle timeout before a session is closed. Applied via `configure`. |
|
|
92
101
|
|
|
93
102
|
`scope`, `dimensions`, `granularities`, and `sampleRate` apply per call from the client.
|
|
103
|
+
`top`, and `metric` with a `range` or `where`, read only `day` rollups: if `granularities`
|
|
104
|
+
leaves out `"day"`, they return `[]` and `0`.
|
|
94
105
|
`retentionDays`, `sampleRate`, and `sessionIdleMs` are persisted for the prune/close-sessions
|
|
95
106
|
crons by calling `analytics.configure(ctx, { ... })` once.
|
|
107
|
+
`TProps` is compile-time typing only; validate untrusted props in host wrappers. There is no
|
|
108
|
+
`propsValidator` constructor option.
|
|
109
|
+
|
|
110
|
+
When `sessionRef` is supplied, ingest uses a token bucket per `(scope, sessionRef)`:
|
|
111
|
+
100 events/minute refill, capacity 10. These limits are currently fixed, not client config.
|
|
112
|
+
Exhaustion and sampling both return `"dropped"`; without `sessionRef`, this limiter is skipped.
|
|
96
113
|
|
|
97
114
|
## API
|
|
98
115
|
|
|
99
|
-
| Verb
|
|
100
|
-
|
|
101
|
-
| `track(ctx, name, opts)`
|
|
102
|
-
| `metric(ctx, name, opts)`
|
|
103
|
-
| `top(ctx, name, dimension, opts)`
|
|
104
|
-
| `timeseries(ctx, name, opts)`
|
|
105
|
-
| `uniques(ctx, opts)`
|
|
106
|
-
| `funnel(ctx, steps, opts)`
|
|
107
|
-
| `retention(ctx, opts)`
|
|
108
|
-
| `distribution(ctx, name, measure, opts)` | query
|
|
109
|
-
| `list(ctx, name, paginationOpts, opts)`
|
|
110
|
-
| `configure(ctx, opts)`
|
|
111
|
-
|
|
112
|
-
|
|
116
|
+
| Verb | Kind | Purpose |
|
|
117
|
+
| ---------------------------------------- | -------- | -------------------------------------------------------------------------------------------------------- |
|
|
118
|
+
| `track(ctx, name, opts)` | mutation | Ingest an event; rollup-on-write + raw event + counter. Returns `"tracked" \| "dropped" \| "duplicate"`. |
|
|
119
|
+
| `metric(ctx, name, opts)` | query | Total count over a range, optionally filtered by a dimension value. |
|
|
120
|
+
| `top(ctx, name, dimension, opts)` | query | Top values of a dimension (breakdown). |
|
|
121
|
+
| `timeseries(ctx, name, opts)` | query | Bucketed counts over a range. |
|
|
122
|
+
| `uniques(ctx, opts)` | query | DAU / WAU / MAU from subjects. |
|
|
123
|
+
| `funnel(ctx, steps, opts)` | query | Ordered step conversion, keyed by `subjectRef`. |
|
|
124
|
+
| `retention(ctx, opts)` | query | Cohort return rates by first-seen period. |
|
|
125
|
+
| `distribution(ctx, name, measure, opts)` | query | Histogram of a numeric measure over declared buckets + overflow (with `count` / `sum`). |
|
|
126
|
+
| `list(ctx, name, paginationOpts, opts)` | query | Paginated raw events, newest first. |
|
|
127
|
+
| `configure(ctx, opts)` | mutation | Persist cron-relevant config (retention / sampling / idle). |
|
|
128
|
+
|
|
129
|
+
`timeseries` and `uniques` require `range` and `granularity`; `funnel` requires `range`;
|
|
130
|
+
`retention` requires `cohortRange` and `periods`; `distribution` requires `buckets`.
|
|
131
|
+
`list` requires pagination options. See [docs/client-sdk.md](docs/client-sdk.md) for exact types.
|
|
132
|
+
|
|
133
|
+
### Optional REST access
|
|
134
|
+
|
|
135
|
+
Expose the routes by mounting with `app.use(analytics, { httpPrefix: "/analytics" })`.
|
|
136
|
+
Then configure keys from a trusted host mutation (not a public unauthenticated endpoint):
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
await ctx.runMutation(components.analytics.mutations.configSet, {
|
|
140
|
+
scope: "default",
|
|
141
|
+
key: "apiKeys",
|
|
142
|
+
value: JSON.stringify([apiKey]), // host-provided secret; never ship it to the browser
|
|
143
|
+
});
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
curl -H "x-api-key: $ANALYTICS_API_KEY" \
|
|
148
|
+
"https://your-deployment.convex.site/analytics/metric?name=signup"
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
There is no client `configSet` method. Keys are stored per scope; missing/unconfigured/invalid
|
|
152
|
+
keys return HTTP 401. See [docs/api-reference.md](docs/api-reference.md).
|
|
113
153
|
|
|
114
154
|
## What it serves
|
|
115
155
|
|
|
116
156
|
The Convex-native, authoritative in-app aggregate layer — predefined-dimension rollups served
|
|
117
|
-
**reactively**
|
|
118
|
-
Declare the dimensions
|
|
157
|
+
**reactively** from pre-aggregated rows. It complements a product-analytics warehouse; it doesn't replace one.
|
|
158
|
+
Declare the dimensions you'll query; read cost still grows with matching buckets and values; ad-hoc or
|
|
119
159
|
retroactive questions over **non-declared** dimensions, or beyond the raw-event retention window,
|
|
120
160
|
are an export concern. `metric` / `top` / `timeseries` read pre-aggregated rollups (kept forever);
|
|
121
|
-
`funnel` / `
|
|
161
|
+
`funnel` / `distribution` read raw events in range (index-backed, bounded, TTL-pruned) and `retention`
|
|
162
|
+
reads per-subject first/last-seen rows.
|
|
122
163
|
|
|
123
164
|
## Web preset
|
|
124
165
|
|
|
@@ -126,7 +167,9 @@ are an export concern. `metric` / `top` / `timeseries` read pre-aggregated rollu
|
|
|
126
167
|
import { AnalyticsClient } from "@vllnt/convex-analytics";
|
|
127
168
|
import { webDimensions, trackPageview } from "@vllnt/convex-analytics/web";
|
|
128
169
|
|
|
129
|
-
const analytics = new AnalyticsClient(components.analytics, {
|
|
170
|
+
const analytics = new AnalyticsClient(components.analytics, {
|
|
171
|
+
dimensions: [...webDimensions], // readonly tuple; `dimensions` takes a string[]
|
|
172
|
+
});
|
|
130
173
|
|
|
131
174
|
await trackPageview(analytics, ctx, {
|
|
132
175
|
path: "/pricing",
|
|
@@ -150,13 +193,15 @@ const byPlan = useTop(api.analytics.top, { name: "signup", dimension: "plan" });
|
|
|
150
193
|
```
|
|
151
194
|
|
|
152
195
|
Thin reactive wrappers over the host's re-exported query refs (`metric`, `top`, `timeseries`,
|
|
153
|
-
`uniques`). `react`
|
|
196
|
+
`uniques`). `react` is an optional peer dep; backend-only consumers pull no React.
|
|
154
197
|
|
|
155
198
|
## Security
|
|
156
199
|
|
|
157
200
|
- Auth-agnostic mount — the host gates access and passes opaque `subjectRef` / `sessionRef` in.
|
|
158
201
|
- Tables are sandboxed; the host reaches them only through the exported functions.
|
|
159
202
|
- REST endpoints require an `x-api-key` header, compared timing-safe.
|
|
203
|
+
- Invalid input (empty strings, `NaN` / infinite timestamps, non-scalar props) is rejected with a typed `ConvexError`; see [docs/api-reference.md](docs/api-reference.md#input-errors).
|
|
204
|
+
- The component never logs event data. Props and refs are stored as given, so keep personal data out of them (the web preset stores `path`, `referrer`, and geo as received).
|
|
160
205
|
|
|
161
206
|
See [docs/architecture.md](docs/architecture.md).
|
|
162
207
|
|
|
@@ -178,21 +223,37 @@ analyticsTest.register(t);
|
|
|
178
223
|
|
|
179
224
|
[Schema](docs/schema.md) · [Client SDK](docs/client-sdk.md) · [REST API](docs/api-reference.md) ·
|
|
180
225
|
[Web Preset](docs/web-preset.md) · [Multi-Product](docs/multi-product.md) ·
|
|
181
|
-
[Architecture](docs/architecture.md)
|
|
182
|
-
[`llms.txt`](llms.txt)
|
|
226
|
+
[Architecture](docs/architecture.md) ·
|
|
227
|
+
[`llms.txt`](llms.txt) (documentation index).
|
|
228
|
+
|
|
229
|
+
## For coding agents
|
|
230
|
+
|
|
231
|
+
The npm package bundles these docs at `node_modules/@vllnt/convex-analytics/docs/`, along
|
|
232
|
+
with `llms.txt`, `CHANGELOG.md` and the TypeScript `src/`. They match the installed version.
|
|
233
|
+
Read them before writing code against this package.
|
|
234
|
+
|
|
235
|
+
## Related packages
|
|
236
|
+
|
|
237
|
+
| Package | Use it when |
|
|
238
|
+
| ------- | ----------- |
|
|
239
|
+
| [`@vllnt/analytics`](https://oss.vllnt.com/packages/analytics) | You need browser-side tracking with consent management and React integration. Use this component for counts stored in your Convex backend. |
|
|
240
|
+
| [`@vllnt/convex-events`](https://oss.vllnt.com/packages/convex-events) | You need an append-only activity feed and event ledger per subject. Use this component for aggregate counts, breakdowns and trends. |
|
|
241
|
+
| [`@vllnt/convex-experiments`](https://oss.vllnt.com/packages/convex-experiments) | You need A/B variant assignment and deduped exposure tracking. Use this component for general event metrics. |
|
|
183
242
|
|
|
184
243
|
## Contributing
|
|
185
244
|
|
|
186
|
-
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
245
|
+
See [CONTRIBUTING.md](https://github.com/vllnt/convex-analytics/blob/main/CONTRIBUTING.md).
|
|
187
246
|
|
|
188
247
|
## Author
|
|
189
248
|
|
|
190
249
|
Built by [bntvllnt](https://github.com/bntvllnt) · [bntvllnt.com](https://bntvllnt.com) · [X @bntvllnt](https://x.com/bntvllnt)
|
|
191
250
|
|
|
192
|
-
Part of the [@vllnt](https://github.com/vllnt) Convex component fleet — [vllnt.com](https://vllnt.com)
|
|
193
|
-
|
|
194
251
|
If this is useful, [sponsor the work](https://github.com/sponsors/bntvllnt).
|
|
195
252
|
|
|
196
253
|
## License
|
|
197
254
|
|
|
198
255
|
MIT — see [LICENSE](LICENSE).
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
Part of vllnt oss: https://oss.vllnt.com
|
package/dist/component/crons.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cronJobs } from "convex/server";
|
|
2
|
-
import { internal } from "./_generated/api";
|
|
2
|
+
import { internal } from "./_generated/api.js";
|
|
3
3
|
const crons = cronJobs();
|
|
4
4
|
crons.interval("analytics:close-sessions", { minutes: 30 }, internal.internal_mutations.closeSessions, {});
|
|
5
5
|
crons.interval("analytics:prune-events", { hours: 24 }, internal.internal_mutations.prune, {});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crons.js","sourceRoot":"","sources":["../../src/component/crons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"crons.js","sourceRoot":"","sources":["../../src/component/crons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;AAEzB,KAAK,CAAC,QAAQ,CACZ,0BAA0B,EAC1B,EAAE,OAAO,EAAE,EAAE,EAAE,EACf,QAAQ,CAAC,kBAAkB,CAAC,aAAa,EACzC,EAAE,CACH,CAAC;AACF,KAAK,CAAC,QAAQ,CACZ,wBAAwB,EACxB,EAAE,KAAK,EAAE,EAAE,EAAE,EACb,QAAQ,CAAC,kBAAkB,CAAC,KAAK,EACjC,EAAE,CACH,CAAC;AAEF,eAAe,KAAK,CAAC"}
|
package/dist/component/http.d.ts
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Run a handler body and turn a typed input error from the component (a `ConvexError`
|
|
3
|
+
* with `{ code, message }`) into `400 { error, code }`. Anything else still fails the action.
|
|
4
|
+
*/
|
|
5
|
+
export declare function withInputErrors(run: () => Promise<Response>): Promise<Response>;
|
|
1
6
|
export declare const trackEndpoint: import("convex/server").PublicHttpAction;
|
|
2
7
|
export declare const metricEndpoint: import("convex/server").PublicHttpAction;
|
|
3
8
|
export declare const topEndpoint: import("convex/server").PublicHttpAction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/component/http.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/component/http.ts"],"names":[],"mappings":"AAkBA;;;GAGG;AACH,wBAAsB,eAAe,CAAC,GAAG,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAUrF;AAsFD,eAAO,MAAM,aAAa,0CA0CxB,CAAC;AAEH,eAAO,MAAM,cAAc,0CAmBzB,CAAC;AAEH,eAAO,MAAM,WAAW,0CAoBtB,CAAC;AAEH,eAAO,MAAM,kBAAkB,0CAqB7B,CAAC;AAEH,eAAO,MAAM,eAAe,0CAkB1B,CAAC;AAEH;;;;GAIG;AACH,QAAA,MAAM,IAAI,oCAAe,CAAC;eAOX,IAAI"}
|
package/dist/component/http.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { httpRouter } from "convex/server";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { ConvexError } from "convex/values";
|
|
3
|
+
import { httpAction } from "./_generated/server.js";
|
|
4
|
+
import { assertProps } from "./validators.js";
|
|
5
|
+
import { api } from "./_generated/api.js";
|
|
4
6
|
function json(data, status = 200) {
|
|
5
7
|
return new Response(JSON.stringify(data), {
|
|
6
8
|
status,
|
|
@@ -10,6 +12,26 @@ function json(data, status = 200) {
|
|
|
10
12
|
function error(message, status = 400) {
|
|
11
13
|
return json({ error: message }, status);
|
|
12
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* Run a handler body and turn a typed input error from the component (a `ConvexError`
|
|
17
|
+
* with `{ code, message }`) into `400 { error, code }`. Anything else still fails the action.
|
|
18
|
+
*/
|
|
19
|
+
export async function withInputErrors(run) {
|
|
20
|
+
try {
|
|
21
|
+
return await run();
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
const data = e instanceof ConvexError ? e.data : undefined;
|
|
25
|
+
if (typeof data === "object" && data !== null && "code" in data && "message" in data) {
|
|
26
|
+
return json({ error: String(data.message), code: String(data.code) }, 400);
|
|
27
|
+
}
|
|
28
|
+
throw e;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/** An `httpAction` whose typed input errors are returned as 400 responses. */
|
|
32
|
+
function handle(fn) {
|
|
33
|
+
return httpAction((ctx, request) => withInputErrors(() => fn(ctx, request)));
|
|
34
|
+
}
|
|
13
35
|
function timingSafeEqual(a, b) {
|
|
14
36
|
if (a.length !== b.length)
|
|
15
37
|
return false;
|
|
@@ -22,6 +44,16 @@ function timingSafeEqual(a, b) {
|
|
|
22
44
|
function scopeOf(value) {
|
|
23
45
|
return typeof value === "string" && value.length > 0 ? value : "default";
|
|
24
46
|
}
|
|
47
|
+
/** The stored `apiKeys` value as a string array, or `null` when it is not one. */
|
|
48
|
+
function parseApiKeys(raw) {
|
|
49
|
+
try {
|
|
50
|
+
const keys = JSON.parse(raw);
|
|
51
|
+
return Array.isArray(keys) && keys.every((k) => typeof k === "string") ? keys : null;
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
25
57
|
/**
|
|
26
58
|
* Gate a request by API key. Keys are a JSON string array stored at config
|
|
27
59
|
* `(scope, "apiKeys")`. Returns an error Response on failure, else null.
|
|
@@ -36,7 +68,9 @@ async function requireApiKey(ctx, request, scope) {
|
|
|
36
68
|
});
|
|
37
69
|
if (!config)
|
|
38
70
|
return error("API keys not configured", 401);
|
|
39
|
-
const keys =
|
|
71
|
+
const keys = parseApiKeys(config);
|
|
72
|
+
if (keys === null)
|
|
73
|
+
return error("API keys misconfigured", 500);
|
|
40
74
|
const matched = keys.some((stored) => timingSafeEqual(stored, key));
|
|
41
75
|
if (!matched)
|
|
42
76
|
return error("Invalid API key", 401);
|
|
@@ -48,20 +82,31 @@ function parseJsonSafe(request) {
|
|
|
48
82
|
function getParams(request) {
|
|
49
83
|
return new URL(request.url).searchParams;
|
|
50
84
|
}
|
|
85
|
+
/** A numeric query param; blank or malformed values become NaN so the component rejects them. */
|
|
86
|
+
function numberParam(params, name) {
|
|
87
|
+
const raw = params.get(name);
|
|
88
|
+
if (raw === null)
|
|
89
|
+
return undefined;
|
|
90
|
+
return raw.trim() === "" ? NaN : Number(raw);
|
|
91
|
+
}
|
|
51
92
|
function range(params) {
|
|
52
|
-
const from = params
|
|
53
|
-
const to = params
|
|
54
|
-
if (from ===
|
|
93
|
+
const from = numberParam(params, "from");
|
|
94
|
+
const to = numberParam(params, "to");
|
|
95
|
+
if (from === undefined && to === undefined)
|
|
55
96
|
return undefined;
|
|
56
|
-
return {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
97
|
+
return { from, to };
|
|
98
|
+
}
|
|
99
|
+
const GRANULARITIES = ["minute", "hour", "day"];
|
|
100
|
+
function isStringArray(value) {
|
|
101
|
+
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
60
102
|
}
|
|
61
|
-
export const trackEndpoint =
|
|
103
|
+
export const trackEndpoint = handle(async (ctx, request) => {
|
|
62
104
|
const parsed = await parseJsonSafe(request);
|
|
63
105
|
if (!parsed.ok)
|
|
64
106
|
return error("Invalid JSON body");
|
|
107
|
+
if (typeof parsed.data !== "object" || parsed.data === null || Array.isArray(parsed.data)) {
|
|
108
|
+
return error("Body must be a JSON object");
|
|
109
|
+
}
|
|
65
110
|
const body = parsed.data;
|
|
66
111
|
const scope = scopeOf(body["scope"]);
|
|
67
112
|
const authError = await requireApiKey(ctx, request, scope);
|
|
@@ -70,24 +115,34 @@ export const trackEndpoint = httpAction(async (ctx, request) => {
|
|
|
70
115
|
if (typeof body["name"] !== "string" || body["name"].length === 0) {
|
|
71
116
|
return error("name is required");
|
|
72
117
|
}
|
|
73
|
-
if (!
|
|
118
|
+
if (!isStringArray(body["dimensions"])) {
|
|
74
119
|
return error("dimensions (string[]) is required");
|
|
75
120
|
}
|
|
121
|
+
const props = body["props"] ?? undefined;
|
|
122
|
+
if (props !== undefined && (typeof props !== "object" || Array.isArray(props))) {
|
|
123
|
+
return error("props must be a flat object of scalar values");
|
|
124
|
+
}
|
|
125
|
+
if (props !== undefined)
|
|
126
|
+
assertProps(props);
|
|
127
|
+
const granularities = body["granularities"] ?? ["day"];
|
|
128
|
+
if (!isStringArray(granularities) || !granularities.every((g) => GRANULARITIES.includes(g))) {
|
|
129
|
+
return error("granularities must be an array of minute, hour, or day");
|
|
130
|
+
}
|
|
76
131
|
const result = await ctx.runMutation(api.mutations.track, {
|
|
77
132
|
scope,
|
|
78
133
|
name: body["name"],
|
|
79
134
|
subjectRef: typeof body["subjectRef"] === "string" ? body["subjectRef"] : undefined,
|
|
80
135
|
sessionRef: typeof body["sessionRef"] === "string" ? body["sessionRef"] : undefined,
|
|
81
|
-
props
|
|
136
|
+
props,
|
|
82
137
|
ts: typeof body["ts"] === "number" ? body["ts"] : undefined,
|
|
83
138
|
dedupeKey: typeof body["dedupeKey"] === "string" ? body["dedupeKey"] : undefined,
|
|
84
139
|
dimensions: body["dimensions"],
|
|
85
|
-
granularities
|
|
140
|
+
granularities,
|
|
86
141
|
sampleRate: typeof body["sampleRate"] === "number" ? body["sampleRate"] : undefined,
|
|
87
142
|
});
|
|
88
143
|
return json({ result }, 201);
|
|
89
144
|
});
|
|
90
|
-
export const metricEndpoint =
|
|
145
|
+
export const metricEndpoint = handle(async (ctx, request) => {
|
|
91
146
|
const params = getParams(request);
|
|
92
147
|
const scope = scopeOf(params.get("scope"));
|
|
93
148
|
const authError = await requireApiKey(ctx, request, scope);
|
|
@@ -106,7 +161,7 @@ export const metricEndpoint = httpAction(async (ctx, request) => {
|
|
|
106
161
|
});
|
|
107
162
|
return json({ name, count });
|
|
108
163
|
});
|
|
109
|
-
export const topEndpoint =
|
|
164
|
+
export const topEndpoint = handle(async (ctx, request) => {
|
|
110
165
|
const params = getParams(request);
|
|
111
166
|
const scope = scopeOf(params.get("scope"));
|
|
112
167
|
const authError = await requireApiKey(ctx, request, scope);
|
|
@@ -123,11 +178,11 @@ export const topEndpoint = httpAction(async (ctx, request) => {
|
|
|
123
178
|
name,
|
|
124
179
|
dimension,
|
|
125
180
|
range: range(params),
|
|
126
|
-
limit: params
|
|
181
|
+
limit: numberParam(params, "limit"),
|
|
127
182
|
});
|
|
128
183
|
return json(result);
|
|
129
184
|
});
|
|
130
|
-
export const timeseriesEndpoint =
|
|
185
|
+
export const timeseriesEndpoint = handle(async (ctx, request) => {
|
|
131
186
|
const params = getParams(request);
|
|
132
187
|
const scope = scopeOf(params.get("scope"));
|
|
133
188
|
const authError = await requireApiKey(ctx, request, scope);
|
|
@@ -137,7 +192,7 @@ export const timeseriesEndpoint = httpAction(async (ctx, request) => {
|
|
|
137
192
|
if (!name)
|
|
138
193
|
return error("name parameter required");
|
|
139
194
|
const granularity = params.get("granularity") ?? "day";
|
|
140
|
-
if (granularity
|
|
195
|
+
if (!GRANULARITIES.includes(granularity)) {
|
|
141
196
|
return error("granularity must be minute, hour, or day");
|
|
142
197
|
}
|
|
143
198
|
const result = await ctx.runQuery(api.queries.timeseries, {
|
|
@@ -148,14 +203,14 @@ export const timeseriesEndpoint = httpAction(async (ctx, request) => {
|
|
|
148
203
|
});
|
|
149
204
|
return json(result);
|
|
150
205
|
});
|
|
151
|
-
export const uniquesEndpoint =
|
|
206
|
+
export const uniquesEndpoint = handle(async (ctx, request) => {
|
|
152
207
|
const params = getParams(request);
|
|
153
208
|
const scope = scopeOf(params.get("scope"));
|
|
154
209
|
const authError = await requireApiKey(ctx, request, scope);
|
|
155
210
|
if (authError)
|
|
156
211
|
return authError;
|
|
157
212
|
const granularity = params.get("granularity") ?? "day";
|
|
158
|
-
if (granularity
|
|
213
|
+
if (!GRANULARITIES.includes(granularity)) {
|
|
159
214
|
return error("granularity must be minute, hour, or day");
|
|
160
215
|
}
|
|
161
216
|
const result = await ctx.runQuery(api.queries.uniques, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/component/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/component/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAE1C,SAAS,IAAI,CAAC,IAAa,EAAE,MAAM,GAAG,GAAG;IACvC,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE;QACxC,MAAM;QACN,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;KAChD,CAAC,CAAC;AACL,CAAC;AAED,SAAS,KAAK,CAAC,OAAe,EAAE,MAAM,GAAG,GAAG;IAC1C,OAAO,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;AAC1C,CAAC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