@meet-sudo/sdk 0.1.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 +192 -0
- package/dist/index.d.mts +86 -0
- package/dist/index.d.ts +86 -0
- package/dist/index.js +496 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +468 -0
- package/dist/index.mjs.map +1 -0
- package/dist/meetsudo.global.js +2 -0
- package/dist/meetsudo.global.js.map +1 -0
- package/package.json +50 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,496 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
MeetSudo: () => MeetSudo,
|
|
24
|
+
meetsudo: () => meetsudo
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(index_exports);
|
|
27
|
+
|
|
28
|
+
// src/sdk.ts
|
|
29
|
+
var STORAGE_KEY = "meetsudo_anon_id";
|
|
30
|
+
var FLUSH_INTERVAL = 5e3;
|
|
31
|
+
var REPLAY_FLUSH_INTERVAL = 1e4;
|
|
32
|
+
var MeetSudo = class {
|
|
33
|
+
constructor() {
|
|
34
|
+
this.state = {
|
|
35
|
+
apiKey: null,
|
|
36
|
+
apiUrl: "https://api.meetsudo.com",
|
|
37
|
+
widgetUrl: "https://widget.meetsudo.com",
|
|
38
|
+
anonId: null,
|
|
39
|
+
custId: null,
|
|
40
|
+
features: null,
|
|
41
|
+
workspaceName: null,
|
|
42
|
+
initialized: false,
|
|
43
|
+
iframe: null,
|
|
44
|
+
eventQ: [],
|
|
45
|
+
flushTimer: null,
|
|
46
|
+
replaySessionId: null,
|
|
47
|
+
replaySequence: 0,
|
|
48
|
+
replayEvents: [],
|
|
49
|
+
replayFlushTimer: null,
|
|
50
|
+
replayStopFn: null,
|
|
51
|
+
replayTotalEvents: 0,
|
|
52
|
+
replayStartedAt: null,
|
|
53
|
+
replayRageClickCount: 0,
|
|
54
|
+
replayErrorCount: 0,
|
|
55
|
+
lastClickTime: 0,
|
|
56
|
+
lastClickTarget: null,
|
|
57
|
+
clickCount: 0,
|
|
58
|
+
capturedEmails: {}
|
|
59
|
+
};
|
|
60
|
+
this.config = null;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Initialize the MeetSudo SDK
|
|
64
|
+
*/
|
|
65
|
+
async init(config) {
|
|
66
|
+
if (!config.apiKey) {
|
|
67
|
+
throw new Error("MeetSudo: apiKey is required");
|
|
68
|
+
}
|
|
69
|
+
this.config = config;
|
|
70
|
+
this.state.apiKey = config.apiKey;
|
|
71
|
+
this.state.apiUrl = config.apiUrl || "https://api.meetsudo.com";
|
|
72
|
+
this.state.widgetUrl = config.widgetUrl || "https://widget.meetsudo.com";
|
|
73
|
+
this.state.anonId = this.getAnonId();
|
|
74
|
+
try {
|
|
75
|
+
const res = await this.api("/widget/init", {
|
|
76
|
+
anonymous_id: this.state.anonId,
|
|
77
|
+
url: window.location.href,
|
|
78
|
+
referrer: document.referrer
|
|
79
|
+
});
|
|
80
|
+
this.state.custId = res.customer_id;
|
|
81
|
+
this.state.features = res.features;
|
|
82
|
+
this.state.workspaceName = res.workspace_name;
|
|
83
|
+
this.state.initialized = true;
|
|
84
|
+
if (res.features.chat_enabled && !config.disableChat) {
|
|
85
|
+
this.createIframe(res);
|
|
86
|
+
}
|
|
87
|
+
if (res.features.events_enabled && !config.disableEvents) {
|
|
88
|
+
this.state.flushTimer = setInterval(() => this.flushEvents(), FLUSH_INTERVAL);
|
|
89
|
+
if (res.features.events_auto_page && !config.disableAutoPageView) {
|
|
90
|
+
this.page();
|
|
91
|
+
}
|
|
92
|
+
this.setupEmailCapture();
|
|
93
|
+
}
|
|
94
|
+
if (this.shouldSampleReplay() && !config.disableReplay) {
|
|
95
|
+
this.startReplay();
|
|
96
|
+
}
|
|
97
|
+
window.addEventListener("beforeunload", () => this.handleUnload());
|
|
98
|
+
} catch (error) {
|
|
99
|
+
console.error("MeetSudo: init failed", error);
|
|
100
|
+
throw error;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Identify a user
|
|
105
|
+
*/
|
|
106
|
+
async identify(userId, traits) {
|
|
107
|
+
if (!this.state.initialized) {
|
|
108
|
+
console.warn("MeetSudo: call init() before identify()");
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
const res = await this.api("/widget/identify", {
|
|
113
|
+
anonymous_id: this.state.anonId,
|
|
114
|
+
external_id: userId,
|
|
115
|
+
properties: traits || {}
|
|
116
|
+
});
|
|
117
|
+
this.state.custId = res.customer_id;
|
|
118
|
+
if (this.state.iframe?.contentWindow) {
|
|
119
|
+
this.state.iframe.contentWindow.postMessage(
|
|
120
|
+
{
|
|
121
|
+
type: "fi:identify",
|
|
122
|
+
customerId: res.customer_id,
|
|
123
|
+
merged: res.merged
|
|
124
|
+
},
|
|
125
|
+
"*"
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
} catch (error) {
|
|
129
|
+
console.error("MeetSudo: identify failed", error);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Track a custom event
|
|
134
|
+
*/
|
|
135
|
+
track(eventName, properties) {
|
|
136
|
+
if (!this.state.initialized || !this.state.features?.events_enabled) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
this.state.eventQ.push({
|
|
140
|
+
name: eventName,
|
|
141
|
+
properties: properties || {},
|
|
142
|
+
page_url: window.location.href,
|
|
143
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Track a page view
|
|
148
|
+
*/
|
|
149
|
+
page(properties) {
|
|
150
|
+
const props = {
|
|
151
|
+
url: window.location.href,
|
|
152
|
+
title: document.title,
|
|
153
|
+
referrer: document.referrer,
|
|
154
|
+
...properties
|
|
155
|
+
};
|
|
156
|
+
this.track("page_view", props);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Control the chat widget
|
|
160
|
+
*/
|
|
161
|
+
chat(action) {
|
|
162
|
+
if (!this.state.iframe?.contentWindow) return;
|
|
163
|
+
switch (action) {
|
|
164
|
+
case "open":
|
|
165
|
+
this.state.iframe.contentWindow.postMessage({ type: "fi:chat", action: "open" }, "*");
|
|
166
|
+
this.state.iframe.style.width = "400px";
|
|
167
|
+
this.state.iframe.style.height = "560px";
|
|
168
|
+
break;
|
|
169
|
+
case "close":
|
|
170
|
+
this.state.iframe.contentWindow.postMessage({ type: "fi:chat", action: "close" }, "*");
|
|
171
|
+
this.state.iframe.style.width = "80px";
|
|
172
|
+
this.state.iframe.style.height = "80px";
|
|
173
|
+
break;
|
|
174
|
+
case "hide":
|
|
175
|
+
this.state.iframe.style.display = "none";
|
|
176
|
+
break;
|
|
177
|
+
case "show":
|
|
178
|
+
this.state.iframe.style.display = "";
|
|
179
|
+
break;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Check if SDK is initialized
|
|
184
|
+
*/
|
|
185
|
+
isInitialized() {
|
|
186
|
+
return this.state.initialized;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Get the anonymous ID
|
|
190
|
+
*/
|
|
191
|
+
getAnonymousId() {
|
|
192
|
+
return this.state.anonId;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Get the customer ID (after identify)
|
|
196
|
+
*/
|
|
197
|
+
getCustomerId() {
|
|
198
|
+
return this.state.custId;
|
|
199
|
+
}
|
|
200
|
+
// Private methods
|
|
201
|
+
getAnonId() {
|
|
202
|
+
try {
|
|
203
|
+
const stored = localStorage.getItem(STORAGE_KEY);
|
|
204
|
+
if (stored) return stored;
|
|
205
|
+
} catch {
|
|
206
|
+
}
|
|
207
|
+
const id = crypto.randomUUID?.() || this.generateUUID();
|
|
208
|
+
try {
|
|
209
|
+
localStorage.setItem(STORAGE_KEY, id);
|
|
210
|
+
} catch {
|
|
211
|
+
}
|
|
212
|
+
return id;
|
|
213
|
+
}
|
|
214
|
+
generateUUID() {
|
|
215
|
+
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
216
|
+
const r = Math.random() * 16 | 0;
|
|
217
|
+
return (c === "x" ? r : r & 3 | 8).toString(16);
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
async api(path, data) {
|
|
221
|
+
const res = await fetch(this.state.apiUrl + path, {
|
|
222
|
+
method: "POST",
|
|
223
|
+
headers: {
|
|
224
|
+
"Content-Type": "application/json",
|
|
225
|
+
"X-API-Key": this.state.apiKey
|
|
226
|
+
},
|
|
227
|
+
body: JSON.stringify(data)
|
|
228
|
+
});
|
|
229
|
+
if (!res.ok) {
|
|
230
|
+
throw new Error(`HTTP ${res.status}`);
|
|
231
|
+
}
|
|
232
|
+
return res.json();
|
|
233
|
+
}
|
|
234
|
+
createIframe(initData) {
|
|
235
|
+
if (this.state.iframe) return;
|
|
236
|
+
const pos = this.state.features?.chat_position || "bottom-right";
|
|
237
|
+
const iframe = document.createElement("iframe");
|
|
238
|
+
iframe.id = "meetsudo-widget";
|
|
239
|
+
const posCSS = pos === "bottom-left" ? "left:0;" : "right:0;";
|
|
240
|
+
iframe.style.cssText = `position:fixed;bottom:0;${posCSS}width:80px;height:80px;border:none;z-index:999999;background:transparent;color-scheme:normal;`;
|
|
241
|
+
iframe.allow = "clipboard-write";
|
|
242
|
+
iframe.src = this.state.widgetUrl;
|
|
243
|
+
document.body.appendChild(iframe);
|
|
244
|
+
this.state.iframe = iframe;
|
|
245
|
+
iframe.onload = () => {
|
|
246
|
+
iframe.contentWindow?.postMessage(
|
|
247
|
+
{
|
|
248
|
+
type: "fi:config",
|
|
249
|
+
apiKey: this.state.apiKey,
|
|
250
|
+
apiUrl: this.state.apiUrl,
|
|
251
|
+
anonymousId: this.state.anonId,
|
|
252
|
+
customerId: this.state.custId,
|
|
253
|
+
workspaceName: this.state.workspaceName,
|
|
254
|
+
features: this.state.features,
|
|
255
|
+
conversationId: initData.open_conversation_id,
|
|
256
|
+
messages: initData.messages || []
|
|
257
|
+
},
|
|
258
|
+
"*"
|
|
259
|
+
);
|
|
260
|
+
};
|
|
261
|
+
window.addEventListener("message", (e) => {
|
|
262
|
+
if (e.data?.type === "fi:resize") {
|
|
263
|
+
if (e.data.state === "open") {
|
|
264
|
+
iframe.style.width = "400px";
|
|
265
|
+
iframe.style.height = "560px";
|
|
266
|
+
} else {
|
|
267
|
+
iframe.style.width = "80px";
|
|
268
|
+
iframe.style.height = "80px";
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
flushEvents() {
|
|
274
|
+
if (!this.state.eventQ.length) return;
|
|
275
|
+
const batch = this.state.eventQ.splice(0);
|
|
276
|
+
this.api("/widget/events", {
|
|
277
|
+
anonymous_id: this.state.anonId,
|
|
278
|
+
events: batch
|
|
279
|
+
}).catch(() => {
|
|
280
|
+
this.state.eventQ = batch.concat(this.state.eventQ);
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
shouldSampleReplay() {
|
|
284
|
+
if (!this.state.features?.replay_enabled) return false;
|
|
285
|
+
return Math.random() < (this.state.features.replay_sample_rate || 0);
|
|
286
|
+
}
|
|
287
|
+
startReplay() {
|
|
288
|
+
this.state.replaySessionId = crypto.randomUUID?.() || this.generateUUID();
|
|
289
|
+
this.state.replaySequence = 0;
|
|
290
|
+
this.state.replayEvents = [];
|
|
291
|
+
this.state.replayTotalEvents = 0;
|
|
292
|
+
this.state.replayStartedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
293
|
+
this.state.replayErrorCount = 0;
|
|
294
|
+
this.state.replayRageClickCount = 0;
|
|
295
|
+
this.setupRageClickDetection();
|
|
296
|
+
this.setupErrorCapture();
|
|
297
|
+
const script = document.createElement("script");
|
|
298
|
+
script.type = "module";
|
|
299
|
+
script.src = this.state.widgetUrl.replace(/\/?(index\.html)?$/, "") + "/replay.js";
|
|
300
|
+
document.head.appendChild(script);
|
|
301
|
+
let attempts = 0;
|
|
302
|
+
const checkRrweb = setInterval(() => {
|
|
303
|
+
attempts++;
|
|
304
|
+
if (window.rrweb?.record) {
|
|
305
|
+
clearInterval(checkRrweb);
|
|
306
|
+
this.initRrweb();
|
|
307
|
+
} else if (attempts > 50) {
|
|
308
|
+
clearInterval(checkRrweb);
|
|
309
|
+
console.warn("MeetSudo: replay failed to load");
|
|
310
|
+
}
|
|
311
|
+
}, 100);
|
|
312
|
+
}
|
|
313
|
+
initRrweb() {
|
|
314
|
+
this.state.replayStopFn = window.rrweb.record({
|
|
315
|
+
emit: (event) => {
|
|
316
|
+
this.state.replayEvents.push(event);
|
|
317
|
+
this.state.replayTotalEvents++;
|
|
318
|
+
},
|
|
319
|
+
maskAllInputs: false,
|
|
320
|
+
maskInputFn: (text, element) => {
|
|
321
|
+
if (this.isSensitiveInput(element)) {
|
|
322
|
+
return "*".repeat(text.length || 8);
|
|
323
|
+
}
|
|
324
|
+
return text;
|
|
325
|
+
},
|
|
326
|
+
blockSelector: ".meetsudo-no-record, [data-meetsudo-no-record]",
|
|
327
|
+
inlineStylesheet: true,
|
|
328
|
+
sampling: {
|
|
329
|
+
mousemove: 50,
|
|
330
|
+
mouseInteraction: true,
|
|
331
|
+
scroll: 150,
|
|
332
|
+
input: "last"
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
this.state.replayFlushTimer = setInterval(() => this.flushReplayChunk(), REPLAY_FLUSH_INTERVAL);
|
|
336
|
+
}
|
|
337
|
+
isSensitiveInput(el) {
|
|
338
|
+
if (!el) return true;
|
|
339
|
+
const input = el;
|
|
340
|
+
const type = (input.type || "").toLowerCase();
|
|
341
|
+
const name = (input.name || "").toLowerCase();
|
|
342
|
+
const id = (input.id || "").toLowerCase();
|
|
343
|
+
if (type === "password") return true;
|
|
344
|
+
const sensitivePatterns = [/password/i, /card/i, /cvv/i, /cvc/i, /ssn/i, /secret/i, /token/i];
|
|
345
|
+
const identifiers = name + " " + id;
|
|
346
|
+
return sensitivePatterns.some((p) => p.test(identifiers));
|
|
347
|
+
}
|
|
348
|
+
flushReplayChunk() {
|
|
349
|
+
if (!this.state.replayEvents.length) return;
|
|
350
|
+
const events = this.state.replayEvents.splice(0);
|
|
351
|
+
const seq = this.state.replaySequence++;
|
|
352
|
+
const payload = {
|
|
353
|
+
anonymous_id: this.state.anonId,
|
|
354
|
+
session_id: this.state.replaySessionId,
|
|
355
|
+
sequence: seq,
|
|
356
|
+
events,
|
|
357
|
+
error_count: this.state.replayErrorCount,
|
|
358
|
+
rage_click_count: this.state.replayRageClickCount
|
|
359
|
+
};
|
|
360
|
+
if (seq === 0) {
|
|
361
|
+
payload.page_url = window.location.href;
|
|
362
|
+
payload.user_agent = navigator.userAgent;
|
|
363
|
+
payload.screen_width = window.innerWidth;
|
|
364
|
+
payload.screen_height = window.innerHeight;
|
|
365
|
+
payload.started_at = this.state.replayStartedAt;
|
|
366
|
+
}
|
|
367
|
+
this.api("/widget/replay/chunk", payload).catch(() => {
|
|
368
|
+
this.state.replayEvents = events.concat(this.state.replayEvents);
|
|
369
|
+
this.state.replaySequence--;
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
setupRageClickDetection() {
|
|
373
|
+
document.addEventListener(
|
|
374
|
+
"click",
|
|
375
|
+
(e) => {
|
|
376
|
+
if (!this.state.replaySessionId) return;
|
|
377
|
+
const now = Date.now();
|
|
378
|
+
const target = e.target;
|
|
379
|
+
if (target === this.state.lastClickTarget && now - this.state.lastClickTime < 500) {
|
|
380
|
+
this.state.clickCount++;
|
|
381
|
+
if (this.state.clickCount >= 3) {
|
|
382
|
+
this.state.replayRageClickCount++;
|
|
383
|
+
this.state.clickCount = 0;
|
|
384
|
+
this.track("rage_click", { page_url: window.location.href });
|
|
385
|
+
}
|
|
386
|
+
} else {
|
|
387
|
+
this.state.clickCount = 1;
|
|
388
|
+
}
|
|
389
|
+
this.state.lastClickTime = now;
|
|
390
|
+
this.state.lastClickTarget = target;
|
|
391
|
+
},
|
|
392
|
+
true
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
setupErrorCapture() {
|
|
396
|
+
window.onerror = (message, source, lineno, colno) => {
|
|
397
|
+
if (this.state.replaySessionId) {
|
|
398
|
+
this.state.replayErrorCount++;
|
|
399
|
+
this.track("js_error", {
|
|
400
|
+
message: String(message).substring(0, 500),
|
|
401
|
+
source: source || "",
|
|
402
|
+
lineno: lineno || 0
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
return false;
|
|
406
|
+
};
|
|
407
|
+
window.addEventListener("unhandledrejection", (e) => {
|
|
408
|
+
if (this.state.replaySessionId) {
|
|
409
|
+
this.state.replayErrorCount++;
|
|
410
|
+
const message = e.reason instanceof Error ? e.reason.message : String(e.reason);
|
|
411
|
+
this.track("js_error", { message: message.substring(0, 500), type: "unhandledrejection" });
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
setupEmailCapture() {
|
|
416
|
+
document.addEventListener(
|
|
417
|
+
"blur",
|
|
418
|
+
(e) => {
|
|
419
|
+
const el = e.target;
|
|
420
|
+
if (!el || el.tagName !== "INPUT") return;
|
|
421
|
+
const type = (el.type || "").toLowerCase();
|
|
422
|
+
const name = (el.name || "").toLowerCase();
|
|
423
|
+
if (type === "email" || /email/.test(name)) {
|
|
424
|
+
const value = el.value?.trim();
|
|
425
|
+
if (value && /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value) && !this.state.capturedEmails[value]) {
|
|
426
|
+
this.state.capturedEmails[value] = true;
|
|
427
|
+
this.track("email_captured", { email: value });
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
true
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
handleUnload() {
|
|
435
|
+
if (this.state.flushTimer) {
|
|
436
|
+
clearInterval(this.state.flushTimer);
|
|
437
|
+
}
|
|
438
|
+
if (this.state.eventQ.length && this.state.apiKey) {
|
|
439
|
+
const apiKey = this.state.apiKey;
|
|
440
|
+
try {
|
|
441
|
+
fetch(this.state.apiUrl + "/widget/events", {
|
|
442
|
+
method: "POST",
|
|
443
|
+
headers: {
|
|
444
|
+
"Content-Type": "application/json",
|
|
445
|
+
"X-API-Key": apiKey
|
|
446
|
+
},
|
|
447
|
+
body: JSON.stringify({
|
|
448
|
+
anonymous_id: this.state.anonId,
|
|
449
|
+
events: this.state.eventQ
|
|
450
|
+
}),
|
|
451
|
+
keepalive: true
|
|
452
|
+
}).catch(() => {
|
|
453
|
+
});
|
|
454
|
+
} catch {
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
if (this.state.replaySessionId && this.state.apiKey) {
|
|
458
|
+
const replayApiKey = this.state.apiKey;
|
|
459
|
+
if (this.state.replayStopFn) {
|
|
460
|
+
this.state.replayStopFn();
|
|
461
|
+
}
|
|
462
|
+
if (this.state.replayFlushTimer) {
|
|
463
|
+
clearInterval(this.state.replayFlushTimer);
|
|
464
|
+
}
|
|
465
|
+
try {
|
|
466
|
+
fetch(this.state.apiUrl + "/widget/replay/end", {
|
|
467
|
+
method: "POST",
|
|
468
|
+
headers: {
|
|
469
|
+
"Content-Type": "application/json",
|
|
470
|
+
"X-API-Key": replayApiKey
|
|
471
|
+
},
|
|
472
|
+
body: JSON.stringify({
|
|
473
|
+
anonymous_id: this.state.anonId,
|
|
474
|
+
session_id: this.state.replaySessionId,
|
|
475
|
+
ended_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
476
|
+
event_count: this.state.replayTotalEvents,
|
|
477
|
+
error_count: this.state.replayErrorCount,
|
|
478
|
+
rage_click_count: this.state.replayRageClickCount
|
|
479
|
+
}),
|
|
480
|
+
keepalive: true
|
|
481
|
+
}).catch(() => {
|
|
482
|
+
});
|
|
483
|
+
} catch {
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
};
|
|
488
|
+
|
|
489
|
+
// src/index.ts
|
|
490
|
+
var meetsudo = new MeetSudo();
|
|
491
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
492
|
+
0 && (module.exports = {
|
|
493
|
+
MeetSudo,
|
|
494
|
+
meetsudo
|
|
495
|
+
});
|
|
496
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/sdk.ts"],"sourcesContent":["export { MeetSudo } from \"./sdk\";\nexport type {\n MeetSudoConfig,\n UserTraits,\n EventProperties,\n PageProperties,\n ChatAction,\n} from \"./types\";\n\n// Default instance for convenience\nimport { MeetSudo } from \"./sdk\";\nexport const meetsudo = new MeetSudo();\n","import type {\n MeetSudoConfig,\n UserTraits,\n EventProperties,\n PageProperties,\n Features,\n InitResponse,\n IdentifyResponse,\n ChatAction,\n} from \"./types\";\n\nconst STORAGE_KEY = \"meetsudo_anon_id\";\nconst FLUSH_INTERVAL = 5000;\nconst REPLAY_FLUSH_INTERVAL = 10000;\n\ninterface EventData {\n name: string;\n properties: EventProperties;\n page_url: string;\n timestamp: string;\n}\n\ninterface State {\n apiKey: string | null;\n apiUrl: string;\n widgetUrl: string;\n anonId: string | null;\n custId: string | null;\n features: Features | null;\n workspaceName: string | null;\n initialized: boolean;\n iframe: HTMLIFrameElement | null;\n eventQ: EventData[];\n flushTimer: ReturnType<typeof setInterval> | null;\n replaySessionId: string | null;\n replaySequence: number;\n replayEvents: unknown[];\n replayFlushTimer: ReturnType<typeof setInterval> | null;\n replayStopFn: (() => void) | null;\n replayTotalEvents: number;\n replayStartedAt: string | null;\n replayRageClickCount: number;\n replayErrorCount: number;\n lastClickTime: number;\n lastClickTarget: EventTarget | null;\n clickCount: number;\n capturedEmails: Record<string, boolean>;\n}\n\nexport class MeetSudo {\n private state: State = {\n apiKey: null,\n apiUrl: \"https://api.meetsudo.com\",\n widgetUrl: \"https://widget.meetsudo.com\",\n anonId: null,\n custId: null,\n features: null,\n workspaceName: null,\n initialized: false,\n iframe: null,\n eventQ: [],\n flushTimer: null,\n replaySessionId: null,\n replaySequence: 0,\n replayEvents: [],\n replayFlushTimer: null,\n replayStopFn: null,\n replayTotalEvents: 0,\n replayStartedAt: null,\n replayRageClickCount: 0,\n replayErrorCount: 0,\n lastClickTime: 0,\n lastClickTarget: null,\n clickCount: 0,\n capturedEmails: {},\n };\n\n private config: MeetSudoConfig | null = null;\n\n /**\n * Initialize the MeetSudo SDK\n */\n async init(config: MeetSudoConfig): Promise<void> {\n if (!config.apiKey) {\n throw new Error(\"MeetSudo: apiKey is required\");\n }\n\n this.config = config;\n this.state.apiKey = config.apiKey;\n this.state.apiUrl = config.apiUrl || \"https://api.meetsudo.com\";\n this.state.widgetUrl = config.widgetUrl || \"https://widget.meetsudo.com\";\n this.state.anonId = this.getAnonId();\n\n try {\n const res = await this.api<InitResponse>(\"/widget/init\", {\n anonymous_id: this.state.anonId,\n url: window.location.href,\n referrer: document.referrer,\n });\n\n this.state.custId = res.customer_id;\n this.state.features = res.features;\n this.state.workspaceName = res.workspace_name;\n this.state.initialized = true;\n\n // Create chat iframe if enabled\n if (res.features.chat_enabled && !config.disableChat) {\n this.createIframe(res);\n }\n\n // Start event tracking if enabled\n if (res.features.events_enabled && !config.disableEvents) {\n this.state.flushTimer = setInterval(() => this.flushEvents(), FLUSH_INTERVAL);\n if (res.features.events_auto_page && !config.disableAutoPageView) {\n this.page();\n }\n this.setupEmailCapture();\n }\n\n // Start session replay if enabled and sampled in\n if (this.shouldSampleReplay() && !config.disableReplay) {\n this.startReplay();\n }\n\n // Setup beforeunload handler\n window.addEventListener(\"beforeunload\", () => this.handleUnload());\n } catch (error) {\n console.error(\"MeetSudo: init failed\", error);\n throw error;\n }\n }\n\n /**\n * Identify a user\n */\n async identify(userId: string, traits?: UserTraits): Promise<void> {\n if (!this.state.initialized) {\n console.warn(\"MeetSudo: call init() before identify()\");\n return;\n }\n\n try {\n const res = await this.api<IdentifyResponse>(\"/widget/identify\", {\n anonymous_id: this.state.anonId,\n external_id: userId,\n properties: traits || {},\n });\n\n this.state.custId = res.customer_id;\n\n // Notify chat iframe about identity change\n if (this.state.iframe?.contentWindow) {\n this.state.iframe.contentWindow.postMessage(\n {\n type: \"fi:identify\",\n customerId: res.customer_id,\n merged: res.merged,\n },\n \"*\"\n );\n }\n } catch (error) {\n console.error(\"MeetSudo: identify failed\", error);\n }\n }\n\n /**\n * Track a custom event\n */\n track(eventName: string, properties?: EventProperties): void {\n if (!this.state.initialized || !this.state.features?.events_enabled) {\n return;\n }\n\n this.state.eventQ.push({\n name: eventName,\n properties: properties || {},\n page_url: window.location.href,\n timestamp: new Date().toISOString(),\n });\n }\n\n /**\n * Track a page view\n */\n page(properties?: PageProperties): void {\n const props: PageProperties = {\n url: window.location.href,\n title: document.title,\n referrer: document.referrer,\n ...properties,\n };\n this.track(\"page_view\", props);\n }\n\n /**\n * Control the chat widget\n */\n chat(action: ChatAction): void {\n if (!this.state.iframe?.contentWindow) return;\n\n switch (action) {\n case \"open\":\n this.state.iframe.contentWindow.postMessage({ type: \"fi:chat\", action: \"open\" }, \"*\");\n this.state.iframe.style.width = \"400px\";\n this.state.iframe.style.height = \"560px\";\n break;\n case \"close\":\n this.state.iframe.contentWindow.postMessage({ type: \"fi:chat\", action: \"close\" }, \"*\");\n this.state.iframe.style.width = \"80px\";\n this.state.iframe.style.height = \"80px\";\n break;\n case \"hide\":\n this.state.iframe.style.display = \"none\";\n break;\n case \"show\":\n this.state.iframe.style.display = \"\";\n break;\n }\n }\n\n /**\n * Check if SDK is initialized\n */\n isInitialized(): boolean {\n return this.state.initialized;\n }\n\n /**\n * Get the anonymous ID\n */\n getAnonymousId(): string | null {\n return this.state.anonId;\n }\n\n /**\n * Get the customer ID (after identify)\n */\n getCustomerId(): string | null {\n return this.state.custId;\n }\n\n // Private methods\n\n private getAnonId(): string {\n try {\n const stored = localStorage.getItem(STORAGE_KEY);\n if (stored) return stored;\n } catch {\n /* private browsing */\n }\n\n const id = crypto.randomUUID?.() || this.generateUUID();\n try {\n localStorage.setItem(STORAGE_KEY, id);\n } catch {\n /* ignore */\n }\n return id;\n }\n\n private generateUUID(): string {\n return \"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx\".replace(/[xy]/g, (c) => {\n const r = (Math.random() * 16) | 0;\n return (c === \"x\" ? r : (r & 0x3) | 0x8).toString(16);\n });\n }\n\n private async api<T>(path: string, data: unknown): Promise<T> {\n const res = await fetch(this.state.apiUrl + path, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"X-API-Key\": this.state.apiKey!,\n },\n body: JSON.stringify(data),\n });\n\n if (!res.ok) {\n throw new Error(`HTTP ${res.status}`);\n }\n\n return res.json();\n }\n\n private createIframe(initData: InitResponse): void {\n if (this.state.iframe) return;\n\n const pos = this.state.features?.chat_position || \"bottom-right\";\n const iframe = document.createElement(\"iframe\");\n iframe.id = \"meetsudo-widget\";\n const posCSS = pos === \"bottom-left\" ? \"left:0;\" : \"right:0;\";\n iframe.style.cssText = `position:fixed;bottom:0;${posCSS}width:80px;height:80px;border:none;z-index:999999;background:transparent;color-scheme:normal;`;\n iframe.allow = \"clipboard-write\";\n iframe.src = this.state.widgetUrl;\n\n document.body.appendChild(iframe);\n this.state.iframe = iframe;\n\n iframe.onload = () => {\n iframe.contentWindow?.postMessage(\n {\n type: \"fi:config\",\n apiKey: this.state.apiKey,\n apiUrl: this.state.apiUrl,\n anonymousId: this.state.anonId,\n customerId: this.state.custId,\n workspaceName: this.state.workspaceName,\n features: this.state.features,\n conversationId: initData.open_conversation_id,\n messages: initData.messages || [],\n },\n \"*\"\n );\n };\n\n window.addEventListener(\"message\", (e) => {\n if (e.data?.type === \"fi:resize\") {\n if (e.data.state === \"open\") {\n iframe.style.width = \"400px\";\n iframe.style.height = \"560px\";\n } else {\n iframe.style.width = \"80px\";\n iframe.style.height = \"80px\";\n }\n }\n });\n }\n\n private flushEvents(): void {\n if (!this.state.eventQ.length) return;\n\n const batch = this.state.eventQ.splice(0);\n this.api(\"/widget/events\", {\n anonymous_id: this.state.anonId,\n events: batch,\n }).catch(() => {\n // Put events back on failure\n this.state.eventQ = batch.concat(this.state.eventQ);\n });\n }\n\n private shouldSampleReplay(): boolean {\n if (!this.state.features?.replay_enabled) return false;\n return Math.random() < (this.state.features.replay_sample_rate || 0);\n }\n\n private startReplay(): void {\n this.state.replaySessionId = crypto.randomUUID?.() || this.generateUUID();\n this.state.replaySequence = 0;\n this.state.replayEvents = [];\n this.state.replayTotalEvents = 0;\n this.state.replayStartedAt = new Date().toISOString();\n this.state.replayErrorCount = 0;\n this.state.replayRageClickCount = 0;\n\n this.setupRageClickDetection();\n this.setupErrorCapture();\n\n // Load rrweb dynamically\n const script = document.createElement(\"script\");\n script.type = \"module\";\n script.src = this.state.widgetUrl.replace(/\\/?(index\\.html)?$/, \"\") + \"/replay.js\";\n document.head.appendChild(script);\n\n // Wait for rrweb to load\n let attempts = 0;\n const checkRrweb = setInterval(() => {\n attempts++;\n // @ts-expect-error rrweb is loaded dynamically\n if (window.rrweb?.record) {\n clearInterval(checkRrweb);\n this.initRrweb();\n } else if (attempts > 50) {\n clearInterval(checkRrweb);\n console.warn(\"MeetSudo: replay failed to load\");\n }\n }, 100);\n }\n\n private initRrweb(): void {\n // @ts-expect-error rrweb is loaded dynamically\n this.state.replayStopFn = window.rrweb.record({\n emit: (event: unknown) => {\n this.state.replayEvents.push(event);\n this.state.replayTotalEvents++;\n },\n maskAllInputs: false,\n maskInputFn: (text: string, element: HTMLElement) => {\n if (this.isSensitiveInput(element)) {\n return \"*\".repeat(text.length || 8);\n }\n return text;\n },\n blockSelector: \".meetsudo-no-record, [data-meetsudo-no-record]\",\n inlineStylesheet: true,\n sampling: {\n mousemove: 50,\n mouseInteraction: true,\n scroll: 150,\n input: \"last\",\n },\n });\n\n this.state.replayFlushTimer = setInterval(() => this.flushReplayChunk(), REPLAY_FLUSH_INTERVAL);\n }\n\n private isSensitiveInput(el: HTMLElement): boolean {\n if (!el) return true;\n const input = el as HTMLInputElement;\n const type = (input.type || \"\").toLowerCase();\n const name = (input.name || \"\").toLowerCase();\n const id = (input.id || \"\").toLowerCase();\n\n if (type === \"password\") return true;\n\n const sensitivePatterns = [/password/i, /card/i, /cvv/i, /cvc/i, /ssn/i, /secret/i, /token/i];\n const identifiers = name + \" \" + id;\n return sensitivePatterns.some((p) => p.test(identifiers));\n }\n\n private flushReplayChunk(): void {\n if (!this.state.replayEvents.length) return;\n\n const events = this.state.replayEvents.splice(0);\n const seq = this.state.replaySequence++;\n\n const payload: Record<string, unknown> = {\n anonymous_id: this.state.anonId,\n session_id: this.state.replaySessionId,\n sequence: seq,\n events,\n error_count: this.state.replayErrorCount,\n rage_click_count: this.state.replayRageClickCount,\n };\n\n if (seq === 0) {\n payload.page_url = window.location.href;\n payload.user_agent = navigator.userAgent;\n payload.screen_width = window.innerWidth;\n payload.screen_height = window.innerHeight;\n payload.started_at = this.state.replayStartedAt;\n }\n\n this.api(\"/widget/replay/chunk\", payload).catch(() => {\n this.state.replayEvents = events.concat(this.state.replayEvents);\n this.state.replaySequence--;\n });\n }\n\n private setupRageClickDetection(): void {\n document.addEventListener(\n \"click\",\n (e) => {\n if (!this.state.replaySessionId) return;\n\n const now = Date.now();\n const target = e.target;\n\n if (target === this.state.lastClickTarget && now - this.state.lastClickTime < 500) {\n this.state.clickCount++;\n if (this.state.clickCount >= 3) {\n this.state.replayRageClickCount++;\n this.state.clickCount = 0;\n this.track(\"rage_click\", { page_url: window.location.href });\n }\n } else {\n this.state.clickCount = 1;\n }\n\n this.state.lastClickTime = now;\n this.state.lastClickTarget = target;\n },\n true\n );\n }\n\n private setupErrorCapture(): void {\n window.onerror = (message, source, lineno, colno) => {\n if (this.state.replaySessionId) {\n this.state.replayErrorCount++;\n this.track(\"js_error\", {\n message: String(message).substring(0, 500),\n source: source || \"\",\n lineno: lineno || 0,\n });\n }\n return false;\n };\n\n window.addEventListener(\"unhandledrejection\", (e) => {\n if (this.state.replaySessionId) {\n this.state.replayErrorCount++;\n const message = e.reason instanceof Error ? e.reason.message : String(e.reason);\n this.track(\"js_error\", { message: message.substring(0, 500), type: \"unhandledrejection\" });\n }\n });\n }\n\n private setupEmailCapture(): void {\n document.addEventListener(\n \"blur\",\n (e) => {\n const el = e.target as HTMLInputElement;\n if (!el || el.tagName !== \"INPUT\") return;\n\n const type = (el.type || \"\").toLowerCase();\n const name = (el.name || \"\").toLowerCase();\n if (type === \"email\" || /email/.test(name)) {\n const value = el.value?.trim();\n if (value && /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(value) && !this.state.capturedEmails[value]) {\n this.state.capturedEmails[value] = true;\n this.track(\"email_captured\", { email: value });\n }\n }\n },\n true\n );\n }\n\n private handleUnload(): void {\n if (this.state.flushTimer) {\n clearInterval(this.state.flushTimer);\n }\n\n // Flush remaining events\n if (this.state.eventQ.length && this.state.apiKey) {\n const apiKey = this.state.apiKey;\n try {\n fetch(this.state.apiUrl + \"/widget/events\", {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"X-API-Key\": apiKey,\n },\n body: JSON.stringify({\n anonymous_id: this.state.anonId,\n events: this.state.eventQ,\n }),\n keepalive: true,\n }).catch(() => {});\n } catch {\n /* ignore */\n }\n }\n\n // End replay\n if (this.state.replaySessionId && this.state.apiKey) {\n const replayApiKey = this.state.apiKey;\n if (this.state.replayStopFn) {\n this.state.replayStopFn();\n }\n if (this.state.replayFlushTimer) {\n clearInterval(this.state.replayFlushTimer);\n }\n\n try {\n fetch(this.state.apiUrl + \"/widget/replay/end\", {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n \"X-API-Key\": replayApiKey,\n },\n body: JSON.stringify({\n anonymous_id: this.state.anonId,\n session_id: this.state.replaySessionId,\n ended_at: new Date().toISOString(),\n event_count: this.state.replayTotalEvents,\n error_count: this.state.replayErrorCount,\n rage_click_count: this.state.replayRageClickCount,\n }),\n keepalive: true,\n }).catch(() => {});\n } catch {\n /* ignore */\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACWA,IAAM,cAAc;AACpB,IAAM,iBAAiB;AACvB,IAAM,wBAAwB;AAoCvB,IAAM,WAAN,MAAe;AAAA,EAAf;AACL,SAAQ,QAAe;AAAA,MACrB,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,WAAW;AAAA,MACX,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,UAAU;AAAA,MACV,eAAe;AAAA,MACf,aAAa;AAAA,MACb,QAAQ;AAAA,MACR,QAAQ,CAAC;AAAA,MACT,YAAY;AAAA,MACZ,iBAAiB;AAAA,MACjB,gBAAgB;AAAA,MAChB,cAAc,CAAC;AAAA,MACf,kBAAkB;AAAA,MAClB,cAAc;AAAA,MACd,mBAAmB;AAAA,MACnB,iBAAiB;AAAA,MACjB,sBAAsB;AAA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