@gurulu/web 1.0.1 → 1.1.0
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/dist/crypto.d.ts +6 -0
- package/dist/crypto.d.ts.map +1 -0
- package/dist/fingerprint.d.ts +31 -0
- package/dist/fingerprint.d.ts.map +1 -0
- package/dist/react.d.ts +10 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +1431 -0
- package/dist/replay.d.ts +97 -0
- package/dist/replay.d.ts.map +1 -0
- package/package.json +17 -2
package/dist/replay.d.ts
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
export type ReplayCaptureMode = 'always_on' | 'sampled' | 'triggered';
|
|
2
|
+
export interface ReplaySettings {
|
|
3
|
+
capture_mode: ReplayCaptureMode;
|
|
4
|
+
/** 0..1 — only used when capture_mode = 'sampled'. */
|
|
5
|
+
sample_rate: number;
|
|
6
|
+
capture_console: boolean;
|
|
7
|
+
capture_network: boolean;
|
|
8
|
+
capture_custom_events: boolean;
|
|
9
|
+
/** rrweb `maskAllInputs`. */
|
|
10
|
+
privacy_mask_inputs: boolean;
|
|
11
|
+
/** Banner_required → require explicit `consent.replay === true`. */
|
|
12
|
+
consent_required: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface ReplayConsentState {
|
|
15
|
+
/** Explicit replay opt-in. Falsy → if `consent_required` is true, no capture. */
|
|
16
|
+
replay?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export interface ReplayConfig {
|
|
19
|
+
workspaceId: string;
|
|
20
|
+
apiKey: string;
|
|
21
|
+
/** Default: 'https://ingest.gurulu.io'. */
|
|
22
|
+
ingestBaseUrl: string;
|
|
23
|
+
anonymousId: string;
|
|
24
|
+
sessionId: string;
|
|
25
|
+
/** Optional initial consent snapshot. */
|
|
26
|
+
consent?: ReplayConsentState;
|
|
27
|
+
/** SDK version for chunk metadata. */
|
|
28
|
+
sdkVersion?: string;
|
|
29
|
+
/** Default settings override — Agent A backend fetch wires real endpoint here. */
|
|
30
|
+
settingsOverride?: ReplaySettings;
|
|
31
|
+
/** Test seam — settings fetcher (default reads sessionStorage cache + hard-coded defaults). */
|
|
32
|
+
fetchSettings?: () => Promise<ReplaySettings>;
|
|
33
|
+
/** Test seam — transport. */
|
|
34
|
+
fetchImpl?: typeof fetch;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* GuruluReplay — orchestrates rrweb capture + chunk flush. One instance per
|
|
38
|
+
* Gurulu SDK lifecycle; `stop()` on `reset()/logout()`.
|
|
39
|
+
*/
|
|
40
|
+
export declare class GuruluReplay {
|
|
41
|
+
private config;
|
|
42
|
+
private stopFn;
|
|
43
|
+
private buffer;
|
|
44
|
+
private chunkSeq;
|
|
45
|
+
private flushTimer;
|
|
46
|
+
private settings;
|
|
47
|
+
private rrweb;
|
|
48
|
+
private sessionStartedAt;
|
|
49
|
+
private lastChunkEndOffset;
|
|
50
|
+
private hasConsoleError;
|
|
51
|
+
private hasConversion;
|
|
52
|
+
private networkOriginals;
|
|
53
|
+
private consoleOriginals;
|
|
54
|
+
private windowErrorHandler;
|
|
55
|
+
private started;
|
|
56
|
+
private debug;
|
|
57
|
+
constructor(config: ReplayConfig, opts?: {
|
|
58
|
+
debug?: boolean;
|
|
59
|
+
});
|
|
60
|
+
/** Begin capture — async (rrweb dynamic import + settings fetch). Idempotent. */
|
|
61
|
+
start(): Promise<void>;
|
|
62
|
+
/** Annotate a tracked event into the replay stream. */
|
|
63
|
+
annotateCustomEvent(eventName: string, properties: Record<string, unknown>): void;
|
|
64
|
+
/** Mark conversion — next chunk carries `has_conversion: true`. */
|
|
65
|
+
markConversion(): void;
|
|
66
|
+
/** Mark error — next chunk carries `has_console_error: true`. */
|
|
67
|
+
markError(): void;
|
|
68
|
+
/** Stop capture + final flush. */
|
|
69
|
+
stop(): void;
|
|
70
|
+
private shouldCapture;
|
|
71
|
+
private resolveSettings;
|
|
72
|
+
private cachedDefaults;
|
|
73
|
+
private loadRrweb;
|
|
74
|
+
private attachConsoleCapture;
|
|
75
|
+
private detachConsoleCapture;
|
|
76
|
+
private attachNetworkCapture;
|
|
77
|
+
private detachNetworkCapture;
|
|
78
|
+
private flush;
|
|
79
|
+
private warn;
|
|
80
|
+
}
|
|
81
|
+
declare function safeStringify(v: unknown): string;
|
|
82
|
+
/**
|
|
83
|
+
* gzip string → Uint8Array via CompressionStream API. Modern browsers only
|
|
84
|
+
* (Chrome 80+/Firefox 113+/Safari 16.4+). Legacy fallback out of scope.
|
|
85
|
+
*/
|
|
86
|
+
declare function gzipString(input: string): Promise<Uint8Array>;
|
|
87
|
+
declare function base64FromBytes(bytes: Uint8Array): string;
|
|
88
|
+
export declare const __test__: {
|
|
89
|
+
DEFAULT_SETTINGS: ReplaySettings;
|
|
90
|
+
REPLAY_SETTINGS_CACHE_KEY: string;
|
|
91
|
+
REPLAY_SETTINGS_TTL_MS: number;
|
|
92
|
+
gzipString: typeof gzipString;
|
|
93
|
+
base64FromBytes: typeof base64FromBytes;
|
|
94
|
+
safeStringify: typeof safeStringify;
|
|
95
|
+
};
|
|
96
|
+
export {};
|
|
97
|
+
//# sourceMappingURL=replay.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replay.d.ts","sourceRoot":"","sources":["../src/replay.ts"],"names":[],"mappings":"AA2BA,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,SAAS,GAAG,WAAW,CAAC;AAEtE,MAAM,WAAW,cAAc;IAC7B,YAAY,EAAE,iBAAiB,CAAC;IAChC,sDAAsD;IACtD,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,OAAO,CAAC;IACzB,eAAe,EAAE,OAAO,CAAC;IACzB,qBAAqB,EAAE,OAAO,CAAC;IAC/B,6BAA6B;IAC7B,mBAAmB,EAAE,OAAO,CAAC;IAC7B,oEAAoE;IACpE,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAkB;IACjC,iFA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B,uDAAuD;IACvD,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAcjF,mEAAmE;IACnE,cAAc,IAAI,IAAI;IAItB,iEAAiE;IACjE,SAAS,IAAI,IAAI;IAIjB,kCAAkC;IAClC,IAAI,IAAI,IAAI;IAyBZ,OAAO,CAAC,aAAa;YAaP,eAAe;IAY7B,OAAO,CAAC,cAAc;YAgCR,SAAS;IAgBvB,OAAO,CAAC,oBAAoB;IAyC5B,OAAO,CAAC,oBAAoB;IAiB5B,OAAO,CAAC,oBAAoB;IAiG5B,OAAO,CAAC,oBAAoB;YAed,KAAK;IAgEnB,OAAO,CAAC,IAAI;CAWb;AAID,iBAAS,aAAa,CAAC,CAAC,EAAE,OAAO,GAAG,MAAM,CAWzC;AAED;;;GAGG;AACH,iBAAe,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAoB5D;AAED,iBAAS,eAAe,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAalD;AAGD,eAAO,MAAM,QAAQ;;;;;;;CAOpB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gurulu/web",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -28,12 +28,17 @@
|
|
|
28
28
|
"import": "./dist/index.js",
|
|
29
29
|
"default": "./dist/index.js"
|
|
30
30
|
},
|
|
31
|
+
"./react": {
|
|
32
|
+
"types": "./dist/react.d.ts",
|
|
33
|
+
"import": "./dist/react.js",
|
|
34
|
+
"default": "./dist/react.js"
|
|
35
|
+
},
|
|
31
36
|
"./t.js": "./dist/t.js",
|
|
32
37
|
"./package.json": "./package.json"
|
|
33
38
|
},
|
|
34
39
|
"scripts": {
|
|
35
40
|
"build": "rm -rf dist && bun run build:esm && bun run build:cdn && bun run build:types",
|
|
36
|
-
"build:esm": "bun build ./src/index.ts --outdir ./dist --target browser --format=esm",
|
|
41
|
+
"build:esm": "bun build ./src/index.ts ./src/react.ts --outdir ./dist --target browser --format=esm --external react",
|
|
37
42
|
"build:cdn": "bun build ./src/index.ts --outdir ./dist --entry-naming t.js --target browser --minify --sourcemap=external",
|
|
38
43
|
"build:types": "tsc -p tsconfig.build.json",
|
|
39
44
|
"build:dev": "bun build ./src/index.ts --outdir ./dist --target browser",
|
|
@@ -43,7 +48,17 @@
|
|
|
43
48
|
"clean": "rm -rf dist .turbo"
|
|
44
49
|
},
|
|
45
50
|
"dependencies": {},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"react": ">=18"
|
|
53
|
+
},
|
|
54
|
+
"peerDependenciesMeta": {
|
|
55
|
+
"react": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
58
|
+
},
|
|
46
59
|
"devDependencies": {
|
|
60
|
+
"@types/react": "^19.0.0",
|
|
61
|
+
"react": "^19.0.0",
|
|
47
62
|
"typescript": "^5.6.0"
|
|
48
63
|
}
|
|
49
64
|
}
|