@vllnt/convex-analytics 0.2.0-canary.d5fa959 → 0.2.0-canary.dee16f7

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.
Files changed (58) hide show
  1. package/CHANGELOG.md +113 -49
  2. package/README.md +461 -157
  3. package/dist/client/index.d.ts +34 -12
  4. package/dist/client/index.d.ts.map +1 -1
  5. package/dist/client/index.js +34 -12
  6. package/dist/client/index.js.map +1 -1
  7. package/dist/client/types.d.ts +9 -5
  8. package/dist/client/types.d.ts.map +1 -1
  9. package/dist/component/convex.config.d.ts +1 -0
  10. package/dist/component/convex.config.d.ts.map +1 -1
  11. package/dist/component/convex.config.js +1 -0
  12. package/dist/component/convex.config.js.map +1 -1
  13. package/dist/component/internal_mutations.d.ts +1 -1
  14. package/dist/component/internal_mutations.d.ts.map +1 -1
  15. package/dist/component/internal_mutations.js +16 -6
  16. package/dist/component/internal_mutations.js.map +1 -1
  17. package/dist/component/mutations.d.ts.map +1 -1
  18. package/dist/component/mutations.js +22 -20
  19. package/dist/component/mutations.js.map +1 -1
  20. package/dist/component/queries.d.ts.map +1 -1
  21. package/dist/component/queries.js +67 -17
  22. package/dist/component/queries.js.map +1 -1
  23. package/dist/component/validators.d.ts +15 -1
  24. package/dist/component/validators.d.ts.map +1 -1
  25. package/dist/component/validators.js +32 -0
  26. package/dist/component/validators.js.map +1 -1
  27. package/dist/react/index.d.ts +2 -3
  28. package/dist/react/index.d.ts.map +1 -1
  29. package/dist/react/index.js +2 -3
  30. package/dist/react/index.js.map +1 -1
  31. package/dist/test.d.ts +3 -1
  32. package/dist/test.d.ts.map +1 -1
  33. package/dist/test.js +3 -1
  34. package/dist/test.js.map +1 -1
  35. package/dist/web/index.d.ts +3 -2
  36. package/dist/web/index.d.ts.map +1 -1
  37. package/dist/web/index.js +2 -1
  38. package/dist/web/index.js.map +1 -1
  39. package/docs/api-reference.md +29 -10
  40. package/docs/architecture.md +33 -20
  41. package/docs/client-sdk.md +358 -140
  42. package/docs/multi-product.md +51 -40
  43. package/docs/quick-start.md +67 -70
  44. package/docs/react.md +146 -0
  45. package/docs/schema.md +13 -9
  46. package/docs/web-preset.md +96 -61
  47. package/llms.txt +43 -25
  48. package/package.json +14 -10
  49. package/src/client/index.ts +34 -12
  50. package/src/client/types.ts +9 -5
  51. package/src/component/convex.config.ts +1 -0
  52. package/src/component/internal_mutations.ts +16 -6
  53. package/src/component/mutations.ts +26 -20
  54. package/src/component/queries.ts +68 -16
  55. package/src/component/validators.ts +39 -0
  56. package/src/react/index.tsx +2 -3
  57. package/src/test.ts +3 -1
  58. package/src/web/index.ts +3 -2
package/CHANGELOG.md CHANGED
@@ -5,24 +5,29 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [0.2.0] - Unreleased
9
-
10
- This release changes behaviour for invalid input: calls that `0.1.0` accepted with `NaN` or
11
- infinite numbers, empty strings or out-of-range limits now throw typed `ConvexError` codes (see
12
- **Fixed**), and the REST routes answer them with `400`; non-scalar REST `props` return `400`
13
- instead of failing unhandled. Hosts that passed such input must handle these errors before
14
- upgrading from `^0.1.0`. The next `convex deploy` also builds the changed indexes (see
15
- **Changed**) over existing rows, which takes longer on large `rollups` tables.
8
+ ## [0.2.0] - 2026-11-28
9
+
10
+ **Breaking:** this release changes behaviour for invalid input: calls that `0.1.0` accepted with
11
+ `NaN` or infinite numbers, empty strings (on writes, reads and `backfill`), strings over 512
12
+ characters in the fields a write stores in index keys, non-positive or non-integer limits, blank
13
+ or malformed `list` cursors, or `configSet` values that `configure` would refuse now throw typed
14
+ `ConvexError` codes (see **Changed**), and the REST routes answer them with
15
+ `400`; non-scalar REST `props` return `400` instead of failing unhandled. Hosts that passed such
16
+ input must handle these errors before upgrading from `^0.1.0`. Node 20 or later is required.
17
+ The next `convex deploy` also builds the new indexes (see **Changed**) over existing rows, which
18
+ takes longer on large `rollups` and `subjects` tables.
16
19
 
