@vllnt/convex-analytics 0.1.0-canary.332b387

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 (83) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +209 -0
  3. package/dist/client/index.d.ts +94 -0
  4. package/dist/client/index.d.ts.map +1 -0
  5. package/dist/client/index.js +132 -0
  6. package/dist/client/index.js.map +1 -0
  7. package/dist/client/types.d.ts +109 -0
  8. package/dist/client/types.d.ts.map +1 -0
  9. package/dist/client/types.js +2 -0
  10. package/dist/client/types.js.map +1 -0
  11. package/dist/component/_generated/api.d.ts +22 -0
  12. package/dist/component/_generated/api.d.ts.map +1 -0
  13. package/dist/component/_generated/api.js +12 -0
  14. package/dist/component/_generated/api.js.map +1 -0
  15. package/dist/component/_generated/dataModel.d.ts +13 -0
  16. package/dist/component/_generated/dataModel.d.ts.map +1 -0
  17. package/dist/component/_generated/dataModel.js +8 -0
  18. package/dist/component/_generated/dataModel.js.map +1 -0
  19. package/dist/component/_generated/server.d.ts +20 -0
  20. package/dist/component/_generated/server.d.ts.map +1 -0
  21. package/dist/component/_generated/server.js +15 -0
  22. package/dist/component/_generated/server.js.map +1 -0
  23. package/dist/component/convex.config.d.ts +3 -0
  24. package/dist/component/convex.config.d.ts.map +1 -0
  25. package/dist/component/convex.config.js +10 -0
  26. package/dist/component/convex.config.js.map +1 -0
  27. package/dist/component/http.d.ts +13 -0
  28. package/dist/component/http.d.ts.map +1 -0
  29. package/dist/component/http.js +180 -0
  30. package/dist/component/http.js.map +1 -0
  31. package/dist/component/internal_mutations.d.ts +26 -0
  32. package/dist/component/internal_mutations.d.ts.map +1 -0
  33. package/dist/component/internal_mutations.js +126 -0
  34. package/dist/component/internal_mutations.js.map +1 -0
  35. package/dist/component/mutations.d.ts +24 -0
  36. package/dist/component/mutations.d.ts.map +1 -0
  37. package/dist/component/mutations.js +209 -0
  38. package/dist/component/mutations.js.map +1 -0
  39. package/dist/component/queries.d.ts +148 -0
  40. package/dist/component/queries.d.ts.map +1 -0
  41. package/dist/component/queries.js +376 -0
  42. package/dist/component/queries.js.map +1 -0
  43. package/dist/component/schema.d.ts +104 -0
  44. package/dist/component/schema.d.ts.map +1 -0
  45. package/dist/component/schema.js +72 -0
  46. package/dist/component/schema.js.map +1 -0
  47. package/dist/component/validators.d.ts +195 -0
  48. package/dist/component/validators.d.ts.map +1 -0
  49. package/dist/component/validators.js +71 -0
  50. package/dist/component/validators.js.map +1 -0
  51. package/dist/react/index.d.ts +89 -0
  52. package/dist/react/index.d.ts.map +1 -0
  53. package/dist/react/index.js +63 -0
  54. package/dist/react/index.js.map +1 -0
  55. package/dist/shared.d.ts +14 -0
  56. package/dist/shared.d.ts.map +1 -0
  57. package/dist/shared.js +18 -0
  58. package/dist/shared.js.map +1 -0
  59. package/dist/test.d.ts +117 -0
  60. package/dist/test.d.ts.map +1 -0
  61. package/dist/test.js +28 -0
  62. package/dist/test.js.map +1 -0
  63. package/dist/web/index.d.ts +121 -0
  64. package/dist/web/index.d.ts.map +1 -0
  65. package/dist/web/index.js +169 -0
  66. package/dist/web/index.js.map +1 -0
  67. package/package.json +116 -0
  68. package/src/client/index.ts +259 -0
  69. package/src/client/types.ts +121 -0
  70. package/src/component/_generated/api.ts +35 -0
  71. package/src/component/_generated/dataModel.ts +24 -0
  72. package/src/component/_generated/server.ts +42 -0
  73. package/src/component/convex.config.ts +12 -0
  74. package/src/component/http.ts +204 -0
  75. package/src/component/internal_mutations.ts +165 -0
  76. package/src/component/mutations.ts +255 -0
  77. package/src/component/queries.ts +436 -0
  78. package/src/component/schema.ts +76 -0
  79. package/src/component/validators.ts +94 -0
  80. package/src/react/index.tsx +127 -0
  81. package/src/shared.ts +30 -0
  82. package/src/test.ts +44 -0
  83. package/src/web/index.ts +232 -0
