@infinitewatch/web-core 1.1.0 → 1.1.1
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 +31 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +31 -35
- package/dist/index.js.map +1 -1
- package/dist/watch.js +31 -35
- package/dist/watch.js.map +1 -1
- package/package.json +3 -3
package/dist/watch.js
CHANGED
|
@@ -8,14 +8,16 @@
|
|
|
8
8
|
if (!data || data.source !== 0) return null;
|
|
9
9
|
return data;
|
|
10
10
|
};
|
|
11
|
-
var LIB_VERSION = "v43.
|
|
11
|
+
var LIB_VERSION = "v43.4";
|
|
12
12
|
var EXCLUDED_ORGANIZATIONS = {
|
|
13
|
-
|
|
13
|
+
// Add organizations here as needed:
|
|
14
|
+
// EXAMPLE_ORG: 'organization_id_here',
|
|
14
15
|
};
|
|
15
16
|
var EXCLUDED_ORG_IDS = new Set(Object.values(EXCLUDED_ORGANIZATIONS));
|
|
16
17
|
var DEFAULT_CONFIG = {
|
|
17
18
|
baseUrl: "https://ingest.infinitewatch.ai",
|
|
18
19
|
endpoint: "https://ingest.infinitewatch.ai/v1/ingest",
|
|
20
|
+
endpointInsights: "https://iw-backend-live.fly.dev",
|
|
19
21
|
endpointConfig: "https://ingest.infinitewatch.ai/v1/ingest/config",
|
|
20
22
|
sessionId: null,
|
|
21
23
|
userId: null,
|
|
@@ -360,17 +362,26 @@
|
|
|
360
362
|
if (sessionHeartbeatTimer) {
|
|
361
363
|
clearInterval(sessionHeartbeatTimer);
|
|
362
364
|
}
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
365
|
+
const checkInterval = config.sessionHeartbeatInterval || 6e4;
|
|
366
|
+
sessionHeartbeatTimer = setInterval(() => {
|
|
367
|
+
if (isSessionActive) {
|
|
368
|
+
if (sessionStartTime) {
|
|
369
|
+
const totalDuration = now() - sessionStartTime;
|
|
370
|
+
if (totalDuration > config.sessionTimeout) {
|
|
371
|
+
log(
|
|
372
|
+
`Session expired (exceeded max duration of ${config.sessionTimeout / 6e4} minutes), stopping session`
|
|
373
|
+
);
|
|
374
|
+
stopRecordingSession();
|
|
375
|
+
return;
|
|
370
376
|
}
|
|
371
377
|
}
|
|
372
|
-
|
|
373
|
-
|
|
378
|
+
if (config.refresh) {
|
|
379
|
+
updateSessionActivity();
|
|
380
|
+
} else {
|
|
381
|
+
saveSessionToStorage();
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}, checkInterval);
|
|
374
385
|
};
|
|
375
386
|
const stopSessionHeartbeat = () => {
|
|
376
387
|
if (sessionHeartbeatTimer) {
|
|
@@ -764,34 +775,18 @@
|
|
|
764
775
|
return;
|
|
765
776
|
}
|
|
766
777
|
sessionId = hardSessionId || sessionId;
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
timestamp: now(),
|
|
770
|
-
data: {}
|
|
771
|
-
};
|
|
772
|
-
const payload = {
|
|
773
|
-
session_id: sessionId,
|
|
774
|
-
user_id: userId,
|
|
775
|
-
organization_id: organizationId,
|
|
776
|
-
events: [event],
|
|
777
|
-
client_version: LIB_VERSION
|
|
778
|
-
};
|
|
779
|
-
if (externalId) {
|
|
780
|
-
payload.external_id = externalId;
|
|
778
|
+
if (!sessionId || !organizationId) {
|
|
779
|
+
return;
|
|
781
780
|
}
|
|
781
|
+
const base = (config.endpointInsights || config.baseUrl || "").toString().replace(/\/$/, "");
|
|
782
|
+
if (!base) return;
|
|
783
|
+
const endpointUrl = `${base}/v1/sessions/${encodeURIComponent(sessionId)}/insights`;
|
|
784
|
+
const payload = { organization_id: organizationId };
|
|
782
785
|
const payloadString = JSON.stringify(payload);
|
|
783
|
-
const payloadSizeKB = new Blob([payloadString]).size / BYTES_IN_KILOBYTE;
|
|
784
786
|
try {
|
|
785
|
-
const endpointUrl = buildEndpointUrl(
|
|
786
|
-
config.endpoint,
|
|
787
|
-
"f",
|
|
788
|
-
false,
|
|
789
|
-
payloadSizeKB,
|
|
790
|
-
false
|
|
791
|
-
);
|
|
792
787
|
const response = await fetch(endpointUrl, {
|
|
793
788
|
method: "POST",
|
|
794
|
-
headers: { "Content-Type": "
|
|
789
|
+
headers: { "Content-Type": "application/json" },
|
|
795
790
|
body: payloadString,
|
|
796
791
|
mode: "cors",
|
|
797
792
|
credentials: "omit"
|
|
@@ -914,7 +909,8 @@
|
|
|
914
909
|
const IDLE_MS = 15e3;
|
|
915
910
|
const BLOCKED_NET_HOSTS = /* @__PURE__ */ new Set([
|
|
916
911
|
"ingest.infinitewatch.ai",
|
|
917
|
-
"ingest.humanbehavior.co"
|
|
912
|
+
"ingest.humanbehavior.co",
|
|
913
|
+
"iw-backend-live.fly.dev"
|
|
918
914
|
]);
|
|
919
915
|
let __iw_lastUserIntentAt = now();
|
|
920
916
|
let __iw_intentInstalled = false;
|