@sheeptrack/web 0.2.1 → 0.5.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.
@@ -1,9 +0,0 @@
1
- import type { BannerArgs, ConsentCfg } from './ctx.js';
2
- /** [r, g, b] of a #rrggbb or a computed rgb()/rgba() colour; null when unknown or (almost) transparent. */
3
- export declare const rgb: (c?: string | null) => number[] | null;
4
- /** Look of the host page (font, text and background colours, its first button) so the banner fits the site without settings. */
5
- export declare function pageTheme(): Record<string, string>;
6
- /** Small floating "Manage my cookies" button, so a choice can be changed or withdrawn at any time (FR-CMP-07). */
7
- export declare function manage(cfg: ConsentCfg, onOpen: () => void): () => void;
8
- /** Consent banner in a Shadow DOM, fixed-position overlay (no layout shift). Texts are set with textContent only. */
9
- export declare function show({ cfg, current, onChoice, onClose }: BannerArgs): () => void;
@@ -1,30 +0,0 @@
1
- import type { ConsentCategory, ConsentState, RemoteConfig } from '@sheeptrack/protocol';
2
- export type Choices = Partial<Record<ConsentCategory, boolean>>;
3
- export type ConsentCfg = NonNullable<RemoteConfig['consent']>;
4
- /** What the lazy replay module receives from the core (it never imports the core). */
5
- export interface ReplayCtx {
6
- cfg: RemoteConfig['replay'];
7
- sessionId(): string;
8
- distinctId(): string;
9
- consent(): ConsentState;
10
- nextSeq(): number;
11
- dropParams: string[];
12
- /** Resolves with the final HTTP status (0 = gave up). */
13
- post(sid: string, seq: number, json: string): Promise<number>;
14
- /** false when the browser refused it (size limit): the chunk is kept for a later POST. */
15
- beacon(sid: string, seq: number, json: string): boolean;
16
- }
17
- export interface ReplayHandle {
18
- stop(): void;
19
- pause(): void;
20
- resume(): void;
21
- beacon(): void;
22
- }
23
- export interface BannerArgs {
24
- cfg: ConsentCfg;
25
- /** Current choices when reopened through consent.open(). */
26
- current: Choices | null;
27
- onChoice(c: Choices): void;
28
- /** Banner removed, with or without a choice (Escape = no choice recorded). */
29
- onClose(): void;
30
- }
@@ -1,17 +0,0 @@
1
- type Capture = (name: string, props: Record<string, unknown>) => void;
2
- export interface DebugOpts {
3
- errors: boolean;
4
- network: boolean;
5
- console: string[] | false;
6
- vitals: boolean;
7
- drop: () => string[];
8
- host: string;
9
- release?: string;
10
- /** Called with the fingerprint and type of each captured $error (error clicks). */
11
- onError?: (e: {
12
- fingerprint: string;
13
- type: string;
14
- }) => void;
15
- }
16
- export declare function installDebug(capture: Capture, o: DebugOpts, onNav: (cb: () => void) => void): void;
17
- export {};
@@ -1,21 +0,0 @@
1
- export interface FlagsCtx {
2
- json(path: string, body?: unknown): Promise<any>;
3
- id(): string;
4
- props(): Record<string, unknown>;
5
- /** Cache read/write (the write is a no-op without analytics consent). */
6
- load(): string | null;
7
- save(v: string): void;
8
- capture(name: string, p: Record<string, unknown>): void;
9
- key: string;
10
- env?: string;
11
- pollMs: number;
12
- canPost(): boolean;
13
- }
14
- export declare function createFlags(c: FlagsCtx): {
15
- isEnabled: (k: string) => boolean;
16
- getVariant: (k: string) => string | undefined;
17
- getPayload: (k: string) => unknown;
18
- reload: () => Promise<void>;
19
- onChange(cb: () => void): () => void;
20
- reset(): void;
21
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,47 +0,0 @@
1
- /** Copy of the protocol type so the published .d.ts does not import the private workspace package. */
2
- export type ConsentCategory = 'necessary' | 'analytics' | 'replay' | 'personalization' | 'marketing';
3
- export type ConsentChoices = Partial<Record<ConsentCategory, boolean>>;
4
- export interface InitOptions {
5
- host: string;
6
- /** Default: the project's "default environment" setting. */
7
- environment?: 'prod' | 'dev';
8
- /** App version, sent as `app_version` and with every `$error`. */
9
- release?: string;
10
- autocapture?: boolean;
11
- pageviews?: boolean;
12
- errors?: boolean;
13
- network?: boolean;
14
- vitals?: boolean;
15
- frustration?: boolean;
16
- /** Console levels captured. Default warn+error: console.log often carries personal data. */
17
- console?: ('log' | 'info' | 'warn' | 'error' | 'debug')[] | false;
18
- /** Extra query params stripped from every URL we record. */
19
- sensitiveParams?: string[];
20
- batchInterval?: number;
21
- batchSize?: number;
22
- flagsPollMs?: number;
23
- }
24
- export declare function init(publicKey: string, options: InitOptions): void;
25
- export declare function track(event: string, p?: Record<string, unknown>): void;
26
- export declare function identify(userId_: string, t?: Record<string, unknown>): void;
27
- export declare function reset(): void;
28
- export declare const optIn: (cats?: ConsentCategory[]) => void;
29
- export declare const optOut: () => void;
30
- export declare const consent: {
31
- open: () => Promise<void>;
32
- /** The visitor's choice per category, or null while there is none (or it expired, or the policy version changed). */
33
- get: () => ConsentChoices | null;
34
- /** Called with consent.get() each time it changes; returns the unsubscribe function. */
35
- onChange: (cb: (c: ConsentChoices | null) => void) => () => void;
36
- };
37
- export declare const replay: {
38
- pause(): void;
39
- resume(): void;
40
- };
41
- export declare const flags: {
42
- isEnabled: (k: string) => boolean;
43
- getVariant: (k: string) => string | undefined;
44
- getPayload: (k: string) => unknown;
45
- reload: () => Promise<void> | undefined;
46
- onChange: (cb: () => void) => () => void;
47
- };
@@ -1,4 +0,0 @@
1
- import type { ReplayCtx, ReplayHandle } from './ctx.js';
2
- /** srcset parsed as the HTML spec does (URL up to whitespace, descriptors up to the next comma, with or without a space), each URL cleaned. */
3
- export declare function cleanSrcset(v: string, drop: string[]): string;
4
- export declare function start(ctx: ReplayCtx): ReplayHandle;
@@ -1,9 +0,0 @@
1
- export declare const SENSITIVE_PARAMS: string[];
2
- export declare function uuid7(): string;
3
- export declare const trunc: (s: unknown, n: number) => string;
4
- /** Absolute URL without credentials, sensitive query params, or a hash that is not a plain route. */
5
- export declare function cleanUrl(u: string, drop: string[]): string;
6
- /** Short CSS path (max 4 levels, tag + #id or first plain class). Never uses text content. */
7
- export declare function selector(el: Element): string;
8
- /** gzip when CompressionStream exists; text/plain avoids the CORS preflight. */
9
- export declare function pack(s: string): Promise<Blob>;