@@ -0,0 +1,195 @@
1
+ /** A single property value — string, number, boolean, or null. No nested objects/arrays. */
2
+ export declare const scalarValidator: import("convex/values").VUnion<string | number | boolean | null, [import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">, import("convex/values").VBoolean<boolean, "required">, import("convex/values").VNull<null, "required">], "required", never>;
3
+ /** Event properties: a flat record of scalar values. The generic, typed default — never `v.any()`. */
4
+ export declare const propsValidator: import("convex/values").VRecord<Record<string, string | number | boolean | null>, import("convex/values").VString<string, "required">, import("convex/values").VUnion<string | number | boolean | null, [import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">, import("convex/values").VBoolean<boolean, "required">, import("convex/values").VNull<null, "required">], "required", never>, "required", string>;
5
+ /** A time range in epoch millis. */
6
+ export declare const rangeValidator: import("convex/values").VObject<{
7
+ from?: number | undefined;
8
+ to?: number | undefined;
9
+ }, {
10
+ from: import("convex/values").VFloat64<number | undefined, "optional">;
11
+ to: import("convex/values").VFloat64<number | undefined, "optional">;
12
+ }, "required", "from" | "to">;
13
+ /** A dimension filter: count only events whose `dim` prop equals `val`. */
14
+ export declare const whereValidator: import("convex/values").VObject<{
15
+ dim: string;
16
+ val: string | number | boolean | null;
17
+ }, {
18
+ dim: import("convex/values").VString<string, "required">;
19
+ val: import("convex/values").VUnion<string | number | boolean | null, [import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">, import("convex/values").VBoolean<boolean, "required">, import("convex/values").VNull<null, "required">], "required", never>;
20
+ }, "required", "dim" | "val">;
21
+ /** Rollup bucket granularity. `minute` is opt-in for short live windows. */
22
+ export declare const granularityValidator: import("convex/values").VUnion<"minute" | "hour" | "day", [import("convex/values").VLiteral<"minute", "required">, import("convex/values").VLiteral<"hour", "required">, import("convex/values").VLiteral<"day", "required">], "required", never>;
23
+ /** Array of granularities (the `granularities` config, shared by `track` + `backfill`). */
24
+ export declare const granularitiesValidator: import("convex/values").VArray<("minute" | "hour" | "day")[], import("convex/values").VUnion<"minute" | "hour" | "day", [import("convex/values").VLiteral<"minute", "required">, import("convex/values").VLiteral<"hour", "required">, import("convex/values").VLiteral<"day", "required">], "required", never>, "required">;
25
+ /** A raw event as returned by reads. */
26
+ export declare const eventView: import("convex/values").VObject<{
27
+ subjectRef?: string | undefined;
28
+ sessionRef?: string | undefined;
29
+ dedupeKey?: string | undefined;
30
+ _creationTime: number;
31
+ name: string;
32
+ ts: number;
33
+ _id: string;
34
+ scope: string;
35
+ props: Record<string, string | number | boolean | null>;
36
+ seq: number;
37
+ }, {
38
+ _id: import("convex/values").VString<string, "required">;
39
+ _creationTime: import("convex/values").VFloat64<number, "required">;
40
+ scope: import("convex/values").VString<string, "required">;
41
+ name: import("convex/values").VString<string, "required">;
42
+ subjectRef: import("convex/values").VString<string | undefined, "optional">;
43
+ sessionRef: import("convex/values").VString<string | undefined, "optional">;
44
+ props: import("convex/values").VRecord<Record<string, string | number | boolean | null>, import("convex/values").VString<string, "required">, import("convex/values").VUnion<string | number | boolean | null, [import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">, import("convex/values").VBoolean<boolean, "required">, import("convex/values").VNull<null, "required">], "required", never>, "required", string>;
45
+ ts: import("convex/values").VFloat64<number, "required">;
46
+ seq: import("convex/values").VFloat64<number, "required">;
47
+ dedupeKey: import("convex/values").VString<string | undefined, "optional">;
48
+ }, "required", "_creationTime" | "name" | "ts" | "_id" | "scope" | "subjectRef" | "sessionRef" | "props" | "seq" | "dedupeKey" | `props.${string}`>;
49
+ /** A `(value, count)` pair for `top` breakdowns. */
50
+ export declare const topRow: import("convex/values").VObject<{
51
+ count: number;
52
+ value: string;
53
+ }, {
54
+ value: import("convex/values").VString<string, "required">;
55
+ count: import("convex/values").VFloat64<number, "required">;
56
+ }, "required", "count" | "value">;
57
+ /** A `(bucket, count)` pair for `timeseries`. */
58
+ export declare const timeseriesPoint: import("convex/values").VObject<{
59
+ count: number;
60
+ bucket: number;
61
+ }, {
62
+ bucket: import("convex/values").VFloat64<number, "required">;
63
+ count: import("convex/values").VFloat64<number, "required">;
64
+ }, "required", "count" | "bucket">;
65
+ /** DAU/WAU/MAU rollup of distinct subjects. */
66
+ export declare const uniquesView: import("convex/values").VObject<{
67
+ dau: number;
68
+ wau: number;
69
+ mau: number;
70
+ trend: {
71
+ bucket: number;
72
+ uniques: number;
73
+ }[];
74
+ }, {
75
+ dau: import("convex/values").VFloat64<number, "required">;
76
+ wau: import("convex/values").VFloat64<number, "required">;
77
+ mau: import("convex/values").VFloat64<number, "required">;
78
+ trend: import("convex/values").VArray<{
79
+ bucket: number;
80
+ uniques: number;
81
+ }[], import("convex/values").VObject<{
82
+ bucket: number;
83
+ uniques: number;
84
+ }, {
85
+ bucket: import("convex/values").VFloat64<number, "required">;
86
+ uniques: import("convex/values").VFloat64<number, "required">;
87
+ }, "required", "bucket" | "uniques">, "required">;
88
+ }, "required", "dau" | "wau" | "mau" | "trend">;
89
+ /** A single funnel step result. */
90
+ export declare const funnelStep: import("convex/values").VObject<{
91
+ count: number;
92
+ name: string;
93
+ rate: number;
94
+ }, {
95
+ name: import("convex/values").VString<string, "required">;
96
+ count: import("convex/values").VFloat64<number, "required">;
97
+ rate: import("convex/values").VFloat64<number, "required">;
98
+ }, "required", "count" | "name" | "rate">;
99
+ /** A single retention cohort row. */
100
+ export declare const retentionCohort: import("convex/values").VObject<{
101
+ cohort: number;
102
+ size: number;
103
+ retained: number[];
104
+ }, {
105
+ cohort: import("convex/values").VFloat64<number, "required">;
106
+ size: import("convex/values").VFloat64<number, "required">;
107
+ retained: import("convex/values").VArray<number[], import("convex/values").VFloat64<number, "required">, "required">;
108
+ }, "required", "cohort" | "size" | "retained">;
109
+ /** Paginated raw-event page (Convex pagination result shape). */
110
+ export declare const eventPage: import("convex/values").VObject<{
111
+ page: {
112
+ subjectRef?: string | undefined;
113
+ sessionRef?: string | undefined;
114
+ dedupeKey?: string | undefined;
115
+ _creationTime: number;
116
+ name: string;
117
+ ts: number;
118
+ _id: string;
119
+ scope: string;
120
+ props: Record<string, string | number | boolean | null>;
121
+ seq: number;
122
+ }[];
123
+ isDone: boolean;
124
+ continueCursor: string;
125
+ }, {
126
+ page: import("convex/values").VArray<{
127
+ subjectRef?: string | undefined;
128
+ sessionRef?: string | undefined;
129
+ dedupeKey?: string | undefined;
130
+ _creationTime: number;
131
+ name: string;
132
+ ts: number;
133
+ _id: string;
134
+ scope: string;
135
+ props: Record<string, string | number | boolean | null>;
136
+ seq: number;
137
+ }[], import("convex/values").VObject<{
138
+ subjectRef?: string | undefined;
139
+ sessionRef?: string | undefined;
140
+ dedupeKey?: string | undefined;
141
+ _creationTime: number;
142
+ name: string;
143
+ ts: number;
144
+ _id: string;
145
+ scope: string;
146
+ props: Record<string, string | number | boolean | null>;
147
+ seq: number;
148
+ }, {
149
+ _id: import("convex/values").VString<string, "required">;
150
+ _creationTime: import("convex/values").VFloat64<number, "required">;
151
+ scope: import("convex/values").VString<string, "required">;
152
+ name: import("convex/values").VString<string, "required">;
153
+ subjectRef: import("convex/values").VString<string | undefined, "optional">;
154
+ sessionRef: import("convex/values").VString<string | undefined, "optional">;
155
+ props: import("convex/values").VRecord<Record<string, string | number | boolean | null>, import("convex/values").VString<string, "required">, import("convex/values").VUnion<string | number | boolean | null, [import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">, import("convex/values").VBoolean<boolean, "required">, import("convex/values").VNull<null, "required">], "required", never>, "required", string>;
156
+ ts: import("convex/values").VFloat64<number, "required">;
157
+ seq: import("convex/values").VFloat64<number, "required">;
158
+ dedupeKey: import("convex/values").VString<string | undefined, "optional">;
159
+ }, "required", "_creationTime" | "name" | "ts" | "_id" | "scope" | "subjectRef" | "sessionRef" | "props" | "seq" | "dedupeKey" | `props.${string}`>, "required">;
160
+ isDone: import("convex/values").VBoolean<boolean, "required">;
161
+ continueCursor: import("convex/values").VString<string, "required">;
162
+ }, "required", "page" | "isDone" | "continueCursor">;
163
+ /** A single histogram bin: events whose measure falls at or below `upper`. */
164
+ export declare const distributionBin: import("convex/values").VObject<{
165
+ count: number;
166
+ upper: number;
167
+ }, {
168
+ upper: import("convex/values").VFloat64<number, "required">;
169
+ count: import("convex/values").VFloat64<number, "required">;
170
+ }, "required", "count" | "upper">;
171
+ /** Histogram of a numeric measure: ascending upper-bound bins + an overflow bucket. */
172
+ export declare const distributionView: import("convex/values").VObject<{
173
+ count: number;
174
+ sum: number;
175
+ bins: {
176
+ count: number;
177
+ upper: number;
178
+ }[];
179
+ overflow: number;
180
+ }, {
181
+ bins: import("convex/values").VArray<{
182
+ count: number;
183
+ upper: number;
184
+ }[], import("convex/values").VObject<{
185
+ count: number;
186
+ upper: number;
187
+ }, {
188
+ upper: import("convex/values").VFloat64<number, "required">;
189
+ count: import("convex/values").VFloat64<number, "required">;
190
+ }, "required", "count" | "upper">, "required">;
191
+ overflow: import("convex/values").VFloat64<number, "required">;
192
+ count: import("convex/values").VFloat64<number, "required">;
193
+ sum: import("convex/values").VFloat64<number, "required">;
194
+ }, "required", "count" | "sum" | "bins" | "overflow">;
195
+ //# sourceMappingURL=validators.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.d.ts","sourceRoot":"","sources":["../../src/component/validators.ts"],"names":[],"mappings":"AAEA,4FAA4F;AAC5F,eAAO,MAAM,eAAe,0SAK3B,CAAC;AAEF,sGAAsG;AACtG,eAAO,MAAM,cAAc,scAAwC,CAAC;AAEpE,oCAAoC;AACpC,eAAO,MAAM,cAAc;;;;;;6BAGzB,CAAC;AAEH,2EAA2E;AAC3E,eAAO,MAAM,cAAc;;;;;;6BAGzB,CAAC;AAEH,4EAA4E;AAC5E,eAAO,MAAM,oBAAoB,mPAIhC,CAAC;AAEF,2FAA2F;AAC3F,eAAO,MAAM,sBAAsB,8TAAgC,CAAC;AAEpE,wCAAwC;AACxC,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;mJAWpB,CAAC;AAEH,oDAAoD;AACpD,eAAO,MAAM,MAAM;;;;;;iCAAqD,CAAC;AAEzE,iDAAiD;AACjD,eAAO,MAAM,eAAe;;;;;;kCAAsD,CAAC;AAEnF,+CAA+C;AAC/C,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;+CAKtB,CAAC;AAEH,mCAAmC;AACnC,eAAO,MAAM,UAAU;;;;;;;;yCAIrB,CAAC;AAEH,qCAAqC;AACrC,eAAO,MAAM,eAAe;;;;;;;;8CAI1B,CAAC;AAEH,iEAAiE;AACjE,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oDAIpB,CAAC;AAEH,8EAA8E;AAC9E,eAAO,MAAM,eAAe;;;;;;iCAAqD,CAAC;AAElF,uFAAuF;AACvF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;qDAK3B,CAAC"}
@@ -0,0 +1,71 @@
1
+ import { v } from "convex/values";
2
+ /** A single property value — string, number, boolean, or null. No nested objects/arrays. */
3
+ export const scalarValidator = v.union(v.string(), v.number(), v.boolean(), v.null());
4
+ /** Event properties: a flat record of scalar values. The generic, typed default — never `v.any()`. */
5
+ export const propsValidator = v.record(v.string(), scalarValidator);
6
+ /** A time range in epoch millis. */
7
+ export const rangeValidator = v.object({
8
+ from: v.optional(v.number()),
9
+ to: v.optional(v.number()),
10
+ });
11
+ /** A dimension filter: count only events whose `dim` prop equals `val`. */
12
+ export const whereValidator = v.object({
13
+ dim: v.string(),
14
+ val: scalarValidator,
15
+ });
16
+ /** Rollup bucket granularity. `minute` is opt-in for short live windows. */
17
+ export const granularityValidator = v.union(v.literal("minute"), v.literal("hour"), v.literal("day"));
18
+ /** Array of granularities (the `granularities` config, shared by `track` + `backfill`). */
19
+ export const granularitiesValidator = v.array(granularityValidator);
20
+ /** A raw event as returned by reads. */
21
+ export const eventView = v.object({
22
+ _id: v.string(),
23
+ _creationTime: v.number(),
24
+ scope: v.string(),
25
+ name: v.string(),
26
+ subjectRef: v.optional(v.string()),
27
+ sessionRef: v.optional(v.string()),
28
+ props: propsValidator,
29
+ ts: v.number(),
30
+ seq: v.number(),
31
+ dedupeKey: v.optional(v.string()),
32
+ });
33
+ /** A `(value, count)` pair for `top` breakdowns. */
34
+ export const topRow = v.object({ value: v.string(), count: v.number() });
35
+ /** A `(bucket, count)` pair for `timeseries`. */
36
+ export const timeseriesPoint = v.object({ bucket: v.number(), count: v.number() });
37
+ /** DAU/WAU/MAU rollup of distinct subjects. */
38
+ export const uniquesView = v.object({
39
+ dau: v.number(),
40
+ wau: v.number(),
41
+ mau: v.number(),
42
+ trend: v.array(v.object({ bucket: v.number(), uniques: v.number() })),
43
+ });
44
+ /** A single funnel step result. */
45
+ export const funnelStep = v.object({
46
+ name: v.string(),
47
+ count: v.number(),
48
+ rate: v.number(),
49
+ });
50
+ /** A single retention cohort row. */
51
+ export const retentionCohort = v.object({
52
+ cohort: v.number(),
53
+ size: v.number(),
54
+ retained: v.array(v.number()),
55
+ });
56
+ /** Paginated raw-event page (Convex pagination result shape). */
57
+ export const eventPage = v.object({
58
+ page: v.array(eventView),
59
+ isDone: v.boolean(),
60
+ continueCursor: v.string(),
61
+ });
62
+ /** A single histogram bin: events whose measure falls at or below `upper`. */
63
+ export const distributionBin = v.object({ upper: v.number(), count: v.number() });
64
+ /** Histogram of a numeric measure: ascending upper-bound bins + an overflow bucket. */
65
+ export const distributionView = v.object({
66
+ bins: v.array(distributionBin),
67
+ overflow: v.number(),
68
+ count: v.number(),
69
+ sum: v.number(),
70
+ });
71
+ //# sourceMappingURL=validators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../src/component/validators.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAElC,4FAA4F;AAC5F,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CACpC,CAAC,CAAC,MAAM,EAAE,EACV,CAAC,CAAC,MAAM,EAAE,EACV,CAAC,CAAC,OAAO,EAAE,EACX,CAAC,CAAC,IAAI,EAAE,CACT,CAAC;AAEF,sGAAsG;AACtG,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CA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EAAE;IAChB,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;CAC9B,CAAC,CAAC;AAEH,iEAAiE;AACjE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;IACxB,MAAM,EAAE,CAAC,CAAC,OAAO,EAAE;IACnB,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;CAC3B,CAAC,CAAC;AAEH,8EAA8E;AAC9E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAElF,uFAAuF;AACvF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC;IAC9B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;IACjB,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE;CAChB,CAAC,CAAC"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Optional React hooks for `@vllnt/convex-analytics`.
3
+ *
4
+ * Thin, tree-shakeable wrappers over `convex/react`'s `useQuery` for the
5
+ * component's **aggregate** read verbs (metric, timeseries, top, uniques).
6
+ * The backend core installs and runs with zero React — these hooks are an
7
+ * opt-in `./react` entry; `react` and `convex` are optional peer deps.
8
+ *
9
+ * No-leak: aggregates ONLY (no raw events) and every call is scope-gated, so a
10
+ * hook can never surface another scope's rows or a raw event payload on the
11
+ * client.
12
+ *
13
+ * The component never owns the host's `api`. The host re-exports the analytics
14
+ * query refs from its own Convex functions and passes the matching ref into
15
+ * each hook — these wrappers forward the host's exact args and the reactive
16
+ * return, while pinning the aggregate return type for ergonomics.
17
+ *
18
+ * @packageDocumentation
19
+ */
20
+ import type { OptionalRestArgsOrSkip } from "convex/react";
21
+ import type { FunctionReference, DefaultFunctionArgs } from "convex/server";
22
+ import type { Range, Where, Granularity, TopRow, TimeseriesPoint, UniquesView } from "../client/types.js";
23
+ export type { Range, Where, Granularity, TopRow, TimeseriesPoint, UniquesView };
24
+ /** A host-re-exported public analytics query ref returning `R`. */
25
+ type QueryRef<R> = FunctionReference<"query", "public", DefaultFunctionArgs, R>;
26
+ /** The args a host's re-exported `metric` query is expected to accept. */
27
+ export interface MetricArgs {
28
+ scope?: string;
29
+ name: string;
30
+ range?: Range;
31
+ where?: Where;
32
+ }
33
+ /** The args a host's re-exported `top` query is expected to accept. */
34
+ export interface TopArgs {
35
+ scope?: string;
36
+ name: string;
37
+ dimension: string;
38
+ range?: Range;
39
+ limit?: number;
40
+ }
41
+ /** The args a host's re-exported `timeseries` query is expected to accept. */
42
+ export interface TimeseriesArgs {
43
+ scope?: string;
44
+ name: string;
45
+ granularity: Granularity;
46
+ range: Range;
47
+ where?: Where;
48
+ }
49
+ /** The args a host's re-exported `uniques` query is expected to accept. */
50
+ export interface UniquesArgs {
51
+ scope?: string;
52
+ range: Range;
53
+ granularity: Granularity;
54
+ }
55
+ /**
56
+ * Reactive total count for an event over a range (optionally filtered).
57
+ *
58
+ * @param ref - The host's re-exported `metric` query reference.
59
+ * @param args - The query args (`{ name, scope?, range?, where? }`), or
60
+ * `"skip"` to defer until ready. The host ref's own validator is the
61
+ * contract; {@link MetricArgs} documents the expected shape.
62
+ * @returns The count, or `undefined` while loading.
63
+ */
64
+ export declare function useMetric<Ref extends QueryRef<number>>(ref: Ref, ...args: OptionalRestArgsOrSkip<Ref>): number | undefined;
65
+ /**
66
+ * Reactive breakdown — top values of a dimension for an event.
67
+ *
68
+ * @param ref - The host's re-exported `top` query reference.
69
+ * @param args - `{ name, dimension, scope?, range?, limit? }`, or `"skip"`.
70
+ * @returns The rows, or `undefined` while loading.
71
+ */
72
+ export declare function useTop<Ref extends QueryRef<TopRow[]>>(ref: Ref, ...args: OptionalRestArgsOrSkip<Ref>): TopRow[] | undefined;
73
+ /**
74
+ * Reactive bucketed counts for an event over a range.
75
+ *
76
+ * @param ref - The host's re-exported `timeseries` query reference.
77
+ * @param args - `{ name, granularity, range, scope?, where? }`, or `"skip"`.
78
+ * @returns The points, or `undefined` while loading.
79
+ */
80
+ export declare function useTimeseries<Ref extends QueryRef<TimeseriesPoint[]>>(ref: Ref, ...args: OptionalRestArgsOrSkip<Ref>): TimeseriesPoint[] | undefined;
81
+ /**
82
+ * Reactive DAU/WAU/MAU + trend from subjects.
83
+ *
84
+ * @param ref - The host's re-exported `uniques` query reference.
85
+ * @param args - `{ range, granularity, scope? }`, or `"skip"`.
86
+ * @returns The uniques view, or `undefined` while loading.
87
+ */
88
+ export declare function useUniques<Ref extends QueryRef<UniquesView>>(ref: Ref, ...args: OptionalRestArgsOrSkip<Ref>): UniquesView | undefined;
89
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC5E,OAAO,KAAK,EACV,KAAK,EACL,KAAK,EACL,WAAW,EACX,MAAM,EACN,eAAe,EACf,WAAW,EACZ,MAAM,oBAAoB,CAAC;AAE5B,YAAY,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,CAAC;AAEhF,mEAAmE;AACnE,KAAK,QAAQ,CAAC,CAAC,IAAI,iBAAiB,CAAC,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,CAAC,CAAC,CAAC;AAEhF,0E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EAAE,sBAAsB,CAAC,GAAG,CAAC,GACnC,eAAe,EAAE,GAAG,SAAS,CAE/B;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,GAAG,SAAS,QAAQ,CAAC,WAAW,CAAC,EAC1D,GAAG,EAAE,GAAG,EACR,GAAG,IAAI,EAAE,sBAAsB,CAAC,GAAG,CAAC,GACnC,WAAW,GAAG,SAAS,CAEzB"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Optional React hooks for `@vllnt/convex-analytics`.
3
+ *
4
+ * Thin, tree-shakeable wrappers over `convex/react`'s `useQuery` for the
5
+ * component's **aggregate** read verbs (metric, timeseries, top, uniques).
6
+ * The backend core installs and runs with zero React — these hooks are an
7
+ * opt-in `./react` entry; `react` and `convex` are optional peer deps.
8
+ *
9
+ * No-leak: aggregates ONLY (no raw events) and every call is scope-gated, so a
10
+ * hook can never surface another scope's rows or a raw event payload on the
11
+ * client.
12
+ *
13
+ * The component never owns the host's `api`. The host re-exports the analytics
14
+ * query refs from its own Convex functions and passes the matching ref into
15
+ * each hook — these wrappers forward the host's exact args and the reactive
16
+ * return, while pinning the aggregate return type for ergonomics.
17
+ *
18
+ * @packageDocumentation
19
+ */
20
+ import { useQuery } from "convex/react";
21
+ /**
22
+ * Reactive total count for an event over a range (optionally filtered).
23
+ *
24
+ * @param ref - The host's re-exported `metric` query reference.
25
+ * @param args - The query args (`{ name, scope?, range?, where? }`), or
26
+ * `"skip"` to defer until ready. The host ref's own validator is the
27
+ * contract; {@link MetricArgs} documents the expected shape.
28
+ * @returns The count, or `undefined` while loading.
29
+ */
30
+ export function useMetric(ref, ...args) {
31
+ return useQuery(ref, ...args);
32
+ }
33
+ /**
34
+ * Reactive breakdown — top values of a dimension for an event.
35
+ *
36
+ * @param ref - The host's re-exported `top` query reference.
37
+ * @param args - `{ name, dimension, scope?, range?, limit? }`, or `"skip"`.
38
+ * @returns The rows, or `undefined` while loading.
39
+ */
40
+ export function useTop(ref, ...args) {
41
+ return useQuery(ref, ...args);
42
+ }
43
+ /**
44
+ * Reactive bucketed counts for an event over a range.
45
+ *
46
+ * @param ref - The host's re-exported `timeseries` query reference.
47
+ * @param args - `{ name, granularity, range, scope?, where? }`, or `"skip"`.
48
+ * @returns The points, or `undefined` while loading.
49
+ */
50
+ export function useTimeseries(ref, ...args) {
51
+ return useQuery(ref, ...args);
52
+ }
53
+ /**
54
+ * Reactive DAU/WAU/MAU + trend from subjects.
55
+ *
56
+ * @param ref - The host's re-exported `uniques` query reference.
57
+ * @param args - `{ range, granularity, scope? }`, or `"skip"`.
58
+ * @returns The uniques view, or `undefined` while loading.
59
+ */
60
+ export function useUniques(ref, ...args) {
61
+ return useQuery(ref, ...args);
62
+ }
63
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/react/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAkDxC;;;;;;;;GAQG;AACH,MAAM,UAAU,SAAS,CACvB,GAAQ,EACR,GAAG,IAAiC;IAEpC,OAAO,QAAQ,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;AAChC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,MAAM,CACpB,GAAQ,EACR,GAAG,IAAiC;IAEpC,OAAO,QAAQ,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;AAChC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAC3B,GAAQ,EACR,GAAG,IAAiC;IAEpC,OAAO,QAAQ,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;AAChC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CACxB,GAAQ,EACR,GAAG,IAAiC;IAEpC,OAAO,QAAQ,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;AAChC,CAAC"}
@@ -0,0 +1,14 @@
1
+ /** Shared pure helpers + types for the generic analytics component. */
2
+ /** A single property value. */
3
+ export type Scalar = string | number | boolean | null;
4
+ /** Event properties: a flat record of scalar values. */
5
+ export type Props = Record<string, Scalar>;
6
+ /** Rollup bucket granularity. `minute` is opt-in for short live windows. */
7
+ export type Granularity = "minute" | "hour" | "day";
8
+ /** Bucket size in millis for a granularity. */
9
+ export declare function bucketSize(granularity: Granularity): number;
10
+ /** Truncate an epoch-millis timestamp to the start of its `granularity` bucket. */
11
+ export declare function bucketStart(ts: number, granularity: Granularity): number;
12
+ /** Coerce a scalar prop value to the string form used as a rollup `val` key. */
13
+ export declare function valKey(value: Scalar): string;
14
+ //# sourceMappingURL=shared.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,uEAAuE;AAEvE,+BAA+B;AAC/B,MAAM,MAAM,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AAEtD,wDAAwD;AACxD,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAE3C,4EAA4E;AAC5E,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,MAAM,GAAG,KAAK,CAAC;AAMpD,+CAA+C;AAC/C,wBAAgB,UAAU,CAAC,WAAW,EAAE,WAAW,GAAG,MAAM,CAE3D;AAED,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,GAAG,MAAM,CAGxE;AAED,gFAAgF;AAChF,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE5C"}
package/dist/shared.js ADDED
@@ -0,0 +1,18 @@
1
+ /** Shared pure helpers + types for the generic analytics component. */
2
+ const MINUTE_MS = 60 * 1000;
3
+ const HOUR_MS = 60 * MINUTE_MS;
4
+ const DAY_MS = 24 * HOUR_MS;
5
+ /** Bucket size in millis for a granularity. */
6
+ export function bucketSize(granularity) {
7
+ return granularity === "minute" ? MINUTE_MS : granularity === "hour" ? HOUR_MS : DAY_MS;
8
+ }
9
+ /** Truncate an epoch-millis timestamp to the start of its `granularity` bucket. */
10
+ export function bucketStart(ts, granularity) {
11
+ const size = bucketSize(granularity);
12
+ return Math.floor(ts / size) * size;
13
+ }
14
+ /** Coerce a scalar prop value to the string form used as a rollup `val` key. */
15
+ export function valKey(value) {
16
+ return value === null ? "null" : String(value);
17
+ }
18
+ //# sourceMappingURL=shared.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,uEAAuE;AAWvE,MAAM,SAAS,GAAG,EAAE,GAAG,IAAI,CAAC;AAC5B,MAAM,OAAO,GAAG,EAAE,GAAG,SAAS,CAAC;AAC/B,MAAM,MAAM,GAAG,EAAE,GAAG,OAAO,CAAC;AAE5B,+CAA+C;AAC/C,MAAM,UAAU,UAAU,CAAC,WAAwB;IACjD,OAAO,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,KAAK,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;AAC1F,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,WAAW,CAAC,EAAU,EAAE,WAAwB;IAC9D,MAAM,IAAI,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;IACrC,OAAO,IAAI,CAAC,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;AACtC,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,MAAM,CAAC,KAAa;IAClC,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACjD,CAAC"}
package/dist/test.d.ts ADDED
@@ -0,0 +1,117 @@
1
+ import type { TestConvex } from "convex-test";
2
+ import type { GenericSchema, SchemaDefinition } from "convex/server";
3
+ /**
4
+ * Register the convex-analytics component (and its child components) with a
5
+ * convex-test instance. Child components are registered under nested paths
6
+ * (`<name>/aggregate`, `<name>/shardedCounter`, `<name>/rateLimiter`) so that
7
+ * `track`'s aggregate/counter/rate-limiter calls resolve end-to-end.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import analyticsTest from "@vllnt/convex-analytics/test";
12
+ * import { convexTest } from "convex-test";
13
+ *
14
+ * const t = convexTest(hostSchema, hostModules);
15
+ * analyticsTest.register(t);
16
+ * ```
17
+ */
18
+ export declare function register(t: TestConvex<SchemaDefinition<GenericSchema, boolean>>, name?: string): void;
19
+ declare const _default: {
20
+ register: typeof register;
21
+ schema: SchemaDefinition<{
22
+ events: import("convex/server").TableDefinition<import("convex/values").VObject<{
23
+ subjectRef?: string | undefined;
24
+ sessionRef?: string | undefined;
25
+ dedupeKey?: string | undefined;
26
+ name: string;
27
+ ts: number;
28
+ scope: string;
29
+ props: Record<string, string | number | boolean | null>;
30
+ seq: number;
31
+ }, {
32
+ scope: import("convex/values").VString<string, "required">;
33
+ name: import("convex/values").VString<string, "required">;
34
+ subjectRef: import("convex/values").VString<string | undefined, "optional">;
35
+ sessionRef: import("convex/values").VString<string | undefined, "optional">;
36
+ props: import("convex/values").VRecord<Record<string, string | number | boolean | null>, import("convex/values").VString<string, "required">, import("convex/values").VUnion<string | number | boolean | null, [import("convex/values").VString<string, "required">, import("convex/values").VFloat64<number, "required">, import("convex/values").VBoolean<boolean, "required">, import("convex/values").VNull<null, "required">], "required", never>, "required", string>;
37
+ ts: import("convex/values").VFloat64<number, "required">;
38
+ seq: import("convex/values").VFloat64<number, "required">;
39
+ dedupeKey: import("convex/values").VString<string | undefined, "optional">;
40
+ }, "required", "name" | "ts" | "scope" | "subjectRef" | "sessionRef" | "props" | "seq" | "dedupeKey" | `props.${string}`>, {
41
+ by_scope_name_ts: ["scope", "name", "ts", "_creationTime"];
42
+ by_scope_subject_ts: ["scope", "subjectRef", "ts", "_creationTime"];
43
+ by_scope_session_ts: ["scope", "sessionRef", "ts", "_creationTime"];
44
+ by_dedupe: ["scope", "dedupeKey", "_creationTime"];
45
+ }, {}, {}>;
46
+ rollups: import("convex/server").TableDefinition<import("convex/values").VObject<{
47
+ count: number;
48
+ name: string;
49
+ dim: string;
50
+ val: string;
51
+ scope: string;
52
+ bucket: number;
53
+ granularity: "minute" | "hour" | "day";
54
+ }, {
55
+ scope: import("convex/values").VString<string, "required">;
56
+ name: import("convex/values").VString<string, "required">;
57
+ granularity: import("convex/values").VUnion<"minute" | "hour" | "day", [import("convex/values").VLiteral<"minute", "required">, import("convex/values").VLiteral<"hour", "required">, import("convex/values").VLiteral<"day", "required">], "required", never>;
58
+ bucket: import("convex/values").VFloat64<number, "required">;
59
+ dim: import("convex/values").VString<string, "required">;
60
+ val: import("convex/values").VString<string, "required">;
61
+ count: import("convex/values").VFloat64<number, "required">;
62
+ }, "required", "count" | "name" | "dim" | "val" | "scope" | "bucket" | "granularity">, {
63
+ by_scope_name_gran_bucket_dim: ["scope", "name", "granularity", "bucket", "dim", "val", "_creationTime"];
64
+ by_scope_name_dim_val: ["scope", "name", "dim", "val", "_creationTime"];
65
+ }, {}, {}>;
66
+ subjects: import("convex/server").TableDefinition<import("convex/values").VObject<{
67
+ scope: string;
68
+ subjectRef: string;
69
+ firstSeen: number;
70
+ lastSeen: number;
71
+ eventCount: number;
72
+ }, {
73
+ scope: import("convex/values").VString<string, "required">;
74
+ subjectRef: import("convex/values").VString<string, "required">;
75
+ firstSeen: import("convex/values").VFloat64<number, "required">;
76
+ lastSeen: import("convex/values").VFloat64<number, "required">;
77
+ eventCount: import("convex/values").VFloat64<number, "required">;
78
+ }, "required", "scope" | "subjectRef" | "firstSeen" | "lastSeen" | "eventCount">, {
79
+ by_scope_subject: ["scope", "subjectRef", "_creationTime"];
80
+ by_scope_firstSeen: ["scope", "firstSeen", "_creationTime"];
81
+ }, {}, {}>;
82
+ sessions: import("convex/server").TableDefinition<import("convex/values").VObject<{
83
+ subjectRef?: string | undefined;
84
+ endTs?: number | undefined;
85
+ scope: string;
86
+ sessionRef: string;
87
+ eventCount: number;
88
+ startTs: number;
89
+ lastTs: number;
90
+ }, {
91
+ scope: import("convex/values").VString<string, "required">;
92
+ sessionRef: import("convex/values").VString<string, "required">;
93
+ subjectRef: import("convex/values").VString<string | undefined, "optional">;
94
+ startTs: import("convex/values").VFloat64<number, "required">;
95
+ endTs: import("convex/values").VFloat64<number | undefined, "optional">;
96
+ lastTs: import("convex/values").VFloat64<number, "required">;
97
+ eventCount: import("convex/values").VFloat64<number, "required">;
98
+ }, "required", "scope" | "subjectRef" | "sessionRef" | "eventCount" | "startTs" | "endTs" | "lastTs">, {
99
+ by_scope_session: ["scope", "sessionRef", "_creationTime"];
100
+ by_scope_lastTs: ["scope", "lastTs", "_creationTime"];
101
+ }, {}, {}>;
102
+ config: import("convex/server").TableDefinition<import("convex/values").VObject<{
103
+ value: string;
104
+ key: string;
105
+ scope: string;
106
+ }, {
107
+ scope: import("convex/values").VString<string, "required">;
108
+ key: import("convex/values").VString<string, "required">;
109
+ value: import("convex/values").VString<string, "required">;
110
+ }, "required", "value" | "key" | "scope">, {
111
+ by_scope_key: ["scope", "key", "_creationTime"];
112
+ }, {}, {}>;
113
+ }, true>;
114
+ modules: Record<string, () => Promise<unknown>>;
115
+ };
116
+ export default _default;
117
+ //# sourceMappingURL=test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAQrE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,QAAQ,CACtB,CAAC,EAAE,UAAU,CAAC,gBAAgB,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC,EACvD,IAAI,GAAE,MAAoB,GACzB,IAAI,CAaN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAED,wBAA6C"}
package/dist/test.js ADDED
@@ -0,0 +1,28 @@
1
+ import aggregateTest from "@convex-dev/aggregate/test";
2
+ import shardedCounterTest from "@convex-dev/sharded-counter/test";
3
+ import rateLimiterTest from "@convex-dev/rate-limiter/test";
4
+ import schema from "./component/schema.js";
5
+ const modules = import.meta.glob("./component/**/*.ts");
6
+ /**
7
+ * Register the convex-analytics component (and its child components) with a
8
+ * convex-test instance. Child components are registered under nested paths
9
+ * (`<name>/aggregate`, `<name>/shardedCounter`, `<name>/rateLimiter`) so that
10
+ * `track`'s aggregate/counter/rate-limiter calls resolve end-to-end.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * import analyticsTest from "@vllnt/convex-analytics/test";
15
+ * import { convexTest } from "convex-test";
16
+ *
17
+ * const t = convexTest(hostSchema, hostModules);
18
+ * analyticsTest.register(t);
19
+ * ```
20
+ */
21
+ export function register(t, name = "analytics") {
22
+ t.registerComponent(name, schema, modules);
23
+ t.registerComponent(`${name}/aggregate`, aggregateTest.schema, aggregateTest.modules);
24
+ t.registerComponent(`${name}/shardedCounter`, shardedCounterTest.schema, shardedCounterTest.modules);
25
+ t.registerComponent(`${name}/rateLimiter`, rateLimiterTest.schema, rateLimiterTest.modules);
26
+ }
27
+ export default { register, schema, modules };
28
+ //# sourceMappingURL=test.js.map