17
20
  ### Added
18
21
 
19
22
  - The npm package now ships the user docs (`docs/*.md`), `llms.txt` and `CHANGELOG.md`, so
20
23
  `node_modules/@vllnt/convex-analytics/` holds docs that match the installed version.
21
- `llms.txt` links to them with relative paths. `pnpm test:package` (run in CI) installs the
22
- packed tarball and fails when a required file is missing, an internal file ships, or a
23
- relative link does not resolve.
24
+ `llms.txt` links to them with relative paths.
24
25
  - Export `./convex.config.js` (same target as `./convex.config`), which the Convex Components
25
26
  Directory preflight requires alongside `./_generated/component.js`.
27
+ - Rewritten README for coding agents: when to use, a complete quick start, a table of every
28
+ export of every entry point, common tasks, every error code and message with its fix, limits
29
+ and caps, and compatibility. New `docs/react.md`; every export has a TSDoc summary and a
30
+ reference heading.
26
31
 
27
32
  ### Fixed
28
33
 
@@ -30,56 +35,115 @@ upgrading from `^0.1.0`. The next `convex deploy` also builds the changed indexe
30
35
  `INVALID_TIMESTAMP`, `INVALID_SAMPLE_RATE`, `INVALID_PROP_VALUE`, `INVALID_PROP_KEY`,
31
36
  `INVALID_COUNT`, `INVALID_CURSOR`, `INVALID_BUCKETS`, `INVALID_CONFIG`): `NaN` or infinite
32
37
  `ts`, range bounds, `sampleRate` and number props; empty `scope`, `name`, `subjectRef`,
33
- `sessionRef`, `dedupeKey`, dimensions and config keys; non-scalar props; non-positive or
34
- non-integer `limit`, `periods` and `numItems`; and non-numeric `list` cursors. A negative
35
- `top` limit used to return all but the last rows; non-finite timestamps used to create `NaN`
36
- rollup buckets.
38
+ `sessionRef`, `dedupeKey`, dimensions and config keys; prop keys Convex cannot store;
39
+ non-scalar REST `props` values; non-positive or non-integer `limit`, `periods` and
40
+ `numItems`; non-finite `distribution` buckets; and empty, blank or malformed `list` cursors.
41
+ A negative `top` limit used to return all but the last rows; a `NaN` or infinite `ts` used to
42
+ create a `NaN` or infinite rollup bucket.
37
43
  - `configure` rejects non-positive `retentionDays` and `sessionIdleMs`, which would otherwise
38
- make `prune` delete every event.
44
+ make `prune` delete every event or `closeSessions` close every session.
39
45
  - Inherited keys such as `constructor` are no longer rolled up as dimensions.
46
+ - A dimension or granularity listed twice in `dimensions` / `granularities` (in `track`, the
47
+ client config, `POST /track` or `backfill`) no longer counts one event several times; each
48
+ distinct entry is used once.
49
+ - `configSet` no longer stores a `retentionDays`, `sessionIdleMs` or `sampleRate` value that
50
+ `configure` would reject (for example `retentionDays: "0"`, after which the next `prune`
51
+ deleted every raw event in the scope). The `prune` and `closeSessions` crons also ignore a
52
+ stored value that is not a positive finite number and use the default, so a row written by an
53
+ earlier version cannot wipe data.
54
+ - `metric`, `top`, `timeseries`, `uniques`, `funnel`, `retention`, `distribution`, `list` and
55
+ `backfill` reject empty strings with `EMPTY_STRING`, as the writes do; they used to return
56
+ `0` or empty results, and `backfill` with `dimensions: [""]` dropped every dimension rollup.
57
+ - `list` no longer skips events that share a `ts` at a page edge: the cursor now carries the
58
+ event's `_creationTime` as a tie-break, so paging returns every event exactly once. A
59
+ `cursor: ""` no longer restarts from the newest page.
40
60
  - The REST routes return `400 { error, code }` for typed input errors, including nested `props`
41
- values and non-numeric `from`, `to` or `limit` (blank or malformed values used to widen the
42
- range silently), and `400 { error }` for non-object bodies and malformed `dimensions` /
43
- `granularities` / `props`; a malformed stored `apiKeys` value returns `500` with a clear
44
- message instead of an unhandled exception.
45
- - `metric`, `top` and `timeseries` read only the rollup buckets in the requested range, and
46
- `uniques` reads only subjects active in range through a new `by_scope_lastSeen` index.
61
+ values and blank or non-numeric `from`, `to` or `limit` (which used to be misread silently),
62
+ and `400 { error }` for non-object bodies and malformed `dimensions` / `granularities` /
63
+ `props`; a malformed stored `apiKeys` value returns `500` with a clear message instead of an
64
+ unhandled exception.
47
65
  - Add `.js` extensions to every relative import in `src/` so `@vllnt/convex-analytics/test`
