@codefast/tracking 0.7.0 → 0.7.2
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/CHANGELOG.md +21 -0
- package/README.md +235 -105
- package/dist/adapters/tanstack-start.d.ts +12 -9
- package/dist/adapters/tanstack-start.js +5 -6
- package/dist/client/ad-framework-consent.d.ts +9 -8
- package/dist/client/ad-framework-consent.js +4 -5
- package/dist/client/browser-cookie.d.ts +2 -3
- package/dist/client/browser-cookie.js +2 -3
- package/dist/client/consent-runtime.d.ts +6 -5
- package/dist/client/consent-runtime.js +2 -3
- package/dist/client/consent-storage.d.ts +1 -2
- package/dist/client/consent-storage.js +1 -2
- package/dist/client/consent-withdrawal.d.ts +5 -4
- package/dist/client/consent-withdrawal.js +2 -3
- package/dist/client/cookie-anonymous-id.d.ts +8 -5
- package/dist/client/cookie-anonymous-id.js +2 -3
- package/dist/client/create-client-tracker.d.ts +8 -3
- package/dist/client/create-client-tracker.js +3 -2
- package/dist/client/gpc.d.ts +1 -2
- package/dist/client/gpc.js +1 -2
- package/dist/client/initial-consent-store.d.ts +7 -6
- package/dist/client/initial-consent-store.js +2 -3
- package/dist/client/is-analytics-allowed.d.ts +5 -4
- package/dist/client/is-analytics-allowed.js +2 -3
- package/dist/client/server-persisted-anonymous-id.d.ts +5 -4
- package/dist/client/server-persisted-anonymous-id.js +2 -3
- package/dist/core/consent-config.d.ts +3 -4
- package/dist/core/consent-config.js +2 -3
- package/dist/core/consent-receipt.d.ts +7 -8
- package/dist/core/consent-receipt.js +2 -3
- package/dist/core/consent.d.ts +24 -13
- package/dist/core/consent.js +13 -10
- package/dist/core/cookie.d.ts +3 -4
- package/dist/core/cookie.js +3 -4
- package/dist/core/destination.d.ts +1 -2
- package/dist/core/destination.js +1 -2
- package/dist/core/event-catalog.d.ts +2 -3
- package/dist/core/event-catalog.js +2 -3
- package/dist/core/event-id.d.ts +1 -2
- package/dist/core/event-id.js +1 -2
- package/dist/core/tracked-event.d.ts +1 -2
- package/dist/core/tracked-event.js +1 -2
- package/dist/destinations/ad-consent.d.ts +3 -4
- package/dist/destinations/ad-consent.js +2 -3
- package/dist/destinations/google-analytics.d.ts +17 -10
- package/dist/destinations/google-analytics.js +5 -6
- package/dist/destinations/google-consent.d.ts +10 -9
- package/dist/destinations/google-consent.js +6 -7
- package/dist/destinations/meta.d.ts +8 -7
- package/dist/destinations/meta.js +3 -4
- package/dist/destinations/microsoft-uet.d.ts +8 -7
- package/dist/destinations/microsoft-uet.js +3 -4
- package/dist/destinations/shared.d.ts +8 -5
- package/dist/destinations/shared.js +4 -3
- package/dist/destinations/tiktok.d.ts +8 -7
- package/dist/destinations/tiktok.js +3 -4
- package/dist/destinations/vercel-analytics.d.ts +4 -3
- package/dist/destinations/vercel-analytics.js +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/react/consent-banner.d.ts +29 -2
- package/dist/react/consent-banner.js +12 -9
- package/dist/react/gtag-consent-bootstrap.d.ts +5 -4
- package/dist/react/gtag-consent-bootstrap.js +2 -3
- package/dist/react/use-consent.d.ts +5 -2
- package/dist/react/use-consent.js +1 -2
- package/dist/react/use-google-consent-sync.d.ts +5 -4
- package/dist/react/use-google-consent-sync.js +2 -3
- package/dist/react/use-initial-consent.d.ts +2 -3
- package/dist/react/use-initial-consent.js +2 -3
- package/dist/server/anonymous-id-cookie.d.ts +8 -7
- package/dist/server/anonymous-id-cookie.js +5 -6
- package/dist/server/consent-receipt-store.d.ts +5 -6
- package/dist/server/consent-receipt-store.js +3 -4
- package/dist/server/consent-receipt.d.ts +5 -6
- package/dist/server/consent-receipt.js +4 -5
- package/dist/server/initial-consent.d.ts +5 -4
- package/dist/server/initial-consent.js +2 -3
- package/dist/server/measurement-protocol.d.ts +10 -9
- package/dist/server/measurement-protocol.js +4 -5
- package/dist/server/region.d.ts +3 -4
- package/dist/server/region.js +3 -4
- package/dist/server/user-deletion.d.ts +10 -7
- package/dist/server/user-deletion.js +3 -4
- package/dist/tooling/import-protection.d.ts +2 -3
- package/dist/tooling/import-protection.js +2 -3
- package/package.json +11 -62
- package/dist/adapters/tanstack-start.d.ts.map +0 -1
- package/dist/adapters/tanstack-start.js.map +0 -1
- package/dist/client/ad-framework-consent.d.ts.map +0 -1
- package/dist/client/ad-framework-consent.js.map +0 -1
- package/dist/client/browser-cookie.d.ts.map +0 -1
- package/dist/client/browser-cookie.js.map +0 -1
- package/dist/client/consent-runtime.d.ts.map +0 -1
- package/dist/client/consent-runtime.js.map +0 -1
- package/dist/client/consent-storage.d.ts.map +0 -1
- package/dist/client/consent-storage.js.map +0 -1
- package/dist/client/consent-withdrawal.d.ts.map +0 -1
- package/dist/client/consent-withdrawal.js.map +0 -1
- package/dist/client/cookie-anonymous-id.d.ts.map +0 -1
- package/dist/client/cookie-anonymous-id.js.map +0 -1
- package/dist/client/create-client-tracker.d.ts.map +0 -1
- package/dist/client/create-client-tracker.js.map +0 -1
- package/dist/client/gpc.d.ts.map +0 -1
- package/dist/client/gpc.js.map +0 -1
- package/dist/client/initial-consent-store.d.ts.map +0 -1
- package/dist/client/initial-consent-store.js.map +0 -1
- package/dist/client/is-analytics-allowed.d.ts.map +0 -1
- package/dist/client/is-analytics-allowed.js.map +0 -1
- package/dist/client/server-persisted-anonymous-id.d.ts.map +0 -1
- package/dist/client/server-persisted-anonymous-id.js.map +0 -1
- package/dist/core/consent-config.d.ts.map +0 -1
- package/dist/core/consent-config.js.map +0 -1
- package/dist/core/consent-receipt.d.ts.map +0 -1
- package/dist/core/consent-receipt.js.map +0 -1
- package/dist/core/consent.d.ts.map +0 -1
- package/dist/core/consent.js.map +0 -1
- package/dist/core/cookie.d.ts.map +0 -1
- package/dist/core/cookie.js.map +0 -1
- package/dist/core/destination.d.ts.map +0 -1
- package/dist/core/destination.js.map +0 -1
- package/dist/core/event-catalog.d.ts.map +0 -1
- package/dist/core/event-catalog.js.map +0 -1
- package/dist/core/event-id.d.ts.map +0 -1
- package/dist/core/event-id.js.map +0 -1
- package/dist/core/tracked-event.d.ts.map +0 -1
- package/dist/core/tracked-event.js.map +0 -1
- package/dist/destinations/ad-consent.d.ts.map +0 -1
- package/dist/destinations/ad-consent.js.map +0 -1
- package/dist/destinations/google-analytics.d.ts.map +0 -1
- package/dist/destinations/google-analytics.js.map +0 -1
- package/dist/destinations/google-consent.d.ts.map +0 -1
- package/dist/destinations/google-consent.js.map +0 -1
- package/dist/destinations/meta.d.ts.map +0 -1
- package/dist/destinations/meta.js.map +0 -1
- package/dist/destinations/microsoft-uet.d.ts.map +0 -1
- package/dist/destinations/microsoft-uet.js.map +0 -1
- package/dist/destinations/shared.d.ts.map +0 -1
- package/dist/destinations/shared.js.map +0 -1
- package/dist/destinations/tiktok.d.ts.map +0 -1
- package/dist/destinations/tiktok.js.map +0 -1
- package/dist/destinations/vercel-analytics.d.ts.map +0 -1
- package/dist/destinations/vercel-analytics.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/react/consent-banner.d.ts.map +0 -1
- package/dist/react/consent-banner.js.map +0 -1
- package/dist/react/gtag-consent-bootstrap.d.ts.map +0 -1
- package/dist/react/gtag-consent-bootstrap.js.map +0 -1
- package/dist/react/use-consent.d.ts.map +0 -1
- package/dist/react/use-consent.js.map +0 -1
- package/dist/react/use-google-consent-sync.d.ts.map +0 -1
- package/dist/react/use-google-consent-sync.js.map +0 -1
- package/dist/react/use-initial-consent.d.ts.map +0 -1
- package/dist/react/use-initial-consent.js.map +0 -1
- package/dist/server/anonymous-id-cookie.d.ts.map +0 -1
- package/dist/server/anonymous-id-cookie.js.map +0 -1
- package/dist/server/consent-receipt-store.d.ts.map +0 -1
- package/dist/server/consent-receipt-store.js.map +0 -1
- package/dist/server/consent-receipt.d.ts.map +0 -1
- package/dist/server/consent-receipt.js.map +0 -1
- package/dist/server/initial-consent.d.ts.map +0 -1
- package/dist/server/initial-consent.js.map +0 -1
- package/dist/server/measurement-protocol.d.ts.map +0 -1
- package/dist/server/measurement-protocol.js.map +0 -1
- package/dist/server/region.d.ts.map +0 -1
- package/dist/server/region.js.map +0 -1
- package/dist/server/user-deletion.d.ts.map +0 -1
- package/dist/server/user-deletion.js.map +0 -1
- package/dist/tooling/import-protection.d.ts.map +0 -1
- package/dist/tooling/import-protection.js.map +0 -1
- package/src/adapters/tanstack-start.ts +0 -135
- package/src/client/ad-framework-consent.ts +0 -86
- package/src/client/browser-cookie.ts +0 -16
- package/src/client/consent-runtime.ts +0 -80
- package/src/client/consent-storage.ts +0 -125
- package/src/client/consent-withdrawal.ts +0 -32
- package/src/client/cookie-anonymous-id.ts +0 -112
- package/src/client/create-client-tracker.ts +0 -168
- package/src/client/gpc.ts +0 -15
- package/src/client/initial-consent-store.ts +0 -218
- package/src/client/is-analytics-allowed.ts +0 -43
- package/src/client/server-persisted-anonymous-id.ts +0 -102
- package/src/core/consent-config.ts +0 -27
- package/src/core/consent-receipt.ts +0 -115
- package/src/core/consent.ts +0 -286
- package/src/core/cookie.ts +0 -29
- package/src/core/destination.ts +0 -29
- package/src/core/event-catalog.ts +0 -54
- package/src/core/event-id.ts +0 -8
- package/src/core/tracked-event.ts +0 -14
- package/src/css/consent.css +0 -119
- package/src/destinations/ad-consent.ts +0 -29
- package/src/destinations/google-analytics.ts +0 -296
- package/src/destinations/google-consent.ts +0 -164
- package/src/destinations/meta.ts +0 -96
- package/src/destinations/microsoft-uet.ts +0 -86
- package/src/destinations/shared.ts +0 -45
- package/src/destinations/tiktok.ts +0 -85
- package/src/destinations/vercel-analytics.ts +0 -39
- package/src/index.ts +0 -171
- package/src/react/consent-banner.tsx +0 -360
- package/src/react/gtag-consent-bootstrap.tsx +0 -48
- package/src/react/use-consent.ts +0 -119
- package/src/react/use-google-consent-sync.ts +0 -38
- package/src/react/use-initial-consent.ts +0 -22
- package/src/server/anonymous-id-cookie.ts +0 -103
- package/src/server/consent-receipt-store.ts +0 -79
- package/src/server/consent-receipt.ts +0 -89
- package/src/server/initial-consent.ts +0 -46
- package/src/server/measurement-protocol.ts +0 -114
- package/src/server/region.ts +0 -77
- package/src/server/user-deletion.ts +0 -93
- package/src/tooling/import-protection.ts +0 -22
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
* mirror): Secure on HTTPS so values never ride plain HTTP, SameSite=Lax, never HttpOnly —
|
|
4
4
|
* the client must read its own cookies back. A no-op without a `document` (SSR).
|
|
5
5
|
*
|
|
6
|
-
* @since
|
|
6
|
+
* @since 0.5.0-canary.6
|
|
7
7
|
*/
|
|
8
|
-
export declare function writeBrowserCookie(cookieName: string, value: string, maxAgeSeconds: number): void;
|
|
9
|
-
//# sourceMappingURL=browser-cookie.d.ts.map
|
|
8
|
+
export declare function writeBrowserCookie(cookieName: string, value: string, maxAgeSeconds: number): void;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* mirror): Secure on HTTPS so values never ride plain HTTP, SameSite=Lax, never HttpOnly —
|
|
4
4
|
* the client must read its own cookies back. A no-op without a `document` (SSR).
|
|
5
5
|
*
|
|
6
|
-
* @since
|
|
6
|
+
* @since 0.5.0-canary.6
|
|
7
7
|
*/
|
|
8
8
|
export function writeBrowserCookie(cookieName, value, maxAgeSeconds) {
|
|
9
9
|
if (typeof document === "undefined") {
|
|
@@ -11,5 +11,4 @@ export function writeBrowserCookie(cookieName, value, maxAgeSeconds) {
|
|
|
11
11
|
}
|
|
12
12
|
const secure = globalThis.location.protocol === "https:" ? "; secure" : "";
|
|
13
13
|
document.cookie = `${cookieName}=${value}; path=/; max-age=${String(maxAgeSeconds)}; samesite=lax${secure}`;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=browser-cookie.js.map
|
|
14
|
+
}
|
|
@@ -2,7 +2,9 @@ import type { InitialConsentStore } from "#/client/initial-consent-store";
|
|
|
2
2
|
import type { ConsentStorage, InitialConsent } from "#/core/consent";
|
|
3
3
|
import type { ConsentConfig } from "#/core/consent-config";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Options for `createConsentRuntime`.
|
|
6
|
+
*
|
|
7
|
+
* @since 0.5.0-canary.6
|
|
6
8
|
*/
|
|
7
9
|
export interface ConsentRuntimeOptions {
|
|
8
10
|
config: ConsentConfig;
|
|
@@ -25,7 +27,7 @@ export interface ConsentRuntimeOptions {
|
|
|
25
27
|
* it once at module scope and every surface (banner hook, tracker gate, privacy page)
|
|
26
28
|
* shares the same storage and region resolution by construction.
|
|
27
29
|
*
|
|
28
|
-
* @since
|
|
30
|
+
* @since 0.5.0-canary.6
|
|
29
31
|
*/
|
|
30
32
|
export interface ConsentRuntime {
|
|
31
33
|
config: ConsentConfig;
|
|
@@ -47,7 +49,6 @@ export interface ConsentRuntime {
|
|
|
47
49
|
* `localStorage`-backed decision storage, the initial-consent store over the app's
|
|
48
50
|
* server lane, and the non-React analytics gate wired to that store's resolved mode.
|
|
49
51
|
*
|
|
50
|
-
* @since
|
|
52
|
+
* @since 0.5.0-canary.6
|
|
51
53
|
*/
|
|
52
|
-
export declare function createConsentRuntime(options: ConsentRuntimeOptions): ConsentRuntime;
|
|
53
|
-
//# sourceMappingURL=consent-runtime.d.ts.map
|
|
54
|
+
export declare function createConsentRuntime(options: ConsentRuntimeOptions): ConsentRuntime;
|
|
@@ -7,7 +7,7 @@ import { createIsAnalyticsAllowed } from "#/client/is-analytics-allowed";
|
|
|
7
7
|
* `localStorage`-backed decision storage, the initial-consent store over the app's
|
|
8
8
|
* server lane, and the non-React analytics gate wired to that store's resolved mode.
|
|
9
9
|
*
|
|
10
|
-
* @since
|
|
10
|
+
* @since 0.5.0-canary.6
|
|
11
11
|
*/
|
|
12
12
|
export function createConsentRuntime(options) {
|
|
13
13
|
const { config } = options;
|
|
@@ -29,5 +29,4 @@ export function createConsentRuntime(options) {
|
|
|
29
29
|
isAnalyticsAllowed,
|
|
30
30
|
storage,
|
|
31
31
|
};
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=consent-runtime.js.map
|
|
32
|
+
}
|
|
@@ -17,5 +17,4 @@ import type { ConsentStorage } from "#/core/consent";
|
|
|
17
17
|
*
|
|
18
18
|
* @since 0.5.0-canary.4
|
|
19
19
|
*/
|
|
20
|
-
export declare function createLocalStorageConsentStorage(storageKey: string): ConsentStorage;
|
|
21
|
-
//# sourceMappingURL=consent-storage.d.ts.map
|
|
20
|
+
export declare function createLocalStorageConsentStorage(storageKey: string): ConsentStorage;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ConsentDecision } from "#/core/consent";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Options for `createConsentWithdrawalHandler`.
|
|
4
|
+
*
|
|
5
|
+
* @since 0.5.0-canary.6
|
|
4
6
|
*/
|
|
5
7
|
export interface ConsentWithdrawalHandlerOptions {
|
|
6
8
|
/** Forget the cookie-backed visitor id when analytics is denied. */
|
|
@@ -12,7 +14,6 @@ export interface ConsentWithdrawalHandlerOptions {
|
|
|
12
14
|
* `useConsent({ onDecision })` handler that clears first-party tracking state when the
|
|
13
15
|
* visitor denies (or withdraws) analytics. Grant paths are a no-op.
|
|
14
16
|
*
|
|
15
|
-
* @since
|
|
17
|
+
* @since 0.5.0-canary.6
|
|
16
18
|
*/
|
|
17
|
-
export declare function createConsentWithdrawalHandler(options: ConsentWithdrawalHandlerOptions): (decision: ConsentDecision) => void;
|
|
18
|
-
//# sourceMappingURL=consent-withdrawal.d.ts.map
|
|
19
|
+
export declare function createConsentWithdrawalHandler(options: ConsentWithdrawalHandlerOptions): (decision: ConsentDecision) => void;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* `useConsent({ onDecision })` handler that clears first-party tracking state when the
|
|
3
3
|
* visitor denies (or withdraws) analytics. Grant paths are a no-op.
|
|
4
4
|
*
|
|
5
|
-
* @since
|
|
5
|
+
* @since 0.5.0-canary.6
|
|
6
6
|
*/
|
|
7
7
|
export function createConsentWithdrawalHandler(options) {
|
|
8
8
|
const { clearAnonymousId, clearGoogleAnalyticsCookies } = options;
|
|
@@ -13,5 +13,4 @@ export function createConsentWithdrawalHandler(options) {
|
|
|
13
13
|
clearAnonymousId?.();
|
|
14
14
|
clearGoogleAnalyticsCookies?.();
|
|
15
15
|
};
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=consent-withdrawal.js.map
|
|
16
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Options for `createCookieAnonymousId`.
|
|
3
|
+
*
|
|
4
|
+
* @since 0.5.0-canary.6
|
|
3
5
|
*/
|
|
4
6
|
export interface CookieAnonymousIdOptions {
|
|
5
7
|
/** Cookie name — must not collide with another cookie on the domain. */
|
|
@@ -8,7 +10,9 @@ export interface CookieAnonymousIdOptions {
|
|
|
8
10
|
maxAgeSeconds?: number | undefined;
|
|
9
11
|
}
|
|
10
12
|
/**
|
|
11
|
-
*
|
|
13
|
+
* A cookie-backed anonymous id handle: lazy minting, expiry refresh, and clearing on withdrawal.
|
|
14
|
+
*
|
|
15
|
+
* @since 0.5.0-canary.6
|
|
12
16
|
*/
|
|
13
17
|
export interface CookieAnonymousId {
|
|
14
18
|
/** Expires the cookie — call when the visitor withdraws tracking consent. */
|
|
@@ -35,7 +39,6 @@ export interface CookieAnonymousId {
|
|
|
35
39
|
* it's invoked lazily, so the cookie is minted only once an event is actually allowed to
|
|
36
40
|
* send, never as an import-time side effect.
|
|
37
41
|
*
|
|
38
|
-
* @since
|
|
42
|
+
* @since 0.5.0-canary.6
|
|
39
43
|
*/
|
|
40
|
-
export declare function createCookieAnonymousId(options: CookieAnonymousIdOptions): CookieAnonymousId;
|
|
41
|
-
//# sourceMappingURL=cookie-anonymous-id.d.ts.map
|
|
44
|
+
export declare function createCookieAnonymousId(options: CookieAnonymousIdOptions): CookieAnonymousId;
|
|
@@ -7,7 +7,7 @@ import { ONE_YEAR_IN_SECONDS, readCookieValue } from "#/core/cookie";
|
|
|
7
7
|
* it's invoked lazily, so the cookie is minted only once an event is actually allowed to
|
|
8
8
|
* send, never as an import-time side effect.
|
|
9
9
|
*
|
|
10
|
-
* @since
|
|
10
|
+
* @since 0.5.0-canary.6
|
|
11
11
|
*/
|
|
12
12
|
export function createCookieAnonymousId(options) {
|
|
13
13
|
const { cookieName, maxAgeSeconds = ONE_YEAR_IN_SECONDS } = options;
|
|
@@ -61,5 +61,4 @@ export function createCookieAnonymousId(options) {
|
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
63
|
};
|
|
64
|
-
}
|
|
65
|
-
//# sourceMappingURL=cookie-anonymous-id.js.map
|
|
64
|
+
}
|
|
@@ -5,7 +5,7 @@ import type { TrackedEvent } from "#/core/tracked-event";
|
|
|
5
5
|
/**
|
|
6
6
|
* Context handed to {@link ClientTrackerOptions.onDeliveryError} for one failed delivery.
|
|
7
7
|
*
|
|
8
|
-
* @since
|
|
8
|
+
* @since 0.5.0-canary.6
|
|
9
9
|
*/
|
|
10
10
|
export interface DeliveryErrorContext {
|
|
11
11
|
destination: Destination;
|
|
@@ -13,6 +13,8 @@ export interface DeliveryErrorContext {
|
|
|
13
13
|
event: TrackedEvent;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
|
+
* Options for `createClientTracker`.
|
|
17
|
+
*
|
|
16
18
|
* @since 0.5.0-canary.4
|
|
17
19
|
*/
|
|
18
20
|
export interface ClientTrackerOptions<Catalog extends EventCatalog> {
|
|
@@ -42,6 +44,8 @@ export interface ClientTrackerOptions<Catalog extends EventCatalog> {
|
|
|
42
44
|
onDeliveryError?: ((context: DeliveryErrorContext) => void) | undefined;
|
|
43
45
|
}
|
|
44
46
|
/**
|
|
47
|
+
* A client-side tracker delivering catalog-validated events to destinations, plus erasure on withdrawal.
|
|
48
|
+
*
|
|
45
49
|
* @since 0.5.0-canary.4
|
|
46
50
|
*/
|
|
47
51
|
export interface ClientTracker<Catalog extends EventCatalog> {
|
|
@@ -54,7 +58,8 @@ export interface ClientTracker<Catalog extends EventCatalog> {
|
|
|
54
58
|
track: <Name extends keyof Catalog & string>(name: Name, properties: StandardSchemaV1.InferOutput<Catalog[Name]["schema"]>) => void;
|
|
55
59
|
}
|
|
56
60
|
/**
|
|
61
|
+
* Creates a consent-gated tracker that validates each event against the catalog and fans it out to destinations.
|
|
62
|
+
*
|
|
57
63
|
* @since 0.5.0-canary.4
|
|
58
64
|
*/
|
|
59
|
-
export declare function createClientTracker<Catalog extends EventCatalog>(options: ClientTrackerOptions<Catalog>): ClientTracker<Catalog>;
|
|
60
|
-
//# sourceMappingURL=create-client-tracker.d.ts.map
|
|
65
|
+
export declare function createClientTracker<Catalog extends EventCatalog>(options: ClientTrackerOptions<Catalog>): ClientTracker<Catalog>;
|
|
@@ -40,6 +40,8 @@ function eraseInDestination(destination, id) {
|
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
|
+
* Creates a consent-gated tracker that validates each event against the catalog and fans it out to destinations.
|
|
44
|
+
*
|
|
43
45
|
* @since 0.5.0-canary.4
|
|
44
46
|
*/
|
|
45
47
|
export function createClientTracker(options) {
|
|
@@ -87,5 +89,4 @@ export function createClientTracker(options) {
|
|
|
87
89
|
}
|
|
88
90
|
},
|
|
89
91
|
};
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=create-client-tracker.js.map
|
|
92
|
+
}
|
package/dist/client/gpc.d.ts
CHANGED
package/dist/client/gpc.js
CHANGED
|
@@ -3,7 +3,7 @@ import type { InitialConsent } from "#/core/consent";
|
|
|
3
3
|
* External-store view of the visitor's region default — the strictest value until the
|
|
4
4
|
* server lane answers, then the resolved one.
|
|
5
5
|
*
|
|
6
|
-
* @since
|
|
6
|
+
* @since 0.5.0-canary.6
|
|
7
7
|
*/
|
|
8
8
|
export interface InitialConsentSnapshot {
|
|
9
9
|
/** The region-correct default once resolved; {@link STRICTEST_INITIAL_CONSENT} until then. */
|
|
@@ -16,7 +16,9 @@ export interface InitialConsentSnapshot {
|
|
|
16
16
|
isResolved: boolean;
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
19
|
+
* Options for `createInitialConsentStore`.
|
|
20
|
+
*
|
|
21
|
+
* @since 0.5.0-canary.6
|
|
20
22
|
*/
|
|
21
23
|
export interface InitialConsentStoreOptions {
|
|
22
24
|
/**
|
|
@@ -36,7 +38,7 @@ export interface InitialConsentStoreOptions {
|
|
|
36
38
|
* `useSyncExternalStore`-shaped — pass `subscribe`/`getSnapshot`/`getServerSnapshot`
|
|
37
39
|
* straight through, or use the `useInitialConsent` hook from `@codefast/tracking/react`.
|
|
38
40
|
*
|
|
39
|
-
* @since
|
|
41
|
+
* @since 0.5.0-canary.6
|
|
40
42
|
*/
|
|
41
43
|
export interface InitialConsentStore {
|
|
42
44
|
/**
|
|
@@ -57,7 +59,6 @@ export interface InitialConsentStore {
|
|
|
57
59
|
* (consent UI still renders, under the strictest default), and a retry the next time the
|
|
58
60
|
* tab becomes visible — so one failed request never locks the whole SPA session.
|
|
59
61
|
*
|
|
60
|
-
* @since
|
|
62
|
+
* @since 0.5.0-canary.6
|
|
61
63
|
*/
|
|
62
|
-
export declare function createInitialConsentStore(options: InitialConsentStoreOptions): InitialConsentStore;
|
|
63
|
-
//# sourceMappingURL=initial-consent-store.d.ts.map
|
|
64
|
+
export declare function createInitialConsentStore(options: InitialConsentStoreOptions): InitialConsentStore;
|
|
@@ -9,7 +9,7 @@ const SERVER_SNAPSHOT = {
|
|
|
9
9
|
* (consent UI still renders, under the strictest default), and a retry the next time the
|
|
10
10
|
* tab becomes visible — so one failed request never locks the whole SPA session.
|
|
11
11
|
*
|
|
12
|
-
* @since
|
|
12
|
+
* @since 0.5.0-canary.6
|
|
13
13
|
*/
|
|
14
14
|
export function createInitialConsentStore(options) {
|
|
15
15
|
const listeners = new Set();
|
|
@@ -134,5 +134,4 @@ export function createInitialConsentStore(options) {
|
|
|
134
134
|
};
|
|
135
135
|
},
|
|
136
136
|
};
|
|
137
|
-
}
|
|
138
|
-
//# sourceMappingURL=initial-consent-store.js.map
|
|
137
|
+
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { ConsentMode, ConsentStorage } from "#/core/consent";
|
|
2
2
|
import type { ConsentConfig } from "#/core/consent-config";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Options for `createIsAnalyticsAllowed`.
|
|
5
|
+
*
|
|
6
|
+
* @since 0.5.0-canary.6
|
|
5
7
|
*/
|
|
6
8
|
export interface IsAnalyticsAllowedOptions {
|
|
7
9
|
/** Must be the same object `useConsent` receives — one config, every surface. */
|
|
@@ -20,7 +22,6 @@ export interface IsAnalyticsAllowedOptions {
|
|
|
20
22
|
* Non-React mirror of `useConsent`'s `isAnalyticsAllowed` — pass the returned function as
|
|
21
23
|
* `createClientTracker({ isAnalyticsAllowed })` so the pipeline and the banner share one rule.
|
|
22
24
|
*
|
|
23
|
-
* @since
|
|
25
|
+
* @since 0.5.0-canary.6
|
|
24
26
|
*/
|
|
25
|
-
export declare function createIsAnalyticsAllowed(options: IsAnalyticsAllowedOptions): () => boolean;
|
|
26
|
-
//# sourceMappingURL=is-analytics-allowed.d.ts.map
|
|
27
|
+
export declare function createIsAnalyticsAllowed(options: IsAnalyticsAllowedOptions): () => boolean;
|
|
@@ -3,7 +3,7 @@ import { resolveEffectiveConsent } from "#/core/consent";
|
|
|
3
3
|
* Non-React mirror of `useConsent`'s `isAnalyticsAllowed` — pass the returned function as
|
|
4
4
|
* `createClientTracker({ isAnalyticsAllowed })` so the pipeline and the banner share one rule.
|
|
5
5
|
*
|
|
6
|
-
* @since
|
|
6
|
+
* @since 0.5.0-canary.6
|
|
7
7
|
*/
|
|
8
8
|
export function createIsAnalyticsAllowed(options) {
|
|
9
9
|
const { config, getMode, storage } = options;
|
|
@@ -18,5 +18,4 @@ export function createIsAnalyticsAllowed(options) {
|
|
|
18
18
|
});
|
|
19
19
|
return effectiveConsent.analytics;
|
|
20
20
|
};
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=is-analytics-allowed.js.map
|
|
21
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { CookieAnonymousId } from "#/client/cookie-anonymous-id";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Options for `createServerPersistedAnonymousId`.
|
|
4
|
+
*
|
|
5
|
+
* @since 0.5.0-canary.6
|
|
4
6
|
*/
|
|
5
7
|
export interface ServerPersistedAnonymousIdOptions {
|
|
6
8
|
/** Server round-trip that expires the cookie via `Set-Cookie` — the server half of `clear()`. */
|
|
@@ -24,7 +26,6 @@ export interface ServerPersistedAnonymousIdOptions {
|
|
|
24
26
|
* its full max-age. Same optimistic `document.cookie` write first, so the current event
|
|
25
27
|
* never waits on the round-trip and a failed `persist` degrades to today's behavior.
|
|
26
28
|
*
|
|
27
|
-
* @since
|
|
29
|
+
* @since 0.5.0-canary.6
|
|
28
30
|
*/
|
|
29
|
-
export declare function createServerPersistedAnonymousId(options: ServerPersistedAnonymousIdOptions): CookieAnonymousId;
|
|
30
|
-
//# sourceMappingURL=server-persisted-anonymous-id.d.ts.map
|
|
31
|
+
export declare function createServerPersistedAnonymousId(options: ServerPersistedAnonymousIdOptions): CookieAnonymousId;
|
|
@@ -8,7 +8,7 @@ import { readCookieValue } from "#/core/cookie";
|
|
|
8
8
|
* its full max-age. Same optimistic `document.cookie` write first, so the current event
|
|
9
9
|
* never waits on the round-trip and a failed `persist` degrades to today's behavior.
|
|
10
10
|
*
|
|
11
|
-
* @since
|
|
11
|
+
* @since 0.5.0-canary.6
|
|
12
12
|
*/
|
|
13
13
|
export function createServerPersistedAnonymousId(options) {
|
|
14
14
|
const { clearOnServer, cookieName, maxAgeSeconds, persist } = options;
|
|
@@ -68,5 +68,4 @@ export function createServerPersistedAnonymousId(options) {
|
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
70
|
};
|
|
71
|
-
}
|
|
72
|
-
//# sourceMappingURL=server-persisted-anonymous-id.js.map
|
|
71
|
+
}
|
|
@@ -5,7 +5,7 @@ import type { ConsentCategory } from "#/core/consent";
|
|
|
5
5
|
* cross-surface "must match" contracts hold by construction instead of by hand-threading
|
|
6
6
|
* the same strings through every call site.
|
|
7
7
|
*
|
|
8
|
-
* @since
|
|
8
|
+
* @since 0.5.0-canary.6
|
|
9
9
|
*/
|
|
10
10
|
export interface ConsentConfig {
|
|
11
11
|
/** Bumping re-prompts every visitor — a stored decision under any other version is ignored. */
|
|
@@ -18,7 +18,6 @@ export interface ConsentConfig {
|
|
|
18
18
|
/**
|
|
19
19
|
* Identity helper for declaring the config with inference — `defineEventCatalog`'s consent twin.
|
|
20
20
|
*
|
|
21
|
-
* @since
|
|
21
|
+
* @since 0.5.0-canary.6
|
|
22
22
|
*/
|
|
23
|
-
export declare function defineConsentConfig<Config extends ConsentConfig>(config: Config): Config;
|
|
24
|
-
//# sourceMappingURL=consent-config.d.ts.map
|
|
23
|
+
export declare function defineConsentConfig<Config extends ConsentConfig>(config: Config): Config;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Identity helper for declaring the config with inference — `defineEventCatalog`'s consent twin.
|
|
3
3
|
*
|
|
4
|
-
* @since
|
|
4
|
+
* @since 0.5.0-canary.6
|
|
5
5
|
*/
|
|
6
6
|
export function defineConsentConfig(config) {
|
|
7
7
|
return config;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=consent-config.js.map
|
|
8
|
+
}
|
|
@@ -3,28 +3,28 @@ import type { ConsentDecision } from "#/core/consent";
|
|
|
3
3
|
* Which consent event a receipt records. Receipts are append-only: an `update` or
|
|
4
4
|
* `withdraw` is a new receipt referencing the prior one, never a mutation.
|
|
5
5
|
*
|
|
6
|
-
* @since
|
|
6
|
+
* @since 0.5.0-canary.6
|
|
7
7
|
*/
|
|
8
8
|
export type ConsentReceiptEventType = "give" | "update" | "withdraw";
|
|
9
9
|
/**
|
|
10
10
|
* How the decision was expressed — the "how" dimension a demonstrable-consent record must
|
|
11
11
|
* capture (GDPR Art. 7(1); EDPB 05/2020 §5.1).
|
|
12
12
|
*
|
|
13
|
-
* @since
|
|
13
|
+
* @since 0.5.0-canary.6
|
|
14
14
|
*/
|
|
15
15
|
export type ConsentReceiptMethod = "banner-accept" | "banner-reject" | "granular" | "gpc-signal" | "withdrawal";
|
|
16
16
|
/**
|
|
17
17
|
* What kind of identifier links the receipt to a subject. A cookie-only visitor uses a
|
|
18
18
|
* pseudonymous `cookie` id — the receipt is still valid proof.
|
|
19
19
|
*
|
|
20
|
-
* @since
|
|
20
|
+
* @since 0.5.0-canary.6
|
|
21
21
|
*/
|
|
22
22
|
export type ConsentReceiptSubjectIdType = "cookie" | "email-hash" | "userId";
|
|
23
23
|
/**
|
|
24
24
|
* The caller-supplied fields of a consent receipt. Deliberately carries **no IP** — the
|
|
25
25
|
* server derives a coarsened one from the connection so a full IP never transits the body.
|
|
26
26
|
*
|
|
27
|
-
* @since
|
|
27
|
+
* @since 0.5.0-canary.6
|
|
28
28
|
*/
|
|
29
29
|
export interface ConsentReceiptInput {
|
|
30
30
|
decision: ConsentDecision;
|
|
@@ -49,7 +49,7 @@ export interface ConsentReceiptInput {
|
|
|
49
49
|
* The record is append-only; never mutate a stored receipt. `ipCoarse` is truncated at
|
|
50
50
|
* write time and MUST NOT be a full IP.
|
|
51
51
|
*
|
|
52
|
-
* @since
|
|
52
|
+
* @since 0.5.0-canary.6
|
|
53
53
|
*/
|
|
54
54
|
export interface ConsentReceipt extends ConsentReceiptInput {
|
|
55
55
|
/** Coarsened/pseudonymized IP, or absent — never a full address. */
|
|
@@ -65,7 +65,6 @@ export interface ConsentReceipt extends ConsentReceiptInput {
|
|
|
65
65
|
* Guards a receipt input received from an untrusted client. Rejects a body carrying an
|
|
66
66
|
* `ip`/`ipCoarse` field so a full address can never be persisted from caller input.
|
|
67
67
|
*
|
|
68
|
-
* @since
|
|
68
|
+
* @since 0.5.0-canary.6
|
|
69
69
|
*/
|
|
70
|
-
export declare function isConsentReceiptInput(value: unknown): value is ConsentReceiptInput;
|
|
71
|
-
//# sourceMappingURL=consent-receipt.d.ts.map
|
|
70
|
+
export declare function isConsentReceiptInput(value: unknown): value is ConsentReceiptInput;
|
|
@@ -14,7 +14,7 @@ const RECEIPT_SUBJECT_ID_TYPES = new Set(["cookie", "email-hash", "userId"]);
|
|
|
14
14
|
* Guards a receipt input received from an untrusted client. Rejects a body carrying an
|
|
15
15
|
* `ip`/`ipCoarse` field so a full address can never be persisted from caller input.
|
|
16
16
|
*
|
|
17
|
-
* @since
|
|
17
|
+
* @since 0.5.0-canary.6
|
|
18
18
|
*/
|
|
19
19
|
export function isConsentReceiptInput(value) {
|
|
20
20
|
if (typeof value !== "object" || value === null) {
|
|
@@ -35,5 +35,4 @@ export function isConsentReceiptInput(value) {
|
|
|
35
35
|
isString(input.subjectId) &&
|
|
36
36
|
isString(input.subjectIdType) &&
|
|
37
37
|
RECEIPT_SUBJECT_ID_TYPES.has(input.subjectIdType));
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=consent-receipt.js.map
|
|
38
|
+
}
|
package/dist/core/consent.d.ts
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* The privacy-law region a visitor's consent defaults are resolved for.
|
|
3
|
+
*
|
|
2
4
|
* @since 0.5.0-canary.4
|
|
3
5
|
*/
|
|
4
6
|
export type ConsentRegion = "eu" | "other" | "us" | "vn";
|
|
5
7
|
/**
|
|
6
|
-
*
|
|
8
|
+
* Every consent region, in a stable order shared by guards and iteration.
|
|
9
|
+
*
|
|
10
|
+
* @since 0.5.0-canary.6
|
|
7
11
|
*/
|
|
8
12
|
export declare const CONSENT_REGIONS: ReadonlyArray<ConsentRegion>;
|
|
9
13
|
/**
|
|
10
14
|
* Guards a region read from untrusted storage (a cached `InitialConsent`, a cookie).
|
|
11
15
|
*
|
|
12
|
-
* @since
|
|
16
|
+
* @since 0.5.0-canary.6
|
|
13
17
|
*/
|
|
14
18
|
export declare function isConsentRegion(value: unknown): value is ConsentRegion;
|
|
15
19
|
/**
|
|
20
|
+
* Whether a region requires explicit opt-in before tracking or defaults to opt-out.
|
|
21
|
+
*
|
|
16
22
|
* @since 0.5.0-canary.4
|
|
17
23
|
*/
|
|
18
24
|
export type ConsentMode = "opt-in" | "opt-out";
|
|
@@ -33,6 +39,8 @@ export declare function resolveConsentMode(region: ConsentRegion): ConsentMode;
|
|
|
33
39
|
*/
|
|
34
40
|
export type ConsentCategory = "ads" | "analytics";
|
|
35
41
|
/**
|
|
42
|
+
* Every consent category, in a stable order shared by guards and iteration.
|
|
43
|
+
*
|
|
36
44
|
* @since 0.5.0-canary.4
|
|
37
45
|
*/
|
|
38
46
|
export declare const CONSENT_CATEGORIES: ReadonlyArray<ConsentCategory>;
|
|
@@ -60,17 +68,19 @@ export declare function isConsentDecision(value: unknown): value is ConsentDecis
|
|
|
60
68
|
* dropped, every category becomes an explicit boolean. The one normalization rule every
|
|
61
69
|
* reader of stored consent shares (e.g. `readStoredDecision`).
|
|
62
70
|
*
|
|
63
|
-
* @since
|
|
71
|
+
* @since 0.5.0-canary.6
|
|
64
72
|
*/
|
|
65
73
|
export declare function normalizeConsentDecision(decision: ConsentDecision): ConsentDecision;
|
|
66
74
|
/**
|
|
67
75
|
* Guards a persisted consent record read from untrusted storage (e.g. `localStorage`).
|
|
68
76
|
*
|
|
69
|
-
* @since
|
|
77
|
+
* @since 0.5.0-canary.6
|
|
70
78
|
*/
|
|
71
79
|
export declare function isConsentRecord(value: unknown): value is ConsentRecord;
|
|
72
80
|
/**
|
|
73
|
-
*
|
|
81
|
+
* Options for `resolveDefaultConsent`.
|
|
82
|
+
*
|
|
83
|
+
* @since 0.5.0-canary.6
|
|
74
84
|
*/
|
|
75
85
|
export interface ResolveDefaultConsentOptions {
|
|
76
86
|
/** A "do not sell or share" opt-out — forces `ads` denied under opt-out regions. */
|
|
@@ -98,7 +108,7 @@ export declare function resolveDefaultConsent(options: ResolveDefaultConsentOpti
|
|
|
98
108
|
* `defaultConsent` is the server snapshot — useful when you need request-time `sec-gpc`
|
|
99
109
|
* as-is; analytics-only apps can ignore it because GPC only forces `ads` denied.
|
|
100
110
|
*
|
|
101
|
-
* @since
|
|
111
|
+
* @since 0.5.0-canary.6
|
|
102
112
|
*/
|
|
103
113
|
export interface InitialConsent {
|
|
104
114
|
defaultConsent: ConsentDecision;
|
|
@@ -111,7 +121,7 @@ export interface InitialConsent {
|
|
|
111
121
|
* Prerendered/CDN-cached markup must carry nothing region-specific, and a missing geo
|
|
112
122
|
* header means "unknown visitor", never "known non-EU visitor".
|
|
113
123
|
*
|
|
114
|
-
* @since
|
|
124
|
+
* @since 0.5.0-canary.6
|
|
115
125
|
*/
|
|
116
126
|
export declare const STRICTEST_INITIAL_CONSENT: InitialConsent;
|
|
117
127
|
/**
|
|
@@ -120,7 +130,7 @@ export declare const STRICTEST_INITIAL_CONSENT: InitialConsent;
|
|
|
120
130
|
* {@link STRICTEST_INITIAL_CONSENT}'s own pairing — stricter than the region's usual
|
|
121
131
|
* mode, never looser.
|
|
122
132
|
*
|
|
123
|
-
* @since
|
|
133
|
+
* @since 0.5.0-canary.6
|
|
124
134
|
*/
|
|
125
135
|
export declare function isInitialConsent(value: unknown): value is InitialConsent;
|
|
126
136
|
/**
|
|
@@ -156,11 +166,13 @@ export interface ConsentStorage {
|
|
|
156
166
|
* any tampered extra keys — `undefined` if there is none yet, the record is malformed, or
|
|
157
167
|
* it was recorded under a superseded policy version.
|
|
158
168
|
*
|
|
159
|
-
* @since
|
|
169
|
+
* @since 0.5.0-canary.6
|
|
160
170
|
*/
|
|
161
171
|
export declare function readStoredDecision(storage: ConsentStorage, policyVersion: string): ConsentDecision | undefined;
|
|
162
172
|
/**
|
|
163
|
-
*
|
|
173
|
+
* Options for `resolveEffectiveConsent`.
|
|
174
|
+
*
|
|
175
|
+
* @since 0.5.0-canary.6
|
|
164
176
|
*/
|
|
165
177
|
export interface ResolveEffectiveConsentOptions {
|
|
166
178
|
/** A "do not sell or share" opt-out — forces `ads` denied under opt-out regions. */
|
|
@@ -176,7 +188,6 @@ export interface ResolveEffectiveConsentOptions {
|
|
|
176
188
|
* non-React gate (e.g. a tracker's `isAnalyticsAllowed` option) doesn't have to reimplement
|
|
177
189
|
* "read storage, validate the policy version, fall back to `resolveDefaultConsent`" itself.
|
|
178
190
|
*
|
|
179
|
-
* @since
|
|
191
|
+
* @since 0.5.0-canary.6
|
|
180
192
|
*/
|
|
181
|
-
export declare function resolveEffectiveConsent(options: ResolveEffectiveConsentOptions): ConsentDecision;
|
|
182
|
-
//# sourceMappingURL=consent.d.ts.map
|
|
193
|
+
export declare function resolveEffectiveConsent(options: ResolveEffectiveConsentOptions): ConsentDecision;
|