@interfere/next 0.0.0-alpha.10 → 0.0.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/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.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/encoders.test.d.ts.map +1 -0
- package/dist/{core → __tests__/core}/encoders.test.js +20 -19
- package/dist/__tests__/core/encoders.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__/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/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/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/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/middleware.d.ts +1 -1
- package/dist/next/middleware.js +13 -13
- 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/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/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-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/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.test.d.ts.map +0 -1
- package/dist/core/client.test.js +0 -238
- package/dist/core/client.test.js.map +0 -1
- package/dist/core/encoders.test.d.ts.map +0 -1
- package/dist/core/encoders.test.js.map +0 -1
- package/dist/next/error-boundary.d.ts +0 -17
- package/dist/next/error-boundary.d.ts.map +0 -1
- package/dist/next/error-boundary.jsx +0 -32
- package/dist/next/error-boundary.jsx.map +0 -1
- /package/dist/{core → __tests__/core}/client.test.d.ts +0 -0
- /package/dist/{core → __tests__/core}/encoders.test.d.ts +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { capture } from
|
|
1
|
+
import { capture } from "./client.js";
|
|
2
2
|
// Flag to prevent infinite loops when capturing errors
|
|
3
3
|
let isCapturing = false;
|
|
4
4
|
function serializeError(error) {
|
|
@@ -10,15 +10,15 @@ function serializeError(error) {
|
|
|
10
10
|
cause: error.cause,
|
|
11
11
|
};
|
|
12
12
|
}
|
|
13
|
-
if (typeof error ===
|
|
13
|
+
if (typeof error === "string") {
|
|
14
14
|
return {
|
|
15
15
|
message: error,
|
|
16
|
-
name:
|
|
16
|
+
name: "Error",
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
return {
|
|
20
20
|
message: String(error),
|
|
21
|
-
name:
|
|
21
|
+
name: "UnknownError",
|
|
22
22
|
};
|
|
23
23
|
}
|
|
24
24
|
// Safe capture that doesn't throw if SDK isn't initialized
|
|
@@ -41,21 +41,21 @@ function safeCapture(eventType, payload) {
|
|
|
41
41
|
}
|
|
42
42
|
// Client-side error handling
|
|
43
43
|
export function setupClientErrorHandlers() {
|
|
44
|
-
if (typeof window ===
|
|
44
|
+
if (typeof window === "undefined") {
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
// Handle unhandled errors
|
|
48
|
-
window.addEventListener(
|
|
48
|
+
window.addEventListener("error", (event) => {
|
|
49
49
|
const errorInfo = {
|
|
50
50
|
message: event.message,
|
|
51
|
-
name:
|
|
51
|
+
name: "WindowError",
|
|
52
52
|
fileName: event.filename,
|
|
53
53
|
lineNumber: event.lineno,
|
|
54
54
|
columnNumber: event.colno,
|
|
55
55
|
stack: event.error?.stack,
|
|
56
56
|
};
|
|
57
|
-
safeCapture(
|
|
58
|
-
type:
|
|
57
|
+
safeCapture("error", {
|
|
58
|
+
type: "unhandled_error",
|
|
59
59
|
error: errorInfo,
|
|
60
60
|
url: window.location.href,
|
|
61
61
|
userAgent: navigator.userAgent,
|
|
@@ -63,10 +63,10 @@ export function setupClientErrorHandlers() {
|
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
65
|
// Handle unhandled promise rejections
|
|
66
|
-
window.addEventListener(
|
|
66
|
+
window.addEventListener("unhandledrejection", (event) => {
|
|
67
67
|
const errorInfo = serializeError(event.reason);
|
|
68
|
-
safeCapture(
|
|
69
|
-
type:
|
|
68
|
+
safeCapture("error", {
|
|
69
|
+
type: "unhandled_rejection",
|
|
70
70
|
error: errorInfo,
|
|
71
71
|
url: window.location.href,
|
|
72
72
|
userAgent: navigator.userAgent,
|
|
@@ -81,7 +81,7 @@ export function setupClientErrorHandlers() {
|
|
|
81
81
|
// Convert arguments to a readable format
|
|
82
82
|
const message = args
|
|
83
83
|
.map((arg) => {
|
|
84
|
-
if (typeof arg ===
|
|
84
|
+
if (typeof arg === "object") {
|
|
85
85
|
try {
|
|
86
86
|
return JSON.stringify(arg);
|
|
87
87
|
}
|
|
@@ -91,11 +91,11 @@ export function setupClientErrorHandlers() {
|
|
|
91
91
|
}
|
|
92
92
|
return String(arg);
|
|
93
93
|
})
|
|
94
|
-
.join(
|
|
95
|
-
safeCapture(
|
|
96
|
-
type:
|
|
94
|
+
.join(" ");
|
|
95
|
+
safeCapture("error", {
|
|
96
|
+
type: "console_error",
|
|
97
97
|
message,
|
|
98
|
-
url: typeof window !==
|
|
98
|
+
url: typeof window !== "undefined" ? window.location.href : undefined,
|
|
99
99
|
timestamp: Date.now(),
|
|
100
100
|
});
|
|
101
101
|
};
|
|
@@ -103,11 +103,11 @@ export function setupClientErrorHandlers() {
|
|
|
103
103
|
// Server/Edge error handling for Next.js
|
|
104
104
|
export function captureServerError(error, request, context) {
|
|
105
105
|
const errorInfo = serializeError(error);
|
|
106
|
-
const runtime = typeof globalThis !==
|
|
107
|
-
?
|
|
108
|
-
:
|
|
109
|
-
safeCapture(runtime ===
|
|
110
|
-
type:
|
|
106
|
+
const runtime = typeof globalThis !== "undefined" && "EdgeRuntime" in globalThis
|
|
107
|
+
? "edge"
|
|
108
|
+
: "server";
|
|
109
|
+
safeCapture(runtime === "edge" ? "edge_error" : "server_error", {
|
|
110
|
+
type: "server_error",
|
|
111
111
|
error: errorInfo,
|
|
112
112
|
request: request
|
|
113
113
|
? {
|
|
@@ -122,19 +122,19 @@ export function captureServerError(error, request, context) {
|
|
|
122
122
|
}
|
|
123
123
|
// Next.js specific error boundary helper
|
|
124
124
|
export function captureErrorBoundaryError(error, errorInfo) {
|
|
125
|
-
safeCapture(
|
|
126
|
-
type:
|
|
125
|
+
safeCapture("error", {
|
|
126
|
+
type: "error_boundary",
|
|
127
127
|
error: serializeError(error),
|
|
128
128
|
componentStack: errorInfo.componentStack,
|
|
129
|
-
url: typeof window !==
|
|
129
|
+
url: typeof window !== "undefined" ? window.location.href : undefined,
|
|
130
130
|
timestamp: Date.now(),
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
// Capture Next.js API route errors
|
|
134
134
|
export function captureApiRouteError(error, req, pathname) {
|
|
135
135
|
const errorInfo = serializeError(error);
|
|
136
|
-
safeCapture(
|
|
137
|
-
type:
|
|
136
|
+
safeCapture("server_error", {
|
|
137
|
+
type: "api_route_error",
|
|
138
138
|
error: errorInfo,
|
|
139
139
|
request: {
|
|
140
140
|
url: req.url,
|
|
@@ -147,26 +147,27 @@ export function captureApiRouteError(error, req, pathname) {
|
|
|
147
147
|
}
|
|
148
148
|
// Determine runtime environment
|
|
149
149
|
function getRuntime() {
|
|
150
|
-
if (typeof window !==
|
|
151
|
-
return
|
|
150
|
+
if (typeof window !== "undefined") {
|
|
151
|
+
return "client";
|
|
152
152
|
}
|
|
153
|
-
if (typeof globalThis !==
|
|
154
|
-
return
|
|
153
|
+
if (typeof globalThis !== "undefined" && "EdgeRuntime" in globalThis) {
|
|
154
|
+
return "edge";
|
|
155
155
|
}
|
|
156
|
-
return
|
|
156
|
+
return "server";
|
|
157
157
|
}
|
|
158
158
|
// Get event type based on runtime
|
|
159
159
|
function getErrorEventType(runtime) {
|
|
160
|
+
// biome-ignore lint/nursery/noUnnecessaryConditions: runtime is guaranteed to be one of the values in the switch statement
|
|
160
161
|
switch (runtime) {
|
|
161
|
-
case
|
|
162
|
-
return
|
|
163
|
-
case
|
|
164
|
-
return
|
|
165
|
-
case
|
|
166
|
-
return
|
|
162
|
+
case "client":
|
|
163
|
+
return "error";
|
|
164
|
+
case "edge":
|
|
165
|
+
return "edge_error";
|
|
166
|
+
case "server":
|
|
167
|
+
return "server_error";
|
|
167
168
|
default:
|
|
168
169
|
// This should never happen due to the type constraint, but satisfies the linter
|
|
169
|
-
return
|
|
170
|
+
return "error";
|
|
170
171
|
}
|
|
171
172
|
}
|
|
172
173
|
export function withErrorCapture(fn, context) {
|
|
@@ -178,9 +179,9 @@ export function withErrorCapture(fn, context) {
|
|
|
178
179
|
const runtime = getRuntime();
|
|
179
180
|
const eventType = getErrorEventType(runtime);
|
|
180
181
|
safeCapture(eventType, {
|
|
181
|
-
type:
|
|
182
|
+
type: "wrapped_function_error",
|
|
182
183
|
error: serializeError(error),
|
|
183
|
-
functionName: fn.name ||
|
|
184
|
+
functionName: fn.name || "anonymous",
|
|
184
185
|
context,
|
|
185
186
|
timestamp: Date.now(),
|
|
186
187
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handlers.js","sourceRoot":"","sources":["../../src/core/error-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,uDAAuD;AACvD,IAAI,WAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"error-handlers.js","sourceRoot":"","sources":["../../src/core/error-handlers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC,uDAAuD;AACvD,IAAI,WAAW,GAAG,KAAgB,CAAC;AAYnC,SAAS,cAAc,CAAC,KAAc;IACpC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO;YACL,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,KAAK,CAAC,KAAK;SACnB,CAAC;IACJ,CAAC;IAED,IAAI,OAAO,KAAK,K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,MAAM,SAAS,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;YAE7C,WAAW,CAAC,SAAS,EAAE;gBACrB,IAAI,EAAE,wBAAwB;gBAC9B,KAAK,EAAE,cAAc,CAAC,KAAK,CAAC;gBAC5B,YAAY,EAAE,EAAE,CAAC,IAAI,IAAI,WAAW;gBACpC,OAAO;gBACP,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;aACtB,CAAC,CAAC;YACH,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAM,CAAC;AACV,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/core/runtime.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,OAAO,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;AAEnD,wBAAgB,aAAa,IAAI,OAAO,CAUvC;AAED,wBAAgB,QAAQ,IAAI,OAAO,CAElC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime detection utilities
|
|
3
|
+
*/
|
|
4
|
+
export function detectRuntime() {
|
|
5
|
+
if (typeof window !== "undefined") {
|
|
6
|
+
return "client";
|
|
7
|
+
}
|
|
8
|
+
if (typeof globalThis !== "undefined" && "EdgeRuntime" in globalThis) {
|
|
9
|
+
return "edge";
|
|
10
|
+
}
|
|
11
|
+
return "server";
|
|
12
|
+
}
|
|
13
|
+
export function isClient() {
|
|
14
|
+
return typeof window !== "undefined";
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../src/core/runtime.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,MAAM,UAAU,aAAa;IAC3B,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,IAAI,OAAO,UAAU,KAAK,WAAW,IAAI,aAAa,IAAI,UAAU,EAAE,CAAC;QACrE,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,UAAU,QAAQ;IACtB,OAAO,OAAO,MAAM,KAAK,WAAW,CAAC;AACvC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
1
|
+
/** biome-ignore-all lint/performance/noBarrelFile: Could be improved in the future */
|
|
2
|
+
export type { Config, Env, InitConfig, } from "@interfere/schemas/config";
|
|
3
|
+
export type { Envelope, EventType, } from "@interfere/schemas/envelope";
|
|
4
|
+
export type { SessionId } from "@interfere/schemas/session";
|
|
5
|
+
export type { SurfaceId } from "@interfere/schemas/surface";
|
|
6
|
+
export { capture, flush, getSessionId, init } from "./core/client.js";
|
|
7
|
+
export { decode, encode } from "./core/encoders.js";
|
|
8
|
+
export { captureApiRouteError, captureErrorBoundaryError, captureServerError, setupClientErrorHandlers, withErrorCapture, } from "./core/error-handlers.js";
|
|
9
|
+
export { createInterfereErrorHandler, withInterfereApiRoute, withInterfereMiddleware, withInterfereServerComponent, } from "./next/middleware.js";
|
|
10
|
+
export { InterfereProvider, useInterfere } from "./react/provider.jsx";
|
|
8
11
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,sFAAsF;AAGtF,YAAY,EACV,MAAM,EACN,GAAG,EACH,UAAU,GACX,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EACV,QAAQ,EACR,SAAS,GACV,MAAM,6BAA6B,CAAC;AAErC,YAAY,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5D,YAAY,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,kBAAkB,EAClB,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EACrB,uBAAuB,EACvB,4BAA4B,GAC7B,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
// Core client functionality
|
|
2
|
-
|
|
3
|
-
export {
|
|
2
|
+
/** biome-ignore-all lint/performance/noBarrelFile: Could be improved in the future */
|
|
3
|
+
export { capture, flush, getSessionId, init } from "./core/client.js";
|
|
4
|
+
export { decode, encode } from "./core/encoders.js";
|
|
4
5
|
// Error handling utilities
|
|
5
|
-
export { captureApiRouteError, captureErrorBoundaryError, captureServerError, setupClientErrorHandlers, withErrorCapture, } from
|
|
6
|
-
|
|
7
|
-
export { InterfereErrorBoundary } from './next/error-boundary.jsx';
|
|
8
|
-
export { createInterfereErrorHandler, withInterfereApiRoute, withInterfereMiddleware, withInterfereServerComponent, } from './next/middleware.js';
|
|
6
|
+
export { captureApiRouteError, captureErrorBoundaryError, captureServerError, setupClientErrorHandlers, withErrorCapture, } from "./core/error-handlers.js";
|
|
7
|
+
export { createInterfereErrorHandler, withInterfereApiRoute, withInterfereMiddleware, withInterfereServerComponent, } from "./next/middleware.js";
|
|
9
8
|
// React components and hooks
|
|
10
|
-
export { InterfereProvider, useInterfere } from
|
|
9
|
+
export { InterfereProvider, useInterfere } from "./react/provider.jsx";
|
|
11
10
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4BAA4B;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,4BAA4B;AAC5B,sFAAsF;AAiBtF,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACpD,2BAA2B;AAC3B,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,kBAAkB,EAClB,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EACrB,uBAAuB,EACvB,4BAA4B,GAC7B,MAAM,sBAAsB,CAAC;AAC9B,6BAA6B;AAC7B,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { NextRequest, NextResponse } from
|
|
1
|
+
import type { NextRequest, NextResponse } from "next/server";
|
|
2
2
|
export declare function withInterfereMiddleware(middleware: (request: NextRequest) => Promise<NextResponse> | NextResponse): (request: NextRequest) => Promise<NextResponse<unknown>>;
|
|
3
3
|
export declare function withInterfereApiRoute(handler: (req: NextRequest) => Promise<Response>): (req: NextRequest) => Promise<Response>;
|
|
4
4
|
export declare function withInterfereServerComponent<T extends (...args: unknown[]) => Promise<unknown>>(component: T, componentName?: string): T;
|
package/dist/next/middleware.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { capture } from
|
|
2
|
-
import { captureServerError } from
|
|
1
|
+
import { capture } from "../core/client.js";
|
|
2
|
+
import { captureServerError } from "../core/error-handlers.js";
|
|
3
3
|
// Middleware wrapper to capture errors
|
|
4
4
|
export function withInterfereMiddleware(middleware) {
|
|
5
5
|
return async (request) => {
|
|
@@ -7,8 +7,8 @@ export function withInterfereMiddleware(middleware) {
|
|
|
7
7
|
try {
|
|
8
8
|
// Try to capture the request, but don't fail if SDK isn't initialized
|
|
9
9
|
try {
|
|
10
|
-
capture(
|
|
11
|
-
type:
|
|
10
|
+
capture("edge_req", {
|
|
11
|
+
type: "middleware_request",
|
|
12
12
|
url: request.url,
|
|
13
13
|
method: request.method,
|
|
14
14
|
headers: Object.fromEntries(request.headers.entries()),
|
|
@@ -22,8 +22,8 @@ export function withInterfereMiddleware(middleware) {
|
|
|
22
22
|
const response = await middleware(request);
|
|
23
23
|
// Try to capture successful response timing
|
|
24
24
|
try {
|
|
25
|
-
capture(
|
|
26
|
-
type:
|
|
25
|
+
capture("edge_req", {
|
|
26
|
+
type: "middleware_response",
|
|
27
27
|
url: request.url,
|
|
28
28
|
statusCode: response.status,
|
|
29
29
|
duration: Date.now() - startTime,
|
|
@@ -58,8 +58,8 @@ export function withInterfereApiRoute(handler) {
|
|
|
58
58
|
try {
|
|
59
59
|
// Try to capture API route request
|
|
60
60
|
try {
|
|
61
|
-
capture(
|
|
62
|
-
type:
|
|
61
|
+
capture("server_req", {
|
|
62
|
+
type: "api_route_request",
|
|
63
63
|
url: req.url,
|
|
64
64
|
method: req.method,
|
|
65
65
|
headers: Object.fromEntries(req.headers.entries()),
|
|
@@ -73,8 +73,8 @@ export function withInterfereApiRoute(handler) {
|
|
|
73
73
|
const response = await handler(req);
|
|
74
74
|
// Try to capture response info
|
|
75
75
|
try {
|
|
76
|
-
capture(
|
|
77
|
-
type:
|
|
76
|
+
capture("server_req", {
|
|
77
|
+
type: "api_route_response",
|
|
78
78
|
url: req.url,
|
|
79
79
|
statusCode: response.status,
|
|
80
80
|
duration: Date.now() - startTime,
|
|
@@ -91,7 +91,7 @@ export function withInterfereApiRoute(handler) {
|
|
|
91
91
|
try {
|
|
92
92
|
captureServerError(error, req, {
|
|
93
93
|
pathname: req.nextUrl.pathname,
|
|
94
|
-
type:
|
|
94
|
+
type: "api_route",
|
|
95
95
|
duration: Date.now() - startTime,
|
|
96
96
|
});
|
|
97
97
|
}
|
|
@@ -111,7 +111,7 @@ export function withInterfereServerComponent(component, componentName) {
|
|
|
111
111
|
catch (error) {
|
|
112
112
|
try {
|
|
113
113
|
captureServerError(error, undefined, {
|
|
114
|
-
type:
|
|
114
|
+
type: "server_component",
|
|
115
115
|
componentName: componentName || component.name,
|
|
116
116
|
});
|
|
117
117
|
}
|
|
@@ -128,7 +128,7 @@ export function createInterfereErrorHandler() {
|
|
|
128
128
|
try {
|
|
129
129
|
captureServerError(error, undefined, {
|
|
130
130
|
digest: errorInfo.digest,
|
|
131
|
-
type:
|
|
131
|
+
type: "app_directory_error",
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
134
|
catch {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../src/persistence/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAoExD,eAAO,MAAM,UAAU,iBAAgC,CAAC;AACxD,eAAO,MAAM,YAAY,iBAAkC,CAAC;AAC5D,eAAO,MAAM,WAAW,iBAA0B,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
const createStorage = (storageType) => {
|
|
2
|
+
const memoryStore = {};
|
|
3
|
+
const isSupported = () => {
|
|
4
|
+
if (storageType === "memory") {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
if (typeof window === "undefined") {
|
|
8
|
+
return false;
|
|
9
|
+
}
|
|
10
|
+
try {
|
|
11
|
+
const storage = window[storageType];
|
|
12
|
+
const testKey = "__interfere_test__";
|
|
13
|
+
storage.setItem(testKey, "test");
|
|
14
|
+
storage.removeItem(testKey);
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const getStorage = () => {
|
|
22
|
+
if (storageType === "memory" || !isSupported()) {
|
|
23
|
+
return {
|
|
24
|
+
getItem: (key) => memoryStore[key] ?? null,
|
|
25
|
+
setItem: (key, value) => {
|
|
26
|
+
memoryStore[key] = value;
|
|
27
|
+
},
|
|
28
|
+
removeItem: (key) => {
|
|
29
|
+
delete memoryStore[key];
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return window[storageType];
|
|
34
|
+
};
|
|
35
|
+
return {
|
|
36
|
+
_is_supported: isSupported,
|
|
37
|
+
_parse: (key) => {
|
|
38
|
+
try {
|
|
39
|
+
const value = getStorage().getItem(key);
|
|
40
|
+
return value ? JSON.parse(value) : null;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
_set: (key, value) => {
|
|
47
|
+
try {
|
|
48
|
+
getStorage().setItem(key, JSON.stringify(value));
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
// Silently fail
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
_remove: (key) => {
|
|
55
|
+
try {
|
|
56
|
+
getStorage().removeItem(key);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// Silently fail
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
export const localStore = createStorage("localStorage");
|
|
65
|
+
export const sessionStore = createStorage("sessionStorage");
|
|
66
|
+
export const memoryStore = createStorage("memory");
|
|
67
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/persistence/storage.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AAM,KAAK,GAAG,UAAU,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;gBACxC,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;YAC1C,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QACD,IAAI,EAAE,CAAC,GAAW,EAAE,KAAc,EAAE,EAAE;YACpC,IAAI,CAAC;gBACH,UAAU,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;YACnD,CAAC;YAAC,MAAM,CAAC;gBACP,gBAAgB;YAClB,CAAC;QACH,CAAC;QACD,OAAO,EAAE,CAAC,GAAW,EAAE,EAAE;YACvB,IAAI,CAAC;gBACH,UAAU,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;YAC/B,CAAC;YAAC,MAAM,CAAC;gBACP,gBAAgB;YAClB,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC,cAAc,CAAC,CAAC;AACxD,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC,gBAAgB,CAAC,CAAC;AAC5D,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC,QAAQ,CAAC,CAAC"}
|
package/dist/react/provider.d.ts
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import type { Config
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import type { Config } from "@interfere/schemas/config";
|
|
2
|
+
import type { SurfaceId } from "@interfere/schemas/surface";
|
|
3
|
+
import { type ReactNode } from "react";
|
|
4
|
+
import { capture, flush, getDebugInfo, getSessionId, getWindowId, resetSession } from "../core/client.js";
|
|
5
|
+
type InterfereProviderProps = {
|
|
5
6
|
surface: SurfaceId;
|
|
6
7
|
options?: Partial<Config>;
|
|
7
8
|
children: ReactNode;
|
|
8
|
-
}
|
|
9
|
+
};
|
|
9
10
|
export declare function InterfereProvider(props: InterfereProviderProps): import("react").JSX.Element;
|
|
10
11
|
export declare function useInterfere(): {
|
|
11
12
|
capture: typeof capture;
|
|
12
13
|
flush: typeof flush;
|
|
13
14
|
getSessionId: typeof getSessionId;
|
|
15
|
+
getWindowId: typeof getWindowId;
|
|
16
|
+
getDebugInfo: typeof getDebugInfo;
|
|
17
|
+
resetSession: typeof resetSession;
|
|
14
18
|
};
|
|
15
19
|
export {};
|
|
16
20
|
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/react/provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/react/provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAiB,KAAK,SAAS,EAAyB,MAAM,OAAO,CAAC;AAC7E,OAAO,EACL,OAAO,EACP,KAAK,EACL,YAAY,EACZ,YAAY,EACZ,WAAW,EAEX,YAAY,EACb,MAAM,mBAAmB,CAAC;AAiB3B,KAAK,sBAAsB,GAAG;IAC5B,OAAO,EAAE,SAAS,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IAC1B,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,+BAoC9D;AAED,wBAAgB,YAAY;aApDjB,OAAO,OAAO;WAChB,OAAO,KAAK;kBACL,OAAO,YAAY;iBACpB,OAAO,WAAW;kBACjB,OAAO,YAAY;kBACnB,OAAO,YAAY;EAqDlC"}
|
package/dist/react/provider.jsx
CHANGED
|
@@ -1,24 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
import { createContext, useContext, useEffect } from
|
|
3
|
-
import { capture, flush, getSessionId, init } from
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, useContext, useEffect } from "react";
|
|
3
|
+
import { capture, flush, getDebugInfo, getSessionId, getWindowId, init, resetSession, } from "../core/client.js";
|
|
4
|
+
import { setupRageClick } from "../session/rage-click.js";
|
|
5
|
+
import { setupReplay, stopReplay } from "../session/replay.js";
|
|
6
|
+
import { setupSessionSummary, stopSessionSummary, } from "../session/session-summary.js";
|
|
6
7
|
const InterfereContext = createContext(null);
|
|
7
8
|
export function InterfereProvider(props) {
|
|
8
9
|
useEffect(() => {
|
|
9
10
|
init(props);
|
|
10
|
-
setupSessionSummary(
|
|
11
|
-
setupReplay(
|
|
12
|
-
|
|
11
|
+
setupSessionSummary();
|
|
12
|
+
setupReplay();
|
|
13
|
+
setupRageClick();
|
|
14
|
+
return () => {
|
|
15
|
+
try {
|
|
16
|
+
stopSessionSummary();
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
/* no-op */
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
stopReplay();
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
/* no-op */
|
|
26
|
+
}
|
|
27
|
+
flush();
|
|
28
|
+
};
|
|
13
29
|
}, [props]);
|
|
14
|
-
return (<InterfereContext.Provider value={{
|
|
30
|
+
return (<InterfereContext.Provider value={{
|
|
31
|
+
capture,
|
|
32
|
+
flush,
|
|
33
|
+
getSessionId,
|
|
34
|
+
getWindowId,
|
|
35
|
+
getDebugInfo,
|
|
36
|
+
resetSession,
|
|
37
|
+
}}>
|
|
15
38
|
{props.children}
|
|
16
39
|
</InterfereContext.Provider>);
|
|
17
40
|
}
|
|
18
41
|
export function useInterfere() {
|
|
19
42
|
const context = useContext(InterfereContext);
|
|
20
43
|
if (!context) {
|
|
21
|
-
throw new Error(
|
|
44
|
+
throw new Error("useInterfere() must be used within InterfereProvider");
|
|
22
45
|
}
|
|
23
46
|
return context;
|
|
24
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.jsx","sourceRoot":"","sources":["../../src/react/provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"provider.jsx","sourceRoot":"","sources":["../../src/react/provider.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAKb,OAAO,EAAE,aAAa,EAAkB,UAAU,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC7E,OAAO,EACL,OAAO,EACP,KAAK,EACL,YAAY,EACZ,YAAY,EACZ,WAAW,EACX,IAAI,EACJ,YAAY,GACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC/D,OAAO,EACL,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,+BAA+B,CAAC;AAEvC,MAAM,gBAAgB,GAAG,aAAa,CAO5B,IAAI,CAAC,CAAC;AAQhB,MAAM,UAAU,iBAAiB,CAAC,KAA6B;IAC7D,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,KAAK,CAAC,CAAC;QACZ,mBAAmB,EAAE,CAAC;QACtB,WAAW,EAAE,CAAC;QACd,cAAc,EAAE,CAAC;QAEjB,OAAO,GAAG,EAAE;YACV,IAAI,CAAC;gBACH,kBAAkB,EAAE,CAAC;YACvB,CAAC;YAAC,MAAM,CAAC;gBACP,WAAW;YACb,CAAC;YACD,IAAI,CAAC;gBACH,UAAU,EAAE,CAAC;YACf,CAAC;YAAC,MAAM,CAAC;gBACP,WAAW;YACb,CAAC;YACD,KAAK,EAAE,CAAC;QACV,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEZ,OAAO,CACL,CAAC,gBAAgB,CAAC,QAAQ,CACxB,KAAK,CAAC,CAAC;YACL,OAAO;YACP,KAAK;YACL,YAAY;YACZ,WAAW;YACX,YAAY;YACZ,YAAY;SACb,CAAC,CAEF;MAAA,CAAC,KAAK,CAAC,QAAQ,CACjB;IAAA,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAC7B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,MAAM,OAAO,GAAG,UAAU,CAAC,gBAAgB,CAAC,CAAC;IAC7C,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;IAC1E,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const SESSION_ID = "$session_id";
|
|
2
|
+
export declare const WINDOW_ID = "$window_id";
|
|
3
|
+
export declare const toMs: (seconds: number) => number;
|
|
4
|
+
export declare const toSeconds: (milliseconds: number) => number;
|
|
5
|
+
export declare const DEFAULT_SESSION_IDLE_TIMEOUT_SECONDS: number;
|
|
6
|
+
export declare const MAX_SESSION_IDLE_TIMEOUT_SECONDS: number;
|
|
7
|
+
export declare const MIN_SESSION_IDLE_TIMEOUT_SECONDS = 60;
|
|
8
|
+
export declare const SESSION_LENGTH_LIMIT_MILLISECONDS: number;
|
|
9
|
+
export declare const SESSION_SUMMARY_ENABLED = true;
|
|
10
|
+
export declare const SESSION_SUMMARY_WINDOW_MS = 10000;
|
|
11
|
+
export declare const SESSION_SUMMARY_MAX_EVENTS = 200;
|
|
12
|
+
export declare const ALLOW_BROWSER_AI = true;
|
|
13
|
+
export declare const REPLAY_ENABLED = true;
|
|
14
|
+
export declare const REPLAY_CHUNK_MS = 10000;
|
|
15
|
+
export declare const RAGE_CLICK_ENABLED = true;
|
|
16
|
+
export declare const RAGE_CLICK_RADIUS_PX = 30;
|
|
17
|
+
export declare const RAGE_CLICK_TIMEOUT_MS = 1000;
|
|
18
|
+
export declare const RAGE_CLICK_COUNT = 3;
|
|
19
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/session/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,gBAAgB,CAAC;AACxC,eAAO,MAAM,SAAS,eAAe,CAAC;AAUtC,eAAO,MAAM,IAAI,GAAI,SAAS,MAAM,KAAG,MACL,CAAC;AACnC,eAAO,MAAM,SAAS,GAAI,cAAc,MAAM,KAAG,MACE,CAAC;AAIpD,eAAO,MAAM,oCAAoC,QACC,CAAC;AACnD,eAAO,MAAM,gCAAgC,QAAuB,CAAC;AACrE,eAAO,MAAM,gCAAgC,KAAoB,CAAC;AAGlE,eAAO,MAAM,iCAAiC,QAA4B,CAAC;AAM3E,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAC5C,eAAO,MAAM,yBAAyB,QAAS,CAAC;AAChD,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C,eAAO,MAAM,gBAAgB,OAAO,CAAC;AAGrC,eAAO,MAAM,cAAc,OAAO,CAAC;AACnC,eAAO,MAAM,eAAe,QAAS,CAAC;AAGtC,eAAO,MAAM,kBAAkB,OAAO,CAAC;AACvC,eAAO,MAAM,oBAAoB,KAAK,CAAC;AACvC,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAC1C,eAAO,MAAM,gBAAgB,IAAI,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export const SESSION_ID = "$session_id";
|
|
2
|
+
export const WINDOW_ID = "$window_id";
|
|
3
|
+
// Time constants - all in milliseconds internally
|
|
4
|
+
const SECONDS_IN_MINUTE = 60;
|
|
5
|
+
const MINUTES_IN_HOUR = 60;
|
|
6
|
+
const MILLISECONDS_IN_SECOND = 1000;
|
|
7
|
+
const SECONDS_IN_HOUR = MINUTES_IN_HOUR * SECONDS_IN_MINUTE;
|
|
8
|
+
const MILLISECONDS_IN_HOUR = SECONDS_IN_HOUR * MILLISECONDS_IN_SECOND;
|
|
9
|
+
// Time utility functions
|
|
10
|
+
export const toMs = (seconds) => seconds * MILLISECONDS_IN_SECOND;
|
|
11
|
+
export const toSeconds = (milliseconds) => Math.floor(milliseconds / MILLISECONDS_IN_SECOND);
|
|
12
|
+
// Session timeout constants (exported in seconds for config compatibility)
|
|
13
|
+
const DEFAULT_IDLE_TIMEOUT_MINUTES = 30;
|
|
14
|
+
export const DEFAULT_SESSION_IDLE_TIMEOUT_SECONDS = DEFAULT_IDLE_TIMEOUT_MINUTES * SECONDS_IN_MINUTE; // 30 minutes
|
|
15
|
+
export const MAX_SESSION_IDLE_TIMEOUT_SECONDS = 10 * SECONDS_IN_HOUR; // 10 hours
|
|
16
|
+
export const MIN_SESSION_IDLE_TIMEOUT_SECONDS = SECONDS_IN_MINUTE; // 1 minute
|
|
17
|
+
// Session length limit (in milliseconds)
|
|
18
|
+
export const SESSION_LENGTH_LIMIT_MILLISECONDS = 24 * MILLISECONDS_IN_HOUR; // 24 hours
|
|
19
|
+
// Static SDK configuration values
|
|
20
|
+
// These may become server-configurable in the future
|
|
21
|
+
// Session summary
|
|
22
|
+
export const SESSION_SUMMARY_ENABLED = true; // Always enabled
|
|
23
|
+
export const SESSION_SUMMARY_WINDOW_MS = 10_000; // 10 seconds
|
|
24
|
+
export const SESSION_SUMMARY_MAX_EVENTS = 200;
|
|
25
|
+
export const ALLOW_BROWSER_AI = true;
|
|
26
|
+
// Session replay
|
|
27
|
+
export const REPLAY_ENABLED = true; // Always enabled
|
|
28
|
+
export const REPLAY_CHUNK_MS = 10_000; // 10 seconds
|
|
29
|
+
// Rage click detection
|
|
30
|
+
export const RAGE_CLICK_ENABLED = true; // Always enabled
|
|
31
|
+
export const RAGE_CLICK_RADIUS_PX = 30;
|
|
32
|
+
export const RAGE_CLICK_TIMEOUT_MS = 1000; // 1 second
|
|
33
|
+
export const RAGE_CLICK_COUNT = 3; // 3 rapid clicks trigger rage click
|
|
34
|
+
//# sourceMappingURL=constants.js.map
|