48
66
  type-checks under `moduleResolution: nodenext`.
49
- - `convex` is declared only as a (now required) peer dependency, no longer also as a runtime
50
- dependency, so a host on `convex` 1.45 to 1.47 no longer gets a second, nested `convex` copy.
51
- - The package build's turbo cache now covers the docs it copies from the repo root, so a build
52
- can no longer ship stale or missing `README.md`, `LICENSE`, `llms.txt` or `docs/` after a root
53
- doc change or a cache hit. `pnpm lint` checks this with a turbo dry run.
67
+ - The package build can no longer ship stale or missing `README.md`, `LICENSE`, `llms.txt` or
68
+ `docs/` after a root doc change.
54
69
 
55
70
  ### Changed
56
71
 
72
+ - Calls that now throw for input they accepted before; handle `data.code` or fix the input:
73
+ - `track` with an empty `scope`, `name`, `subjectRef`, `sessionRef`, `dedupeKey` or
74
+ `dimensions` entry (`EMPTY_STRING`), a `NaN` or infinite `ts` (`INVALID_TIMESTAMP`), a
75
+ `sampleRate` outside `0..1` (`INVALID_SAMPLE_RATE`) or a `NaN` or infinite number prop
76
+ (`INVALID_PROP_VALUE`): omit the field or pass a valid value;
77
+ - `configure` with an empty `scope` (`EMPTY_STRING`), a `retentionDays` or `sessionIdleMs`
78
+ that is not a positive finite number (`INVALID_CONFIG`), or a `sampleRate` outside `0..1`
79
+ (`INVALID_SAMPLE_RATE`): pass a valid value or omit it;
80
+ - `configSet` with an empty `scope` or `key` (`EMPTY_STRING`), or an invalid `retentionDays`,
81
+ `sessionIdleMs` or `sampleRate` value (`INVALID_CONFIG`): store what `configure` accepts,
82
+ or call `configure`;
83
+ - `track` (`POST /track` answers `400`; a long `scope` there usually gets `401` first, because
84
+ its `apiKeys` row cannot be stored), `configSet` and `configure` with a capped
85
+ field over 512 characters (`STRING_TOO_LONG`): shorten or hash the value; rows stored earlier
86
+ with longer values stay readable, but `track`, `configSet` and `configure` for them now throw.
87
+ The capped fields are `scope`, `name`, `subjectRef`, `sessionRef`, `dedupeKey`, `dimensions`
88
+ entries and config keys, counted in Unicode code points;
89
+ - reads with an empty `scope`, `name`, `dimension`, `where.dim`, `funnel` step or
90
+ `distribution` `measure`, and `backfill` with an empty `scope`, `name` or `dimensions` entry
91
+ (`EMPTY_STRING`): pass a non-empty value;
92
+ - reads with `NaN` or infinite `range` / `cohortRange` bounds (`INVALID_TIMESTAMP`), a `top`
93
+ `limit`, `retention` `periods` or `list` `numItems` that is not a positive integer
94
+ (`INVALID_COUNT`), or non-finite `distribution` `buckets` (`INVALID_BUCKETS`): pass finite
95
+ values and positive integers;
96
+ - `list` with a `cursor` that is `""`, blank or malformed (`INVALID_CURSOR`): pass `null` for
97
+ the first page, then the previous `continueCursor`. A bare-timestamp cursor from an earlier
98
+ version still works;
99
+ - REST: blank or non-numeric `from`, `to` or `limit`, and a non-null `granularities` that is
100
+ not an array of `minute` / `hour` / `day`, now return `400` (they used to be misread
101
+ silently or, for an unknown granularity, fail with `500`): send valid values.
102
+ - `list` `continueCursor` is now `<ts>:<_creationTime>` (was `<ts>`); treat it as opaque and
103
+ pass it back unchanged.
104
+ - Node: `engines.node` is now `>=20` (was `>=18`), because `convex` 1.45.0, the lowest version
105
+ of the `convex` peer range, requires Node 20 or later.
106
+ - `convex` is now a required peer dependency (range still `^1.45.0`) and no longer also a
107
+ runtime dependency, so a host on an older `convex` 1.x no longer gets a second, nested copy.
108
+ The test suite runs on `convex` 1.51.0, and the README and docs examples are type-checked
109
+ against 1.45.0.
110
+ - Dependencies since `0.1.0`: `@convex-dev/rate-limiter` `^0.3.2` → `^0.4.3` (its component adds a
111
+ `pendingUpdates` table, created on deploy), `@convex-dev/aggregate` `^0.3.0` → `^0.3.4` and
112
+ `@convex-dev/sharded-counter` `^0.2.1` → `^0.2.4`.
113
+ - Reads touch less data: `metric`, `top` and `timeseries` read only the requested series in the
114
+ requested range (`rollups.by_scope_name_dim_val` is replaced by
115
+ `by_scope_name_gran_dim_val_bucket`), and `uniques` reads only subjects active in range
116
+ through a new `subjects.by_scope_lastSeen` index.
57
117
  - `track` no longer writes to the `@convex-dev/aggregate` child: no query read it. One fewer
