@vllnt/convex-analytics 0.1.1-canary.879bde1 → 0.2.0-canary.5b8d0d7

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