@vllnt/convex-analytics 0.1.0-canary.2b9f918
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/LICENSE +21 -0
- package/README.md +198 -0
- package/dist/client/index.d.ts +94 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +132 -0
- package/dist/client/index.js.map +1 -0
- package/dist/client/types.d.ts +109 -0
- package/dist/client/types.d.ts.map +1 -0
- package/dist/client/types.js +2 -0
- package/dist/client/types.js.map +1 -0
- package/dist/component/_generated/api.d.ts +46 -0
- package/dist/component/_generated/api.d.ts.map +1 -0
- package/dist/component/_generated/api.js +31 -0
- package/dist/component/_generated/api.js.map +1 -0
- package/dist/component/_generated/component.d.ts +181 -0
- package/dist/component/_generated/component.d.ts.map +1 -0
- package/dist/component/_generated/component.js +11 -0
- package/dist/component/_generated/component.js.map +1 -0
- package/dist/component/_generated/dataModel.d.ts +46 -0
- package/dist/component/_generated/dataModel.d.ts.map +1 -0
- package/dist/component/_generated/dataModel.js +11 -0
- package/dist/component/_generated/dataModel.js.map +1 -0
- package/dist/component/_generated/server.d.ts +133 -0
- package/dist/component/_generated/server.d.ts.map +1 -0
- package/dist/component/_generated/server.js +80 -0
- package/dist/component/_generated/server.js.map +1 -0
- package/dist/component/convex.config.d.ts +3 -0
- package/dist/component/convex.config.d.ts.map +1 -0
- package/dist/component/convex.config.js +10 -0
- package/dist/component/convex.config.js.map +1 -0
- package/dist/component/http.d.ts +13 -0
- package/dist/component/http.d.ts.map +1 -0
- package/dist/component/http.js +180 -0
- package/dist/component/http.js.map +1 -0
- package/dist/component/internal_mutations.d.ts +26 -0
- package/dist/component/internal_mutations.d.ts.map +1 -0
- package/dist/component/internal_mutations.js +126 -0
- package/dist/component/internal_mutations.js.map +1 -0
- package/dist/component/mutations.d.ts +24 -0
- package/dist/component/mutations.d.ts.map +1 -0
- package/dist/component/mutations.js +209 -0
- package/dist/component/mutations.js.map +1 -0
- package/dist/component/queries.d.ts +148 -0
- package/dist/component/queries.d.ts.map +1 -0
- package/dist/component/queries.js +376 -0
- package/dist/component/queries.js.map +1 -0
- package/dist/component/schema.d.ts +104 -0
- package/dist/component/schema.d.ts.map +1 -0
- package/dist/component/schema.js +72 -0
- package/dist/component/schema.js.map +1 -0
- package/dist/component/validators.d.ts +195 -0
- package/dist/component/validators.d.ts.map +1 -0
- package/dist/component/validators.js +71 -0
- package/dist/component/validators.js.map +1 -0
- package/dist/react/index.d.ts +89 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +63 -0
- package/dist/react/index.js.map +1 -0
- package/dist/shared.d.ts +14 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/shared.js +18 -0
- package/dist/shared.js.map +1 -0
- package/dist/test.d.ts +117 -0
- package/dist/test.d.ts.map +1 -0
- package/dist/test.js +28 -0
- package/dist/test.js.map +1 -0
- package/dist/web/index.d.ts +121 -0
- package/dist/web/index.d.ts.map +1 -0
- package/dist/web/index.js +169 -0
- package/dist/web/index.js.map +1 -0
- package/package.json +121 -0
- package/src/client/index.ts +259 -0
- package/src/client/types.ts +121 -0
- package/src/component/_generated/api.ts +62 -0
- package/src/component/_generated/component.ts +196 -0
- package/src/component/_generated/dataModel.ts +60 -0
- package/src/component/_generated/server.ts +169 -0
- package/src/component/convex.config.ts +12 -0
- package/src/component/http.ts +204 -0
- package/src/component/internal_mutations.ts +167 -0
- package/src/component/mutations.ts +255 -0
- package/src/component/queries.ts +436 -0
- package/src/component/schema.ts +76 -0
- package/src/component/validators.ts +94 -0
- package/src/react/index.tsx +127 -0
- package/src/shared.ts +30 -0
- package/src/test.ts +44 -0
- package/src/web/index.ts +232 -0
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
|
+
dedupeKey?: string | undefined;
|
|
24
|
+
name: string;
|
|
25
|
+
props: Record<string, string | number | boolean | null>;
|
|
26
|
+
scope: string;
|
|
27
|
+
seq: number;
|
|
28
|
+
sessionRef?: string | undefined;
|
|
29
|
+
subjectRef?: string | undefined;
|
|
30
|
+
ts: 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", "dedupeKey" | "name" | "props" | "scope" | "seq" | "sessionRef" | "subjectRef" | "ts" | `props.${string}`>, {
|
|
41
|
+
by_dedupe: ["scope", "dedupeKey", "_creationTime"];
|
|
42
|
+
by_scope_name_ts: ["scope", "name", "ts", "_creationTime"];
|
|
43
|
+
by_scope_session_ts: ["scope", "sessionRef", "ts", "_creationTime"];
|
|
44
|
+
by_scope_subject_ts: ["scope", "subjectRef", "ts", "_creationTime"];
|
|
45
|
+
}, {}, {}>;
|
|
46
|
+
rollups: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
47
|
+
bucket: number;
|
|
48
|
+
count: number;
|
|
49
|
+
dim: string;
|
|
50
|
+
granularity: "day" | "hour" | "minute";
|
|
51
|
+
name: string;
|
|
52
|
+
scope: string;
|
|
53
|
+
val: string;
|
|
54
|
+
}, {
|
|
55
|
+
scope: import("convex/values").VString<string, "required">;
|
|
56
|
+
name: import("convex/values").VString<string, "required">;
|
|
57
|
+
granularity: import("convex/values").VUnion<"day" | "hour" | "minute", [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", "bucket" | "count" | "dim" | "granularity" | "name" | "scope" | "val">, {
|
|
63
|
+
by_scope_name_dim_val: ["scope", "name", "dim", "val", "_creationTime"];
|
|
64
|
+
by_scope_name_gran_bucket_dim: ["scope", "name", "granularity", "bucket", "dim", "val", "_creationTime"];
|
|
65
|
+
}, {}, {}>;
|
|
66
|
+
subjects: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
67
|
+
eventCount: number;
|
|
68
|
+
firstSeen: number;
|
|
69
|
+
lastSeen: number;
|
|
70
|
+
scope: string;
|
|
71
|
+
subjectRef: string;
|
|
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", "eventCount" | "firstSeen" | "lastSeen" | "scope" | "subjectRef">, {
|
|
79
|
+
by_scope_firstSeen: ["scope", "firstSeen", "_creationTime"];
|
|
80
|
+
by_scope_subject: ["scope", "subjectRef", "_creationTime"];
|
|
81
|
+
}, {}, {}>;
|
|
82
|
+
sessions: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
83
|
+
endTs?: number | undefined;
|
|
84
|
+
eventCount: number;
|
|
85
|
+
lastTs: number;
|
|
86
|
+
scope: string;
|
|
87
|
+
sessionRef: string;
|
|
88
|
+
startTs: number;
|
|
89
|
+
subjectRef?: string | undefined;
|
|
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", "endTs" | "eventCount" | "lastTs" | "scope" | "sessionRef" | "startTs" | "subjectRef">, {
|
|
99
|
+
by_scope_lastTs: ["scope", "lastTs", "_creationTime"];
|
|
100
|
+
by_scope_session: ["scope", "sessionRef", "_creationTime"];
|
|
101
|
+
}, {}, {}>;
|
|
102
|
+
config: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
103
|
+
key: string;
|
|
104
|
+
scope: string;
|
|
105
|
+
value: 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", "key" | "scope" | "value">, {
|
|
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"}
|
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
|
package/dist/test.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AAGA,OAAO,aAAa,MAAM,4BAA4B,CAAC;AACvD,OAAO,kBAAkB,MAAM,kCAAkC,CAAC;AAClE,OAAO,eAAe,MAAM,+BAA+B,CAAC;AAC5D,OAAO,MAAM,MAAM,uBAAuB,CAAC;AAE3C,MAAM,OAAO,GAAG,OAAO,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;AAExD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,QAAQ,CACtB,CAAuD,EACvD,IAAI,GAAW,WAAW;IAE1B,CAAC,CAAC,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC,CAAC,iBAAiB,CAAC,GAAG,IAAI,YAAY,EAAE,aAAa,CAAC,MAAM,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;IACtF,CAAC,CAAC,iBAAiB,CACjB,GAAG,IAAI,iBAAiB,EACxB,kBAAkB,CAAC,MAAM,EACzB,kBAAkB,CAAC,OAAO,CAC3B,CAAC;IACF,CAAC,CAAC,iBAAiB,CACjB,GAAG,IAAI,cAAc,EACrB,eAAe,CAAC,MAAM,EACtB,eAAe,CAAC,OAAO,CACxB,CAAC;AACJ,CAAC;AAED,eAAe,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional web preset for `@vllnt/convex-analytics`.
|
|
3
|
+
*
|
|
4
|
+
* Pure, host-side helpers — NOT part of the sandboxed component. A web host
|
|
5
|
+
* opts in by passing {@link webDimensions} to the `AnalyticsClient` `dimensions`
|
|
6
|
+
* config and using {@link trackPageview} to ingest page views. The generic core
|
|
7
|
+
* stays domain-neutral; nothing here runs inside the component sandbox.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
import type { Scalar } from "../shared.js";
|
|
12
|
+
/**
|
|
13
|
+
* Standard web rollup dimensions. Pass to the `AnalyticsClient` `dimensions`
|
|
14
|
+
* config to opt into web breakdowns (path, referrer, device, browser, ...).
|
|
15
|
+
*/
|
|
16
|
+
export declare const webDimensions: readonly ["path", "referrer", "device", "browser", "os", "country", "utmSource", "utmMedium", "utmCampaign"];
|
|
17
|
+
/** A key of {@link webDimensions}. */
|
|
18
|
+
export type WebDimension = (typeof webDimensions)[number];
|
|
19
|
+
/** Parsed user-agent facets. */
|
|
20
|
+
export interface UserAgentInfo {
|
|
21
|
+
device: string;
|
|
22
|
+
browser: string;
|
|
23
|
+
os: string;
|
|
24
|
+
}
|
|
25
|
+
/** Geo facets resolved from edge/CDN request headers. */
|
|
26
|
+
export interface GeoInfo {
|
|
27
|
+
country: string;
|
|
28
|
+
region?: string;
|
|
29
|
+
city?: string;
|
|
30
|
+
}
|
|
31
|
+
/** UTM campaign tags. */
|
|
32
|
+
export interface Utm {
|
|
33
|
+
source?: string;
|
|
34
|
+
medium?: string;
|
|
35
|
+
campaign?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Parse a `User-Agent` string into device / browser / os facets.
|
|
39
|
+
*
|
|
40
|
+
* Pure and dependency-free — coarse buckets suitable for rollups, not exact
|
|
41
|
+
* version detection. Unknown agents fall back to `"Other"` / `"desktop"`.
|
|
42
|
+
*
|
|
43
|
+
* @param ua - The raw `User-Agent` header value.
|
|
44
|
+
* @returns Device, browser, and OS buckets.
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* parseUserAgent("Mozilla/5.0 ... Chrome/120 Safari/537");
|
|
48
|
+
* // { device: "desktop", browser: "Chrome", os: "..." }
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare function parseUserAgent(ua: string): UserAgentInfo;
|
|
52
|
+
/**
|
|
53
|
+
* Resolve geo facets from Cloudflare / Vercel edge request headers.
|
|
54
|
+
*
|
|
55
|
+
* Reads `CF-IPCountry` and the `X-Vercel-IP-*` family. Accepts either a DOM
|
|
56
|
+
* `Headers` instance or a plain object (case-insensitive). Country defaults to
|
|
57
|
+
* `"unknown"` when no header is present.
|
|
58
|
+
*
|
|
59
|
+
* @param headers - Request headers as a `Headers` instance or a plain record.
|
|
60
|
+
* @returns Country (always present) plus optional region / city.
|
|
61
|
+
*/
|
|
62
|
+
export declare function geoFromHeaders(headers: Headers | Record<string, string>): GeoInfo;
|
|
63
|
+
/** A subset of the `AnalyticsClient` surface used by {@link trackPageview}. */
|
|
64
|
+
interface PageviewClient {
|
|
65
|
+
track(ctx: unknown, name: string, opts: {
|
|
66
|
+
subjectRef?: string;
|
|
67
|
+
sessionRef?: string;
|
|
68
|
+
props?: Record<string, Scalar>;
|
|
69
|
+
ts?: number;
|
|
70
|
+
scope?: string;
|
|
71
|
+
dedupeKey?: string;
|
|
72
|
+
}): Promise<unknown>;
|
|
73
|
+
}
|
|
74
|
+
/** Options for {@link trackPageview}. */
|
|
75
|
+
export interface TrackPageviewOpts {
|
|
76
|
+
subjectRef?: string;
|
|
77
|
+
sessionRef?: string;
|
|
78
|
+
/** The page path (e.g. `/pricing`). */
|
|
79
|
+
path: string;
|
|
80
|
+
/** The document referrer, if any. */
|
|
81
|
+
referrer?: string;
|
|
82
|
+
/** Raw `User-Agent` header — parsed into device/browser/os when present. */
|
|
83
|
+
ua?: string;
|
|
84
|
+
/** Request headers — parsed for geo (country/region/city) when present. */
|
|
85
|
+
headers?: Headers | Record<string, string>;
|
|
86
|
+
/** UTM campaign tags. */
|
|
87
|
+
utm?: Utm;
|
|
88
|
+
/** Epoch-millis event time. Defaults to the component's clock when omitted. */
|
|
89
|
+
ts?: number;
|
|
90
|
+
/** Override the client's default scope for this event. */
|
|
91
|
+
scope?: string;
|
|
92
|
+
/** Skip if an event with this dedupe key already exists in the scope. */
|
|
93
|
+
dedupeKey?: string;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Build web `props` from a pageview (parsing UA + geo) and ingest a
|
|
97
|
+
* `"page_view"` event through the generic `AnalyticsClient`.
|
|
98
|
+
*
|
|
99
|
+
* Host-side convenience: the component never sees web concepts — this helper
|
|
100
|
+
* just assembles the `{@link webDimensions}`-shaped props and calls
|
|
101
|
+
* `client.track(ctx, "page_view", { props })`. Pair with
|
|
102
|
+
* `dimensions: webDimensions` on the client to get web rollups.
|
|
103
|
+
*
|
|
104
|
+
* @typeParam C - The `AnalyticsClient` (structural) type.
|
|
105
|
+
* @param client - An `AnalyticsClient` (or compatible) instance.
|
|
106
|
+
* @param ctx - The Convex mutation ctx to run `track` against.
|
|
107
|
+
* @param opts - Pageview fields; `path` is required.
|
|
108
|
+
* @returns The `track` result passed through from the client.
|
|
109
|
+
* @example
|
|
110
|
+
* ```ts
|
|
111
|
+
* const analytics = new AnalyticsClient(components.analytics, { dimensions: webDimensions });
|
|
112
|
+
* await trackPageview(analytics, ctx, {
|
|
113
|
+
* path: "/pricing",
|
|
114
|
+
* ua: request.headers.get("user-agent") ?? undefined,
|
|
115
|
+
* headers: request.headers,
|
|
116
|
+
* });
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare function trackPageview<C extends PageviewClient>(client: C, ctx: unknown, opts: TrackPageviewOpts): Promise<unknown>;
|
|
120
|
+
export {};
|
|
121
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/web/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,aAAa,YACxB,MAAM,EACN,UAAU,EACV,QAAQ,EACR,SAAS,EACT,IAAI,EACJ,SAAS,EACT,WAAW,EACX,WAAW,EACX,aAAa,CACL,CAAC;AAEX,sCAAsC;AACtC,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAE1D,gCAAgC;AAChC,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,yDAAyD;AACzD,MAAM,WAAW,OAAO;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,yBAAyB;AACzB,MAAM,WAAW,GAAG;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AA0BD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,aAAa,CAExD;AAeD;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,OAAO,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}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional web preset for `@vllnt/convex-analytics`.
|
|
3
|
+
*
|
|
4
|
+
* Pure, host-side helpers — NOT part of the sandboxed component. A web host
|
|
5
|
+
* opts in by passing {@link webDimensions} to the `AnalyticsClient` `dimensions`
|
|
6
|
+
* config and using {@link trackPageview} to ingest page views. The generic core
|
|
7
|
+
* stays domain-neutral; nothing here runs inside the component sandbox.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Standard web rollup dimensions. Pass to the `AnalyticsClient` `dimensions`
|
|
13
|
+
* config to opt into web breakdowns (path, referrer, device, browser, ...).
|
|
14
|
+
*/
|
|
15
|
+
export const webDimensions = [
|
|
16
|
+
"path",
|
|
17
|
+
"referrer",
|
|
18
|
+
"device",
|
|
19
|
+
"browser",
|
|
20
|
+
"os",
|
|
21
|
+
"country",
|
|
22
|
+
"utmSource",
|
|
23
|
+
"utmMedium",
|
|
24
|
+
"utmCampaign",
|
|
25
|
+
];
|
|
26
|
+
function browserOf(ua) {
|
|
27
|
+
if (ua.includes("Firefox/"))
|
|
28
|
+
return "Firefox";
|
|
29
|
+
if (ua.includes("Edg/"))
|
|
30
|
+
return "Edge";
|
|
31
|
+
if (ua.includes("Chrome/"))
|
|
32
|
+
return "Chrome";
|
|
33
|
+
if (ua.includes("Safari/") && !ua.includes("Chrome/"))
|
|
34
|
+
return "Safari";
|
|
35
|
+
return "Other";
|
|
36
|
+
}
|
|
37
|
+
function osOf(ua) {
|
|
38
|
+
if (ua.includes("Windows"))
|
|
39
|
+
return "Windows";
|
|
40
|
+
if (ua.includes("iPhone") || ua.includes("iPad"))
|
|
41
|
+
return "iOS";
|
|
42
|
+
if (ua.includes("Android"))
|
|
43
|
+
return "Android";
|
|
44
|
+
if (ua.includes("Mac OS X") || ua.includes("Macintosh"))
|
|
45
|
+
return "macOS";
|
|
46
|
+
if (ua.includes("Linux"))
|
|
47
|
+
return "Linux";
|
|
48
|
+
return "Other";
|
|
49
|
+
}
|
|
50
|
+
function deviceOf(ua) {
|
|
51
|
+
if (/bot|crawler|spider/i.test(ua))
|
|
52
|
+
return "bot";
|
|
53
|
+
if (/iPhone|Android.*Mobile/i.test(ua))
|
|
54
|
+
return "mobile";
|
|
55
|
+
if (/iPad|Android(?!.*Mobile)/i.test(ua))
|
|
56
|
+
return "tablet";
|
|
57
|
+
return "desktop";
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Parse a `User-Agent` string into device / browser / os facets.
|
|
61
|
+
*
|
|
62
|
+
* Pure and dependency-free — coarse buckets suitable for rollups, not exact
|
|
63
|
+
* version detection. Unknown agents fall back to `"Other"` / `"desktop"`.
|
|
64
|
+
*
|
|
65
|
+
* @param ua - The raw `User-Agent` header value.
|
|
66
|
+
* @returns Device, browser, and OS buckets.
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* parseUserAgent("Mozilla/5.0 ... Chrome/120 Safari/537");
|
|
70
|
+
* // { device: "desktop", browser: "Chrome", os: "..." }
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export function parseUserAgent(ua) {
|
|
74
|
+
return { device: deviceOf(ua), browser: browserOf(ua), os: osOf(ua) };
|
|
75
|
+
}
|
|
76
|
+
function headerGetter(headers) {
|
|
77
|
+
if (typeof headers.get === "function") {
|
|
78
|
+
return (name) => headers.get(name) ?? undefined;
|
|
79
|
+
}
|
|
80
|
+
const lower = {};
|
|
81
|
+
for (const [k, v] of Object.entries(headers)) {
|
|
82
|
+
lower[k.toLowerCase()] = v;
|
|
83
|
+
}
|
|
84
|
+
return (name) => lower[name.toLowerCase()];
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Resolve geo facets from Cloudflare / Vercel edge request headers.
|
|
88
|
+
*
|
|
89
|
+
* Reads `CF-IPCountry` and the `X-Vercel-IP-*` family. Accepts either a DOM
|
|
90
|
+
* `Headers` instance or a plain object (case-insensitive). Country defaults to
|
|
91
|
+
* `"unknown"` when no header is present.
|
|
92
|
+
*
|
|
93
|
+
* @param headers - Request headers as a `Headers` instance or a plain record.
|
|
94
|
+
* @returns Country (always present) plus optional region / city.
|
|
95
|
+
*/
|
|
96
|
+
export function geoFromHeaders(headers) {
|
|
97
|
+
const get = headerGetter(headers);
|
|
98
|
+
const country = get("CF-IPCountry") ?? get("X-Vercel-IP-Country") ?? "unknown";
|
|
99
|
+
const region = get("X-Vercel-IP-Country-Region");
|
|
100
|
+
const city = get("X-Vercel-IP-City");
|
|
101
|
+
const info = { country };
|
|
102
|
+
if (region !== undefined)
|
|
103
|
+
info.region = region;
|
|
104
|
+
if (city !== undefined)
|
|
105
|
+
info.city = city;
|
|
106
|
+
return info;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Build web `props` from a pageview (parsing UA + geo) and ingest a
|
|
110
|
+
* `"page_view"` event through the generic `AnalyticsClient`.
|
|
111
|
+
*
|
|
112
|
+
* Host-side convenience: the component never sees web concepts — this helper
|
|
113
|
+
* just assembles the `{@link webDimensions}`-shaped props and calls
|
|
114
|
+
* `client.track(ctx, "page_view", { props })`. Pair with
|
|
115
|
+
* `dimensions: webDimensions` on the client to get web rollups.
|
|
116
|
+
*
|
|
117
|
+
* @typeParam C - The `AnalyticsClient` (structural) type.
|
|
118
|
+
* @param client - An `AnalyticsClient` (or compatible) instance.
|
|
119
|
+
* @param ctx - The Convex mutation ctx to run `track` against.
|
|
120
|
+
* @param opts - Pageview fields; `path` is required.
|
|
121
|
+
* @returns The `track` result passed through from the client.
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* const analytics = new AnalyticsClient(components.analytics, { dimensions: webDimensions });
|
|
125
|
+
* await trackPageview(analytics, ctx, {
|
|
126
|
+
* path: "/pricing",
|
|
127
|
+
* ua: request.headers.get("user-agent") ?? undefined,
|
|
128
|
+
* headers: request.headers,
|
|
129
|
+
* });
|
|
130
|
+
* ```
|
|
131
|
+
*/
|
|
132
|
+
export async function trackPageview(client, ctx, opts) {
|
|
133
|
+
const ua = opts.ua !== undefined ? parseUserAgent(opts.ua) : undefined;
|
|
134
|
+
const geo = opts.headers !== undefined ? geoFromHeaders(opts.headers) : undefined;
|
|
135
|
+
const props = { path: opts.path };
|
|
136
|
+
if (opts.referrer !== undefined)
|
|
137
|
+
props["referrer"] = opts.referrer;
|
|
138
|
+
if (ua !== undefined) {
|
|
139
|
+
props["device"] = ua.device;
|
|
140
|
+
props["browser"] = ua.browser;
|
|
141
|
+
props["os"] = ua.os;
|
|
142
|
+
}
|
|
143
|
+
if (geo !== undefined) {
|
|
144
|
+
props["country"] = geo.country;
|
|
145
|
+
if (geo.region !== undefined)
|
|
146
|
+
props["region"] = geo.region;
|
|
147
|
+
if (geo.city !== undefined)
|
|
148
|
+
props["city"] = geo.city;
|
|
149
|
+
}
|
|
150
|
+
if (opts.utm?.source !== undefined)
|
|
151
|
+
props["utmSource"] = opts.utm.source;
|
|
152
|
+
if (opts.utm?.medium !== undefined)
|
|
153
|
+
props["utmMedium"] = opts.utm.medium;
|
|
154
|
+
if (opts.utm?.campaign !== undefined)
|
|
155
|
+
props["utmCampaign"] = opts.utm.campaign;
|
|
156
|
+
const trackOpts = { props };
|
|
157
|
+
if (opts.subjectRef !== undefined)
|
|
158
|
+
trackOpts.subjectRef = opts.subjectRef;
|
|
159
|
+
if (opts.sessionRef !== undefined)
|
|
160
|
+
trackOpts.sessionRef = opts.sessionRef;
|
|
161
|
+
if (opts.ts !== undefined)
|
|
162
|
+
trackOpts.ts = opts.ts;
|
|
163
|
+
if (opts.scope !== undefined)
|
|
164
|
+
trackOpts.scope = opts.scope;
|
|
165
|
+
if (opts.dedupeKey !== undefined)
|
|
166
|
+
trackOpts.dedupeKey = opts.dedupeKey;
|
|
167
|
+
return client.track(ctx, "page_view", trackOpts);
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=index.js.map
|
|
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AACnD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vllnt/convex-analytics",
|
|
3
|
+
"version": "0.1.0-canary.2b9f918",
|
|
4
|
+
"description": "Generic, configurable analytics component for Convex — any event, any dimension, any domain; rollup-on-write with funnels, retention, uniques",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"packageManager": "pnpm@9.15.0",
|
|
8
|
+
"main": "./dist/client/index.js",
|
|
9
|
+
"module": "./dist/client/index.js",
|
|
10
|
+
"types": "./dist/client/index.d.ts",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"exports": {
|
|
13
|
+
"./package.json": "./package.json",
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/client/index.d.ts",
|
|
16
|
+
"default": "./dist/client/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./test": "./src/test.ts",
|
|
19
|
+
"./web": {
|
|
20
|
+
"types": "./dist/web/index.d.ts",
|
|
21
|
+
"default": "./dist/web/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./react": {
|
|
24
|
+
"types": "./dist/react/index.d.ts",
|
|
25
|
+
"default": "./dist/react/index.js"
|
|
26
|
+
},
|
|
27
|
+
"./convex.config": {
|
|
28
|
+
"types": "./dist/component/convex.config.d.ts",
|
|
29
|
+
"default": "./dist/component/convex.config.js"
|
|
30
|
+
},
|
|
31
|
+
"./_generated/component.js": {
|
|
32
|
+
"types": "./dist/component/_generated/component.d.ts"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"src",
|
|
38
|
+
"README.md",
|
|
39
|
+
"LICENSE"
|
|
40
|
+
],
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "rm -rf dist && tsc && cp ../../README.md ../../LICENSE ./",
|
|
43
|
+
"test": "vitest run",
|
|
44
|
+
"test:watch": "vitest",
|
|
45
|
+
"test:coverage": "vitest run --coverage",
|
|
46
|
+
"typecheck": "tsc --noEmit",
|
|
47
|
+
"typecheck:ci": "tsc --noEmit",
|
|
48
|
+
"lint": "pnpm --dir ../.. check:agents && eslint src/",
|
|
49
|
+
"generate:llms": "node scripts/generate-llms.mjs",
|
|
50
|
+
"preversion": "pnpm install --frozen-lockfile && pnpm build && pnpm test:coverage && pnpm typecheck && pnpm generate:llms",
|
|
51
|
+
"codegen": "node scripts/codegen.mjs",
|
|
52
|
+
"build:codegen": "pnpm codegen && pnpm build"
|
|
53
|
+
},
|
|
54
|
+
"dependencies": {
|
|
55
|
+
"@convex-dev/aggregate": "^0.3.0",
|
|
56
|
+
"@convex-dev/rate-limiter": "^0.3.2",
|
|
57
|
+
"@convex-dev/sharded-counter": "^0.2.1",
|
|
58
|
+
"convex": "^1.45.0"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@edge-runtime/vm": "^5.0.0",
|
|
62
|
+
"@testing-library/react": "^16.3.3",
|
|
63
|
+
"@types/react": "^19.2.18",
|
|
64
|
+
"@typescript/native": "npm:typescript@7.0.2",
|
|
65
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
66
|
+
"@vllnt/eslint-config": "2.0.0",
|
|
67
|
+
"@vllnt/typescript": "2.0.0",
|
|
68
|
+
"convex-test": "^0.0.56",
|
|
69
|
+
"jsdom": "^29.1.1",
|
|
70
|
+
"react": "^19.2.8",
|
|
71
|
+
"react-dom": "^19.2.8",
|
|
72
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
73
|
+
"vite": "^8.2.2",
|
|
74
|
+
"vitest": "^4.1.11"
|
|
75
|
+
},
|
|
76
|
+
"peerDependencies": {
|
|
77
|
+
"convex": "^1.45.0",
|
|
78
|
+
"react": ">=18.0.0"
|
|
79
|
+
},
|
|
80
|
+
"peerDependenciesMeta": {
|
|
81
|
+
"convex": {
|
|
82
|
+
"optional": true
|
|
83
|
+
},
|
|
84
|
+
"react": {
|
|
85
|
+
"optional": true
|
|
86
|
+
}
|
|
87
|
+
},
|
|
88
|
+
"engines": {
|
|
89
|
+
"node": ">=18"
|
|
90
|
+
},
|
|
91
|
+
"publishConfig": {
|
|
92
|
+
"access": "public"
|
|
93
|
+
},
|
|
94
|
+
"author": {
|
|
95
|
+
"name": "bntvllnt",
|
|
96
|
+
"url": "https://bntvllnt.com"
|
|
97
|
+
},
|
|
98
|
+
"funding": {
|
|
99
|
+
"type": "github",
|
|
100
|
+
"url": "https://github.com/sponsors/bntvllnt"
|
|
101
|
+
},
|
|
102
|
+
"homepage": "https://github.com/vllnt/convex-analytics#readme",
|
|
103
|
+
"bugs": {
|
|
104
|
+
"url": "https://github.com/vllnt/convex-analytics/issues"
|
|
105
|
+
},
|
|
106
|
+
"repository": {
|
|
107
|
+
"type": "git",
|
|
108
|
+
"url": "https://github.com/vllnt/convex-analytics.git"
|
|
109
|
+
},
|
|
110
|
+
"keywords": [
|
|
111
|
+
"convex",
|
|
112
|
+
"convex-component",
|
|
113
|
+
"analytics",
|
|
114
|
+
"events",
|
|
115
|
+
"metrics",
|
|
116
|
+
"funnels",
|
|
117
|
+
"retention",
|
|
118
|
+
"rollup",
|
|
119
|
+
"vllnt"
|
|
120
|
+
]
|
|
121
|
+
}
|