@sailfish-ai/recorder 1.9.2-alpha1 → 1.10.1-alpha2

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.
Binary file
Binary file
@@ -45,3 +45,47 @@ export function trackingEvent(trackingData) {
45
45
  };
46
46
  sendMessage(message);
47
47
  }
48
+ // IP tracking: de-duplication flag (one fetch per session)
49
+ let ipSentForSession = null;
50
+ const IP_SERVICES = [
51
+ "https://api.ipify.org?format=json",
52
+ "https://api.ip.sb/jsonip",
53
+ "https://api4.my-ip.io/ip.json",
54
+ ];
55
+ const IP_FETCH_TIMEOUT_MS = 5000;
56
+ // Fetches visitor IP in background and sends it over the websocket.
57
+ // Completely non-blocking: fire-and-forget, never awaited.
58
+ export function fetchAndSendIp(sessionId) {
59
+ if (ipSentForSession === sessionId)
60
+ return;
61
+ ipSentForSession = sessionId;
62
+ (async () => {
63
+ for (const serviceUrl of IP_SERVICES) {
64
+ try {
65
+ const controller = new AbortController();
66
+ const timeoutId = setTimeout(() => controller.abort(), IP_FETCH_TIMEOUT_MS);
67
+ const response = await fetch(serviceUrl, { signal: controller.signal });
68
+ clearTimeout(timeoutId);
69
+ if (!response.ok)
70
+ continue;
71
+ const data = await response.json();
72
+ const ip = data.ip || data.origin || null;
73
+ if (ip && typeof ip === "string" && ip.length <= 45) {
74
+ sendMessage({
75
+ type: "visitorIp",
76
+ ip,
77
+ timestamp: nowTimestamp(),
78
+ });
79
+ return;
80
+ }
81
+ }
82
+ catch {
83
+ // Timeout, network error, or JSON parse error — try next service
84
+ }
85
+ }
86
+ // All services failed — reset so next initRecorder() call can retry
87
+ ipSentForSession = null;
88
+ })().catch(() => {
89
+ ipSentForSession = null;
90
+ });
91
+ }
@@ -5,7 +5,7 @@ export declare const STORAGE_VERSION = 1;
5
5
  export declare const DEFAULT_CAPTURE_SETTINGS: CaptureSettings;
6
6
  export declare const DEFAULT_CONSOLE_RECORDING_SETTINGS: LogRecordOptions;
7
7
  export declare function matchUrlWithWildcard(input: unknown, patterns: string[]): boolean;
8
- export declare function startRecording({ apiKey, backendApi, domainsToPropagateHeaderTo, domainsToNotPropagateHeaderTo, serviceVersion, serviceIdentifier, gitSha, serviceAdditionalMetadata, }: {
8
+ export declare function startRecording({ apiKey, backendApi, domainsToPropagateHeaderTo, domainsToNotPropagateHeaderTo, serviceVersion, serviceIdentifier, gitSha, serviceAdditionalMetadata, enableIpTracking, }: {
9
9
  apiKey: string;
10
10
  backendApi?: string;
11
11
  domainsToPropagateHeaderTo?: string[];
@@ -14,6 +14,7 @@ export declare function startRecording({ apiKey, backendApi, domainsToPropagateH
14
14
  serviceIdentifier?: string;
15
15
  gitSha?: string;
16
16
  serviceAdditionalMetadata?: Record<string, any>;
17
+ enableIpTracking?: boolean;
17
18
  }): Promise<void>;
18
19
  export declare const initRecorder: (options: {
19
20
  apiKey: string;
@@ -27,6 +28,7 @@ export declare const initRecorder: (options: {
27
28
  serviceAdditionalMetadata?: Record<string, any>;
28
29
  customBaseUrl?: string;
29
30
  enableFiberTracking?: boolean;
31
+ enableIpTracking?: boolean;
30
32
  }) => Promise<void>;
31
33
  export * from "./graphql";
32
34
  export { openReportIssueModal } from "./inAppReportIssueModal";
@@ -1,3 +1,4 @@
1
1
  export declare function identify(userId: string, traits?: Record<string, any>, overwrite?: boolean): void;
2
2
  export declare function addOrUpdateMetadata(metadata: Record<string, any>): void;
3
3
  export declare function trackingEvent(trackingData: Record<string, any>): void;
4
+ export declare function fetchAndSendIp(sessionId: string): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sailfish-ai/recorder",
3
- "version": "1.9.2-alpha1",
3
+ "version": "1.10.1-alpha2",
4
4
  "publishPublicly": true,
5
5
  "type": "module",
6
6
  "main": "dist/recorder.cjs",
@@ -44,9 +44,9 @@
44
44
  ],
45
45
  "dependencies": {
46
46
  "@sailfish-ai/sf-map-utils": "0.4.5",
47
- "@sailfish-rrweb/rrweb-plugin-console-record": "0.5.6",
48
- "@sailfish-rrweb/rrweb-record-only": "0.5.6",
49
- "@sailfish-rrweb/types": "0.5.6",
47
+ "@sailfish-rrweb/rrweb-plugin-console-record": "0.5.7",
48
+ "@sailfish-rrweb/rrweb-record-only": "0.5.7",
49
+ "@sailfish-rrweb/types": "0.5.7",
50
50
  "async-mutex": "^0.5.0",
51
51
  "idb": "^8.0.3",
52
52
  "reconnecting-websocket": "^4.4.0",