58
118
  component call and B-tree write per tracked event. The child stays mounted.
59
119
  - Drop the unused `events.by_scope_subject_ts`, `events.by_scope_session_ts` and
60
120
  `sessions.by_scope_lastTs` indexes (2 fewer index writes per event, 1 fewer per session write).
61
- - Replace `rollups.by_scope_name_dim_val` with `by_scope_name_gran_dim_val_bucket`. `metric` and
62
- `timeseries` now read only the requested series instead of every dimension value in the range.
63
- - Release flow: stable versions publish only from a pushed `vX.Y.Z` tag on `main` through
64
- `.github/workflows/publish.yml` (npm trusted publishing with provenance); actions are pinned
65
- to commit SHAs. The changelog now lives in `packages/convex-analytics/`.
66
- - Tooling: pnpm 10 with a release-age gate and blocked install scripts; trimmed dependency
67
- overrides.
68
- - Docs: input-error table, PII guidance, and an explicit statement that the component never
69
- logs event data.
70
- - Docs match the source: the `scopes` table is documented (six tables, not five), the sharded
71
- counter is keyed by `(scope, name)`, `convex` is a required peer dependency, and web-preset
72
- examples spread the readonly `webDimensions` tuple (`dimensions: [...webDimensions]`) so
73
- they type-check.
74
- - Package metadata: `homepage` is https://oss.vllnt.com/packages/convex-analytics. README adds
75
- "For coding agents" and "Related packages" sections.
76
- - Release flow: canary publishes on every qualifying push to `main` without a repository-variable
77
- gate, and a change to the shipped docs, `llms.txt`, README, LICENSE or changelog alone now
78
- triggers it.
79
- - Dependencies since `0.1.0`: `@convex-dev/rate-limiter` `^0.3.2` → `^0.4.3` (its component adds a
80
- `pendingUpdates` table, created on deploy), `@convex-dev/aggregate` `^0.3.0` → `^0.3.4` and
81
- `@convex-dev/sharded-counter` `^0.2.1` → `^0.2.4`. The `convex` peer range stays `^1.45.0`;
82
- tests pass on 1.45.0 and 1.51.0.
121
+ - Docs: Limits and gotchas now state that write throughput per `(scope, name)` is limited by
122
+ shared rollup, counter and rate-limit rows (parallel bursts can fail with an optimistic
123
+ concurrency error, `500` on `POST /track`, and the event is not stored; retry), that Convex's
124
+ per-function read and time limits can end `funnel`, `retention`, `distribution` and
125
+ `backfill` before their caps, and that a very large `list` `numItems` can hit them too. The
126
+ docs name the crons (`analytics:prune-events`, `analytics:close-sessions`), say the rate limit
127
+ is per `(scope, sessionRef)`, list each method's errors, document the `scopes` table (six tables,
128
+ not five) and the `(scope, name)` key of the sharded counter, and add an input-error table,
129
+ PII guidance and a statement that the component never logs event data. Web-preset examples
130
+ spread the readonly `webDimensions` tuple (`dimensions: [...webDimensions]`) so they
131
+ type-check.
132
+ - Package metadata: `homepage` is https://oss.vllnt.com/packages/convex-analytics.
133
+ - Stable versions are published only from a `vX.Y.Z` tag on `main` with npm provenance; every
134
+ push to `main` publishes a canary build under the `canary` dist-tag.
135
+ - Internal: CI (privacy-guard actions pinned to commit SHAs), tests, release workflow (SHA-pinned
136
+ actions) and tooling (pnpm 10, 7-day release-age gate, dependency overrides); the changelog now
137
+ lives in `packages/convex-analytics/`.
138
+
139
+ ### Removed
140
+
141
+ - The repository's `llms-full.txt` bundle; use `llms.txt`.
142
+
143
+ ### Security
144
+
145
+ - Docs no longer claim the React hooks are scope-gated: access control and `scope` belong to the
146
+ host query each hook is given.
83
147
 
84
148
  ## [0.1.0] - 2026-09-01
85
149