@brainfish-ai/web-tracker 0.0.5-beta.2 → 0.0.6-alpha.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.
@@ -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
  }
@@ -14,5 +14,6 @@ export default class Agent {
14
14
  sendEvents: (events: any[]) => Promise<void>;
15
15
  }): Promise<void>;
16
16
  handleTimeout(): void;
17
+ takeFullSnapshot(): void;
17
18
  static handleCustomEvent(customEventType: string): void;
18
19
  }
@@ -37,5 +37,6 @@ declare class Recorder {
37
37
  });
38
38
  start(): void;
39
39
  getMirror(): import('rrweb-snapshot').Mirror;
40
+ takeFullSnapshot(): void;
40
41
  }
41
42
  export default Recorder;
@@ -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.2",
3
+ "version": "0.0.6-alpha.0",
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.5",
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
  },