@interfere/next 0.0.0-alpha.10 → 0.0.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/README.md +1 -0
- package/dist/__tests__/build/with-interfere-coverage.test.d.ts +2 -0
- package/dist/__tests__/build/with-interfere-coverage.test.d.ts.map +1 -0
- package/dist/__tests__/build/with-interfere-coverage.test.js +338 -0
- package/dist/__tests__/build/with-interfere-coverage.test.js.map +1 -0
- package/dist/__tests__/build/with-interfere.test.d.ts +2 -0
- package/dist/__tests__/build/with-interfere.test.d.ts.map +1 -0
- package/dist/__tests__/build/with-interfere.test.js +466 -0
- package/dist/__tests__/build/with-interfere.test.js.map +1 -0
- package/dist/__tests__/core/client.test.d.ts +2 -0
- package/dist/__tests__/core/client.test.d.ts.map +1 -0
- package/dist/__tests__/core/client.test.js +373 -0
- package/dist/__tests__/core/client.test.js.map +1 -0
- package/dist/__tests__/core/debug.test.d.ts +2 -0
- package/dist/__tests__/core/debug.test.d.ts.map +1 -0
- package/dist/__tests__/core/debug.test.js +277 -0
- package/dist/__tests__/core/debug.test.js.map +1 -0
- package/dist/__tests__/core/encoders.test.d.ts +2 -0
- package/dist/__tests__/core/encoders.test.d.ts.map +1 -0
- package/dist/__tests__/core/encoders.test.js +56 -0
- package/dist/__tests__/core/encoders.test.js.map +1 -0
- package/dist/__tests__/core/persistence.test.d.ts +2 -0
- package/dist/__tests__/core/persistence.test.d.ts.map +1 -0
- package/dist/__tests__/core/persistence.test.js +129 -0
- package/dist/__tests__/core/persistence.test.js.map +1 -0
- package/dist/__tests__/core/rage-click.test.d.ts +2 -0
- package/dist/__tests__/core/rage-click.test.d.ts.map +1 -0
- package/dist/__tests__/core/rage-click.test.js +121 -0
- package/dist/__tests__/core/rage-click.test.js.map +1 -0
- package/dist/__tests__/core/session-manager.test.d.ts +2 -0
- package/dist/__tests__/core/session-manager.test.d.ts.map +1 -0
- package/dist/__tests__/core/session-manager.test.js +1132 -0
- package/dist/__tests__/core/session-manager.test.js.map +1 -0
- package/dist/__tests__/integration/release-upload.test.d.ts +2 -0
- package/dist/__tests__/integration/release-upload.test.d.ts.map +1 -0
- package/dist/__tests__/integration/release-upload.test.js +173 -0
- package/dist/__tests__/integration/release-upload.test.js.map +1 -0
- package/dist/__tests__/react/provider.test.d.ts +2 -0
- package/dist/__tests__/react/provider.test.d.ts.map +1 -0
- package/dist/__tests__/react/provider.test.jsx +166 -0
- package/dist/__tests__/react/provider.test.jsx.map +1 -0
- package/dist/__tests__/session/persistence.test.d.ts +2 -0
- package/dist/__tests__/session/persistence.test.d.ts.map +1 -0
- package/dist/__tests__/session/persistence.test.js +129 -0
- package/dist/__tests__/session/persistence.test.js.map +1 -0
- package/dist/__tests__/session/replay.test.d.ts +2 -0
- package/dist/__tests__/session/replay.test.d.ts.map +1 -0
- package/dist/__tests__/session/replay.test.js +296 -0
- package/dist/__tests__/session/replay.test.js.map +1 -0
- package/dist/__tests__/session/session-summary.test.d.ts +2 -0
- package/dist/__tests__/session/session-summary.test.d.ts.map +1 -0
- package/dist/__tests__/session/session-summary.test.js +763 -0
- package/dist/__tests__/session/session-summary.test.js.map +1 -0
- package/dist/build/index.d.ts +3 -0
- package/dist/build/index.d.ts.map +1 -0
- package/dist/build/index.js +2 -0
- package/dist/build/index.js.map +1 -0
- package/dist/build/with-interfere.d.ts +54 -0
- package/dist/build/with-interfere.d.ts.map +1 -0
- package/dist/build/with-interfere.js +267 -0
- package/dist/build/with-interfere.js.map +1 -0
- package/dist/core/client-core.d.ts +27 -0
- package/dist/core/client-core.d.ts.map +1 -0
- package/dist/core/client-core.js +164 -0
- package/dist/core/client-core.js.map +1 -0
- package/dist/core/client.d.ts +70 -18
- package/dist/core/client.d.ts.map +1 -1
- package/dist/core/client.js +112 -104
- package/dist/core/client.js.map +1 -1
- package/dist/core/client.test.js +227 -92
- package/dist/core/client.test.js.map +1 -1
- package/dist/core/constants.d.ts +12 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/constants.js +17 -0
- package/dist/core/constants.js.map +1 -0
- package/dist/core/debug.d.ts +47 -0
- package/dist/core/debug.d.ts.map +1 -0
- package/dist/core/debug.js +79 -0
- package/dist/core/debug.js.map +1 -0
- package/dist/core/encoders.test.js +20 -19
- package/dist/core/encoders.test.js.map +1 -1
- package/dist/core/error-handlers.d.ts.map +1 -1
- package/dist/core/error-handlers.js +42 -41
- package/dist/core/error-handlers.js.map +1 -1
- package/dist/core/runtime.d.ts +7 -0
- package/dist/core/runtime.d.ts.map +1 -0
- package/dist/core/runtime.js +16 -0
- package/dist/core/runtime.js.map +1 -0
- package/dist/index.d.ts +10 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -7
- package/dist/index.js.map +1 -1
- package/dist/next/error-boundary.d.ts +5 -5
- package/dist/next/error-boundary.d.ts.map +1 -1
- package/dist/next/error-boundary.jsx +5 -5
- package/dist/next/middleware.d.ts +1 -1
- package/dist/next/middleware.js +13 -13
- package/dist/persistence/index.d.ts +5 -0
- package/dist/persistence/index.d.ts.map +1 -0
- package/dist/persistence/index.js +67 -0
- package/dist/persistence/index.js.map +1 -0
- package/dist/persistence/storage.d.ts +5 -0
- package/dist/persistence/storage.d.ts.map +1 -0
- package/dist/persistence/storage.js +67 -0
- package/dist/persistence/storage.js.map +1 -0
- package/dist/react/provider.d.ts +9 -5
- package/dist/react/provider.d.ts.map +1 -1
- package/dist/react/provider.jsx +33 -10
- package/dist/react/provider.jsx.map +1 -1
- package/dist/session/constants.d.ts +19 -0
- package/dist/session/constants.d.ts.map +1 -0
- package/dist/session/constants.js +34 -0
- package/dist/session/constants.js.map +1 -0
- package/dist/session/persistence.d.ts +58 -0
- package/dist/session/persistence.d.ts.map +1 -0
- package/dist/session/persistence.js +180 -0
- package/dist/session/persistence.js.map +1 -0
- package/dist/session/persistence.test.d.ts +2 -0
- package/dist/session/persistence.test.d.ts.map +1 -0
- package/dist/session/persistence.test.js +129 -0
- package/dist/session/persistence.test.js.map +1 -0
- package/dist/session/rage-click.d.ts +17 -0
- package/dist/session/rage-click.d.ts.map +1 -0
- package/dist/session/rage-click.js +104 -0
- package/dist/session/rage-click.js.map +1 -0
- package/dist/session/rage-click.test.d.ts +2 -0
- package/dist/session/rage-click.test.d.ts.map +1 -0
- package/dist/session/rage-click.test.js +124 -0
- package/dist/session/rage-click.test.js.map +1 -0
- package/dist/session/replay.d.ts +2 -2
- package/dist/session/replay.d.ts.map +1 -1
- package/dist/session/replay.js +57 -24
- package/dist/session/replay.js.map +1 -1
- package/dist/session/session-manager.d.ts +126 -0
- package/dist/session/session-manager.d.ts.map +1 -0
- package/dist/session/session-manager.js +635 -0
- package/dist/session/session-manager.js.map +1 -0
- package/dist/session/session-manager.test.d.ts +2 -0
- package/dist/session/session-manager.test.d.ts.map +1 -0
- package/dist/session/session-manager.test.js +1134 -0
- package/dist/session/session-manager.test.js.map +1 -0
- package/dist/session/session-summary.d.ts +2 -2
- package/dist/session/session-summary.d.ts.map +1 -1
- package/dist/session/session-summary.js +94 -47
- package/dist/session/session-summary.js.map +1 -1
- package/dist/storage/index.d.ts +5 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +67 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/types/storage.d.ts +7 -0
- package/dist/types/storage.d.ts.map +1 -0
- package/dist/types/storage.js +2 -0
- package/dist/types/storage.js.map +1 -0
- package/package.json +24 -7
package/dist/core/client.d.ts
CHANGED
|
@@ -1,23 +1,75 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Public API for Interfere SDK
|
|
3
|
+
*
|
|
4
|
+
* This module manages the singleton instance and provides
|
|
5
|
+
* the public-facing functions for the SDK.
|
|
6
|
+
*/
|
|
7
|
+
import type { InitConfig } from "@interfere/schemas/config";
|
|
8
|
+
import type { EventType } from "@interfere/schemas/envelope";
|
|
9
|
+
import { InterfereClient } from "./client-core.js";
|
|
10
|
+
/**
|
|
11
|
+
* Initialize the Interfere SDK
|
|
12
|
+
*
|
|
13
|
+
* @param props - Configuration including surface ID and options
|
|
14
|
+
* @returns The initialized client instance
|
|
15
|
+
* @throws Error if surface is not provided or buildId/releaseId are missing
|
|
16
|
+
*/
|
|
18
17
|
export declare const init: (props: InitConfig) => InterfereClient;
|
|
18
|
+
/**
|
|
19
|
+
* Capture an event
|
|
20
|
+
*
|
|
21
|
+
* @param type - The type of event to capture
|
|
22
|
+
* @param payload - The event payload
|
|
23
|
+
* @throws Error if SDK is not initialized
|
|
24
|
+
*/
|
|
19
25
|
export declare const capture: (type: EventType, payload: unknown) => void;
|
|
26
|
+
/**
|
|
27
|
+
* Flush any pending events immediately
|
|
28
|
+
*/
|
|
20
29
|
export declare const flush: () => void;
|
|
30
|
+
/**
|
|
31
|
+
* Get the current session ID
|
|
32
|
+
*
|
|
33
|
+
* @returns The current session ID
|
|
34
|
+
* @throws Error if SDK is not initialized
|
|
35
|
+
*/
|
|
21
36
|
export declare const getSessionId: () => string;
|
|
22
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Get the current window ID
|
|
39
|
+
*
|
|
40
|
+
* @returns The current window ID
|
|
41
|
+
* @throws Error if SDK is not initialized
|
|
42
|
+
*/
|
|
43
|
+
export declare const getWindowId: () => string;
|
|
44
|
+
/**
|
|
45
|
+
* Subscribe to session ID changes
|
|
46
|
+
*
|
|
47
|
+
* @param callback - Callback to invoke when session ID changes
|
|
48
|
+
* @returns Unsubscribe function
|
|
49
|
+
* @throws Error if SDK is not initialized
|
|
50
|
+
*/
|
|
51
|
+
export declare const onSessionId: (callback: (sessionId: string | null, windowId: string | null) => void) => (() => void);
|
|
52
|
+
/**
|
|
53
|
+
* Reset the current session
|
|
54
|
+
*
|
|
55
|
+
* @throws Error if SDK is not initialized
|
|
56
|
+
*/
|
|
57
|
+
export declare const resetSession: () => void;
|
|
58
|
+
/**
|
|
59
|
+
* Get debug information (development only)
|
|
60
|
+
*
|
|
61
|
+
* @returns Debug information about the current SDK state
|
|
62
|
+
* @throws Error if SDK is not initialized
|
|
63
|
+
*/
|
|
64
|
+
export declare const getDebugInfo: () => import("./debug.js").DebugInfo;
|
|
65
|
+
/**
|
|
66
|
+
* Get the current client instance
|
|
67
|
+
*
|
|
68
|
+
* @returns The current client instance or null if not initialized
|
|
69
|
+
*/
|
|
70
|
+
export declare const getInstance: () => InterfereClient | null;
|
|
71
|
+
/**
|
|
72
|
+
* Destroy the SDK instance and clean up resources
|
|
73
|
+
*/
|
|
74
|
+
export declare const destroy: () => void;
|
|
23
75
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/core/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAKnD;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,GAAI,OAAO,UAAU,KAAG,eA6BxC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,GAAI,MAAM,SAAS,EAAE,SAAS,OAAO,KAAG,IAK3D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,KAAK,QAAO,IAExB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,QAAO,MAK/B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,QAAO,MAK9B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GACtB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,KACpE,CAAC,MAAM,IAAI,CAKb,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,YAAY,QAAO,IAK/B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,sCAKxB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,QAAO,eAAe,GAAG,IAEhD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,QAAO,IAK1B,CAAC"}
|
package/dist/core/client.js
CHANGED
|
@@ -1,125 +1,133 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
seq = 0;
|
|
10
|
-
sessionId;
|
|
11
|
-
runtime;
|
|
12
|
-
flushTimer;
|
|
13
|
-
constructor({ surface, options }) {
|
|
14
|
-
this.runtime = this.detectRuntime();
|
|
15
|
-
this.sessionId = options?.sessionId || this.generateSessionId();
|
|
16
|
-
this.surface = surface;
|
|
17
|
-
const { success, data, error } = configSchema.safeParse(options ?? {});
|
|
18
|
-
if (!success) {
|
|
19
|
-
throw new Error(`[Interfere] invalid config: ${error.message}`);
|
|
20
|
-
}
|
|
21
|
-
this.config = data;
|
|
22
|
-
if (this.runtime === 'client') {
|
|
23
|
-
this.startFlushTimer();
|
|
24
|
-
if (typeof window !== 'undefined') {
|
|
25
|
-
window.addEventListener('beforeunload', () => this.flush());
|
|
26
|
-
}
|
|
27
|
-
// Set up client error handlers
|
|
28
|
-
setupClientErrorHandlers();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
detectRuntime() {
|
|
32
|
-
if (typeof window !== 'undefined') {
|
|
33
|
-
return 'client';
|
|
34
|
-
}
|
|
35
|
-
if (typeof globalThis !== 'undefined' && 'EdgeRuntime' in globalThis) {
|
|
36
|
-
return 'edge';
|
|
37
|
-
}
|
|
38
|
-
return 'server';
|
|
39
|
-
}
|
|
40
|
-
generateSessionId() {
|
|
41
|
-
return nanoid();
|
|
42
|
-
}
|
|
43
|
-
startFlushTimer() {
|
|
44
|
-
this.flushTimer = setInterval(() => this.flush(), this.config.flushInterval);
|
|
45
|
-
}
|
|
46
|
-
capture(type, payload) {
|
|
47
|
-
const envelope = {
|
|
48
|
-
v: 0,
|
|
49
|
-
runtime: this.runtime,
|
|
50
|
-
surface: this.surface,
|
|
51
|
-
...this.config,
|
|
52
|
-
clientTs: Date.now(),
|
|
53
|
-
sessionId: this.sessionId,
|
|
54
|
-
seq: ++this.seq,
|
|
55
|
-
type,
|
|
56
|
-
payload: Array.from(encode(payload)),
|
|
57
|
-
};
|
|
58
|
-
this.queue.push(envelope);
|
|
59
|
-
if (this.runtime !== 'client' || this.queue.length >= 10) {
|
|
60
|
-
this.flush();
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
flush() {
|
|
64
|
-
if (this.queue.length === 0) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const batch = [...this.queue];
|
|
68
|
-
this.queue = [];
|
|
69
|
-
const body = JSON.stringify(batch);
|
|
70
|
-
const headers = new Headers({
|
|
71
|
-
'Content-Type': 'application/json',
|
|
72
|
-
'x-interfere-surface': this.surface,
|
|
73
|
-
});
|
|
74
|
-
if (this.runtime === 'client' &&
|
|
75
|
-
typeof window !== 'undefined' &&
|
|
76
|
-
typeof window.navigator?.sendBeacon === 'function') {
|
|
77
|
-
// sendBeacon doesn't support custom headers, so we need to use fetch
|
|
78
|
-
// with keepalive for reliability
|
|
79
|
-
fetch(this.config.endpoint, {
|
|
80
|
-
method: 'POST',
|
|
81
|
-
headers,
|
|
82
|
-
body,
|
|
83
|
-
keepalive: true,
|
|
84
|
-
}).catch(() => {
|
|
85
|
-
// Silently fail - don't capture SDK's own errors to prevent loops
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
fetch(this.config.endpoint, {
|
|
90
|
-
method: 'POST',
|
|
91
|
-
headers,
|
|
92
|
-
body,
|
|
93
|
-
}).catch(() => {
|
|
94
|
-
// Silently fail - don't capture SDK's own errors to prevent loops
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
getSessionId() {
|
|
99
|
-
return this.sessionId;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Public API for Interfere SDK
|
|
3
|
+
*
|
|
4
|
+
* This module manages the singleton instance and provides
|
|
5
|
+
* the public-facing functions for the SDK.
|
|
6
|
+
*/
|
|
7
|
+
import { InterfereClient } from "./client-core.js";
|
|
8
|
+
// Singleton instance
|
|
102
9
|
let instance = null;
|
|
10
|
+
/**
|
|
11
|
+
* Initialize the Interfere SDK
|
|
12
|
+
*
|
|
13
|
+
* @param props - Configuration including surface ID and options
|
|
14
|
+
* @returns The initialized client instance
|
|
15
|
+
* @throws Error if surface is not provided or buildId/releaseId are missing
|
|
16
|
+
*/
|
|
103
17
|
export const init = (props) => {
|
|
104
18
|
if (!props.surface) {
|
|
105
|
-
throw new Error(
|
|
19
|
+
throw new Error("[Interfere] surface is required");
|
|
20
|
+
}
|
|
21
|
+
// Validate required fields early
|
|
22
|
+
const hasBuildId = props.options?.buildId || process.env?.NEXT_PUBLIC_INTERFERE_BUILD_ID;
|
|
23
|
+
if (!hasBuildId) {
|
|
24
|
+
throw new Error("[Interfere] buildId is required. Provide it in options or set NEXT_PUBLIC_INTERFERE_BUILD_ID");
|
|
25
|
+
}
|
|
26
|
+
const hasReleaseId = props.options?.releaseId || process.env?.NEXT_PUBLIC_INTERFERE_RELEASE_ID;
|
|
27
|
+
if (!hasReleaseId) {
|
|
28
|
+
throw new Error("[Interfere] releaseId is required. Provide it in options or set NEXT_PUBLIC_INTERFERE_RELEASE_ID");
|
|
29
|
+
}
|
|
30
|
+
// Clean up existing instance if any
|
|
31
|
+
if (instance) {
|
|
32
|
+
instance.destroy();
|
|
106
33
|
}
|
|
107
34
|
instance = new InterfereClient(props);
|
|
108
35
|
return instance;
|
|
109
36
|
};
|
|
37
|
+
/**
|
|
38
|
+
* Capture an event
|
|
39
|
+
*
|
|
40
|
+
* @param type - The type of event to capture
|
|
41
|
+
* @param payload - The event payload
|
|
42
|
+
* @throws Error if SDK is not initialized
|
|
43
|
+
*/
|
|
110
44
|
export const capture = (type, payload) => {
|
|
111
45
|
if (!instance) {
|
|
112
|
-
throw new Error(
|
|
46
|
+
throw new Error("[Interfere] Not initialized. Call init() first");
|
|
113
47
|
}
|
|
114
48
|
instance.capture(type, payload);
|
|
115
49
|
};
|
|
50
|
+
/**
|
|
51
|
+
* Flush any pending events immediately
|
|
52
|
+
*/
|
|
116
53
|
export const flush = () => {
|
|
117
54
|
instance?.flush();
|
|
118
55
|
};
|
|
56
|
+
/**
|
|
57
|
+
* Get the current session ID
|
|
58
|
+
*
|
|
59
|
+
* @returns The current session ID
|
|
60
|
+
* @throws Error if SDK is not initialized
|
|
61
|
+
*/
|
|
119
62
|
export const getSessionId = () => {
|
|
120
63
|
if (!instance) {
|
|
121
|
-
throw new Error(
|
|
64
|
+
throw new Error("[Interfere] Not initialized. Call init() first");
|
|
122
65
|
}
|
|
123
66
|
return instance.getSessionId();
|
|
124
67
|
};
|
|
68
|
+
/**
|
|
69
|
+
* Get the current window ID
|
|
70
|
+
*
|
|
71
|
+
* @returns The current window ID
|
|
72
|
+
* @throws Error if SDK is not initialized
|
|
73
|
+
*/
|
|
74
|
+
export const getWindowId = () => {
|
|
75
|
+
if (!instance) {
|
|
76
|
+
throw new Error("[Interfere] Not initialized. Call init() first");
|
|
77
|
+
}
|
|
78
|
+
return instance.getWindowId();
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Subscribe to session ID changes
|
|
82
|
+
*
|
|
83
|
+
* @param callback - Callback to invoke when session ID changes
|
|
84
|
+
* @returns Unsubscribe function
|
|
85
|
+
* @throws Error if SDK is not initialized
|
|
86
|
+
*/
|
|
87
|
+
export const onSessionId = (callback) => {
|
|
88
|
+
if (!instance) {
|
|
89
|
+
throw new Error("[Interfere] Not initialized. Call init() first");
|
|
90
|
+
}
|
|
91
|
+
return instance.onSessionId(callback);
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Reset the current session
|
|
95
|
+
*
|
|
96
|
+
* @throws Error if SDK is not initialized
|
|
97
|
+
*/
|
|
98
|
+
export const resetSession = () => {
|
|
99
|
+
if (!instance) {
|
|
100
|
+
throw new Error("[Interfere] Not initialized. Call init() first");
|
|
101
|
+
}
|
|
102
|
+
instance.resetSession();
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* Get debug information (development only)
|
|
106
|
+
*
|
|
107
|
+
* @returns Debug information about the current SDK state
|
|
108
|
+
* @throws Error if SDK is not initialized
|
|
109
|
+
*/
|
|
110
|
+
export const getDebugInfo = () => {
|
|
111
|
+
if (!instance) {
|
|
112
|
+
throw new Error("[Interfere] Not initialized. Call init() first");
|
|
113
|
+
}
|
|
114
|
+
return instance.getDebugInfo();
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Get the current client instance
|
|
118
|
+
*
|
|
119
|
+
* @returns The current client instance or null if not initialized
|
|
120
|
+
*/
|
|
121
|
+
export const getInstance = () => {
|
|
122
|
+
return instance;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Destroy the SDK instance and clean up resources
|
|
126
|
+
*/
|
|
127
|
+
export const destroy = () => {
|
|
128
|
+
if (instance) {
|
|
129
|
+
instance.destroy();
|
|
130
|
+
instance = null;
|
|
131
|
+
}
|
|
132
|
+
};
|
|
125
133
|
//# sourceMappingURL=client.js.map
|
package/dist/core/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/core/client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