@brainfish-ai/web-tracker 0.0.5-beta.1 → 0.0.5-beta.3
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/index.cjs.js +11 -11
- package/dist/index.cjs.js.gz +0 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +652 -602
- package/dist/index.js.gz +0 -0
- package/dist/index.js.map +1 -1
- package/dist/src/index.d.ts +8 -0
- package/dist/src/record/index.d.ts +1 -0
- package/dist/src/record/recorder.d.ts +1 -0
- package/dist/src/session/sessionManager.d.ts +33 -0
- package/package.json +2 -2
package/dist/src/index.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export declare class Tracker extends TrackerSdk {
|
|
|
12
12
|
options: TrackerOptions;
|
|
13
13
|
private lastPath;
|
|
14
14
|
private debounceTimer;
|
|
15
|
+
private readonly agent;
|
|
16
|
+
private readonly sessionManager;
|
|
15
17
|
constructor(options: TrackerOptions);
|
|
16
18
|
private debounce;
|
|
17
19
|
private isServer;
|
|
@@ -21,4 +23,10 @@ export declare class Tracker extends TrackerSdk {
|
|
|
21
23
|
startRecording(): void;
|
|
22
24
|
screenView(properties?: TrackProperties): Promise<void>;
|
|
23
25
|
screenView(path: string, properties?: TrackProperties): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* Handles recording events to the server and manages session state transitions.
|
|
28
|
+
* @param events Array of events to be recorded
|
|
29
|
+
* @returns Promise that resolves when events are recorded and session is managed
|
|
30
|
+
*/
|
|
31
|
+
private recordEventsToServer;
|
|
24
32
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type SessionCallbacks = {
|
|
2
|
+
onSessionChanged?: () => void;
|
|
3
|
+
};
|
|
4
|
+
/**
|
|
5
|
+
* Manages session state and transitions for the tracker
|
|
6
|
+
* This mostly concerns session recording events as the analytics events are considered the 'master' session
|
|
7
|
+
* and the session recording needs to know the session state from the backend which is initiated by analytic events
|
|
8
|
+
*/
|
|
9
|
+
export declare class SessionManager {
|
|
10
|
+
private static instance;
|
|
11
|
+
private sessionId;
|
|
12
|
+
private constructor();
|
|
13
|
+
static getInstance(): SessionManager;
|
|
14
|
+
/**
|
|
15
|
+
* Determines the current session state based on previous and current session IDs
|
|
16
|
+
*/
|
|
17
|
+
private determineSessionState;
|
|
18
|
+
/**
|
|
19
|
+
* Handles session state transitions and triggers appropriate actions
|
|
20
|
+
*/
|
|
21
|
+
private handleSessionTransition;
|
|
22
|
+
/**
|
|
23
|
+
* Updates the session state based on a new session ID
|
|
24
|
+
* @param newSessionId The new session ID from the server
|
|
25
|
+
* @param callbacks Optional callbacks for session state changes
|
|
26
|
+
*/
|
|
27
|
+
updateSession(newSessionId: string, callbacks?: SessionCallbacks): void;
|
|
28
|
+
/**
|
|
29
|
+
* Gets the current session ID
|
|
30
|
+
*/
|
|
31
|
+
getCurrentSessionId(): string | null;
|
|
32
|
+
}
|
|
33
|
+
export default SessionManager;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brainfish-ai/web-tracker",
|
|
3
|
-
"version": "0.0.5-beta.
|
|
3
|
+
"version": "0.0.5-beta.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"description": "Brainfish Tracker for Web",
|
|
6
6
|
"files": [
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"vitest": "^2.1.4"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@brainfish-ai/tracker-sdk": "0.0.1-alpha.
|
|
30
|
+
"@brainfish-ai/tracker-sdk": "0.0.1-alpha.6",
|
|
31
31
|
"html-to-image": "^1.11.11",
|
|
32
32
|
"rrweb": "^2.0.0-alpha.4"
|
|
33
33
|
},
|