@easy-cookie/posthog 0.0.0-stage → 0.1.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 easy-cookie contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,108 @@
1
- # Temporary Holding Version
1
+ # @easy-cookie/posthog
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Keeps [PostHog](https://posthog.com) in sync with easy-cookie consent, with no page reload. It follows the pattern MythicVoices uses in production:
4
+
5
+ - **Before a choice:** PostHog captures nothing.
6
+ - **After a rejection:** cookieless mode only. PostHog sets no cookies and no storage, and creates no person profiles. Autocapture, exceptions, web vitals and heatmaps are dropped.
7
+ - **After an acceptance:** normal capture with cookies, then `identify()` for logged-in users.
8
+
9
+ `posthog-js` is an optional peer dependency. The adapter types PostHog loosely, so any compatible client works.
10
+
11
+ ## Requirements
12
+
13
+ - **posthog-js** with `cookieless_mode` support (≥ 1.200).
14
+ - **Cookieless server hash mode** enabled in the PostHog project settings. Without it, cookieless events are discarded.
15
+ - PostHog **must be initialised with `cookieless_mode: 'on_reject'`**. `posthogInitOptions()` does this for you.
16
+
17
+ ## Install
18
+
19
+ ```sh
20
+ pnpm add @easy-cookie/posthog posthog-js
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ```ts
26
+ import posthog from 'posthog-js';
27
+ import easyCookie from '@easy-cookie/core';
28
+ import { connectPostHog, posthogInitOptions } from '@easy-cookie/posthog';
29
+
30
+ posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
31
+ ...posthogInitOptions({ api: easyCookie }), // cookieless_mode: 'on_reject', persistence, person_profiles, before_send
32
+ api_host: 'https://eu.i.posthog.com',
33
+ });
34
+
35
+ const disconnect = connectPostHog(posthog, easyCookie, {
36
+ category: 'measurement', // default
37
+ identify: () => session?.user?.id, // optional, called after opt-in only
38
+ });
39
+ ```
40
+
41
+ With React, connect it in an effect inside the provider:
42
+
43
+ ```tsx
44
+ 'use client';
45
+ import { useEffect } from 'react';
46
+ import posthog from 'posthog-js';
47
+ import { useEasyCookie } from '@easy-cookie/react';
48
+ import { connectPostHog } from '@easy-cookie/posthog';
49
+
50
+ export function PostHogConsent({ userId }: { userId?: string }) {
51
+ const { api } = useEasyCookie();
52
+ useEffect(() => (api ? connectPostHog(posthog, api, { identify: () => userId }) : undefined), [api, userId]);
53
+ return null;
54
+ }
55
+ ```
56
+
57
+ ## API
58
+
59
+ ### `connectPostHog(posthog, api, { category?, service?, identify? })`
60
+
61
+ The adapter listens to `replay`, `consent` and `change`, and applies the current state immediately, in case the stored choice was replayed before you connected.
62
+
63
+ - **Granted:** it calls `posthog.opt_in_capturing()`, skipped when already opted in. It then calls `posthog.identify(id)` when `identify()` returns an id that differs from the current one.
64
+ - **Not granted (a choice exists):** it calls `posthog.opt_out_capturing()`. With `on_reject`, PostHog keeps counting anonymously without cookies.
65
+ - **No choice yet:** it does nothing.
66
+
67
+ It returns an unsubscribe function. Use `service: 'posthog'` to follow the service toggle instead of the category.
68
+
69
+ ### `posthogInitOptions(opts?)`
70
+
71
+ Returns the recommended init options:
72
+
73
+ ```ts
74
+ {
75
+ cookieless_mode: 'on_reject',
76
+ persistence: 'localStorage+cookie', // used only after opt-in
77
+ person_profiles: 'identified_only',
78
+ before_send: consentBeforeSend(opts),
79
+ }
80
+ ```
81
+
82
+ ### `consentBeforeSend({ category?, api?, isGranted?, drop? })`
83
+
84
+ A `before_send` filter. Without consent it drops `$autocapture`, `$rageclick`, `$dead_click`, `$exception`, `$web_vitals` and `$$heatmap` (the list is `NON_ESSENTIAL_EVENTS`, and you can override it with `drop`). Pageviews and your own events are kept.
85
+
86
+ The consent check works like this:
87
+
88
+ 1. `isGranted`, when you pass it.
89
+ 2. Otherwise the runtime, when you pass `api`.
90
+ 3. Otherwise the state published by the head snippet (`window.__easyCookieHead`). That state is available before the runtime loads.
91
+
92
+ ## License
93
+
94
+ MIT
95
+
96
+ ## Options
97
+
98
+ `connectPostHog(posthog, api, options)`:
99
+
100
+ | Option | Default | Effect |
101
+ |---|---|---|
102
+ | `category` | `measurement` | Category that allows PostHog cookies and profiles |
103
+ | `service` | — | Decide on this service's consent instead of the category |
104
+ | `identify` | — | Returns the logged-in user id; called after opt-in |
105
+ | `beforeChoice` | `'pending'` | `'pending'`: capture nothing until the visitor chooses (a stale stored opt-in is cleared). `'cookieless'`: count visits without cookies before the choice, as after a rejection. Use it only when your privacy policy covers cookieless measurement without consent. |
106
+ | `sessionReplay` | `false` | Start session recording on opt-in and stop it on opt-out |
107
+
108
+ Opt-in does not send a `$opt_in` event: easy-cookie already records the consent.
package/dist/index.cjs ADDED
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var src_exports = {};
22
+ __export(src_exports, {
23
+ NON_ESSENTIAL_EVENTS: () => NON_ESSENTIAL_EVENTS,
24
+ connectPostHog: () => connectPostHog,
25
+ consentBeforeSend: () => consentBeforeSend,
26
+ posthogInitOptions: () => posthogInitOptions
27
+ });
28
+ module.exports = __toCommonJS(src_exports);
29
+ function connectPostHog(posthog, api, options = {}) {
30
+ const category = options.category ?? "measurement";
31
+ const granted = () => options.service ? api.isServiceGranted(options.service) : api.isGranted(category);
32
+ let last = null;
33
+ const apply = () => {
34
+ if (!api.get()) {
35
+ if (options.beforeChoice === "cookieless") {
36
+ if (last !== "out") {
37
+ if (!posthog.has_opted_out_capturing?.()) posthog.opt_out_capturing();
38
+ last = "out";
39
+ }
40
+ } else if (posthog.has_opted_in_capturing?.()) {
41
+ posthog.clear_opt_in_out_capturing?.();
42
+ }
43
+ return;
44
+ }
45
+ if (granted()) {
46
+ if (last !== "in") {
47
+ if (!posthog.has_opted_in_capturing?.()) posthog.opt_in_capturing({ captureEventName: false });
48
+ if (options.sessionReplay) posthog.startSessionRecording?.();
49
+ last = "in";
50
+ }
51
+ const id = options.identify?.();
52
+ if (id && posthog.identify && posthog.get_distinct_id?.() !== id) posthog.identify(id);
53
+ } else if (last !== "out") {
54
+ if (options.sessionReplay) posthog.stopSessionRecording?.();
55
+ if (!posthog.has_opted_out_capturing?.()) posthog.opt_out_capturing();
56
+ last = "out";
57
+ }
58
+ };
59
+ const events = ["replay", "consent", "change"];
60
+ const unsubs = events.map((ev) => api.on(ev, apply));
61
+ apply();
62
+ return () => unsubs.forEach((u) => u());
63
+ }
64
+ var NON_ESSENTIAL_EVENTS = [
65
+ "$autocapture",
66
+ "$rageclick",
67
+ "$dead_click",
68
+ "$exception",
69
+ "$web_vitals",
70
+ "$$heatmap",
71
+ "$heatmap"
72
+ ];
73
+ function headGranted(category) {
74
+ const head = globalThis.__easyCookieHead;
75
+ return !!head?.valid && !!head.granted?.includes(category);
76
+ }
77
+ function consentBeforeSend(options = {}) {
78
+ const category = options.category ?? "measurement";
79
+ const drop = new Set(options.drop ?? NON_ESSENTIAL_EVENTS);
80
+ const isGranted = options.isGranted ?? (() => options.api ? options.api.isGranted(category) : headGranted(category));
81
+ return (event) => {
82
+ if (!event) return event;
83
+ if (drop.has(event.event) && !isGranted()) return null;
84
+ return event;
85
+ };
86
+ }
87
+ function posthogInitOptions(options = {}) {
88
+ return {
89
+ cookieless_mode: "on_reject",
90
+ persistence: "localStorage+cookie",
91
+ person_profiles: "identified_only",
92
+ before_send: consentBeforeSend(options)
93
+ };
94
+ }
95
+ // Annotate the CommonJS export names for ESM import in node:
96
+ 0 && (module.exports = {
97
+ NON_ESSENTIAL_EVENTS,
98
+ connectPostHog,
99
+ consentBeforeSend,
100
+ posthogInitOptions
101
+ });
102
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { EasyCookieApi, EasyCookieEvent } from '@easy-cookie/core/shared';\n\n/**\n * The few posthog-js methods the adapter uses. Typed loosely on purpose, so\n * `posthog-js` stays an optional peer dependency and any compatible client works.\n */\nexport interface PostHogLike {\n opt_in_capturing(options?: { captureEventName?: string | null | false; [key: string]: unknown }): void;\n opt_out_capturing(): void;\n has_opted_in_capturing?(): boolean;\n has_opted_out_capturing?(): boolean;\n clear_opt_in_out_capturing?(): void;\n startSessionRecording?(...args: unknown[]): void;\n stopSessionRecording?(): void;\n identify?(distinctId?: string, ...rest: unknown[]): void;\n get_distinct_id?(): string;\n}\n\n/** Minimal shape of a PostHog event passed to `before_send`. */\nexport interface PostHogEventLike {\n event: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- matches posthog-js `Properties`\n properties?: Record<string, any>;\n}\n\nexport interface ConnectPostHogOptions {\n /** Category that allows PostHog cookies/profiles. Default `measurement`. */\n category?: string;\n /** Service id: when set, the service's own consent decides instead of the category. */\n service?: string;\n /**\n * Return the logged-in user id (or undefined). Called after opt-in, so the\n * identified person profile is created only with consent.\n */\n identify?: () => string | undefined | null;\n /**\n * Before the visitor's first choice:\n * - `'pending'` (default): capture nothing. A stale opt-in left in storage by an\n * earlier setup is cleared, so nothing is captured with cookies.\n * - `'cookieless'`: count visits without cookies (same as after a rejection).\n * Only if your privacy policy covers cookieless measurement without consent.\n */\n beforeChoice?: 'pending' | 'cookieless';\n /** Start session recording on opt-in and stop it on opt-out. Default false. */\n sessionReplay?: boolean;\n}\n\n/**\n * Keep PostHog's capture state in sync with the visitor's consent, without reloads.\n *\n * PostHog must be initialised by the host with `cookieless_mode: 'on_reject'`\n * (see {@link posthogInitOptions}): before a choice it captures nothing, after a\n * rejection it keeps counting anonymously with no cookies or storage, and after\n * an acceptance it switches to normal cookie-based capture.\n *\n * On `replay`, `consent` and `change` the adapter calls `opt_in_capturing()` or\n * `opt_out_capturing()`. Returns an unsubscribe function.\n */\nexport function connectPostHog(posthog: PostHogLike, api: EasyCookieApi, options: ConnectPostHogOptions = {}): () => void {\n const category = options.category ?? 'measurement';\n const granted = () => (options.service ? api.isServiceGranted(options.service) : api.isGranted(category));\n let last: 'in' | 'out' | null = null;\n\n const apply = () => {\n if (!api.get()) {\n if (options.beforeChoice === 'cookieless') {\n if (last !== 'out') {\n if (!posthog.has_opted_out_capturing?.()) posthog.opt_out_capturing();\n last = 'out';\n }\n } else if (posthog.has_opted_in_capturing?.()) {\n // Pending: an opt-in stored by a previous banner must not keep capturing.\n posthog.clear_opt_in_out_capturing?.();\n }\n return;\n }\n if (granted()) {\n if (last !== 'in') {\n // No `$opt_in` event: the consent itself is recorded by easy-cookie.\n if (!posthog.has_opted_in_capturing?.()) posthog.opt_in_capturing({ captureEventName: false });\n if (options.sessionReplay) posthog.startSessionRecording?.();\n last = 'in';\n }\n const id = options.identify?.();\n if (id && posthog.identify && posthog.get_distinct_id?.() !== id) posthog.identify(id);\n } else if (last !== 'out') {\n if (options.sessionReplay) posthog.stopSessionRecording?.();\n if (!posthog.has_opted_out_capturing?.()) posthog.opt_out_capturing();\n last = 'out';\n }\n };\n\n const events: EasyCookieEvent[] = ['replay', 'consent', 'change'];\n const unsubs = events.map((ev) => api.on(ev, apply));\n // The stored choice may have been replayed before we subscribed.\n apply();\n return () => unsubs.forEach((u) => u());\n}\n\n/** Events dropped by {@link consentBeforeSend} while consent is missing. */\nexport const NON_ESSENTIAL_EVENTS: readonly string[] = [\n '$autocapture',\n '$rageclick',\n '$dead_click',\n '$exception',\n '$web_vitals',\n '$$heatmap',\n '$heatmap',\n];\n\nexport interface ConsentBeforeSendOptions {\n /** Category checked by the default `isGranted`. Default `measurement`. */\n category?: string;\n /**\n * Consent check. Defaults to the runtime when `api` is given, otherwise to the\n * state published by the head script (`window.__easyCookieHead.granted`).\n */\n isGranted?: () => boolean;\n api?: Pick<EasyCookieApi, 'isGranted'> | null;\n /** Event names to drop without consent. Default {@link NON_ESSENTIAL_EVENTS}. */\n drop?: readonly string[];\n}\n\nfunction headGranted(category: string): boolean {\n const head = (globalThis as { __easyCookieHead?: { granted?: string[]; valid?: boolean } }).__easyCookieHead;\n return !!head?.valid && !!head.granted?.includes(category);\n}\n\n/**\n * `before_send` filter: without consent, drop autocapture, exceptions, web vitals\n * and heatmap events, so cookieless mode only sends the essentials (pageviews,\n * explicit captures). Pass it as `before_send` or use {@link posthogInitOptions}.\n */\nexport function consentBeforeSend(options: ConsentBeforeSendOptions = {}) {\n const category = options.category ?? 'measurement';\n const drop = new Set(options.drop ?? NON_ESSENTIAL_EVENTS);\n const isGranted =\n options.isGranted ?? (() => (options.api ? options.api.isGranted(category) : headGranted(category)));\n return <T extends PostHogEventLike | null>(event: T): T | null => {\n if (!event) return event;\n if (drop.has(event.event) && !isGranted()) return null;\n return event;\n };\n}\n\nexport interface PostHogInitOptions {\n cookieless_mode: 'on_reject';\n persistence: 'localStorage+cookie';\n person_profiles: 'identified_only';\n before_send: ReturnType<typeof consentBeforeSend>;\n [key: string]: unknown;\n}\n\n/**\n * Recommended `posthog.init()` options for easy-cookie:\n * - `cookieless_mode: 'on_reject'` (requires \"Cookieless server hash mode\" enabled\n * in the PostHog project settings);\n * - `persistence: 'localStorage+cookie'` (only used after opt-in);\n * - `person_profiles: 'identified_only'`;\n * - a consent-aware `before_send` filter.\n *\n * Spread your own options after it: `posthog.init(key, { ...posthogInitOptions(), api_host })`.\n */\nexport function posthogInitOptions(options: ConsentBeforeSendOptions = {}): PostHogInitOptions {\n return {\n cookieless_mode: 'on_reject',\n persistence: 'localStorage+cookie',\n person_profiles: 'identified_only',\n before_send: consentBeforeSend(options),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0DO,SAAS,eAAe,SAAsB,KAAoB,UAAiC,CAAC,GAAe;AACxH,QAAM,WAAW,QAAQ,YAAY;AACrC,QAAM,UAAU,MAAO,QAAQ,UAAU,IAAI,iBAAiB,QAAQ,OAAO,IAAI,IAAI,UAAU,QAAQ;AACvG,MAAI,OAA4B;AAEhC,QAAM,QAAQ,MAAM;AAClB,QAAI,CAAC,IAAI,IAAI,GAAG;AACd,UAAI,QAAQ,iBAAiB,cAAc;AACzC,YAAI,SAAS,OAAO;AAClB,cAAI,CAAC,QAAQ,0BAA0B,EAAG,SAAQ,kBAAkB;AACpE,iBAAO;AAAA,QACT;AAAA,MACF,WAAW,QAAQ,yBAAyB,GAAG;AAE7C,gBAAQ,6BAA6B;AAAA,MACvC;AACA;AAAA,IACF;AACA,QAAI,QAAQ,GAAG;AACb,UAAI,SAAS,MAAM;AAEjB,YAAI,CAAC,QAAQ,yBAAyB,EAAG,SAAQ,iBAAiB,EAAE,kBAAkB,MAAM,CAAC;AAC7F,YAAI,QAAQ,cAAe,SAAQ,wBAAwB;AAC3D,eAAO;AAAA,MACT;AACA,YAAM,KAAK,QAAQ,WAAW;AAC9B,UAAI,MAAM,QAAQ,YAAY,QAAQ,kBAAkB,MAAM,GAAI,SAAQ,SAAS,EAAE;AAAA,IACvF,WAAW,SAAS,OAAO;AACzB,UAAI,QAAQ,cAAe,SAAQ,uBAAuB;AAC1D,UAAI,CAAC,QAAQ,0BAA0B,EAAG,SAAQ,kBAAkB;AACpE,aAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,SAA4B,CAAC,UAAU,WAAW,QAAQ;AAChE,QAAM,SAAS,OAAO,IAAI,CAAC,OAAO,IAAI,GAAG,IAAI,KAAK,CAAC;AAEnD,QAAM;AACN,SAAO,MAAM,OAAO,QAAQ,CAAC,MAAM,EAAE,CAAC;AACxC;AAGO,IAAM,uBAA0C;AAAA,EACrD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAeA,SAAS,YAAY,UAA2B;AAC9C,QAAM,OAAQ,WAA8E;AAC5F,SAAO,CAAC,CAAC,MAAM,SAAS,CAAC,CAAC,KAAK,SAAS,SAAS,QAAQ;AAC3D;AAOO,SAAS,kBAAkB,UAAoC,CAAC,GAAG;AACxE,QAAM,WAAW,QAAQ,YAAY;AACrC,QAAM,OAAO,IAAI,IAAI,QAAQ,QAAQ,oBAAoB;AACzD,QAAM,YACJ,QAAQ,cAAc,MAAO,QAAQ,MAAM,QAAQ,IAAI,UAAU,QAAQ,IAAI,YAAY,QAAQ;AACnG,SAAO,CAAoC,UAAuB;AAChE,QAAI,CAAC,MAAO,QAAO;AACnB,QAAI,KAAK,IAAI,MAAM,KAAK,KAAK,CAAC,UAAU,EAAG,QAAO;AAClD,WAAO;AAAA,EACT;AACF;AAoBO,SAAS,mBAAmB,UAAoC,CAAC,GAAuB;AAC7F,SAAO;AAAA,IACL,iBAAiB;AAAA,IACjB,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,aAAa,kBAAkB,OAAO;AAAA,EACxC;AACF;","names":[]}
@@ -0,0 +1,98 @@
1
+ import { EasyCookieApi } from '@easy-cookie/core/shared';
2
+
3
+ /**
4
+ * The few posthog-js methods the adapter uses. Typed loosely on purpose, so
5
+ * `posthog-js` stays an optional peer dependency and any compatible client works.
6
+ */
7
+ interface PostHogLike {
8
+ opt_in_capturing(options?: {
9
+ captureEventName?: string | null | false;
10
+ [key: string]: unknown;
11
+ }): void;
12
+ opt_out_capturing(): void;
13
+ has_opted_in_capturing?(): boolean;
14
+ has_opted_out_capturing?(): boolean;
15
+ clear_opt_in_out_capturing?(): void;
16
+ startSessionRecording?(...args: unknown[]): void;
17
+ stopSessionRecording?(): void;
18
+ identify?(distinctId?: string, ...rest: unknown[]): void;
19
+ get_distinct_id?(): string;
20
+ }
21
+ /** Minimal shape of a PostHog event passed to `before_send`. */
22
+ interface PostHogEventLike {
23
+ event: string;
24
+ properties?: Record<string, any>;
25
+ }
26
+ interface ConnectPostHogOptions {
27
+ /** Category that allows PostHog cookies/profiles. Default `measurement`. */
28
+ category?: string;
29
+ /** Service id: when set, the service's own consent decides instead of the category. */
30
+ service?: string;
31
+ /**
32
+ * Return the logged-in user id (or undefined). Called after opt-in, so the
33
+ * identified person profile is created only with consent.
34
+ */
35
+ identify?: () => string | undefined | null;
36
+ /**
37
+ * Before the visitor's first choice:
38
+ * - `'pending'` (default): capture nothing. A stale opt-in left in storage by an
39
+ * earlier setup is cleared, so nothing is captured with cookies.
40
+ * - `'cookieless'`: count visits without cookies (same as after a rejection).
41
+ * Only if your privacy policy covers cookieless measurement without consent.
42
+ */
43
+ beforeChoice?: 'pending' | 'cookieless';
44
+ /** Start session recording on opt-in and stop it on opt-out. Default false. */
45
+ sessionReplay?: boolean;
46
+ }
47
+ /**
48
+ * Keep PostHog's capture state in sync with the visitor's consent, without reloads.
49
+ *
50
+ * PostHog must be initialised by the host with `cookieless_mode: 'on_reject'`
51
+ * (see {@link posthogInitOptions}): before a choice it captures nothing, after a
52
+ * rejection it keeps counting anonymously with no cookies or storage, and after
53
+ * an acceptance it switches to normal cookie-based capture.
54
+ *
55
+ * On `replay`, `consent` and `change` the adapter calls `opt_in_capturing()` or
56
+ * `opt_out_capturing()`. Returns an unsubscribe function.
57
+ */
58
+ declare function connectPostHog(posthog: PostHogLike, api: EasyCookieApi, options?: ConnectPostHogOptions): () => void;
59
+ /** Events dropped by {@link consentBeforeSend} while consent is missing. */
60
+ declare const NON_ESSENTIAL_EVENTS: readonly string[];
61
+ interface ConsentBeforeSendOptions {
62
+ /** Category checked by the default `isGranted`. Default `measurement`. */
63
+ category?: string;
64
+ /**
65
+ * Consent check. Defaults to the runtime when `api` is given, otherwise to the
66
+ * state published by the head script (`window.__easyCookieHead.granted`).
67
+ */
68
+ isGranted?: () => boolean;
69
+ api?: Pick<EasyCookieApi, 'isGranted'> | null;
70
+ /** Event names to drop without consent. Default {@link NON_ESSENTIAL_EVENTS}. */
71
+ drop?: readonly string[];
72
+ }
73
+ /**
74
+ * `before_send` filter: without consent, drop autocapture, exceptions, web vitals
75
+ * and heatmap events, so cookieless mode only sends the essentials (pageviews,
76
+ * explicit captures). Pass it as `before_send` or use {@link posthogInitOptions}.
77
+ */
78
+ declare function consentBeforeSend(options?: ConsentBeforeSendOptions): <T extends PostHogEventLike | null>(event: T) => T | null;
79
+ interface PostHogInitOptions {
80
+ cookieless_mode: 'on_reject';
81
+ persistence: 'localStorage+cookie';
82
+ person_profiles: 'identified_only';
83
+ before_send: ReturnType<typeof consentBeforeSend>;
84
+ [key: string]: unknown;
85
+ }
86
+ /**
87
+ * Recommended `posthog.init()` options for easy-cookie:
88
+ * - `cookieless_mode: 'on_reject'` (requires "Cookieless server hash mode" enabled
89
+ * in the PostHog project settings);
90
+ * - `persistence: 'localStorage+cookie'` (only used after opt-in);
91
+ * - `person_profiles: 'identified_only'`;
92
+ * - a consent-aware `before_send` filter.
93
+ *
94
+ * Spread your own options after it: `posthog.init(key, { ...posthogInitOptions(), api_host })`.
95
+ */
96
+ declare function posthogInitOptions(options?: ConsentBeforeSendOptions): PostHogInitOptions;
97
+
98
+ export { type ConnectPostHogOptions, type ConsentBeforeSendOptions, NON_ESSENTIAL_EVENTS, type PostHogEventLike, type PostHogInitOptions, type PostHogLike, connectPostHog, consentBeforeSend, posthogInitOptions };
@@ -0,0 +1,98 @@
1
+ import { EasyCookieApi } from '@easy-cookie/core/shared';
2
+
3
+ /**
4
+ * The few posthog-js methods the adapter uses. Typed loosely on purpose, so
5
+ * `posthog-js` stays an optional peer dependency and any compatible client works.
6
+ */
7
+ interface PostHogLike {
8
+ opt_in_capturing(options?: {
9
+ captureEventName?: string | null | false;
10
+ [key: string]: unknown;
11
+ }): void;
12
+ opt_out_capturing(): void;
13
+ has_opted_in_capturing?(): boolean;
14
+ has_opted_out_capturing?(): boolean;
15
+ clear_opt_in_out_capturing?(): void;
16
+ startSessionRecording?(...args: unknown[]): void;
17
+ stopSessionRecording?(): void;
18
+ identify?(distinctId?: string, ...rest: unknown[]): void;
19
+ get_distinct_id?(): string;
20
+ }
21
+ /** Minimal shape of a PostHog event passed to `before_send`. */
22
+ interface PostHogEventLike {
23
+ event: string;
24
+ properties?: Record<string, any>;
25
+ }
26
+ interface ConnectPostHogOptions {
27
+ /** Category that allows PostHog cookies/profiles. Default `measurement`. */
28
+ category?: string;
29
+ /** Service id: when set, the service's own consent decides instead of the category. */
30
+ service?: string;
31
+ /**
32
+ * Return the logged-in user id (or undefined). Called after opt-in, so the
33
+ * identified person profile is created only with consent.
34
+ */
35
+ identify?: () => string | undefined | null;
36
+ /**
37
+ * Before the visitor's first choice:
38
+ * - `'pending'` (default): capture nothing. A stale opt-in left in storage by an
39
+ * earlier setup is cleared, so nothing is captured with cookies.
40
+ * - `'cookieless'`: count visits without cookies (same as after a rejection).
41
+ * Only if your privacy policy covers cookieless measurement without consent.
42
+ */
43
+ beforeChoice?: 'pending' | 'cookieless';
44
+ /** Start session recording on opt-in and stop it on opt-out. Default false. */
45
+ sessionReplay?: boolean;
46
+ }
47
+ /**
48
+ * Keep PostHog's capture state in sync with the visitor's consent, without reloads.
49
+ *
50
+ * PostHog must be initialised by the host with `cookieless_mode: 'on_reject'`
51
+ * (see {@link posthogInitOptions}): before a choice it captures nothing, after a
52
+ * rejection it keeps counting anonymously with no cookies or storage, and after
53
+ * an acceptance it switches to normal cookie-based capture.
54
+ *
55
+ * On `replay`, `consent` and `change` the adapter calls `opt_in_capturing()` or
56
+ * `opt_out_capturing()`. Returns an unsubscribe function.
57
+ */
58
+ declare function connectPostHog(posthog: PostHogLike, api: EasyCookieApi, options?: ConnectPostHogOptions): () => void;
59
+ /** Events dropped by {@link consentBeforeSend} while consent is missing. */
60
+ declare const NON_ESSENTIAL_EVENTS: readonly string[];
61
+ interface ConsentBeforeSendOptions {
62
+ /** Category checked by the default `isGranted`. Default `measurement`. */
63
+ category?: string;
64
+ /**
65
+ * Consent check. Defaults to the runtime when `api` is given, otherwise to the
66
+ * state published by the head script (`window.__easyCookieHead.granted`).
67
+ */
68
+ isGranted?: () => boolean;
69
+ api?: Pick<EasyCookieApi, 'isGranted'> | null;
70
+ /** Event names to drop without consent. Default {@link NON_ESSENTIAL_EVENTS}. */
71
+ drop?: readonly string[];
72
+ }
73
+ /**
74
+ * `before_send` filter: without consent, drop autocapture, exceptions, web vitals
75
+ * and heatmap events, so cookieless mode only sends the essentials (pageviews,
76
+ * explicit captures). Pass it as `before_send` or use {@link posthogInitOptions}.
77
+ */
78
+ declare function consentBeforeSend(options?: ConsentBeforeSendOptions): <T extends PostHogEventLike | null>(event: T) => T | null;
79
+ interface PostHogInitOptions {
80
+ cookieless_mode: 'on_reject';
81
+ persistence: 'localStorage+cookie';
82
+ person_profiles: 'identified_only';
83
+ before_send: ReturnType<typeof consentBeforeSend>;
84
+ [key: string]: unknown;
85
+ }
86
+ /**
87
+ * Recommended `posthog.init()` options for easy-cookie:
88
+ * - `cookieless_mode: 'on_reject'` (requires "Cookieless server hash mode" enabled
89
+ * in the PostHog project settings);
90
+ * - `persistence: 'localStorage+cookie'` (only used after opt-in);
91
+ * - `person_profiles: 'identified_only'`;
92
+ * - a consent-aware `before_send` filter.
93
+ *
94
+ * Spread your own options after it: `posthog.init(key, { ...posthogInitOptions(), api_host })`.
95
+ */
96
+ declare function posthogInitOptions(options?: ConsentBeforeSendOptions): PostHogInitOptions;
97
+
98
+ export { type ConnectPostHogOptions, type ConsentBeforeSendOptions, NON_ESSENTIAL_EVENTS, type PostHogEventLike, type PostHogInitOptions, type PostHogLike, connectPostHog, consentBeforeSend, posthogInitOptions };
package/dist/index.js ADDED
@@ -0,0 +1,74 @@
1
+ // src/index.ts
2
+ function connectPostHog(posthog, api, options = {}) {
3
+ const category = options.category ?? "measurement";
4
+ const granted = () => options.service ? api.isServiceGranted(options.service) : api.isGranted(category);
5
+ let last = null;
6
+ const apply = () => {
7
+ if (!api.get()) {
8
+ if (options.beforeChoice === "cookieless") {
9
+ if (last !== "out") {
10
+ if (!posthog.has_opted_out_capturing?.()) posthog.opt_out_capturing();
11
+ last = "out";
12
+ }
13
+ } else if (posthog.has_opted_in_capturing?.()) {
14
+ posthog.clear_opt_in_out_capturing?.();
15
+ }
16
+ return;
17
+ }
18
+ if (granted()) {
19
+ if (last !== "in") {
20
+ if (!posthog.has_opted_in_capturing?.()) posthog.opt_in_capturing({ captureEventName: false });
21
+ if (options.sessionReplay) posthog.startSessionRecording?.();
22
+ last = "in";
23
+ }
24
+ const id = options.identify?.();
25
+ if (id && posthog.identify && posthog.get_distinct_id?.() !== id) posthog.identify(id);
26
+ } else if (last !== "out") {
27
+ if (options.sessionReplay) posthog.stopSessionRecording?.();
28
+ if (!posthog.has_opted_out_capturing?.()) posthog.opt_out_capturing();
29
+ last = "out";
30
+ }
31
+ };
32
+ const events = ["replay", "consent", "change"];
33
+ const unsubs = events.map((ev) => api.on(ev, apply));
34
+ apply();
35
+ return () => unsubs.forEach((u) => u());
36
+ }
37
+ var NON_ESSENTIAL_EVENTS = [
38
+ "$autocapture",
39
+ "$rageclick",
40
+ "$dead_click",
41
+ "$exception",
42
+ "$web_vitals",
43
+ "$$heatmap",
44
+ "$heatmap"
45
+ ];
46
+ function headGranted(category) {
47
+ const head = globalThis.__easyCookieHead;
48
+ return !!head?.valid && !!head.granted?.includes(category);
49
+ }
50
+ function consentBeforeSend(options = {}) {
51
+ const category = options.category ?? "measurement";
52
+ const drop = new Set(options.drop ?? NON_ESSENTIAL_EVENTS);
53
+ const isGranted = options.isGranted ?? (() => options.api ? options.api.isGranted(category) : headGranted(category));
54
+ return (event) => {
55
+ if (!event) return event;
56
+ if (drop.has(event.event) && !isGranted()) return null;
57
+ return event;
58
+ };
59
+ }
60
+ function posthogInitOptions(options = {}) {
61
+ return {
62
+ cookieless_mode: "on_reject",
63
+ persistence: "localStorage+cookie",
64
+ person_profiles: "identified_only",
65
+ before_send: consentBeforeSend(options)
66
+ };
67
+ }
68
+ export {
69
+ NON_ESSENTIAL_EVENTS,
70
+ connectPostHog,
71
+ consentBeforeSend,
72
+ posthogInitOptions
73
+ };
74
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { EasyCookieApi, EasyCookieEvent } from '@easy-cookie/core/shared';\n\n/**\n * The few posthog-js methods the adapter uses. Typed loosely on purpose, so\n * `posthog-js` stays an optional peer dependency and any compatible client works.\n */\nexport interface PostHogLike {\n opt_in_capturing(options?: { captureEventName?: string | null | false; [key: string]: unknown }): void;\n opt_out_capturing(): void;\n has_opted_in_capturing?(): boolean;\n has_opted_out_capturing?(): boolean;\n clear_opt_in_out_capturing?(): void;\n startSessionRecording?(...args: unknown[]): void;\n stopSessionRecording?(): void;\n identify?(distinctId?: string, ...rest: unknown[]): void;\n get_distinct_id?(): string;\n}\n\n/** Minimal shape of a PostHog event passed to `before_send`. */\nexport interface PostHogEventLike {\n event: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- matches posthog-js `Properties`\n properties?: Record<string, any>;\n}\n\nexport interface ConnectPostHogOptions {\n /** Category that allows PostHog cookies/profiles. Default `measurement`. */\n category?: string;\n /** Service id: when set, the service's own consent decides instead of the category. */\n service?: string;\n /**\n * Return the logged-in user id (or undefined). Called after opt-in, so the\n * identified person profile is created only with consent.\n */\n identify?: () => string | undefined | null;\n /**\n * Before the visitor's first choice:\n * - `'pending'` (default): capture nothing. A stale opt-in left in storage by an\n * earlier setup is cleared, so nothing is captured with cookies.\n * - `'cookieless'`: count visits without cookies (same as after a rejection).\n * Only if your privacy policy covers cookieless measurement without consent.\n */\n beforeChoice?: 'pending' | 'cookieless';\n /** Start session recording on opt-in and stop it on opt-out. Default false. */\n sessionReplay?: boolean;\n}\n\n/**\n * Keep PostHog's capture state in sync with the visitor's consent, without reloads.\n *\n * PostHog must be initialised by the host with `cookieless_mode: 'on_reject'`\n * (see {@link posthogInitOptions}): before a choice it captures nothing, after a\n * rejection it keeps counting anonymously with no cookies or storage, and after\n * an acceptance it switches to normal cookie-based capture.\n *\n * On `replay`, `consent` and `change` the adapter calls `opt_in_capturing()` or\n * `opt_out_capturing()`. Returns an unsubscribe function.\n */\nexport function connectPostHog(posthog: PostHogLike, api: EasyCookieApi, options: ConnectPostHogOptions = {}): () => void {\n const category = options.category ?? 'measurement';\n const granted = () => (options.service ? api.isServiceGranted(options.service) : api.isGranted(category));\n let last: 'in' | 'out' | null = null;\n\n const apply = () => {\n if (!api.get()) {\n if (options.beforeChoice === 'cookieless') {\n if (last !== 'out') {\n if (!posthog.has_opted_out_capturing?.()) posthog.opt_out_capturing();\n last = 'out';\n }\n } else if (posthog.has_opted_in_capturing?.()) {\n // Pending: an opt-in stored by a previous banner must not keep capturing.\n posthog.clear_opt_in_out_capturing?.();\n }\n return;\n }\n if (granted()) {\n if (last !== 'in') {\n // No `$opt_in` event: the consent itself is recorded by easy-cookie.\n if (!posthog.has_opted_in_capturing?.()) posthog.opt_in_capturing({ captureEventName: false });\n if (options.sessionReplay) posthog.startSessionRecording?.();\n last = 'in';\n }\n const id = options.identify?.();\n if (id && posthog.identify && posthog.get_distinct_id?.() !== id) posthog.identify(id);\n } else if (last !== 'out') {\n if (options.sessionReplay) posthog.stopSessionRecording?.();\n if (!posthog.has_opted_out_capturing?.()) posthog.opt_out_capturing();\n last = 'out';\n }\n };\n\n const events: EasyCookieEvent[] = ['replay', 'consent', 'change'];\n const unsubs = events.map((ev) => api.on(ev, apply));\n // The stored choice may have been replayed before we subscribed.\n apply();\n return () => unsubs.forEach((u) => u());\n}\n\n/** Events dropped by {@link consentBeforeSend} while consent is missing. */\nexport const NON_ESSENTIAL_EVENTS: readonly string[] = [\n '$autocapture',\n '$rageclick',\n '$dead_click',\n '$exception',\n '$web_vitals',\n '$$heatmap',\n '$heatmap',\n];\n\nexport interface ConsentBeforeSendOptions {\n /** Category checked by the default `isGranted`. Default `measurement`. */\n category?: string;\n /**\n * Consent check. Defaults to the runtime when `api` is given, otherwise to the\n * state published by the head script (`window.__easyCookieHead.granted`).\n */\n isGranted?: () => boolean;\n api?: Pick<EasyCookieApi, 'isGranted'> | null;\n /** Event names to drop without consent. Default {@link NON_ESSENTIAL_EVENTS}. */\n drop?: readonly string[];\n}\n\nfunction headGranted(category: string): boolean {\n const head = (globalThis as { __easyCookieHead?: { granted?: string[]; valid?: boolean } }).__easyCookieHead;\n return !!head?.valid && !!head.granted?.includes(category);\n}\n\n/**\n * `before_send` filter: without consent, drop autocapture, exceptions, web vitals\n * and heatmap events, so cookieless mode only sends the essentials (pageviews,\n * explicit captures). Pass it as `before_send` or use {@link posthogInitOptions}.\n */\nexport function consentBeforeSend(options: ConsentBeforeSendOptions = {}) {\n const category = options.category ?? 'measurement';\n const drop = new Set(options.drop ?? NON_ESSENTIAL_EVENTS);\n const isGranted =\n options.isGranted ?? (() => (options.api ? options.api.isGranted(category) : headGranted(category)));\n return <T extends PostHogEventLike | null>(event: T): T | null => {\n if (!event) return event;\n if (drop.has(event.event) && !isGranted()) return null;\n return event;\n };\n}\n\nexport interface PostHogInitOptions {\n cookieless_mode: 'on_reject';\n persistence: 'localStorage+cookie';\n person_profiles: 'identified_only';\n before_send: ReturnType<typeof consentBeforeSend>;\n [key: string]: unknown;\n}\n\n/**\n * Recommended `posthog.init()` options for easy-cookie:\n * - `cookieless_mode: 'on_reject'` (requires \"Cookieless server hash mode\" enabled\n * in the PostHog project settings);\n * - `persistence: 'localStorage+cookie'` (only used after opt-in);\n * - `person_profiles: 'identified_only'`;\n * - a consent-aware `before_send` filter.\n *\n * Spread your own options after it: `posthog.init(key, { ...posthogInitOptions(), api_host })`.\n */\nexport function posthogInitOptions(options: ConsentBeforeSendOptions = {}): PostHogInitOptions {\n return {\n cookieless_mode: 'on_reject',\n persistence: 'localStorage+cookie',\n person_profiles: 'identified_only',\n before_send: consentBeforeSend(options),\n };\n}\n"],"mappings":";AA0DO,SAAS,eAAe,SAAsB,KAAoB,UAAiC,CAAC,GAAe;AACxH,QAAM,WAAW,QAAQ,YAAY;AACrC,QAAM,UAAU,MAAO,QAAQ,UAAU,IAAI,iBAAiB,QAAQ,OAAO,IAAI,IAAI,UAAU,QAAQ;AACvG,MAAI,OAA4B;AAEhC,QAAM,QAAQ,MAAM;AAClB,QAAI,CAAC,IAAI,IAAI,GAAG;AACd,UAAI,QAAQ,iBAAiB,cAAc;AACzC,YAAI,SAAS,OAAO;AAClB,cAAI,CAAC,QAAQ,0BAA0B,EAAG,SAAQ,kBAAkB;AACpE,iBAAO;AAAA,QACT;AAAA,MACF,WAAW,QAAQ,yBAAyB,GAAG;AAE7C,gBAAQ,6BAA6B;AAAA,MACvC;AACA;AAAA,IACF;AACA,QAAI,QAAQ,GAAG;AACb,UAAI,SAAS,MAAM;AAEjB,YAAI,CAAC,QAAQ,yBAAyB,EAAG,SAAQ,iBAAiB,EAAE,kBAAkB,MAAM,CAAC;AAC7F,YAAI,QAAQ,cAAe,SAAQ,wBAAwB;AAC3D,eAAO;AAAA,MACT;AACA,YAAM,KAAK,QAAQ,WAAW;AAC9B,UAAI,MAAM,QAAQ,YAAY,QAAQ,kBAAkB,MAAM,GAAI,SAAQ,SAAS,EAAE;AAAA,IACvF,WAAW,SAAS,OAAO;AACzB,UAAI,QAAQ,cAAe,SAAQ,uBAAuB;AAC1D,UAAI,CAAC,QAAQ,0BAA0B,EAAG,SAAQ,kBAAkB;AACpE,aAAO;AAAA,IACT;AAAA,EACF;AAEA,QAAM,SAA4B,CAAC,UAAU,WAAW,QAAQ;AAChE,QAAM,SAAS,OAAO,IAAI,CAAC,OAAO,IAAI,GAAG,IAAI,KAAK,CAAC;AAEnD,QAAM;AACN,SAAO,MAAM,OAAO,QAAQ,CAAC,MAAM,EAAE,CAAC;AACxC;AAGO,IAAM,uBAA0C;AAAA,EACrD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAeA,SAAS,YAAY,UAA2B;AAC9C,QAAM,OAAQ,WAA8E;AAC5F,SAAO,CAAC,CAAC,MAAM,SAAS,CAAC,CAAC,KAAK,SAAS,SAAS,QAAQ;AAC3D;AAOO,SAAS,kBAAkB,UAAoC,CAAC,GAAG;AACxE,QAAM,WAAW,QAAQ,YAAY;AACrC,QAAM,OAAO,IAAI,IAAI,QAAQ,QAAQ,oBAAoB;AACzD,QAAM,YACJ,QAAQ,cAAc,MAAO,QAAQ,MAAM,QAAQ,IAAI,UAAU,QAAQ,IAAI,YAAY,QAAQ;AACnG,SAAO,CAAoC,UAAuB;AAChE,QAAI,CAAC,MAAO,QAAO;AACnB,QAAI,KAAK,IAAI,MAAM,KAAK,KAAK,CAAC,UAAU,EAAG,QAAO;AAClD,WAAO;AAAA,EACT;AACF;AAoBO,SAAS,mBAAmB,UAAoC,CAAC,GAAuB;AAC7F,SAAO;AAAA,IACL,iBAAiB;AAAA,IACjB,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,aAAa,kBAAkB,OAAO;AAAA,EACxC;AACF;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,57 @@
1
1
  {
2
2
  "name": "@easy-cookie/posthog",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "PostHog adapter for easy-cookie: cookieless on_reject mode and opt-in/out synced with consent.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/Aleloca/easy-cookie.git",
9
+ "directory": "packages/posthog"
10
+ },
11
+ "bugs": {
12
+ "url": "https://github.com/Aleloca/easy-cookie/issues"
13
+ },
14
+ "type": "module",
15
+ "sideEffects": false,
16
+ "main": "./dist/index.cjs",
17
+ "module": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "import": "./dist/index.js",
23
+ "require": "./dist/index.cjs"
24
+ },
25
+ "./package.json": "./package.json"
26
+ },
27
+ "files": [
28
+ "dist"
29
+ ],
30
+ "dependencies": {
31
+ "@easy-cookie/core": "^0.1.1"
32
+ },
33
+ "peerDependencies": {
34
+ "posthog-js": ">=1.200.0"
35
+ },
36
+ "peerDependenciesMeta": {
37
+ "posthog-js": {
38
+ "optional": true
39
+ }
40
+ },
41
+ "publishConfig": {
42
+ "access": "public"
43
+ },
44
+ "homepage": "https://consent.aleloca.dev",
45
+ "keywords": [
46
+ "cookie",
47
+ "consent",
48
+ "gdpr",
49
+ "cookie-banner",
50
+ "consent-mode"
51
+ ],
52
+ "scripts": {
53
+ "build": "tsup",
54
+ "test": "vitest run",
55
+ "typecheck": "tsc --noEmit"
56
+ }
6
57
  }