@sheeptrack/web 0.5.0 → 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.
- package/CHANGELOG.md +5 -0
- package/package.json +1 -1
- package/dist/consent.js +0 -26
- package/dist/esm/chunk-NGXLVBOU.js +0 -1
- package/dist/esm/consent.js +0 -26
- package/dist/esm/index.js +0 -2
- package/dist/esm/replay.js +0 -53
- package/dist/replay.js +0 -53
- package/dist/sheeptrack.js +0 -2
- package/dist/types/autocapture.d.ts +0 -15
- package/dist/types/consent.d.ts +0 -11
- package/dist/types/ctx.d.ts +0 -30
- package/dist/types/debug.d.ts +0 -25
- package/dist/types/flags.d.ts +0 -21
- package/dist/types/iife.d.ts +0 -1
- package/dist/types/index.d.ts +0 -47
- package/dist/types/replay.d.ts +0 -21
- package/dist/types/util.d.ts +0 -9
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
type Capture = (name: string, props: Record<string, unknown>) => void;
|
|
2
|
-
/** Clicks: $autocapture (heatmaps, data-pt-event), $rageclick, $deadclick, $errorclick. Never records text.
|
|
3
|
-
* Returns the hook the error capture calls with each $error's fingerprint/type. */
|
|
4
|
-
export declare function installClicks(capture: Capture, onNav: (cb: () => void) => void, o: {
|
|
5
|
-
frustration: boolean;
|
|
6
|
-
}): (err: Record<string, unknown>) => void;
|
|
7
|
-
/**
|
|
8
|
-
* One $scroll_depth per page view (heatmaps, FR-RPW-15): max depth as % of document height. A tab that goes to the background is
|
|
9
|
-
* reported at once (it may never come back: mobile browsers kill it without pagehide); if the reader returns and goes deeper, the
|
|
10
|
-
* next report (`resumed: true`) carries the new max, and nothing is sent again while the max has not grown.
|
|
11
|
-
* `pageUrl` = URL of the current page view: on popstate the browser has already moved to the next page when the hook runs, so the
|
|
12
|
-
* report of the page left uses it and the last measures, never the live location / document.
|
|
13
|
-
*/
|
|
14
|
-
export declare function installScroll(capture: Capture, onNav: (cb: (popped?: boolean) => void) => void, pageUrl: () => string | undefined): void;
|
|
15
|
-
export {};
|
package/dist/types/consent.d.ts
DELETED
|
@@ -1,11 +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
|
-
/** Text colour with the better contrast on `c`: black and white are equally good at a relative luminance of about 0.179, not 0.4. Names (yellow) are resolved by the browser. */
|
|
5
|
-
export declare const onColor: (c: string) => "#000" | "#fff";
|
|
6
|
-
/** Look of the host page (font, text and background colours, its first button) so the banner fits the site without settings. */
|
|
7
|
-
export declare function pageTheme(): Record<string, string>;
|
|
8
|
-
/** Small floating "Manage my cookies" button, so a choice can be changed or withdrawn at any time (FR-CMP-07). */
|
|
9
|
-
export declare function manage(cfg: ConsentCfg, onOpen: () => void): () => void;
|
|
10
|
-
/** Consent banner in a Shadow DOM, fixed-position overlay (no layout shift). Texts are set with textContent only. */
|
|
11
|
-
export declare function show({ cfg, current, onChoice, onClose }: BannerArgs): () => void;
|
package/dist/types/ctx.d.ts
DELETED
|
@@ -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). body: JSON, or a Blob already packed (gzip). */
|
|
13
|
-
post(sid: string, seq: number, body: string | Blob): 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, body: string | Blob): 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
|
-
}
|
package/dist/types/debug.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
type Capture = (name: string, props: Record<string, unknown>) => void;
|
|
2
|
-
export interface DebugOpts {
|
|
3
|
-
errors: boolean;
|
|
4
|
-
network: boolean;
|
|
5
|
-
vitals: boolean;
|
|
6
|
-
/** Console levels to capture, read on every call: the project's remote config can change them after init. */
|
|
7
|
-
console: () => readonly string[] | false;
|
|
8
|
-
drop: () => string[];
|
|
9
|
-
host: string;
|
|
10
|
-
release?: string;
|
|
11
|
-
/** Called with the fingerprint and type of each captured $error (error clicks). */
|
|
12
|
-
onError?: (e: {
|
|
13
|
-
fingerprint: string;
|
|
14
|
-
type: string;
|
|
15
|
-
}) => void;
|
|
16
|
-
}
|
|
17
|
-
/** One stack-trace line (V8 `at fn (url:1:2)`, Firefox/Safari `fn@url:1:2`, Dart `#0 fn (url:1:2)`) as `function|path`; '' if it is not a frame. */
|
|
18
|
-
export declare function normalizeStackFrame(line: string): string;
|
|
19
|
-
/** The first `max` frame lines of a stack (the `Type: message` header and anything not shaped like a frame are skipped). */
|
|
20
|
-
export declare const stackFrames: (stack: string, max: number) => string[];
|
|
21
|
-
/** Error message without what varies between occurrences or builds: numbers, hex addresses, URL origin/query and bundle hashes. */
|
|
22
|
-
export declare function normalizeErrorMessage(message: string): string;
|
|
23
|
-
/** Returns `syncConsole`, to call when the console levels may have changed (remote config loaded). */
|
|
24
|
-
export declare function installDebug(capture: Capture, o: DebugOpts, onNav: (cb: () => void) => void): () => void;
|
|
25
|
-
export {};
|
package/dist/types/flags.d.ts
DELETED
|
@@ -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
|
-
};
|
package/dist/types/iife.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/types/index.d.ts
DELETED
|
@@ -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. When omitted, the project setting applies (remote config), else 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
|
-
};
|
package/dist/types/replay.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { ReplayCtx, ReplayHandle } from './ctx.js';
|
|
2
|
-
/**
|
|
3
|
-
* A full snapshot at most every 2 min: the player seeks from the last one instead of replaying the session from its start.
|
|
4
|
-
* rrweb checks the delay on each incremental event, so an idle page gets its checkpoint with its next event, not on a clock
|
|
5
|
-
* (nothing happened in between: the seek has nothing to replay there).
|
|
6
|
-
*/
|
|
7
|
-
export declare const CHECKOUT_MS = 120000;
|
|
8
|
-
/** 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. */
|
|
9
|
-
export declare function cleanSrcset(v: string, drop: string[]): string;
|
|
10
|
-
/**
|
|
11
|
-
* Top window: merge the iframes that send their events. Framed page: rrweb would post every event to window.parent
|
|
12
|
-
* with targetOrigin '*', so only do it when the parent's origin is verified and explicitly allowed; otherwise record on its own.
|
|
13
|
-
* Only location.ancestorOrigins names the actual parent; document.referrer is the page that started the navigation, which
|
|
14
|
-
* can differ from the embedding one, so where ancestorOrigins is missing (Firefox) the frame records separately.
|
|
15
|
-
*/
|
|
16
|
-
export declare function crossOriginIframes(cfg: ReplayCtx['cfg'], w?: Window): boolean;
|
|
17
|
-
/** Splits off a trailing rrweb Meta (type 4) so it travels with the FullSnapshot that follows it; a lone Meta is sent as is. */
|
|
18
|
-
export declare function holdTrailingMeta<E extends {
|
|
19
|
-
type: number;
|
|
20
|
-
}>(events: E[]): [E[], E | undefined];
|
|
21
|
-
export declare function start(ctx: ReplayCtx): ReplayHandle;
|
package/dist/types/util.d.ts
DELETED
|
@@ -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 (the server detects it by its magic bytes); text/plain avoids the CORS preflight. A Blob is already packed. */
|
|
9
|
-
export declare function pack(s: string | Blob): Promise<Blob>;
|