@clue-ai/browser-sdk 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 +100 -0
- package/dist/authoring/overlay.d.ts +12 -0
- package/dist/authoring/overlay.js +468 -0
- package/dist/authoring/recording.d.ts +125 -0
- package/dist/authoring/recording.js +481 -0
- package/dist/authoring/service-logo.d.ts +1 -0
- package/dist/authoring/service-logo.generated.d.ts +1 -0
- package/dist/authoring/service-logo.generated.js +3 -0
- package/dist/authoring/service-logo.js +1 -0
- package/dist/authoring/session.d.ts +23 -0
- package/dist/authoring/session.js +127 -0
- package/dist/authoring/surface.d.ts +11 -0
- package/dist/authoring/surface.js +63 -0
- package/dist/authoring/toolbar-constants.d.ts +23 -0
- package/dist/authoring/toolbar-constants.js +42 -0
- package/dist/authoring/toolbar-drag.d.ts +29 -0
- package/dist/authoring/toolbar-drag.js +270 -0
- package/dist/authoring/toolbar-view.d.ts +21 -0
- package/dist/authoring/toolbar-view.js +2584 -0
- package/dist/capture/action.d.ts +2 -0
- package/dist/capture/action.js +62 -0
- package/dist/capture/dom.d.ts +23 -0
- package/dist/capture/dom.js +329 -0
- package/dist/capture/drag.d.ts +2 -0
- package/dist/capture/drag.js +75 -0
- package/dist/capture/error.d.ts +2 -0
- package/dist/capture/error.js +193 -0
- package/dist/capture/form.d.ts +2 -0
- package/dist/capture/form.js +137 -0
- package/dist/capture/frustration.d.ts +2 -0
- package/dist/capture/frustration.js +171 -0
- package/dist/capture/input.d.ts +2 -0
- package/dist/capture/input.js +109 -0
- package/dist/capture/location.d.ts +10 -0
- package/dist/capture/location.js +42 -0
- package/dist/capture/navigation.d.ts +2 -0
- package/dist/capture/navigation.js +100 -0
- package/dist/capture/network.d.ts +13 -0
- package/dist/capture/network.js +903 -0
- package/dist/capture/page.d.ts +2 -0
- package/dist/capture/page.js +78 -0
- package/dist/capture/performance.d.ts +2 -0
- package/dist/capture/performance.js +268 -0
- package/dist/context/account.d.ts +12 -0
- package/dist/context/account.js +129 -0
- package/dist/context/environment.d.ts +42 -0
- package/dist/context/environment.js +208 -0
- package/dist/context/identity.d.ts +14 -0
- package/dist/context/identity.js +123 -0
- package/dist/context/session.d.ts +28 -0
- package/dist/context/session.js +155 -0
- package/dist/context/tab.d.ts +22 -0
- package/dist/context/tab.js +142 -0
- package/dist/context/trace.d.ts +32 -0
- package/dist/context/trace.js +65 -0
- package/dist/core/config.d.ts +4 -0
- package/dist/core/config.js +199 -0
- package/dist/core/constants.d.ts +43 -0
- package/dist/core/constants.js +109 -0
- package/dist/core/contracts.d.ts +58 -0
- package/dist/core/contracts.js +53 -0
- package/dist/core/sdk.d.ts +2 -0
- package/dist/core/sdk.js +831 -0
- package/dist/core/types.d.ts +413 -0
- package/dist/core/types.js +1 -0
- package/dist/core/usage-governor.d.ts +7 -0
- package/dist/core/usage-governor.js +127 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.js +36 -0
- package/dist/integrations/next-router.d.ts +16 -0
- package/dist/integrations/next-router.js +18 -0
- package/dist/integrations/react-router.d.ts +7 -0
- package/dist/integrations/react-router.js +37 -0
- package/dist/internal/metrics.d.ts +9 -0
- package/dist/internal/metrics.js +38 -0
- package/dist/normalize/builders.d.ts +15 -0
- package/dist/normalize/builders.js +786 -0
- package/dist/normalize/canonical.d.ts +13 -0
- package/dist/normalize/canonical.js +77 -0
- package/dist/normalize/event-id.d.ts +8 -0
- package/dist/normalize/event-id.js +39 -0
- package/dist/normalize/path-template.d.ts +1 -0
- package/dist/normalize/path-template.js +33 -0
- package/dist/privacy/local-minimization.d.ts +29 -0
- package/dist/privacy/local-minimization.js +88 -0
- package/dist/privacy/mask.d.ts +7 -0
- package/dist/privacy/mask.js +60 -0
- package/dist/privacy/parameter-snapshot.d.ts +14 -0
- package/dist/privacy/parameter-snapshot.js +206 -0
- package/dist/privacy/sanitize.d.ts +11 -0
- package/dist/privacy/sanitize.js +145 -0
- package/dist/privacy/schema-evidence.d.ts +20 -0
- package/dist/privacy/schema-evidence.js +238 -0
- package/dist/transport/batch.d.ts +37 -0
- package/dist/transport/batch.js +182 -0
- package/dist/transport/client.d.ts +61 -0
- package/dist/transport/client.js +267 -0
- package/dist/transport/queue.d.ts +22 -0
- package/dist/transport/queue.js +56 -0
- package/dist/transport/retry.d.ts +14 -0
- package/dist/transport/retry.js +46 -0
- package/package.json +38 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type TraceContextSnapshot = {
|
|
2
|
+
traceId: string;
|
|
3
|
+
activeSpanId: string | null;
|
|
4
|
+
};
|
|
5
|
+
export type RequestTraceContext = {
|
|
6
|
+
traceId: string;
|
|
7
|
+
parentSpanId: string | null;
|
|
8
|
+
requestId: string;
|
|
9
|
+
requestSpanId: string;
|
|
10
|
+
interactionId: string | null;
|
|
11
|
+
};
|
|
12
|
+
export declare class TraceManager {
|
|
13
|
+
private traceId;
|
|
14
|
+
private activeSpanId;
|
|
15
|
+
private activeInteractionId;
|
|
16
|
+
private activeInteractionExpiresAtMs;
|
|
17
|
+
constructor();
|
|
18
|
+
reset(): void;
|
|
19
|
+
getSnapshot(): TraceContextSnapshot;
|
|
20
|
+
startRootSpan(): {
|
|
21
|
+
traceId: string;
|
|
22
|
+
spanId: string;
|
|
23
|
+
};
|
|
24
|
+
setActiveSpan(spanId: string | null): void;
|
|
25
|
+
startInteraction(input: {
|
|
26
|
+
interactionId?: string | null;
|
|
27
|
+
nowMs?: number;
|
|
28
|
+
propagationWindowMs: number;
|
|
29
|
+
}): string;
|
|
30
|
+
getActiveInteractionId(nowMs?: number): string | null;
|
|
31
|
+
createRequestContext(requestId?: string): RequestTraceContext;
|
|
32
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { generateEventId, generateInteractionId, generateRequestId, generateRequestSpanId, } from "../normalize/event-id";
|
|
2
|
+
const generateTraceId = () => {
|
|
3
|
+
return `trace_${generateEventId()}`;
|
|
4
|
+
};
|
|
5
|
+
const generateSpanId = () => {
|
|
6
|
+
return `span_${generateEventId()}`;
|
|
7
|
+
};
|
|
8
|
+
export class TraceManager {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.traceId = generateTraceId();
|
|
11
|
+
this.activeSpanId = null;
|
|
12
|
+
this.activeInteractionId = null;
|
|
13
|
+
this.activeInteractionExpiresAtMs = null;
|
|
14
|
+
}
|
|
15
|
+
reset() {
|
|
16
|
+
this.traceId = generateTraceId();
|
|
17
|
+
this.activeSpanId = null;
|
|
18
|
+
this.activeInteractionId = null;
|
|
19
|
+
this.activeInteractionExpiresAtMs = null;
|
|
20
|
+
}
|
|
21
|
+
getSnapshot() {
|
|
22
|
+
return {
|
|
23
|
+
traceId: this.traceId,
|
|
24
|
+
activeSpanId: this.activeSpanId,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
startRootSpan() {
|
|
28
|
+
const spanId = generateSpanId();
|
|
29
|
+
this.activeSpanId = spanId;
|
|
30
|
+
return {
|
|
31
|
+
traceId: this.traceId,
|
|
32
|
+
spanId,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
setActiveSpan(spanId) {
|
|
36
|
+
this.activeSpanId = spanId;
|
|
37
|
+
}
|
|
38
|
+
startInteraction(input) {
|
|
39
|
+
const nowMs = input.nowMs ?? Date.now();
|
|
40
|
+
const interactionId = input.interactionId ?? generateInteractionId();
|
|
41
|
+
this.activeInteractionId = interactionId;
|
|
42
|
+
this.activeInteractionExpiresAtMs = nowMs + input.propagationWindowMs;
|
|
43
|
+
return interactionId;
|
|
44
|
+
}
|
|
45
|
+
getActiveInteractionId(nowMs = Date.now()) {
|
|
46
|
+
if (!this.activeInteractionId || this.activeInteractionExpiresAtMs === null) {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
if (nowMs > this.activeInteractionExpiresAtMs) {
|
|
50
|
+
this.activeInteractionId = null;
|
|
51
|
+
this.activeInteractionExpiresAtMs = null;
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
return this.activeInteractionId;
|
|
55
|
+
}
|
|
56
|
+
createRequestContext(requestId) {
|
|
57
|
+
return {
|
|
58
|
+
traceId: this.traceId,
|
|
59
|
+
parentSpanId: this.activeSpanId,
|
|
60
|
+
requestId: requestId ?? generateRequestId(),
|
|
61
|
+
requestSpanId: generateRequestSpanId(),
|
|
62
|
+
interactionId: this.getActiveInteractionId(),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ClueInitOptions, ResolvedClueConfig } from "./types";
|
|
2
|
+
export declare const resolveConfig: (options: ClueInitOptions) => ResolvedClueConfig;
|
|
3
|
+
export declare const validateConfig: (config: ResolvedClueConfig) => string[];
|
|
4
|
+
export declare const isConfigValid: (config: ResolvedClueConfig) => boolean;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { ALWAYS_DENIED_KEYS, DEFAULT_CONFIG, MAX_DIAGNOSTIC_TTL_MS, } from "./constants";
|
|
2
|
+
import { SDK_COLLECTION_MODE } from "./contracts";
|
|
3
|
+
const normalizeKeyList = (keys) => {
|
|
4
|
+
if (!keys || keys.length === 0) {
|
|
5
|
+
return [];
|
|
6
|
+
}
|
|
7
|
+
return [
|
|
8
|
+
...new Set(keys.map((key) => key.trim().toLowerCase()).filter(Boolean)),
|
|
9
|
+
];
|
|
10
|
+
};
|
|
11
|
+
const normalizePathList = (paths) => {
|
|
12
|
+
if (!paths || paths.length === 0) {
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
return [...new Set(paths.map((path) => path.trim()).filter(Boolean))];
|
|
16
|
+
};
|
|
17
|
+
const clampRate = (value, fallback) => {
|
|
18
|
+
if (typeof value !== "number" || Number.isNaN(value)) {
|
|
19
|
+
return fallback;
|
|
20
|
+
}
|
|
21
|
+
if (value < 0) {
|
|
22
|
+
return 0;
|
|
23
|
+
}
|
|
24
|
+
if (value > 1) {
|
|
25
|
+
return 1;
|
|
26
|
+
}
|
|
27
|
+
return value;
|
|
28
|
+
};
|
|
29
|
+
const positiveIntOrFallback = (value, fallback) => {
|
|
30
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
|
|
31
|
+
return fallback;
|
|
32
|
+
}
|
|
33
|
+
return Math.floor(value);
|
|
34
|
+
};
|
|
35
|
+
const normalizeCollectionMode = (value) => {
|
|
36
|
+
if (value === SDK_COLLECTION_MODE.diagnostic) {
|
|
37
|
+
return SDK_COLLECTION_MODE.diagnostic;
|
|
38
|
+
}
|
|
39
|
+
return SDK_COLLECTION_MODE.standard;
|
|
40
|
+
};
|
|
41
|
+
const normalizeDiagnosticScope = (value) => {
|
|
42
|
+
if (!value) {
|
|
43
|
+
return {};
|
|
44
|
+
}
|
|
45
|
+
const entries = Object.entries(value)
|
|
46
|
+
.map(([key, scopeValue]) => [key.trim(), scopeValue])
|
|
47
|
+
.filter(([key]) => key.length > 0)
|
|
48
|
+
.filter(([, scopeValue]) => {
|
|
49
|
+
return (scopeValue === null ||
|
|
50
|
+
typeof scopeValue === "string" ||
|
|
51
|
+
typeof scopeValue === "number" ||
|
|
52
|
+
typeof scopeValue === "boolean");
|
|
53
|
+
})
|
|
54
|
+
.slice(0, 20);
|
|
55
|
+
return Object.fromEntries(entries);
|
|
56
|
+
};
|
|
57
|
+
const normalizeDiagnosticConfig = (value) => {
|
|
58
|
+
const ttlMs = Math.min(positiveIntOrFallback(value?.ttlMs, DEFAULT_CONFIG.collection.diagnostic.ttlMs), MAX_DIAGNOSTIC_TTL_MS);
|
|
59
|
+
const budgetWindowMs = positiveIntOrFallback(value?.budgetWindowMs, DEFAULT_CONFIG.collection.diagnostic.budgetWindowMs);
|
|
60
|
+
const maxEventsPerWindow = positiveIntOrFallback(value?.maxEventsPerWindow, DEFAULT_CONFIG.collection.diagnostic.maxEventsPerWindow);
|
|
61
|
+
return {
|
|
62
|
+
enabledCollectors: normalizeKeyList(value?.enabledCollectors),
|
|
63
|
+
scope: normalizeDiagnosticScope(value?.scope),
|
|
64
|
+
ttlMs,
|
|
65
|
+
expiresAt: value?.expiresAt?.trim() || null,
|
|
66
|
+
budgetWindowMs,
|
|
67
|
+
maxEventsPerWindow,
|
|
68
|
+
sampleRate: clampRate(value?.sampleRate, DEFAULT_CONFIG.collection.diagnostic.sampleRate),
|
|
69
|
+
reason: value?.reason?.trim() || null,
|
|
70
|
+
enabledBy: value?.enabledBy?.trim() || null,
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
const normalizeConfiguredEndpoint = (value) => {
|
|
74
|
+
const trimmed = value.trim();
|
|
75
|
+
if (!trimmed) {
|
|
76
|
+
return "";
|
|
77
|
+
}
|
|
78
|
+
try {
|
|
79
|
+
const parsed = new URL(trimmed);
|
|
80
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
81
|
+
return "";
|
|
82
|
+
}
|
|
83
|
+
return parsed.toString();
|
|
84
|
+
}
|
|
85
|
+
catch {
|
|
86
|
+
return "";
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
export const resolveConfig = (options) => {
|
|
90
|
+
const originalEndpoint = normalizeConfiguredEndpoint(options.endpoint);
|
|
91
|
+
const localSetupCheckEndpoint = normalizeConfiguredEndpoint(options.localSetupCheck?.endpoint ?? "");
|
|
92
|
+
const serviceKey = options.serviceKey?.trim() ||
|
|
93
|
+
options.producerId?.trim() ||
|
|
94
|
+
DEFAULT_CONFIG.serviceKey;
|
|
95
|
+
const customDenied = normalizeKeyList(options.privacy?.deniedKeys);
|
|
96
|
+
const allowedValuePaths = normalizePathList(options.privacy?.allowedValuePaths);
|
|
97
|
+
const deniedKeys = [...new Set([...ALWAYS_DENIED_KEYS, ...customDenied])];
|
|
98
|
+
const tracePropagationOrigins = [
|
|
99
|
+
...new Set((options.network?.tracePropagationOrigins ?? [])
|
|
100
|
+
.map((origin) => origin.trim())
|
|
101
|
+
.filter(Boolean)),
|
|
102
|
+
];
|
|
103
|
+
const important4xxPathPrefixes = [
|
|
104
|
+
...new Set((options.network?.important4xxPathPrefixes ?? [])
|
|
105
|
+
.map((prefix) => prefix.trim())
|
|
106
|
+
.filter(Boolean)
|
|
107
|
+
.map((prefix) => (prefix.startsWith("/") ? prefix : `/${prefix}`))),
|
|
108
|
+
];
|
|
109
|
+
return {
|
|
110
|
+
endpoint: localSetupCheckEndpoint || originalEndpoint,
|
|
111
|
+
originalEndpoint,
|
|
112
|
+
localSetupCheckEndpoint: localSetupCheckEndpoint || null,
|
|
113
|
+
projectKey: options.projectKey?.trim() ?? "",
|
|
114
|
+
environment: options.environment?.trim() ?? "",
|
|
115
|
+
serviceKey,
|
|
116
|
+
producerId: options.producerId?.trim() || serviceKey,
|
|
117
|
+
browserTokenProvider: options.browserTokenProvider ?? null,
|
|
118
|
+
transportProfile: options.transportProfile ?? DEFAULT_CONFIG.transportProfile,
|
|
119
|
+
autocapture: options.autocapture ?? DEFAULT_CONFIG.autocapture,
|
|
120
|
+
captureNetwork: options.captureNetwork ?? DEFAULT_CONFIG.captureNetwork,
|
|
121
|
+
captureErrors: options.captureErrors ?? DEFAULT_CONFIG.captureErrors,
|
|
122
|
+
captureFrustration: options.captureFrustration ?? DEFAULT_CONFIG.captureFrustration,
|
|
123
|
+
capturePerformance: options.capturePerformance ?? DEFAULT_CONFIG.capturePerformance,
|
|
124
|
+
network: {
|
|
125
|
+
tracePropagationOrigins,
|
|
126
|
+
important4xxPathPrefixes,
|
|
127
|
+
interactionPropagationWindowMs: positiveIntOrFallback(options.network?.interactionPropagationWindowMs, DEFAULT_CONFIG.network.interactionPropagationWindowMs),
|
|
128
|
+
},
|
|
129
|
+
batch: {
|
|
130
|
+
enabled: options.batch?.enabled ?? DEFAULT_CONFIG.batch.enabled,
|
|
131
|
+
maxSize: typeof options.batch?.maxSize === "number" && options.batch.maxSize > 0
|
|
132
|
+
? Math.floor(options.batch.maxSize)
|
|
133
|
+
: DEFAULT_CONFIG.batch.maxSize,
|
|
134
|
+
flushIntervalMs: typeof options.batch?.flushIntervalMs === "number" &&
|
|
135
|
+
options.batch.flushIntervalMs > 0
|
|
136
|
+
? Math.floor(options.batch.flushIntervalMs)
|
|
137
|
+
: DEFAULT_CONFIG.batch.flushIntervalMs,
|
|
138
|
+
maxEventBytes: typeof options.batch?.maxEventBytes === "number" &&
|
|
139
|
+
options.batch.maxEventBytes > 0
|
|
140
|
+
? Math.floor(options.batch.maxEventBytes)
|
|
141
|
+
: DEFAULT_CONFIG.batch.maxEventBytes,
|
|
142
|
+
maxPayloadBytes: typeof options.batch?.maxPayloadBytes === "number" &&
|
|
143
|
+
options.batch.maxPayloadBytes > 0
|
|
144
|
+
? Math.floor(options.batch.maxPayloadBytes)
|
|
145
|
+
: DEFAULT_CONFIG.batch.maxPayloadBytes,
|
|
146
|
+
},
|
|
147
|
+
privacy: {
|
|
148
|
+
deniedKeys,
|
|
149
|
+
allowedValuePaths,
|
|
150
|
+
},
|
|
151
|
+
sampling: {
|
|
152
|
+
sessionSampleRate: clampRate(options.sampling?.sessionSampleRate, DEFAULT_CONFIG.sampling.sessionSampleRate),
|
|
153
|
+
},
|
|
154
|
+
collection: {
|
|
155
|
+
mode: normalizeCollectionMode(options.collection?.mode),
|
|
156
|
+
diagnostic: normalizeDiagnosticConfig(options.collection?.diagnostic),
|
|
157
|
+
},
|
|
158
|
+
release: {
|
|
159
|
+
frontendRelease: options.release?.frontendRelease?.trim() ||
|
|
160
|
+
DEFAULT_CONFIG.release.frontendRelease,
|
|
161
|
+
},
|
|
162
|
+
featureFlagsProvider: options.featureFlagsProvider,
|
|
163
|
+
experimentVariantProvider: options.experimentVariantProvider,
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
export const validateConfig = (config) => {
|
|
167
|
+
const issues = [];
|
|
168
|
+
if (!config.endpoint) {
|
|
169
|
+
issues.push("endpoint is required");
|
|
170
|
+
}
|
|
171
|
+
if (!config.projectKey) {
|
|
172
|
+
issues.push("projectKey is required");
|
|
173
|
+
}
|
|
174
|
+
if (!config.environment) {
|
|
175
|
+
issues.push("environment is required");
|
|
176
|
+
}
|
|
177
|
+
if (!config.producerId) {
|
|
178
|
+
issues.push("producerId is required");
|
|
179
|
+
}
|
|
180
|
+
if (!config.serviceKey) {
|
|
181
|
+
issues.push("serviceKey is required");
|
|
182
|
+
}
|
|
183
|
+
if (config.batch.flushIntervalMs < 100) {
|
|
184
|
+
issues.push("batch.flushIntervalMs must be >= 100ms");
|
|
185
|
+
}
|
|
186
|
+
if (config.batch.maxSize < 1) {
|
|
187
|
+
issues.push("batch.maxSize must be >= 1");
|
|
188
|
+
}
|
|
189
|
+
if (config.batch.maxEventBytes < 512) {
|
|
190
|
+
issues.push("batch.maxEventBytes must be >= 512 bytes");
|
|
191
|
+
}
|
|
192
|
+
if (config.batch.maxPayloadBytes < config.batch.maxEventBytes) {
|
|
193
|
+
issues.push("batch.maxPayloadBytes must be >= batch.maxEventBytes");
|
|
194
|
+
}
|
|
195
|
+
return issues;
|
|
196
|
+
};
|
|
197
|
+
export const isConfigValid = (config) => {
|
|
198
|
+
return validateConfig(config).length === 0;
|
|
199
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ClueConsentState, ResolvedClueConfig } from "./types";
|
|
2
|
+
export declare const SDK_NAME = "@clue-ai/browser-sdk";
|
|
3
|
+
export declare const SDK_VERSION = "0.0.1";
|
|
4
|
+
export declare const EVENT_SOURCE: "browser_sdk";
|
|
5
|
+
export declare const EVENT_VERSION = 1;
|
|
6
|
+
export declare const SOURCE_SCHEMA_VERSION = "1";
|
|
7
|
+
export declare const SURFACE_TYPE: "web";
|
|
8
|
+
export declare const MASKED_VALUE = "***masked***";
|
|
9
|
+
export declare const FORBIDDEN_PARAMETER_VALUE = "__forbidden__";
|
|
10
|
+
export declare const TRUNCATED_PARAMETER_VALUE = "__truncated__";
|
|
11
|
+
export declare const DEFAULT_CONSENT: ClueConsentState;
|
|
12
|
+
export declare const DEFAULT_SESSION_TIMEOUT_MS: number;
|
|
13
|
+
export declare const DEFAULT_INTERACTION_PROPAGATION_WINDOW_MS = 5000;
|
|
14
|
+
export declare const DEFAULT_MAX_EVENT_PAYLOAD_BYTES: number;
|
|
15
|
+
export declare const DEFAULT_MAX_BATCH_PAYLOAD_BYTES: number;
|
|
16
|
+
export declare const DEFAULT_MAX_BATCH_QUEUE_BYTES: number;
|
|
17
|
+
export declare const DEFAULT_DIAGNOSTIC_TTL_MS = 600000;
|
|
18
|
+
export declare const MAX_DIAGNOSTIC_TTL_MS = 1800000;
|
|
19
|
+
export declare const DEFAULT_DIAGNOSTIC_BUDGET_WINDOW_MS = 60000;
|
|
20
|
+
export declare const DEFAULT_DIAGNOSTIC_MAX_EVENTS_PER_WINDOW = 100;
|
|
21
|
+
export declare const STORAGE_KEYS: {
|
|
22
|
+
readonly anonymousId: "clue:anon_id";
|
|
23
|
+
readonly userId: "clue:user_id";
|
|
24
|
+
readonly userTraits: "clue:user_traits";
|
|
25
|
+
readonly accountId: "clue:account_id";
|
|
26
|
+
readonly organizationId: "clue:organization_id";
|
|
27
|
+
readonly accountTraits: "clue:account_traits";
|
|
28
|
+
readonly workspaceId: "clue:workspace_id";
|
|
29
|
+
readonly tabId: "clue:tab_id";
|
|
30
|
+
readonly sessionId: "clue:session_id";
|
|
31
|
+
readonly sessionStartedAt: "clue:session_started_at";
|
|
32
|
+
readonly sessionLastActivityAt: "clue:session_last_activity_at";
|
|
33
|
+
};
|
|
34
|
+
export declare const ALWAYS_DENIED_KEYS: readonly ["authorization", "cookie", "set-cookie", "password", "passwd", "secret", "token", "session", "session_token", "refresh_token", "api_key", "apikey", "private_key"];
|
|
35
|
+
export declare const MAX_SCHEMA_DEPTH = 6;
|
|
36
|
+
export declare const MAX_SCHEMA_KEYS = 512;
|
|
37
|
+
export declare const MAX_SANITIZE_DEPTH = 20;
|
|
38
|
+
export declare const DEFAULT_CONFIG: ResolvedClueConfig;
|
|
39
|
+
export declare const RETRY_CONFIG: {
|
|
40
|
+
readonly maxAttempts: 3;
|
|
41
|
+
readonly baseDelayMs: 300;
|
|
42
|
+
readonly maxDelayMs: 5000;
|
|
43
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export const SDK_NAME = "@clue-ai/browser-sdk";
|
|
2
|
+
export const SDK_VERSION = "0.0.1";
|
|
3
|
+
export const EVENT_SOURCE = "browser_sdk";
|
|
4
|
+
export const EVENT_VERSION = 1;
|
|
5
|
+
export const SOURCE_SCHEMA_VERSION = "1";
|
|
6
|
+
export const SURFACE_TYPE = "web";
|
|
7
|
+
export const MASKED_VALUE = "***masked***";
|
|
8
|
+
export const FORBIDDEN_PARAMETER_VALUE = "__forbidden__";
|
|
9
|
+
export const TRUNCATED_PARAMETER_VALUE = "__truncated__";
|
|
10
|
+
export const DEFAULT_CONSENT = "unknown";
|
|
11
|
+
export const DEFAULT_SESSION_TIMEOUT_MS = 30 * 60 * 1000;
|
|
12
|
+
export const DEFAULT_INTERACTION_PROPAGATION_WINDOW_MS = 5000;
|
|
13
|
+
export const DEFAULT_MAX_EVENT_PAYLOAD_BYTES = 48 * 1024;
|
|
14
|
+
export const DEFAULT_MAX_BATCH_PAYLOAD_BYTES = 60 * 1024;
|
|
15
|
+
export const DEFAULT_MAX_BATCH_QUEUE_BYTES = 300 * 1024;
|
|
16
|
+
export const DEFAULT_DIAGNOSTIC_TTL_MS = 600000;
|
|
17
|
+
export const MAX_DIAGNOSTIC_TTL_MS = 1800000;
|
|
18
|
+
export const DEFAULT_DIAGNOSTIC_BUDGET_WINDOW_MS = 60000;
|
|
19
|
+
export const DEFAULT_DIAGNOSTIC_MAX_EVENTS_PER_WINDOW = 100;
|
|
20
|
+
export const STORAGE_KEYS = {
|
|
21
|
+
anonymousId: "clue:anon_id",
|
|
22
|
+
userId: "clue:user_id",
|
|
23
|
+
userTraits: "clue:user_traits",
|
|
24
|
+
accountId: "clue:account_id",
|
|
25
|
+
organizationId: "clue:organization_id",
|
|
26
|
+
accountTraits: "clue:account_traits",
|
|
27
|
+
workspaceId: "clue:workspace_id",
|
|
28
|
+
tabId: "clue:tab_id",
|
|
29
|
+
sessionId: "clue:session_id",
|
|
30
|
+
sessionStartedAt: "clue:session_started_at",
|
|
31
|
+
sessionLastActivityAt: "clue:session_last_activity_at",
|
|
32
|
+
};
|
|
33
|
+
export const ALWAYS_DENIED_KEYS = [
|
|
34
|
+
"authorization",
|
|
35
|
+
"cookie",
|
|
36
|
+
"set-cookie",
|
|
37
|
+
"password",
|
|
38
|
+
"passwd",
|
|
39
|
+
"secret",
|
|
40
|
+
"token",
|
|
41
|
+
"session",
|
|
42
|
+
"session_token",
|
|
43
|
+
"refresh_token",
|
|
44
|
+
"api_key",
|
|
45
|
+
"apikey",
|
|
46
|
+
"private_key",
|
|
47
|
+
];
|
|
48
|
+
export const MAX_SCHEMA_DEPTH = 6;
|
|
49
|
+
export const MAX_SCHEMA_KEYS = 512;
|
|
50
|
+
export const MAX_SANITIZE_DEPTH = 20;
|
|
51
|
+
export const DEFAULT_CONFIG = {
|
|
52
|
+
endpoint: "",
|
|
53
|
+
originalEndpoint: "",
|
|
54
|
+
localSetupCheckEndpoint: null,
|
|
55
|
+
projectKey: "",
|
|
56
|
+
environment: "",
|
|
57
|
+
serviceKey: "frontend",
|
|
58
|
+
producerId: "frontend",
|
|
59
|
+
browserTokenProvider: null,
|
|
60
|
+
transportProfile: "standard",
|
|
61
|
+
autocapture: true,
|
|
62
|
+
captureNetwork: true,
|
|
63
|
+
captureErrors: true,
|
|
64
|
+
captureFrustration: true,
|
|
65
|
+
capturePerformance: true,
|
|
66
|
+
network: {
|
|
67
|
+
tracePropagationOrigins: [],
|
|
68
|
+
important4xxPathPrefixes: [],
|
|
69
|
+
interactionPropagationWindowMs: DEFAULT_INTERACTION_PROPAGATION_WINDOW_MS,
|
|
70
|
+
},
|
|
71
|
+
batch: {
|
|
72
|
+
enabled: true,
|
|
73
|
+
maxSize: 50,
|
|
74
|
+
flushIntervalMs: 180000,
|
|
75
|
+
maxEventBytes: DEFAULT_MAX_EVENT_PAYLOAD_BYTES,
|
|
76
|
+
maxPayloadBytes: DEFAULT_MAX_BATCH_PAYLOAD_BYTES,
|
|
77
|
+
},
|
|
78
|
+
privacy: {
|
|
79
|
+
deniedKeys: [...ALWAYS_DENIED_KEYS],
|
|
80
|
+
allowedValuePaths: [],
|
|
81
|
+
},
|
|
82
|
+
sampling: {
|
|
83
|
+
sessionSampleRate: 1,
|
|
84
|
+
},
|
|
85
|
+
collection: {
|
|
86
|
+
mode: "standard",
|
|
87
|
+
diagnostic: {
|
|
88
|
+
enabledCollectors: [],
|
|
89
|
+
scope: {},
|
|
90
|
+
ttlMs: DEFAULT_DIAGNOSTIC_TTL_MS,
|
|
91
|
+
expiresAt: null,
|
|
92
|
+
budgetWindowMs: DEFAULT_DIAGNOSTIC_BUDGET_WINDOW_MS,
|
|
93
|
+
maxEventsPerWindow: DEFAULT_DIAGNOSTIC_MAX_EVENTS_PER_WINDOW,
|
|
94
|
+
sampleRate: 1,
|
|
95
|
+
reason: null,
|
|
96
|
+
enabledBy: null,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
release: {
|
|
100
|
+
frontendRelease: null,
|
|
101
|
+
},
|
|
102
|
+
featureFlagsProvider: undefined,
|
|
103
|
+
experimentVariantProvider: undefined,
|
|
104
|
+
};
|
|
105
|
+
export const RETRY_CONFIG = {
|
|
106
|
+
maxAttempts: 3,
|
|
107
|
+
baseDelayMs: 300,
|
|
108
|
+
maxDelayMs: 5000,
|
|
109
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export declare const FRONTEND_EVENT_CATEGORY: {
|
|
2
|
+
readonly session: "session";
|
|
3
|
+
readonly navigation: "navigation";
|
|
4
|
+
readonly action: "action";
|
|
5
|
+
readonly interaction: "interaction";
|
|
6
|
+
readonly request: "request";
|
|
7
|
+
readonly error: "error";
|
|
8
|
+
readonly performance: "performance";
|
|
9
|
+
readonly support: "support";
|
|
10
|
+
readonly custom: "custom";
|
|
11
|
+
};
|
|
12
|
+
export type FrontendEventCategory = (typeof FRONTEND_EVENT_CATEGORY)[keyof typeof FRONTEND_EVENT_CATEGORY];
|
|
13
|
+
export declare const FRONTEND_EVENT_STATUS: {
|
|
14
|
+
readonly observed: "observed";
|
|
15
|
+
readonly finished: "finished";
|
|
16
|
+
readonly failed: "failed";
|
|
17
|
+
};
|
|
18
|
+
export type FrontendEventStatus = (typeof FRONTEND_EVENT_STATUS)[keyof typeof FRONTEND_EVENT_STATUS];
|
|
19
|
+
export declare const SDK_COLLECTION_MODE: {
|
|
20
|
+
readonly standard: "standard";
|
|
21
|
+
readonly diagnostic: "diagnostic";
|
|
22
|
+
};
|
|
23
|
+
export type SdkCollectionMode = (typeof SDK_COLLECTION_MODE)[keyof typeof SDK_COLLECTION_MODE];
|
|
24
|
+
export declare const FRONTEND_EVENT_NAME: {
|
|
25
|
+
readonly sessionStarted: "session_started";
|
|
26
|
+
readonly sessionEnded: "session_ended";
|
|
27
|
+
readonly pageView: "page_view";
|
|
28
|
+
readonly pageLeave: "page_leave";
|
|
29
|
+
readonly routeChange: "route_change";
|
|
30
|
+
readonly elementClicked: "element_clicked";
|
|
31
|
+
readonly formSubmitted: "form_submitted";
|
|
32
|
+
readonly inputCommitted: "input_committed";
|
|
33
|
+
readonly toggleChanged: "toggle_changed";
|
|
34
|
+
readonly selectionCommitted: "selection_committed";
|
|
35
|
+
readonly fileSelected: "file_selected";
|
|
36
|
+
readonly dragDropCompleted: "drag_drop_completed";
|
|
37
|
+
readonly requestFinished: "request_finished";
|
|
38
|
+
readonly requestFailed: "request_failed";
|
|
39
|
+
readonly frontendError: "frontend_error";
|
|
40
|
+
readonly unhandledRejection: "unhandled_rejection";
|
|
41
|
+
readonly performanceSummaryObserved: "performance_summary_observed";
|
|
42
|
+
readonly browserReportSummaryObserved: "browser_report_summary_observed";
|
|
43
|
+
readonly uiLifecycleSummaryObserved: "ui_lifecycle_summary_observed";
|
|
44
|
+
readonly streamLifecycleSummaryObserved: "stream_lifecycle_summary_observed";
|
|
45
|
+
readonly sdkDiagnosticObserved: "sdk_diagnostic_observed";
|
|
46
|
+
readonly deadClickDetected: "dead_click_detected";
|
|
47
|
+
readonly errorClickDetected: "error_click_detected";
|
|
48
|
+
readonly rageClickDetected: "rage_click_detected";
|
|
49
|
+
readonly customEmitted: "custom_emitted";
|
|
50
|
+
};
|
|
51
|
+
export type FrontendEventName = (typeof FRONTEND_EVENT_NAME)[keyof typeof FRONTEND_EVENT_NAME];
|
|
52
|
+
export declare const PARAMETER_CAPTURE_MODE: {
|
|
53
|
+
readonly allowedPlaintext: "allowed_plaintext";
|
|
54
|
+
readonly maskedFingerprint: "masked_fingerprint";
|
|
55
|
+
readonly forbidden: "forbidden";
|
|
56
|
+
readonly truncated: "truncated";
|
|
57
|
+
};
|
|
58
|
+
export type ParameterCaptureMode = (typeof PARAMETER_CAPTURE_MODE)[keyof typeof PARAMETER_CAPTURE_MODE];
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export const FRONTEND_EVENT_CATEGORY = {
|
|
2
|
+
session: "session",
|
|
3
|
+
navigation: "navigation",
|
|
4
|
+
action: "action",
|
|
5
|
+
interaction: "interaction",
|
|
6
|
+
request: "request",
|
|
7
|
+
error: "error",
|
|
8
|
+
performance: "performance",
|
|
9
|
+
support: "support",
|
|
10
|
+
custom: "custom",
|
|
11
|
+
};
|
|
12
|
+
export const FRONTEND_EVENT_STATUS = {
|
|
13
|
+
observed: "observed",
|
|
14
|
+
finished: "finished",
|
|
15
|
+
failed: "failed",
|
|
16
|
+
};
|
|
17
|
+
export const SDK_COLLECTION_MODE = {
|
|
18
|
+
standard: "standard",
|
|
19
|
+
diagnostic: "diagnostic",
|
|
20
|
+
};
|
|
21
|
+
export const FRONTEND_EVENT_NAME = {
|
|
22
|
+
sessionStarted: "session_started",
|
|
23
|
+
sessionEnded: "session_ended",
|
|
24
|
+
pageView: "page_view",
|
|
25
|
+
pageLeave: "page_leave",
|
|
26
|
+
routeChange: "route_change",
|
|
27
|
+
elementClicked: "element_clicked",
|
|
28
|
+
formSubmitted: "form_submitted",
|
|
29
|
+
inputCommitted: "input_committed",
|
|
30
|
+
toggleChanged: "toggle_changed",
|
|
31
|
+
selectionCommitted: "selection_committed",
|
|
32
|
+
fileSelected: "file_selected",
|
|
33
|
+
dragDropCompleted: "drag_drop_completed",
|
|
34
|
+
requestFinished: "request_finished",
|
|
35
|
+
requestFailed: "request_failed",
|
|
36
|
+
frontendError: "frontend_error",
|
|
37
|
+
unhandledRejection: "unhandled_rejection",
|
|
38
|
+
performanceSummaryObserved: "performance_summary_observed",
|
|
39
|
+
browserReportSummaryObserved: "browser_report_summary_observed",
|
|
40
|
+
uiLifecycleSummaryObserved: "ui_lifecycle_summary_observed",
|
|
41
|
+
streamLifecycleSummaryObserved: "stream_lifecycle_summary_observed",
|
|
42
|
+
sdkDiagnosticObserved: "sdk_diagnostic_observed",
|
|
43
|
+
deadClickDetected: "dead_click_detected",
|
|
44
|
+
errorClickDetected: "error_click_detected",
|
|
45
|
+
rageClickDetected: "rage_click_detected",
|
|
46
|
+
customEmitted: "custom_emitted",
|
|
47
|
+
};
|
|
48
|
+
export const PARAMETER_CAPTURE_MODE = {
|
|
49
|
+
allowedPlaintext: "allowed_plaintext",
|
|
50
|
+
maskedFingerprint: "masked_fingerprint",
|
|
51
|
+
forbidden: "forbidden",
|
|
52
|
+
truncated: "truncated",
|
|
53
|
+
};
|