sonar-sdk 0.2.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.
- package/README.md +78 -0
- package/dist/browser/auto.d.ts +28 -0
- package/dist/browser/auto.d.ts.map +1 -0
- package/dist/browser/auto.js +207 -0
- package/dist/browser/auto.js.map +1 -0
- package/dist/browser/consent.d.ts +19 -0
- package/dist/browser/consent.d.ts.map +1 -0
- package/dist/browser/consent.js +132 -0
- package/dist/browser/consent.js.map +1 -0
- package/dist/browser/frustration.d.ts +34 -0
- package/dist/browser/frustration.d.ts.map +1 -0
- package/dist/browser/frustration.js +257 -0
- package/dist/browser/frustration.js.map +1 -0
- package/dist/browser/index.d.ts +10 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +9 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/screenshot.d.ts +21 -0
- package/dist/browser/screenshot.d.ts.map +1 -0
- package/dist/browser/screenshot.js +143 -0
- package/dist/browser/screenshot.js.map +1 -0
- package/dist/browser/session-recorder.d.ts +19 -0
- package/dist/browser/session-recorder.d.ts.map +1 -0
- package/dist/browser/session-recorder.js +68 -0
- package/dist/browser/session-recorder.js.map +1 -0
- package/dist/browser/sonar-web.d.ts +28 -0
- package/dist/browser/sonar-web.d.ts.map +1 -0
- package/dist/browser/sonar-web.js +186 -0
- package/dist/browser/sonar-web.js.map +1 -0
- package/dist/browser/transport.d.ts +19 -0
- package/dist/browser/transport.d.ts.map +1 -0
- package/dist/browser/transport.js +128 -0
- package/dist/browser/transport.js.map +1 -0
- package/dist/browser/types.d.ts +119 -0
- package/dist/browser/types.d.ts.map +1 -0
- package/dist/browser/types.js +2 -0
- package/dist/browser/types.js.map +1 -0
- package/dist/browser/video-recorder.d.ts +25 -0
- package/dist/browser/video-recorder.d.ts.map +1 -0
- package/dist/browser/video-recorder.js +121 -0
- package/dist/browser/video-recorder.js.map +1 -0
- package/dist/browser/visitor.d.ts +9 -0
- package/dist/browser/visitor.d.ts.map +1 -0
- package/dist/browser/visitor.js +67 -0
- package/dist/browser/visitor.js.map +1 -0
- package/dist/client.d.ts +12 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +81 -0
- package/dist/client.js.map +1 -0
- package/dist/index.browser.d.ts +13 -0
- package/dist/index.browser.d.ts.map +1 -0
- package/dist/index.browser.js +11 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +53 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +33 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +52 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
function hashString(str) {
|
|
2
|
+
let hash = 5381;
|
|
3
|
+
for (let i = 0; i < str.length; i++) {
|
|
4
|
+
hash = ((hash << 5) + hash) + str.charCodeAt(i);
|
|
5
|
+
}
|
|
6
|
+
return (hash >>> 0).toString(36);
|
|
7
|
+
}
|
|
8
|
+
function fingerprintElement(target) {
|
|
9
|
+
if (!target || !(target instanceof Element))
|
|
10
|
+
return '';
|
|
11
|
+
const el = target;
|
|
12
|
+
const parts = [
|
|
13
|
+
el.tagName.toLowerCase(),
|
|
14
|
+
el.id || '',
|
|
15
|
+
...Array.from(el.classList).sort(),
|
|
16
|
+
el.getAttribute('href') || '',
|
|
17
|
+
el.getAttribute('name') || '',
|
|
18
|
+
el.getAttribute('type') || '',
|
|
19
|
+
el.getAttribute('role') || '',
|
|
20
|
+
el.textContent?.trim()?.slice(0, 60) || '',
|
|
21
|
+
el.getAttribute('data-sonar-track') || '',
|
|
22
|
+
];
|
|
23
|
+
return hashString(parts.join('|'));
|
|
24
|
+
}
|
|
25
|
+
function isInteractive(el) {
|
|
26
|
+
const tag = el.tagName.toLowerCase();
|
|
27
|
+
if (['a', 'button', 'input', 'select', 'textarea'].includes(tag))
|
|
28
|
+
return true;
|
|
29
|
+
const role = el.getAttribute('role');
|
|
30
|
+
if (role === 'button' || role === 'link' || role === 'tab')
|
|
31
|
+
return true;
|
|
32
|
+
if (el.onclick !== null)
|
|
33
|
+
return true;
|
|
34
|
+
if (window.getComputedStyle(el).cursor === 'pointer')
|
|
35
|
+
return true;
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
function describe(el) {
|
|
39
|
+
const tag = el.tagName.toLowerCase();
|
|
40
|
+
const text = el.textContent?.trim()?.slice(0, 80) || '';
|
|
41
|
+
const id = el.id || '';
|
|
42
|
+
const cls = Array.from(el.classList).slice(0, 3).join('.');
|
|
43
|
+
return [tag, id, cls, text].filter(Boolean).join('#');
|
|
44
|
+
}
|
|
45
|
+
export class FrustrationDetector {
|
|
46
|
+
host;
|
|
47
|
+
opts;
|
|
48
|
+
clickMap = new Map();
|
|
49
|
+
signalWindow = [];
|
|
50
|
+
idleTimer = null;
|
|
51
|
+
lastHoveredEl = null;
|
|
52
|
+
scrollHistory = [];
|
|
53
|
+
mutationObserver = null;
|
|
54
|
+
pendingDeadClick = null;
|
|
55
|
+
deadClickTimer = null;
|
|
56
|
+
clickHandler = null;
|
|
57
|
+
mouseMoveHandler = null;
|
|
58
|
+
scrollHandler = null;
|
|
59
|
+
active = false;
|
|
60
|
+
defaults = {
|
|
61
|
+
rageClick: { enabled: true, threshold: 3, windowMs: 2000 },
|
|
62
|
+
deadClick: { enabled: true, timeoutMs: 2000 },
|
|
63
|
+
hoverHesitation: { enabled: true, thresholdMs: 800 },
|
|
64
|
+
scrollChaos: { enabled: true },
|
|
65
|
+
cascadeDetection: { enabled: true, windowMs: 5000 },
|
|
66
|
+
};
|
|
67
|
+
constructor(host, opts) {
|
|
68
|
+
this.host = host;
|
|
69
|
+
this.opts = this.resolveOpts(opts);
|
|
70
|
+
}
|
|
71
|
+
resolveOpts(opts) {
|
|
72
|
+
const d = this.defaults;
|
|
73
|
+
const pick = (val, def) => {
|
|
74
|
+
if (val === false)
|
|
75
|
+
return { ...def, enabled: false };
|
|
76
|
+
if (typeof val === 'object' && val !== null)
|
|
77
|
+
return { ...def, ...val };
|
|
78
|
+
return def;
|
|
79
|
+
};
|
|
80
|
+
return {
|
|
81
|
+
rageClick: pick(opts?.rageClick, d.rageClick),
|
|
82
|
+
deadClick: pick(opts?.deadClick, d.deadClick),
|
|
83
|
+
hoverHesitation: pick(opts?.hoverHesitation, d.hoverHesitation),
|
|
84
|
+
scrollChaos: pick(opts?.scrollChaos, d.scrollChaos),
|
|
85
|
+
cascadeDetection: pick(opts?.cascadeDetection, d.cascadeDetection),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
init() {
|
|
89
|
+
if (this.active)
|
|
90
|
+
return;
|
|
91
|
+
this.active = true;
|
|
92
|
+
this.clickHandler = (e) => this.handleClick(e);
|
|
93
|
+
document.addEventListener('click', this.clickHandler, { passive: true });
|
|
94
|
+
this.mouseMoveHandler = (e) => this.handleMouseMove(e);
|
|
95
|
+
document.addEventListener('mousemove', this.mouseMoveHandler, { passive: true });
|
|
96
|
+
this.scrollHandler = () => this.handleScroll();
|
|
97
|
+
window.addEventListener('scroll', this.scrollHandler, { passive: true });
|
|
98
|
+
}
|
|
99
|
+
destroy() {
|
|
100
|
+
this.active = false;
|
|
101
|
+
if (this.clickHandler)
|
|
102
|
+
document.removeEventListener('click', this.clickHandler);
|
|
103
|
+
if (this.mouseMoveHandler)
|
|
104
|
+
document.removeEventListener('mousemove', this.mouseMoveHandler);
|
|
105
|
+
if (this.scrollHandler)
|
|
106
|
+
window.removeEventListener('scroll', this.scrollHandler);
|
|
107
|
+
this.stopDeadClick();
|
|
108
|
+
if (this.idleTimer)
|
|
109
|
+
clearTimeout(this.idleTimer);
|
|
110
|
+
this.scrollHistory = [];
|
|
111
|
+
this.signalWindow = [];
|
|
112
|
+
this.clickMap.clear();
|
|
113
|
+
}
|
|
114
|
+
handleClick(e) {
|
|
115
|
+
const target = e.target;
|
|
116
|
+
if (!target)
|
|
117
|
+
return;
|
|
118
|
+
if (target.closest?.('[data-sonar-ignore]'))
|
|
119
|
+
return;
|
|
120
|
+
const fp = fingerprintElement(target);
|
|
121
|
+
if (!fp)
|
|
122
|
+
return;
|
|
123
|
+
const now = Date.now();
|
|
124
|
+
if (this.opts.rageClick.enabled) {
|
|
125
|
+
const timestamps = this.clickMap.get(fp) || [];
|
|
126
|
+
timestamps.push(now);
|
|
127
|
+
const recent = timestamps.filter(t => now - t <= this.opts.rageClick.windowMs);
|
|
128
|
+
this.clickMap.set(fp, recent);
|
|
129
|
+
if (recent.length >= this.opts.rageClick.threshold) {
|
|
130
|
+
this.emit('frustration_rage_click', Math.min(0.5 + recent.length * 0.1, 0.95), {
|
|
131
|
+
count: recent.length,
|
|
132
|
+
windowMs: this.opts.rageClick.windowMs,
|
|
133
|
+
fingerprint: fp,
|
|
134
|
+
element: describe(target),
|
|
135
|
+
tagName: target.tagName.toLowerCase(),
|
|
136
|
+
text: target.textContent?.trim()?.slice(0, 100) || null,
|
|
137
|
+
coords: { x: e.clientX, y: e.clientY },
|
|
138
|
+
});
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (this.opts.deadClick.enabled && isInteractive(target)) {
|
|
143
|
+
this.startDeadClick(target, fp);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
handleMouseMove(e) {
|
|
147
|
+
if (!this.opts.hoverHesitation.enabled)
|
|
148
|
+
return;
|
|
149
|
+
const target = e.target;
|
|
150
|
+
if (!target)
|
|
151
|
+
return;
|
|
152
|
+
if (this.lastHoveredEl === target)
|
|
153
|
+
return;
|
|
154
|
+
this.lastHoveredEl = target;
|
|
155
|
+
if (this.idleTimer)
|
|
156
|
+
clearTimeout(this.idleTimer);
|
|
157
|
+
if (isInteractive(target)) {
|
|
158
|
+
this.idleTimer = setTimeout(() => {
|
|
159
|
+
const el = document.elementFromPoint(e.clientX, e.clientY);
|
|
160
|
+
if (el === target) {
|
|
161
|
+
this.emit('frustration_hesitation', 0.3, {
|
|
162
|
+
durationMs: this.opts.hoverHesitation.thresholdMs,
|
|
163
|
+
fingerprint: fingerprintElement(target),
|
|
164
|
+
element: describe(target),
|
|
165
|
+
tagName: target.tagName.toLowerCase(),
|
|
166
|
+
text: target.textContent?.trim()?.slice(0, 100) || null,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}, this.opts.hoverHesitation.thresholdMs);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
handleScroll() {
|
|
173
|
+
if (!this.opts.scrollChaos.enabled)
|
|
174
|
+
return;
|
|
175
|
+
const now = Date.now();
|
|
176
|
+
this.scrollHistory.push({ y: window.scrollY, time: now });
|
|
177
|
+
this.scrollHistory = this.scrollHistory.filter(s => now - s.time <= 3000);
|
|
178
|
+
if (this.scrollHistory.length < 6)
|
|
179
|
+
return;
|
|
180
|
+
let changes = 0;
|
|
181
|
+
for (let i = 2; i < this.scrollHistory.length; i++) {
|
|
182
|
+
const d1 = this.scrollHistory[i - 1].y - this.scrollHistory[i - 2].y;
|
|
183
|
+
const d2 = this.scrollHistory[i].y - this.scrollHistory[i - 1].y;
|
|
184
|
+
if ((d1 > 0 && d2 < 0) || (d1 < 0 && d2 > 0))
|
|
185
|
+
changes++;
|
|
186
|
+
}
|
|
187
|
+
if (changes >= 3) {
|
|
188
|
+
const first = this.scrollHistory[0];
|
|
189
|
+
const last = this.scrollHistory[this.scrollHistory.length - 1];
|
|
190
|
+
const dt = Math.max(last.time - first.time, 1);
|
|
191
|
+
const velocity = Math.abs(last.y - first.y) / dt * 1000;
|
|
192
|
+
this.emit('frustration_scroll_chaos', Math.min(0.3 + changes * 0.05 + velocity * 0.00001, 0.8), {
|
|
193
|
+
directionChanges: changes,
|
|
194
|
+
velocity: Math.round(velocity),
|
|
195
|
+
durationMs: dt,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
startDeadClick(el, fp) {
|
|
200
|
+
this.stopDeadClick();
|
|
201
|
+
this.pendingDeadClick = { element: el, fingerprint: fp, time: Date.now() };
|
|
202
|
+
this.mutationObserver = new MutationObserver(() => this.stopDeadClick());
|
|
203
|
+
this.mutationObserver.observe(document.body, {
|
|
204
|
+
childList: true,
|
|
205
|
+
subtree: true,
|
|
206
|
+
attributeFilter: ['class', 'style'],
|
|
207
|
+
});
|
|
208
|
+
this.deadClickTimer = setTimeout(() => {
|
|
209
|
+
if (this.pendingDeadClick) {
|
|
210
|
+
this.emit('frustration_dead_click', 0.5, {
|
|
211
|
+
fingerprint: this.pendingDeadClick.fingerprint,
|
|
212
|
+
element: describe(this.pendingDeadClick.element),
|
|
213
|
+
tagName: this.pendingDeadClick.element.tagName.toLowerCase(),
|
|
214
|
+
text: this.pendingDeadClick.element.textContent?.trim()?.slice(0, 100) || null,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
this.stopDeadClick();
|
|
218
|
+
}, this.opts.deadClick.timeoutMs);
|
|
219
|
+
}
|
|
220
|
+
stopDeadClick() {
|
|
221
|
+
this.pendingDeadClick = null;
|
|
222
|
+
this.mutationObserver?.disconnect();
|
|
223
|
+
this.mutationObserver = null;
|
|
224
|
+
if (this.deadClickTimer)
|
|
225
|
+
clearTimeout(this.deadClickTimer);
|
|
226
|
+
this.deadClickTimer = null;
|
|
227
|
+
}
|
|
228
|
+
emit(type, severity, data) {
|
|
229
|
+
const now = Date.now();
|
|
230
|
+
this.signalWindow.push({ type, time: now, severity, data });
|
|
231
|
+
this.signalWindow = this.signalWindow.filter(s => now - s.time <= 10000);
|
|
232
|
+
this.host.track(type, severity, data);
|
|
233
|
+
if (severity >= 0.5)
|
|
234
|
+
this.host.requestScreenshot(type);
|
|
235
|
+
if (this.opts.cascadeDetection.enabled)
|
|
236
|
+
this.checkCascade(now);
|
|
237
|
+
}
|
|
238
|
+
checkCascade(now) {
|
|
239
|
+
const window = this.opts.cascadeDetection.windowMs;
|
|
240
|
+
const recent = this.signalWindow.filter(s => now - s.time <= window);
|
|
241
|
+
if (recent.length < 3)
|
|
242
|
+
return;
|
|
243
|
+
const types = new Set(recent.map(s => s.type));
|
|
244
|
+
if (types.size >= 3) {
|
|
245
|
+
const avg = recent.reduce((s, e) => s + e.severity, 0) / recent.length;
|
|
246
|
+
const cascadeSev = Math.min(avg + recent.length * 0.05, 0.98);
|
|
247
|
+
this.host.track('frustration_cascade', cascadeSev, {
|
|
248
|
+
signals: recent.map(s => ({ type: s.type, severity: s.severity })),
|
|
249
|
+
count: recent.length,
|
|
250
|
+
distinct: types.size,
|
|
251
|
+
durationMs: now - recent[0].time,
|
|
252
|
+
});
|
|
253
|
+
this.signalWindow = [];
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=frustration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frustration.js","sourceRoot":"","sources":["../../src/browser/frustration.ts"],"names":[],"mappings":"AAOA,SAAS,UAAU,CAAC,GAAW;IAC7B,IAAI,IAAI,GAAG,IAAI,CAAA;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;IACjD,CAAC;IACD,OAAO,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;AAClC,CAAC;AAED,SAAS,kBAAkB,CAAC,MAA0B;IACpD,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,MAAM,YAAY,OAAO,CAAC;QAAE,OAAO,EAAE,CAAA;IACtD,MAAM,EAAE,GAAG,MAAiB,CAAA;IAC5B,MAAM,KAAK,GAAG;QACZ,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE;QACxB,EAAE,CAAC,EAAE,IAAI,EAAE;QACX,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,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,GAAG,IAAI,EAAE,IAAI,CAAC,CAAA;YAE7D,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,qBAAqB,EAAE,UAAU,EAAE;gBACjD,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAClE,KAAK,EAAE,MAAM,CAAC,MAAM;gBACpB,QAAQ,EAAE,KAAK,CAAC,IAAI;gBACpB,UAAU,EAAE,GAAG,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI;aACjC,CAAC,CAAA;YACF,IAAI,CAAC,YAAY,GAAG,EAAE,CAAA;QACxB,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { SonarWeb } from './sonar-web';
|
|
2
|
+
export { ConsentManager } from './consent';
|
|
3
|
+
export { BatchTransport } from './transport';
|
|
4
|
+
export { VisitorManager } from './visitor';
|
|
5
|
+
export { AutoTracker } from './auto';
|
|
6
|
+
export { SmartScreenshotCapture } from './screenshot';
|
|
7
|
+
export { SessionRecorder } from './session-recorder';
|
|
8
|
+
export { FrustrationDetector } from './frustration';
|
|
9
|
+
export type { SonarWebOptions, ConsentState, ConsentBannerOptions, AutoTrackOptions, SessionRecorderOptions, ScreenshotOptions, AnalyticsEventPayload, AnalyticsSessionPayload, FrustrationOptions, SmartScreenshotOptions, IntelligenceOptions, } from './types';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,YAAY,EACV,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EAChB,sBAAsB,EACtB,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,SAAS,CAAA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { SonarWeb } from './sonar-web';
|
|
2
|
+
export { ConsentManager } from './consent';
|
|
3
|
+
export { BatchTransport } from './transport';
|
|
4
|
+
export { VisitorManager } from './visitor';
|
|
5
|
+
export { AutoTracker } from './auto';
|
|
6
|
+
export { SmartScreenshotCapture } from './screenshot';
|
|
7
|
+
export { SessionRecorder } from './session-recorder';
|
|
8
|
+
export { FrustrationDetector } from './frustration';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { SmartScreenshotOptions } from './types';
|
|
2
|
+
export type ScreenshotCallback = {
|
|
3
|
+
track: (event: string, severity: number, properties?: Record<string, unknown>) => void;
|
|
4
|
+
};
|
|
5
|
+
type Priority = 'critical' | 'high' | 'normal' | 'low';
|
|
6
|
+
export declare function ensureHtml2canvas(): Promise<boolean>;
|
|
7
|
+
export declare function captureViewport(): Promise<string | null>;
|
|
8
|
+
export declare class SmartScreenshotCapture {
|
|
9
|
+
private callback;
|
|
10
|
+
private opts;
|
|
11
|
+
private queue;
|
|
12
|
+
private capturing;
|
|
13
|
+
private lastErrorCapture;
|
|
14
|
+
constructor(opts: SmartScreenshotOptions, callback?: ScreenshotCallback | null);
|
|
15
|
+
capture(reason?: string, priority?: Priority): void;
|
|
16
|
+
private process;
|
|
17
|
+
private flushSync;
|
|
18
|
+
destroy(): void;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=screenshot.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/browser/screenshot.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAErD,MAAM,MAAM,kBAAkB,GAAG;IAC/B,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;CACvF,CAAA;AAED,KAAK,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAA;AA+BtD,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC,CAG1D;AAED,wBAAsB,eAAe,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAmB9D;AAeD,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,IAAI,CAA2B;IACvC,OAAO,CAAC,KAAK,CAAmB;IAChC,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,gBAAgB,CAAI;gBAEhB,IAAI,EAAE,sBAAsB,EAAE,QAAQ,CAAC,EAAE,kBAAkB,GAAG,IAAI;IAwB9E,OAAO,CAAC,MAAM,SAAW,EAAE,QAAQ,GAAE,QAAmB;YAc1C,OAAO;IAmCrB,OAAO,CAAC,SAAS;IAKjB,OAAO;CAGR"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
const PRIORITY_ORDER = { critical: 0, high: 1, normal: 2, low: 3 };
|
|
2
|
+
function adaptiveQuality() {
|
|
3
|
+
let q = 0.8;
|
|
4
|
+
const nav = navigator;
|
|
5
|
+
if (nav.deviceMemory && nav.deviceMemory < 2)
|
|
6
|
+
q = 0.3;
|
|
7
|
+
else if (nav.deviceMemory && nav.deviceMemory < 4)
|
|
8
|
+
q = 0.5;
|
|
9
|
+
if (nav.connection?.downlink !== undefined && nav.connection.downlink < 0.5)
|
|
10
|
+
q = Math.min(q, 0.3);
|
|
11
|
+
else if (nav.connection?.downlink !== undefined && nav.connection.downlink < 1)
|
|
12
|
+
q = Math.min(q, 0.5);
|
|
13
|
+
return q;
|
|
14
|
+
}
|
|
15
|
+
let html2canvasRef = null;
|
|
16
|
+
async function loadHtml2canvas() {
|
|
17
|
+
if (html2canvasRef)
|
|
18
|
+
return;
|
|
19
|
+
try {
|
|
20
|
+
// @ts-expect-error html2canvas is an optional peer dependency
|
|
21
|
+
const mod = await import('html2canvas');
|
|
22
|
+
html2canvasRef = mod.default;
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
const w = typeof window !== 'undefined' ? window : undefined;
|
|
26
|
+
if (w?.html2canvas)
|
|
27
|
+
html2canvasRef = w.html2canvas;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export async function ensureHtml2canvas() {
|
|
31
|
+
await loadHtml2canvas();
|
|
32
|
+
return html2canvasRef !== null;
|
|
33
|
+
}
|
|
34
|
+
export async function captureViewport() {
|
|
35
|
+
if (!html2canvasRef)
|
|
36
|
+
return null;
|
|
37
|
+
try {
|
|
38
|
+
const q = adaptiveQuality();
|
|
39
|
+
const scale = Math.min(window.devicePixelRatio || 1, q > 0.5 ? 2 : 1);
|
|
40
|
+
const result = await html2canvasRef(document.documentElement, {
|
|
41
|
+
width: window.innerWidth,
|
|
42
|
+
height: window.innerHeight,
|
|
43
|
+
x: window.scrollX,
|
|
44
|
+
y: window.scrollY,
|
|
45
|
+
useCORS: true,
|
|
46
|
+
scale,
|
|
47
|
+
logging: false,
|
|
48
|
+
});
|
|
49
|
+
const dataUrl = typeof result === 'string' ? result : 'toDataURL' in result ? result.toDataURL('image/jpeg') : '';
|
|
50
|
+
return dataUrl.slice(0, 500_000) || null;
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export class SmartScreenshotCapture {
|
|
57
|
+
callback = null;
|
|
58
|
+
opts;
|
|
59
|
+
queue = [];
|
|
60
|
+
capturing = false;
|
|
61
|
+
lastErrorCapture = 0;
|
|
62
|
+
constructor(opts, callback) {
|
|
63
|
+
this.opts = {
|
|
64
|
+
enabled: opts.enabled ?? true,
|
|
65
|
+
quality: opts.quality ?? 0.8,
|
|
66
|
+
maxWidth: opts.maxWidth ?? 1920,
|
|
67
|
+
triggers: {
|
|
68
|
+
onError: opts.triggers?.onError ?? true,
|
|
69
|
+
onRageClick: opts.triggers?.onRageClick ?? true,
|
|
70
|
+
onDeadClick: opts.triggers?.onDeadClick ?? true,
|
|
71
|
+
onUnload: opts.triggers?.onUnload ?? true,
|
|
72
|
+
onCriticalAction: opts.triggers?.onCriticalAction ?? true,
|
|
73
|
+
},
|
|
74
|
+
};
|
|
75
|
+
this.callback = callback ?? null;
|
|
76
|
+
if (this.opts.triggers.onError) {
|
|
77
|
+
window.addEventListener('error', () => this.capture('error', 'critical'));
|
|
78
|
+
}
|
|
79
|
+
if (this.opts.triggers.onUnload) {
|
|
80
|
+
window.addEventListener('beforeunload', () => this.flushSync());
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
capture(reason = 'manual', priority = 'normal') {
|
|
84
|
+
if (!this.opts.enabled)
|
|
85
|
+
return;
|
|
86
|
+
if (reason === 'error') {
|
|
87
|
+
const now = Date.now();
|
|
88
|
+
if (now - this.lastErrorCapture < 5000)
|
|
89
|
+
return;
|
|
90
|
+
this.lastErrorCapture = now;
|
|
91
|
+
}
|
|
92
|
+
this.queue.push({ reason, priority, time: Date.now() });
|
|
93
|
+
this.queue.sort((a, b) => PRIORITY_ORDER[a.priority] - PRIORITY_ORDER[b.priority]);
|
|
94
|
+
this.process();
|
|
95
|
+
}
|
|
96
|
+
async process() {
|
|
97
|
+
if (this.capturing || this.queue.length === 0 || !this.opts.enabled)
|
|
98
|
+
return;
|
|
99
|
+
this.capturing = true;
|
|
100
|
+
await loadHtml2canvas();
|
|
101
|
+
if (!html2canvasRef) {
|
|
102
|
+
this.capturing = false;
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
while (this.queue.length > 0) {
|
|
106
|
+
const job = this.queue.shift();
|
|
107
|
+
try {
|
|
108
|
+
const q = this.opts.quality * adaptiveQuality();
|
|
109
|
+
const scale = Math.min(window.devicePixelRatio || 1, q > 0.5 ? 2 : 1);
|
|
110
|
+
const result = await html2canvasRef(document.documentElement, {
|
|
111
|
+
width: window.innerWidth,
|
|
112
|
+
height: window.innerHeight,
|
|
113
|
+
x: window.scrollX,
|
|
114
|
+
y: window.scrollY,
|
|
115
|
+
useCORS: true,
|
|
116
|
+
scale,
|
|
117
|
+
logging: false,
|
|
118
|
+
});
|
|
119
|
+
const dataUrl = typeof result === 'string' ? result : 'toDataURL' in result ? result.toDataURL('image/jpeg') : '';
|
|
120
|
+
const truncated = dataUrl.slice(0, 500_000);
|
|
121
|
+
if (truncated) {
|
|
122
|
+
this.callback?.track('screenshot', 0, {
|
|
123
|
+
reason: job.reason,
|
|
124
|
+
data: truncated,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
// skip
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
this.capturing = false;
|
|
133
|
+
}
|
|
134
|
+
flushSync() {
|
|
135
|
+
if (this.queue.length === 0 || !this.opts.enabled)
|
|
136
|
+
return;
|
|
137
|
+
this.process();
|
|
138
|
+
}
|
|
139
|
+
destroy() {
|
|
140
|
+
this.queue = [];
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=screenshot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshot.js","sourceRoot":"","sources":["../../src/browser/screenshot.ts"],"names":[],"mappings":"AASA,MAAM,cAAc,GAA6B,EAAE,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,CAAA;AAE5F,SAAS,eAAe;IACtB,IAAI,CAAC,GAAG,GAAG,CAAA;IACX,MAAM,GAAG,GAAG,SAAqF,CAAA;IACjG,IAAI,GAAG,CAAC,YAAY,IAAI,GAAG,CAAC,YAAY,GAAG,CAAC;QAAE,CAAC,GAAG,GAAG,CAAA;SAChD,IAAI,GAAG,CAAC,YAAY,IAAI,GAAG,CAAC,YAAY,GAAG,CAAC;QAAE,CAAC,GAAG,GAAG,CAAA;IAC1D,IAAI,GAAG,CAAC,UAAU,EAAE,QAAQ,KAAK,SAAS,IAAI,GAAG,CAAC,UAAU,CAAC,QAAQ,GAAG,GAAG;QAAE,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EA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E,OAAO,CAAC,CAAA;gBAC3C,IAAI,SAAS,EAAE,CAAC;oBACd,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC,EAAE;wBACpC,MAAM,EAAE,GAAG,CAAC,MAAM;wBAClB,IAAI,EAAE,SAAS;qBAChB,CAAC,CAAA;gBACJ,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO;YACT,CAAC;QACH,CAAC;QACD,IAAI,CAAC,SAAS,GAAG,KAAK,CAAA;IACxB,CAAC;IAEO,SAAS;QACf,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO;YAAE,OAAM;QACzD,IAAI,CAAC,OAAO,EAAE,CAAA;IAChB,CAAC;IAED,OAAO;QACL,IAAI,CAAC,KAAK,GAAG,EAAE,CAAA;IACjB,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { SessionRecorderOptions } from './types';
|
|
2
|
+
export type RecorderHost = {
|
|
3
|
+
track: (event: string, properties?: Record<string, unknown>) => void;
|
|
4
|
+
};
|
|
5
|
+
export declare class SessionRecorder {
|
|
6
|
+
private host;
|
|
7
|
+
private opts;
|
|
8
|
+
private mouseEvents;
|
|
9
|
+
private mouseHandler;
|
|
10
|
+
private scrollHandler;
|
|
11
|
+
private clickHandler;
|
|
12
|
+
private flushTimer;
|
|
13
|
+
private active;
|
|
14
|
+
constructor(host: RecorderHost, opts: SessionRecorderOptions);
|
|
15
|
+
init(): void;
|
|
16
|
+
destroy(): void;
|
|
17
|
+
private flushMouseEvents;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=session-recorder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-recorder.d.ts","sourceRoot":"","sources":["../../src/browser/session-recorder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAA;AAErD,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAA;CACrE,CAAA;AAQD,qBAAa,eAAe;IAC1B,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,IAAI,CAAwB;IACpC,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,YAAY,CAAyC;IAC7D,OAAO,CAAC,aAAa,CAA4B;IACjD,OAAO,CAAC,YAAY,CAAyC;IAC7D,OAAO,CAAC,UAAU,CAA8C;IAChE,OAAO,CAAC,MAAM,CAAQ;gBAEV,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,sBAAsB;IAQ5D,IAAI;IAgCJ,OAAO;IASP,OAAO,CAAC,gBAAgB;CAQzB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export class SessionRecorder {
|
|
2
|
+
host;
|
|
3
|
+
opts;
|
|
4
|
+
mouseEvents = [];
|
|
5
|
+
mouseHandler = null;
|
|
6
|
+
scrollHandler = null;
|
|
7
|
+
clickHandler = null;
|
|
8
|
+
flushTimer = null;
|
|
9
|
+
active = false;
|
|
10
|
+
constructor(host, opts) {
|
|
11
|
+
this.host = host;
|
|
12
|
+
this.opts = {
|
|
13
|
+
enabled: opts.enabled ?? true,
|
|
14
|
+
sampleIntervalMs: opts.sampleIntervalMs ?? 100,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
init() {
|
|
18
|
+
if (this.active || !this.opts.enabled)
|
|
19
|
+
return;
|
|
20
|
+
this.active = true;
|
|
21
|
+
this.mouseHandler = (e) => {
|
|
22
|
+
const now = Date.now();
|
|
23
|
+
const last = this.mouseEvents[this.mouseEvents.length - 1];
|
|
24
|
+
if (last && (now - last.t) < this.opts.sampleIntervalMs)
|
|
25
|
+
return;
|
|
26
|
+
this.mouseEvents.push({ x: e.clientX, y: e.clientY, t: now });
|
|
27
|
+
};
|
|
28
|
+
document.addEventListener('mousemove', this.mouseHandler);
|
|
29
|
+
this.scrollHandler = () => {
|
|
30
|
+
this.host.track('recording_scroll', {
|
|
31
|
+
x: window.scrollX,
|
|
32
|
+
y: window.scrollY,
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
window.addEventListener('scroll', this.scrollHandler);
|
|
36
|
+
this.clickHandler = (e) => {
|
|
37
|
+
this.host.track('recording_click', {
|
|
38
|
+
x: e.clientX,
|
|
39
|
+
y: e.clientY,
|
|
40
|
+
target: e.target?.tagName?.toLowerCase() ?? null,
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
document.addEventListener('click', this.clickHandler);
|
|
44
|
+
this.flushTimer = setInterval(() => this.flushMouseEvents(), 10_000);
|
|
45
|
+
}
|
|
46
|
+
destroy() {
|
|
47
|
+
this.active = false;
|
|
48
|
+
if (this.mouseHandler)
|
|
49
|
+
document.removeEventListener('mousemove', this.mouseHandler);
|
|
50
|
+
if (this.scrollHandler)
|
|
51
|
+
window.removeEventListener('scroll', this.scrollHandler);
|
|
52
|
+
if (this.clickHandler)
|
|
53
|
+
document.removeEventListener('click', this.clickHandler);
|
|
54
|
+
if (this.flushTimer)
|
|
55
|
+
clearInterval(this.flushTimer);
|
|
56
|
+
this.flushMouseEvents();
|
|
57
|
+
}
|
|
58
|
+
flushMouseEvents() {
|
|
59
|
+
if (this.mouseEvents.length === 0)
|
|
60
|
+
return;
|
|
61
|
+
const batch = this.mouseEvents.splice(0, this.mouseEvents.length);
|
|
62
|
+
this.host.track('recording_mouse', {
|
|
63
|
+
events: batch,
|
|
64
|
+
count: batch.length,
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=session-recorder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-recorder.js","sourceRoot":"","sources":["../../src/browser/session-recorder.ts"],"names":[],"mappings":"AAY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A;IACzB,CAAC;IAEO,gBAAgB;QACtB,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,CAAC;YAAE,OAAM;QACzC,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAA;QACjE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE;YACjC,MAAM,EAAE,KAAK;YACb,KAAK,EAAE,KAAK,CAAC,MAAM;SACpB,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { SonarWebOptions, ConsentState } from './types';
|
|
2
|
+
import type { AutoTrackerHost } from './auto';
|
|
3
|
+
import type { FrustrationHost } from './frustration';
|
|
4
|
+
export declare class SonarWeb implements AutoTrackerHost, FrustrationHost {
|
|
5
|
+
private consent;
|
|
6
|
+
private visitor;
|
|
7
|
+
private transport;
|
|
8
|
+
private autoTracker;
|
|
9
|
+
private sessionRecorder;
|
|
10
|
+
private videoRecorder;
|
|
11
|
+
private smartScreenshot;
|
|
12
|
+
private frustrationDetector;
|
|
13
|
+
private releaseUnlistenConsent;
|
|
14
|
+
private started;
|
|
15
|
+
constructor(options: SonarWebOptions);
|
|
16
|
+
private initIntelligence;
|
|
17
|
+
private start;
|
|
18
|
+
private stop;
|
|
19
|
+
requestScreenshot(reason: string): void;
|
|
20
|
+
identify(visitorId: string, traits?: Record<string, unknown>): void;
|
|
21
|
+
page(name?: string, properties?: Record<string, unknown>): void;
|
|
22
|
+
track(event: string, propertiesOrSeverity?: Record<string, unknown> | number, maybeProperties?: Record<string, unknown>): void;
|
|
23
|
+
screenshot(): Promise<string | null>;
|
|
24
|
+
setConsent(state: ConsentState): void;
|
|
25
|
+
getConsent(): ConsentState;
|
|
26
|
+
destroy(): void;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=sonar-web.d.ts.map
|
|
@@ -0,0 +1 @@
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