@vllnt/analytics 0.2.0-canary.c351189 → 0.2.0-canary.d796133

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/docs/API.md ADDED
@@ -0,0 +1,490 @@
1
+ # @vllnt/analytics API
2
+
3
+ Reference for every public export of this package version, written from `src/index.ts` and
4
+ `src/react.tsx`. Those sources ship in this package under `src/`. Errors and their fixes are in the
5
+ README: [Errors and fixes](../README.md#errors-and-fixes).
6
+
7
+ The library has no transport. Events are queued and gated by consent, then dropped; with
8
+ `debug: true` they are written to `console.log`. Send them to your own backend yourself.
9
+
10
+ ## Entry points
11
+
12
+ Only these subpaths are exported (`package.json` `exports`). Each has ESM, CommonJS and type
13
+ declarations in `dist/`.
14
+
15
+ | Import | Contents |
16
+ | ------------------------------- | ------------------------------------------------------------------ |
17
+ | `@vllnt/analytics` | Tracking functions, consent functions and constants, types |
18
+ | `@vllnt/analytics/react` | `AnalyticsProvider`, `useAnalytics`, `useConsent`, `initAnalytics` |
19
+ | `@vllnt/analytics/package.json` | Package metadata |
20
+
21
+ Types are exported from `@vllnt/analytics` only. Within one module format, both entry points share
22
+ one analytics state, so `initAnalytics` from `./react` and `track` from `.` act on the same instance.
23
+ The ESM and CommonJS builds each have their own copy, so mixing `import` and `require` in one
24
+ process gives two instances.
25
+
26
+ Peer dependency: `react` `^18.0.0 || ^19.0.0` (used by `./react` only).
27
+
28
+ All browser APIs are guarded, so importing on the server is safe. On the server `track`,
29
+ `trackPage`, `identify` and `resetAnalytics` return early, `loadConsent` returns `null`, and
30
+ `isStorageAvailable` and `isDoNotTrackEnabled` return `false`. `getConsentFromCookie` only parses
31
+ the string it is given, so it is the consent reader to use on the server. `initAnalytics`,
32
+ `enableAnalytics` and `disableAnalytics` have no server guard: `initAnalytics` on the server
33
+ starts the process-wide instance, so call it only in the browser.
34
+
35
+ ## Tracking (`@vllnt/analytics`)
36
+
37
+ ### `initAnalytics`
38
+
39
+ Signature: `initAnalytics(config: AnalyticsConfig): void`
40
+
41
+ Starts the shared analytics instance and flushes queued events. Later calls do nothing while an
42
+ instance exists. It does not start, and blocks tracking, when Do Not Track is on (`"1"` or
43
+ `"yes"`) or stored consent has `analytics: false`; already queued events are then dropped, so
44
+ they are never flushed later. With no stored consent it starts, so call it only after the user
45
+ accepts if you need opt-in (`AnalyticsProvider` does this for you). Once tracking is blocked (by a
46
+ blocked init or by `disableAnalytics`), calling `initAnalytics` again does not unblock it; only
47
+ `enableAnalytics` does.
48
+
49
+ ```ts
50
+ import { initAnalytics } from "@vllnt/analytics";
51
+
52
+ initAnalytics({ app: "my-app", version: 1, debug: true });
53
+ ```
54
+
55
+ ### `track`
56
+
57
+ Signature: `track(name: string, properties?: Record<string, unknown>): void`
58
+
59
+ Records a custom event. Before `initAnalytics` the event is queued; while blocked it is dropped.
60
+ An empty or non-string `name` is ignored.
61
+
62
+ ```ts
63
+ import { track } from "@vllnt/analytics";
64
+
65
+ track("button_click", { id: "cta-hero" });
66
+ ```
67
+
68
+ ### `trackPage`
69
+
70
+ Signature: `trackPage(properties?: Record<string, unknown>): void`
71
+
72
+ Records a page view, queued before init like `track`.
73
+
74
+ ```ts
75
+ import { trackPage } from "@vllnt/analytics";
76
+
77
+ trackPage({ path: "/about" });
78
+ ```
79
+
80
+ ### `identify`
81
+
82
+ Signature: `identify(userId: string, traits?: Record<string, unknown>): void`
83
+
84
+ Stores a user id and traits on the started instance. Ignored before init, while blocked, or
85
+ when `userId` is empty or not a string. Not queued.
86
+
87
+ ```ts
88
+ import { identify } from "@vllnt/analytics";
89
+
90
+ identify("user-123", { plan: "pro" });
91
+ ```
92
+
93
+ ### `resetAnalytics`
94
+
95
+ Signature: `resetAnalytics(): void`
96
+
97
+ Clears the stored user id and traits (for logout). The instance stays started.
98
+
99
+ ```ts
100
+ import { resetAnalytics } from "@vllnt/analytics";
101
+
102
+ resetAnalytics();
103
+ ```
104
+
105
+ ### `enableAnalytics`
106
+
107
+ Signature: `enableAnalytics(config: AnalyticsConfig): void`
108
+
109
+ Unblocks, discards the current instance and runs `initAnalytics(config)` again. Does nothing
110
+ unless tracking is currently blocked, and does nothing while Do Not Track is on. Because it
111
+ re-reads stored consent, save the accepted consent first: a stored `analytics: false` blocks it
112
+ again. The new instance has no `userId` or `traits`.
113
+
114
+ ```ts
115
+ import { createAcceptAllConsent, enableAnalytics, saveConsent } from "@vllnt/analytics";
116
+
117
+ saveConsent(createAcceptAllConsent());
118
+ enableAnalytics({ app: "my-app" });
119
+ ```
120
+
121
+ ### `disableAnalytics`
122
+
123
+ Signature: `disableAnalytics(): void`
124
+
125
+ Blocks tracking and empties the queue after consent is revoked. It keeps the in-memory user id
126
+ and traits; call `resetAnalytics()` or reload the page to clear them.
127
+
128
+ ```ts
129
+ import { disableAnalytics, resetAnalytics } from "@vllnt/analytics";
130
+
131
+ disableAnalytics();
132
+ resetAnalytics();
133
+ ```
134
+
135
+ ### `isAnalyticsEnabled`
136
+
137
+ Signature: `isAnalyticsEnabled(): boolean`
138
+
139
+ `true` when the instance has started and is not blocked.
140
+
141
+ ```ts
142
+ import { isAnalyticsEnabled, track } from "@vllnt/analytics";
143
+
144
+ if (isAnalyticsEnabled()) track("export_clicked");
145
+ ```
146
+
147
+ ### `getAnalyticsState`
148
+
149
+ Signature: `getAnalyticsState(): { app: string; debug?: boolean; version?: number; userId?: string; traits?: Record<string, unknown> } | undefined`
150
+
151
+ Returns the current instance state for debugging, or `undefined` before init. The state type is
152
+ not exported.
153
+
154
+ ```ts
155
+ import { getAnalyticsState } from "@vllnt/analytics";
156
+
157
+ console.log(getAnalyticsState()?.userId);
158
+ ```
159
+
160
+ ### Tutorial helpers
161
+
162
+ Typed wrappers around `track` with fixed event names (`TutorialEventName`). Every helper
163
+ needs `tutorial_id`, `tutorial_title` and `locale`.
164
+
165
+ | Function | Event name | Extra required fields |
166
+ | ------------------------------------- | --------------------------- | ------------------------------- |
167
+ | `trackTutorialStart(properties)` | `tutorial_start` | none (`section_id` not allowed) |
168
+ | `trackSectionView(properties)` | `tutorial_section_view` | none |
169
+ | `trackSectionComplete(properties)` | `tutorial_section_complete` | none |
170
+ | `trackTutorialComplete(properties)` | `tutorial_complete` | none (`section_id` not allowed) |
171
+ | `trackTutorialNavigation(properties)` | `tutorial_navigation` | `navigation_type` |
172
+ | `trackTimeSpent(properties)` | `tutorial_time_spent` | `time_spent_seconds` |
173
+
174
+ ```ts
175
+ import { trackSectionView, trackTutorialNavigation } from "@vllnt/analytics";
176
+
177
+ const base = { tutorial_id: "intro", tutorial_title: "Intro", locale: "en" };
178
+ trackSectionView({ ...base, section_id: "setup", section_index: 0, total_sections: 5 });
179
+ trackTutorialNavigation({ ...base, section_id: "setup", navigation_type: "next" });
180
+ ```
181
+
182
+ ## Consent (`@vllnt/analytics`)
183
+
184
+ Consent is stored as JSON in `localStorage` under `CONSENT_STORAGE_KEY` and mirrored to the
185
+ `CONSENT_COOKIE_NAME` cookie (`1` allowed, `0` declined; one-year expiry, `path=/`,
186
+ `SameSite=Lax`) so the server can read it.
187
+
188
+ ### Constants
189
+
190
+ | Name | Value |
191
+ | --------------------- | --------------------------- |
192
+ | `CONSENT_VERSION` | `1` |
193
+ | `CONSENT_STORAGE_KEY` | `"vllnt:analytics-consent"` |
194
+ | `CONSENT_COOKIE_NAME` | `"vllnt-consent"` |
195
+
196
+ ### `loadConsent`
197
+
198
+ Signature: `loadConsent(): ConsentState | null`
199
+
200
+ Reads and validates stored consent. `null` when none, invalid, or storage is unavailable.
201
+
202
+ ```ts
203
+ import { loadConsent } from "@vllnt/analytics";
204
+
205
+ const consent = loadConsent();
206
+ console.log(consent?.analytics);
207
+ ```
208
+
209
+ ### `saveConsent`
210
+
211
+ Signature: `saveConsent(state: ConsentState): void`
212
+
213
+ Writes consent to `localStorage` and the cookie. Does nothing when storage is unavailable. Logs
214
+ `Failed to save consent:` with `console.warn` when the write throws.
215
+
216
+ ```ts
217
+ import { createAcceptAllConsent, saveConsent } from "@vllnt/analytics";
218
+
219
+ saveConsent(createAcceptAllConsent());
220
+ ```
221
+
222
+ ### `clearConsent`
223
+
224
+ Signature: `clearConsent(): void`
225
+
226
+ Removes stored consent and expires the cookie.
227
+
228
+ ```ts
229
+ import { clearConsent } from "@vllnt/analytics";
230
+
231
+ clearConsent();
232
+ ```
233
+
234
+ ### `createAcceptAllConsent`
235
+
236
+ Signature: `createAcceptAllConsent(): ConsentState`
237
+
238
+ New state with `analytics: true`, `functional: true`, the current time and `CONSENT_VERSION`. To
239
+ record another version, override it: `{ ...createAcceptAllConsent(), version: 2 }`.
240
+
241
+ ```ts
242
+ import { createAcceptAllConsent } from "@vllnt/analytics";
243
+
244
+ const accepted = createAcceptAllConsent();
245
+ console.log(accepted.version);
246
+ ```
247
+
248
+ ### `createDeclineAnalyticsConsent`
249
+
250
+ Signature: `createDeclineAnalyticsConsent(): ConsentState`
251
+
252
+ New state with `analytics: false`, `functional: true`, the current time and `CONSENT_VERSION`.
253
+
254
+ ```ts
255
+ import { createDeclineAnalyticsConsent } from "@vllnt/analytics";
256
+
257
+ const declined = createDeclineAnalyticsConsent();
258
+ console.log(declined.analytics);
259
+ ```
260
+
261
+ ### `updateConsentCategory`
262
+
263
+ Signature: `updateConsentCategory(current: ConsentState, category: ConsentCategory, value: boolean): ConsentState`
264
+
265
+ Returns a copy with one category changed and a new timestamp. Setting `functional` to `false`
266
+ returns `current` unchanged.
267
+
268
+ ```ts
269
+ import { loadConsent, saveConsent, updateConsentCategory } from "@vllnt/analytics";
270
+
271
+ const stored = loadConsent();
272
+ if (stored) saveConsent(updateConsentCategory(stored, "analytics", false));
273
+ ```
274
+
275
+ ### `needsRePrompt`
276
+
277
+ Signature: `needsRePrompt(consent: ConsentState, currentVersion: number): boolean`
278
+
279
+ `true` when `consent.version < currentVersion`.
280
+
281
+ ```ts
282
+ import { clearConsent, loadConsent, needsRePrompt } from "@vllnt/analytics";
283
+
284
+ const consent = loadConsent();
285
+ if (consent && needsRePrompt(consent, 2)) clearConsent();
286
+ ```
287
+
288
+ ### `getConsentFromCookie`
289
+
290
+ Signature: `getConsentFromCookie(cookieString: string): boolean | null`
291
+
292
+ Parses a `Cookie` header: `true` for `1`, `false` for any other value, `null` when the cookie is
293
+ absent or empty (`vllnt-consent=`). The name must start the string or follow `;`, so
294
+ `evil-vllnt-consent=1` does not match.
295
+
296
+ ```ts
297
+ import { getConsentFromCookie } from "@vllnt/analytics";
298
+
299
+ export function isAllowed(request: Request): boolean | null {
300
+ return getConsentFromCookie(request.headers.get("cookie") ?? "");
301
+ }
302
+ ```
303
+
304
+ ### `isDoNotTrackEnabled`
305
+
306
+ Signature: `isDoNotTrackEnabled(): boolean`
307
+
308
+ Reads `navigator.doNotTrack`, then `window.doNotTrack`, then `navigator.msDoNotTrack`, and
309
+ returns `true` when the first one that is set equals `"1"` or `"yes"`. `false` on the server.
310
+
311
+ ```ts
312
+ import { isDoNotTrackEnabled } from "@vllnt/analytics";
313
+
314
+ const showBanner = !isDoNotTrackEnabled();
315
+ console.log(showBanner);
316
+ ```
317
+
318
+ ### `isStorageAvailable`
319
+
320
+ Signature: `isStorageAvailable(): boolean`
321
+
322
+ `true` when `localStorage` can be written. `false` on the server or when storage throws.
323
+
324
+ ```ts
325
+ import { isStorageAvailable } from "@vllnt/analytics";
326
+
327
+ if (!isStorageAvailable()) console.warn("consent will not persist");
328
+ ```
329
+
330
+ ### `isValidConsentState`
331
+
332
+ Signature: `isValidConsentState(value: unknown): value is ConsentState`
333
+
334
+ Type guard: checks the four fields and their types.
335
+
336
+ ```ts
337
+ import { isValidConsentState, saveConsent } from "@vllnt/analytics";
338
+
339
+ const parsed: unknown = JSON.parse('{"analytics":true,"functional":true,"timestamp":"2026-01-01T00:00:00.000Z","version":1}');
340
+ if (isValidConsentState(parsed)) saveConsent(parsed);
341
+ ```
342
+
343
+ ## React (`@vllnt/analytics/react`)
344
+
345
+ Both builds of this entry (`dist/react.js` and `dist/react.cjs`) start with `"use client"`; the
346
+ core entry does not.
347
+
348
+ Both `AnalyticsProvider` and `useConsent` read stored consent during the first render. On the
349
+ server that read returns `null`, so `consent` is `null` and `hasResponded` is `false` there, while
350
+ the first browser render may already see stored consent. If you render a banner from
351
+ `hasResponded`, render it only after the component has mounted to avoid a hydration mismatch.
352
+
353
+ ### `AnalyticsProvider`
354
+
355
+ Signature: `AnalyticsProvider(props: { children: ReactNode; config: AnalyticsConfig; consentVersion?: number }): React.JSX.Element`
356
+
357
+ `consentVersion` defaults to `CONSENT_VERSION`. The provider reads stored consent, clears it when
358
+ `needsRePrompt(stored, consentVersion)`, calls `initAnalytics(config)` while consent has
359
+ `analytics: true`, and calls `disableAnalytics()` while it has `analytics: false`, so after a
360
+ stored decline `track()` calls are dropped, not queued. `acceptAll` and `declineAnalytics` save
361
+ consent with `consentVersion`; `updateConsent` copies the current consent, so it keeps the stored
362
+ version. The actions call `enableAnalytics` or `disableAnalytics`. Before the user responds (no
363
+ stored consent), events are queued in memory and flushed if the user accepts; after
364
+ `resetConsent()`, tracking is blocked and events are dropped until the user responds again. Pass a stable
365
+ `config` (for example a module constant), because the init effect depends on it.
366
+
367
+ ```tsx
368
+ import type { ReactNode } from "react";
369
+ import { AnalyticsProvider } from "@vllnt/analytics/react";
370
+
371
+ const config = { app: "my-app", version: 1 };
372
+
373
+ export function Root({ children }: { children: ReactNode }) {
374
+ return <AnalyticsProvider config={config}>{children}</AnalyticsProvider>;
375
+ }
376
+ ```
377
+
378
+ ### `useAnalytics`
379
+
380
+ Signature: `useAnalytics(): UseConsentReturn & { config: AnalyticsConfig }`
381
+
382
+ Returns the provider context; throws `useAnalytics must be used within an AnalyticsProvider`
383
+ outside one. Fields: `config`, `consent`, `hasResponded`, `isLoading` (always `false`),
384
+ `acceptAll()`, `declineAnalytics()`, `updateConsent(category, value)`, `resetConsent()`.
385
+ `updateConsent` does nothing while `consent` is `null` (before the user has responded).
386
+
387
+ ```tsx
388
+ import { useEffect, useState } from "react";
389
+ import { useAnalytics } from "@vllnt/analytics/react";
390
+
391
+ export function CookieBanner() {
392
+ const { hasResponded, acceptAll, declineAnalytics } = useAnalytics();
393
+ const [mounted, setMounted] = useState(false);
394
+ useEffect(() => setMounted(true), []);
395
+ if (!mounted || hasResponded) return null;
396
+ return (
397
+ <div>
398
+ <button onClick={acceptAll}>Accept</button>
399
+ <button onClick={declineAnalytics}>Decline</button>
400
+ </div>
401
+ );
402
+ }
403
+ ```
404
+
405
+ ### `useConsent`
406
+
407
+ Signature: `useConsent(options?: UseConsentOptions): UseConsentReturn`
408
+
409
+ Standalone consent state with the same fields as `useAnalytics()` except `config`. It reads and
410
+ writes stored consent only: it does not start or stop analytics and does not share state with
411
+ `AnalyticsProvider`. Inside a provider, use `useAnalytics()` for a banner so accepting starts
412
+ tracking.
413
+
414
+ ```tsx
415
+ import { useConsent } from "@vllnt/analytics/react";
416
+
417
+ export function ConsentStatus() {
418
+ const { consent, updateConsent } = useConsent({ consentVersion: 1 });
419
+ return (
420
+ <button onClick={() => updateConsent("analytics", !consent?.analytics)}>
421
+ Analytics: {consent?.analytics ? "on" : "off"}
422
+ </button>
423
+ );
424
+ }
425
+ ```
426
+
427
+ ### `initAnalytics` (re-export)
428
+
429
+ Re-export of the core [`initAnalytics`](#initanalytics), for apps that only import from `./react`.
430
+
431
+ ### Consent versions
432
+
433
+ In `AnalyticsProvider` and `useConsent`, `acceptAll` and `declineAnalytics` save the choice with
434
+ `consentVersion`. `updateConsent` copies the current consent, so it keeps the stored version. Raising
435
+ `consentVersion` asks every visitor once more; the new choice is then kept on later visits.
436
+
437
+ ## Types
438
+
439
+ Exported from `@vllnt/analytics` as types only.
440
+
441
+ ```ts
442
+ type AnalyticsConfig = { app: string; debug?: boolean; version?: number };
443
+
444
+ type AnalyticsEvent = {
445
+ name: string;
446
+ properties?: Record<string, unknown>;
447
+ timestamp?: string;
448
+ };
449
+
450
+ type ConsentCategory = "analytics" | "functional";
451
+
452
+ type ConsentState = {
453
+ analytics: boolean;
454
+ functional: boolean;
455
+ timestamp: string; // ISO time of the choice
456
+ version: number;
457
+ };
458
+
459
+ type TutorialEventName =
460
+ | "tutorial_complete"
461
+ | "tutorial_navigation"
462
+ | "tutorial_section_complete"
463
+ | "tutorial_section_view"
464
+ | "tutorial_start"
465
+ | "tutorial_time_spent";
466
+
467
+ type TutorialEventProperties = {
468
+ tutorial_id: string;
469
+ tutorial_title: string;
470
+ locale: string;
471
+ completion_percent?: number; // 0-100
472
+ navigation_type?: "keyboard" | "next" | "prev" | "toc";
473
+ section_id?: string;
474
+ section_index?: number; // 0-based
475
+ time_spent_seconds?: number;
476
+ total_sections?: number;
477
+ };
478
+
479
+ type UseConsentOptions = { consentVersion?: number };
480
+
481
+ type UseConsentReturn = {
482
+ acceptAll: () => void;
483
+ consent: ConsentState | null;
484
+ declineAnalytics: () => void;
485
+ hasResponded: boolean;
486
+ isLoading: boolean;
487
+ resetConsent: () => void;
488
+ updateConsent: (category: ConsentCategory, value: boolean) => void;
489
+ };
490
+ ```
package/llms.txt ADDED
@@ -0,0 +1,74 @@
1
+ # @vllnt/analytics
2
+
3
+ > Cookie consent state and consent-gated event tracking for React and TypeScript, with Do Not Track and an SSR consent cookie.
4
+
5
+ Facts for AI tools. The library has no transport: it queues and gates events, and only
6
+ `console.log`s them when `debug: true`. Events never leave the page.
7
+
8
+ ## For coding agents
9
+
10
+ The docs are bundled in the package at `node_modules/@vllnt/analytics/docs/`, with this file,
11
+ `CHANGELOG.md` and the TypeScript sources in `src/`. They match the installed version. Read them
12
+ before writing code.
13
+
14
+ ## When to use
15
+
16
+ - Use it when a React app needs cookie-banner state stored in `localStorage` and a cookie.
17
+ - Use it when tracking calls must wait for consent and stop on Do Not Track or a decline.
18
+ - Use it when server code must read the visitor's choice from the `Cookie` header.
19
+ - Do not use it when events must reach a backend: it sends nothing; use your analytics vendor's SDK.
20
+ - Do not use it for a server-side consent record: use `@vllnt/convex-consent`.
21
+
22
+ ## Package
23
+
24
+ - npm: `@vllnt/analytics` (MIT), repo: https://github.com/vllnt/analytics
25
+ - Unreleased builds from `main` use the `canary` dist-tag
26
+ - Ships ESM, CommonJS and type declarations from `dist` (built with tsup); both builds of
27
+ `./react` start with `"use client"`
28
+ - Entry points: `@vllnt/analytics` (core + consent + types), `@vllnt/analytics/react` (`AnalyticsProvider`, `useAnalytics`, `useConsent`, `initAnalytics`)
29
+ - Peer dependency: React `^18.0.0 || ^19.0.0`
30
+ - Install: `pnpm add @vllnt/analytics`
31
+
32
+ ## Behaviour
33
+
34
+ - Events tracked before `initAnalytics()` are queued and flushed on the first unblocked init;
35
+ a blocked init drops them. The queue has no size limit.
36
+ - `initAnalytics()` blocks tracking when Do Not Track is on (`"1"` or `"yes"`) or stored consent
37
+ has `analytics: false`. With no stored consent it starts tracking. `AnalyticsProvider` calls it
38
+ while consent has `analytics: true` and calls `disableAnalytics()` after a stored decline, so a
39
+ declined visitor's events are dropped. Before the user responds, events are queued in memory,
40
+ except after `resetConsent()`, which blocks and drops events until the user responds again.
41
+ - Once blocked, only `enableAnalytics(config)` unblocks; it re-reads stored consent.
42
+ - Consent is stored in `localStorage` (`vllnt:analytics-consent`) and a `vllnt-consent` cookie
43
+ (`1` or `0`) for SSR; `getConsentFromCookie(cookieString)` reads it with an anchored match.
44
+ - Consent is versioned; a stored version below the hook's `consentVersion` (default
45
+ `CONSENT_VERSION`) re-prompts once, and the hooks save the new choice with that version.
46
+ - `track()` ignores empty or non-string names; `identify()` ignores empty or non-string ids.
47
+ - Browser APIs are guarded, so server-side import is safe. `initAnalytics()` has no server
48
+ guard and starts the process-wide instance there, so call it only in the browser.
49
+ - The only thrown error is `useAnalytics must be used within an AnalyticsProvider`; there are no
50
+ error codes.
51
+
52
+ ## Docs
53
+
54
+ - [API reference](./docs/API.md): every public export, signatures, examples, entry points
55
+ - [Errors and fixes](./README.md#errors-and-fixes): every message the package throws or logs
56
+ - [Limits and gotchas](./README.md#limits-and-gotchas): defaults and calls that do nothing
57
+ - [README](./README.md): usage, common tasks, compatibility
58
+ - [Changelog](./CHANGELOG.md): release history
59
+ - [Core exports](./src/index.ts) and [React exports](./src/react.tsx): source of the public API
60
+
61
+ ## Optional
62
+
63
+ - [Contributing](https://github.com/vllnt/analytics/blob/main/CONTRIBUTING.md): setup, checks, release flow
64
+ - [Security policy](https://github.com/vllnt/analytics/blob/main/SECURITY.md): private vulnerability reporting
65
+ - [AGENTS.md](https://github.com/vllnt/analytics/blob/main/AGENTS.md): instructions for contributing agents
66
+
67
+ ## Ecosystem
68
+
69
+ - [Package page](https://oss.vllnt.com/packages/analytics)
70
+ - [Release feed](https://oss.vllnt.com/packages/analytics/rss.xml)
71
+ - [All @vllnt packages](https://oss.vllnt.com/llms.txt)
72
+ - [Search vllnt packages and docs](https://index.vllnt.com)
73
+ - [vllnt](https://vllnt.com/llms.txt)
74
+ - [Author](https://bntvllnt.com)
package/package.json CHANGED
@@ -1,25 +1,47 @@
1
1
  {
2
2
  "name": "@vllnt/analytics",
3
- "version": "0.2.0-canary.c351189",
4
- "description": "Lightweight, privacy-first analytics with consent management and React integration",
3
+ "version": "0.2.0-canary.d796133",
4
+ "description": "Cookie consent state and consent-gated event tracking for React and TypeScript, with Do Not Track and an SSR consent cookie.",
5
5
  "type": "module",
6
- "packageManager": "pnpm@10.34.8",
6
+ "packageManager": "pnpm@12.22.0",
7
7
  "license": "MIT",
8
+ "author": {
9
+ "name": "bntvllnt",
10
+ "url": "https://bntvllnt.com"
11
+ },
12
+ "funding": {
13
+ "type": "github",
14
+ "url": "https://github.com/sponsors/bntvllnt"
15
+ },
8
16
  "repository": {
9
17
  "type": "git",
10
18
  "url": "git+https://github.com/vllnt/analytics.git"
11
19
  },
20
+ "homepage": "https://oss.vllnt.com/packages/analytics",
21
+ "bugs": {
22
+ "url": "https://github.com/vllnt/analytics/issues"
23
+ },
12
24
  "keywords": [
13
25
  "analytics",
14
- "consent",
15
- "privacy",
26
+ "event-tracking",
27
+ "cookie-consent",
28
+ "consent-management",
16
29
  "gdpr",
30
+ "do-not-track",
31
+ "privacy",
17
32
  "react",
18
- "do-not-track"
33
+ "react-hooks",
34
+ "ssr",
35
+ "typescript"
19
36
  ],
20
37
  "sideEffects": false,
21
38
  "files": [
22
- "dist"
39
+ "dist",
40
+ "src",
41
+ "!src/__tests__",
42
+ "docs/API.md",
43
+ "CHANGELOG.md",
44
+ "llms.txt"
23
45
  ],
24
46
  "main": "./dist/index.cjs",
25
47
  "module": "./dist/index.js",
@@ -62,31 +84,18 @@
62
84
  "react": "^18.0.0 || ^19.0.0"
63
85
  },
64
86
  "devDependencies": {
65
- "@testing-library/jest-dom": "^7.0.1",
87
+ "@testing-library/jest-dom": "^8.0.0",
66
88
  "@testing-library/react": "^16.3.3",
67
89
  "@types/node": "^24.19.2",
68
90
  "@types/react": "^19.3.0",
69
- "@vitest/coverage-v8": "^5.1.0",
91
+ "@vitest/coverage-v8": "^5.1.1",
70
92
  "@vllnt/eslint-config": "^2.1.0",
71
- "@vllnt/typescript": "^2.0.0",
93
+ "@vllnt/typescript": "^3.0.0",
72
94
  "eslint": "^9.39.5",
73
- "jsdom": "^30.1.3",
95
+ "jsdom": "^31.0.1",
74
96
  "react": "^19.3.1",
75
97
  "tsup": "^9.0.0",
76
98
  "typescript": "^6.0.3",
77
- "vitest": "^5.1.0"
78
- },
79
- "pnpm": {
80
- "minimumReleaseAge": 10080,
81
- "minimumReleaseAgeExclude": [
82
- "@vllnt/*"
83
- ],
84
- "overrides": {
85
- "deepmerge-ts@<8.0.0": "8.0.0",
86
- "handlebars@<4.7.10": "4.7.10"
87
- },
88
- "ignoredBuiltDependencies": [
89
- "esbuild"
90
- ]
99
+ "vitest": "^5.1.1"
91
100
  }
92
101
  }