@magicfeedback/popup-sdk 1.2.0 → 1.3.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 +113 -70
- package/dist/assets/assets/style.css +5 -1
- package/dist/chunk-R4B3K2ZW.mjs +176 -0
- package/dist/chunk-R4B3K2ZW.mjs.map +1 -0
- package/dist/chunk-XFA2Y6CK.mjs +197 -0
- package/dist/chunk-XFA2Y6CK.mjs.map +1 -0
- package/dist/index.d.mts +11 -5
- package/dist/index.d.ts +11 -5
- package/dist/index.js +239 -895
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +235 -29
- package/dist/index.mjs.map +1 -1
- package/dist/react-native.d.mts +1 -1
- package/dist/react-native.d.ts +1 -1
- package/dist/react-native.js +241 -896
- package/dist/react-native.js.map +1 -1
- package/dist/react-native.mjs +237 -30
- package/dist/react-native.mjs.map +1 -1
- package/dist/{renderPopup-R53C7DB3.mjs → renderPopup-NJK7Z46E.mjs} +4 -870
- package/dist/renderPopup-NJK7Z46E.mjs.map +1 -0
- package/dist/{renderPopup-NHWJ7YSI.mjs → renderPopup-ZYXOUBCP.mjs} +4 -870
- package/dist/renderPopup-ZYXOUBCP.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/chunk-4UXOEIAB.mjs +0 -172
- package/dist/chunk-4UXOEIAB.mjs.map +0 -1
- package/dist/chunk-XOTM5CHX.mjs +0 -193
- package/dist/chunk-XOTM5CHX.mjs.map +0 -1
- package/dist/renderPopup-NHWJ7YSI.mjs.map +0 -1
- package/dist/renderPopup-R53C7DB3.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -7,8 +7,9 @@ import {
|
|
|
7
7
|
buildSurveyIdentity,
|
|
8
8
|
createDefaultStorage,
|
|
9
9
|
sdkWarn,
|
|
10
|
-
setLogger
|
|
11
|
-
|
|
10
|
+
setLogger,
|
|
11
|
+
style_default
|
|
12
|
+
} from "./chunk-XFA2Y6CK.mjs";
|
|
12
13
|
|
|
13
14
|
// src/types/index.ts
|
|
14
15
|
var POPUP_TRIGGER_CONDITION_STATUSES = [
|
|
@@ -195,6 +196,15 @@ function resolveEnvironment(nodeEnv) {
|
|
|
195
196
|
}
|
|
196
197
|
|
|
197
198
|
// src/ui/surveyHtml.ts
|
|
199
|
+
var POSITION_MAP = {
|
|
200
|
+
center: { justifyContent: "center", alignItems: "center", padding: "0", background: "rgba(0,0,0,0.5)" },
|
|
201
|
+
bottom: { justifyContent: "center", alignItems: "flex-end", padding: "16px", background: "transparent" },
|
|
202
|
+
"bottom-right": { justifyContent: "flex-end", alignItems: "flex-end", padding: "16px", background: "transparent" },
|
|
203
|
+
"bottom-left": { justifyContent: "flex-start", alignItems: "flex-end", padding: "16px", background: "transparent" },
|
|
204
|
+
top: { justifyContent: "center", alignItems: "flex-start", padding: "16px", background: "transparent" },
|
|
205
|
+
"top-right": { justifyContent: "flex-end", alignItems: "flex-start", padding: "16px", background: "transparent" },
|
|
206
|
+
"top-left": { justifyContent: "flex-start", alignItems: "flex-start", padding: "16px", background: "transparent" }
|
|
207
|
+
};
|
|
198
208
|
function buildSurveyHtml(opts) {
|
|
199
209
|
const env = opts.env === "development" ? "dev" : "prod";
|
|
200
210
|
const version = opts.version ?? "2.2.4";
|
|
@@ -205,17 +215,141 @@ function buildSurveyHtml(opts) {
|
|
|
205
215
|
const metaJson = JSON.stringify(opts.metadata ?? []);
|
|
206
216
|
const fontFaceCss = opts.font ? buildFontFaceCss(opts.font.family, opts.font.url) : "";
|
|
207
217
|
const fontFamilyValue = opts.font ? buildFontFamilyValue(opts.font.family) : "-apple-system,system-ui,sans-serif";
|
|
218
|
+
const popupClass = opts.font?.family ? "deepdots-popup deepdots-has-font" : "deepdots-popup";
|
|
219
|
+
const isDark = opts.theme === "dark";
|
|
220
|
+
const popupBg = isDark ? "#1e1e1e" : "#fff";
|
|
221
|
+
const colorScheme = isDark ? "dark" : "light";
|
|
222
|
+
const textPrimary = isDark ? "#f0f0f0" : "#111";
|
|
223
|
+
const pos = POSITION_MAP[opts.position ?? "center"] ?? POSITION_MAP.center;
|
|
224
|
+
const backLabel = JSON.stringify(opts.actions?.back?.label ?? "Back");
|
|
225
|
+
const startLabel = JSON.stringify(opts.actions?.start?.label ?? "Start survey");
|
|
226
|
+
const completeLabel = JSON.stringify(opts.actions?.complete?.label ?? "Complete survey");
|
|
227
|
+
const submitLabel = JSON.stringify(opts.actions?.accept?.label ?? "Send");
|
|
208
228
|
return `<!DOCTYPE html><html><head>
|
|
209
229
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
210
|
-
<meta name="color-scheme" content="
|
|
211
|
-
<style
|
|
230
|
+
<meta name="color-scheme" content="${colorScheme}"/>
|
|
231
|
+
<style>
|
|
232
|
+
${style_default}
|
|
233
|
+
${fontFaceCss}
|
|
234
|
+
html,body{margin:0;padding:0;height:100%;font-family:${fontFamilyValue}}
|
|
235
|
+
body{display:flex;justify-content:${pos.justifyContent};align-items:${pos.alignItems};background:${pos.background};padding:${pos.padding};box-sizing:border-box}
|
|
236
|
+
.deepdots-popup{position:relative;display:flex;flex-direction:column;justify-content:flex-start;background:${popupBg};color-scheme:${colorScheme};border-radius:8px;padding:24px;box-shadow:0 4px 6px rgba(0,0,0,0.1);max-width:600px;width:90%;min-height:200px;box-sizing:border-box}
|
|
237
|
+
.deepdots-popup-header{display:flex;justify-content:flex-end;align-items:center;width:100%}
|
|
238
|
+
#dd-close{background:transparent;border:none;width:32px;height:32px;display:flex;align-items:center;justify-content:center;border-radius:8px;cursor:pointer;color:${textPrimary};padding:4px}
|
|
239
|
+
.deepdots-popup-container-content{display:flex;flex-direction:column;padding:0 20px 12px 20px;max-height:80vh;overflow:hidden;box-sizing:border-box}
|
|
240
|
+
.deepdots-popup-main{display:flex;flex-direction:column;width:100%;max-height:80vh;overflow-y:auto;overflow-x:hidden;position:relative}
|
|
241
|
+
#dd-form-wrapper{width:100%;flex:1 1 auto}
|
|
242
|
+
#mf{width:100%;box-sizing:border-box;visibility:hidden}
|
|
243
|
+
.deepdots-popup-main *{max-width:100%;box-sizing:border-box}
|
|
244
|
+
#dd-logo{max-height:40px;max-width:100%;object-fit:contain}
|
|
245
|
+
.deepdots-error-hint{display:none;margin:12px 0 0 0;padding:10px 12px;border-radius:6px;background:#FEF3C7;color:#92400E;border:1px solid #FCD34D;font-size:13px}
|
|
246
|
+
.deepdots-popup-footer{display:flex;flex-direction:row-reverse;justify-content:space-between;align-items:center;gap:8px;margin-top:auto;width:100%;padding-top:16px}
|
|
247
|
+
.dd-nav-btn{display:none;border:none;padding:12px 24px;border-radius:4px;cursor:pointer;font-size:14px;box-shadow:0 2px 4px rgba(0,0,0,0.1);align-items:center;justify-content:center;text-align:center}
|
|
248
|
+
#dd-back{background:transparent;color:#333;border:1px solid #999}
|
|
249
|
+
#dd-start,#dd-complete,#dd-submit{background:#1E293B;color:#fff;border:none}
|
|
250
|
+
#dd-submit:disabled,#dd-start:disabled,#dd-back:disabled,#dd-complete:disabled{opacity:0.6;cursor:not-allowed}
|
|
251
|
+
.mf-spinner{display:none;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}
|
|
252
|
+
.mf-spinner-circle{width:28px;height:28px;border:3px solid #e0e6ed;border-top-color:#1E293B;border-radius:50%;animation:ddspin 0.9s linear infinite}
|
|
253
|
+
@keyframes ddspin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}
|
|
254
|
+
@media (max-width:640px){
|
|
255
|
+
.deepdots-popup{width:calc(100% - 24px);max-width:calc(100% - 24px);border-radius:12px}
|
|
256
|
+
.deepdots-popup-footer{flex-direction:column-reverse;gap:12px}
|
|
257
|
+
.dd-nav-btn{width:100%}
|
|
258
|
+
.magicfeedback-checkbox-container,.magicfeedback-radio-container{margin:4px 0;padding:4px 8px}
|
|
259
|
+
.magicfeedback-checkbox label,.magicfeedback-radio-container label{font-size:15px}
|
|
260
|
+
.deepdots-popup input[type="radio"]{margin:6px 0 6px 8px}
|
|
261
|
+
.deepdots-popup input[type="checkbox"]{width:16px;height:16px}
|
|
262
|
+
}
|
|
263
|
+
</style>
|
|
212
264
|
</head><body>
|
|
213
|
-
<div id="
|
|
265
|
+
<div class="${popupClass}" id="dd-popup">
|
|
266
|
+
<div class="deepdots-popup-header">
|
|
267
|
+
<button type="button" id="dd-close" aria-label="Close popup">
|
|
268
|
+
<svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
269
|
+
<path d="M6 6L18 18M6 18L18 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
270
|
+
</svg>
|
|
271
|
+
</button>
|
|
272
|
+
</div>
|
|
273
|
+
<div class="deepdots-popup-container-content">
|
|
274
|
+
<div class="deepdots-popup-main" id="dd-main">
|
|
275
|
+
<div id="dd-form-wrapper">
|
|
276
|
+
<div class="mf-spinner" id="dd-spinner" role="status" aria-label="Loading survey"><div class="mf-spinner-circle"></div></div>
|
|
277
|
+
<div id="mf"></div>
|
|
278
|
+
</div>
|
|
279
|
+
<div class="deepdots-error-hint" id="dd-error" role="alert" aria-live="polite"></div>
|
|
280
|
+
<div class="deepdots-popup-footer" id="dd-footer">
|
|
281
|
+
<button type="button" class="dd-nav-btn" id="dd-submit">Send</button>
|
|
282
|
+
<button type="button" class="dd-nav-btn" id="dd-back">Back</button>
|
|
283
|
+
<button type="button" class="dd-nav-btn" id="dd-complete">Complete survey</button>
|
|
284
|
+
<button type="button" class="dd-nav-btn" id="dd-start">Start survey</button>
|
|
285
|
+
</div>
|
|
286
|
+
</div>
|
|
287
|
+
</div>
|
|
288
|
+
</div>
|
|
214
289
|
<script>
|
|
215
290
|
(function(){
|
|
216
291
|
function emit(s){ try{ if(window.ReactNativeWebView){ window.ReactNativeWebView.postMessage(s); } }catch(e){} }
|
|
217
292
|
function emitJSON(n,p){ try{ emit(JSON.stringify({name:n,payload:p||{}})); }catch(e){} }
|
|
218
293
|
window.DeepdotsClose = function(){ emitJSON('popup_close'); };
|
|
294
|
+
|
|
295
|
+
var popup=document.getElementById('dd-popup');
|
|
296
|
+
var main=document.getElementById('dd-main');
|
|
297
|
+
var footer=document.getElementById('dd-footer');
|
|
298
|
+
var spinner=document.getElementById('dd-spinner');
|
|
299
|
+
var formHost=document.getElementById('mf');
|
|
300
|
+
var errorHint=document.getElementById('dd-error');
|
|
301
|
+
var backBtn=document.getElementById('dd-back');
|
|
302
|
+
var startBtn=document.getElementById('dd-start');
|
|
303
|
+
var completeBtn=document.getElementById('dd-complete');
|
|
304
|
+
var submitBtn=document.getElementById('dd-submit');
|
|
305
|
+
|
|
306
|
+
backBtn.textContent=${backLabel};
|
|
307
|
+
startBtn.textContent=${startLabel};
|
|
308
|
+
completeBtn.textContent=${completeLabel};
|
|
309
|
+
submitBtn.textContent=${submitLabel};
|
|
310
|
+
|
|
311
|
+
document.getElementById('dd-close').onclick=function(){ emitJSON('popup_close'); };
|
|
312
|
+
backBtn.onclick=function(){ if(window.DeepdotsForm && window.DeepdotsForm.back){ window.DeepdotsForm.back(); } };
|
|
313
|
+
startBtn.onclick=function(){ if(window.DeepdotsForm && window.DeepdotsForm.startForm){ window.DeepdotsForm.startForm(); } };
|
|
314
|
+
completeBtn.onclick=function(){ emitJSON('popup_close'); };
|
|
315
|
+
var surveyCompletedEmitted=false;
|
|
316
|
+
submitBtn.onclick=function(){
|
|
317
|
+
if(surveyCompletedEmitted) return;
|
|
318
|
+
if(window.DeepdotsForm && window.DeepdotsForm.send){ window.DeepdotsForm.send(); }
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
function updateButtons(state){
|
|
322
|
+
backBtn.style.display='none';
|
|
323
|
+
startBtn.style.display='none';
|
|
324
|
+
submitBtn.style.display='none';
|
|
325
|
+
completeBtn.style.display='none';
|
|
326
|
+
backBtn.style.width='';
|
|
327
|
+
startBtn.style.width='';
|
|
328
|
+
submitBtn.style.width='';
|
|
329
|
+
completeBtn.style.width='';
|
|
330
|
+
if(state==='start'){
|
|
331
|
+
startBtn.style.display='inline-flex';
|
|
332
|
+
startBtn.style.width='100%';
|
|
333
|
+
} else if(state==='in_progress_first'){
|
|
334
|
+
submitBtn.style.display='inline-flex';
|
|
335
|
+
} else if(state==='in_progress_next'){
|
|
336
|
+
backBtn.style.display='inline-flex';
|
|
337
|
+
submitBtn.style.display='inline-flex';
|
|
338
|
+
} else if(state==='completed'){
|
|
339
|
+
completeBtn.style.display='inline-flex';
|
|
340
|
+
completeBtn.style.width='100%';
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function setLoading(isLoading){
|
|
345
|
+
spinner.style.display=isLoading?'flex':'none';
|
|
346
|
+
if(!isLoading){ formHost.style.visibility='visible'; }
|
|
347
|
+
footer.style.display=isLoading?'none':'flex';
|
|
348
|
+
backBtn.disabled=isLoading; startBtn.disabled=isLoading; completeBtn.disabled=isLoading; submitBtn.disabled=isLoading;
|
|
349
|
+
if(isLoading){ updateButtons(null); }
|
|
350
|
+
}
|
|
351
|
+
setLoading(true);
|
|
352
|
+
|
|
219
353
|
var initialized=false;
|
|
220
354
|
function initMF(){
|
|
221
355
|
if(initialized || !window.magicfeedback) return initialized;
|
|
@@ -224,23 +358,85 @@ function buildSurveyHtml(opts) {
|
|
|
224
358
|
window.magicfeedback.init({ debug:false, env:'${env}' });
|
|
225
359
|
var form = window.magicfeedback.form(${sid}, ${pid}, ${profileJson}, ${metaJson});
|
|
226
360
|
window.DeepdotsForm = form;
|
|
361
|
+
var stylesInjected=false;
|
|
227
362
|
form.generate('mf', {
|
|
228
363
|
addButton:false,
|
|
229
364
|
getMetaData:true,
|
|
230
|
-
onLoadedEvent:function(){
|
|
231
|
-
|
|
365
|
+
onLoadedEvent:function(args){
|
|
366
|
+
var s=args && args.formData ? args.formData.style : null;
|
|
367
|
+
if(s && !stylesInjected){
|
|
368
|
+
stylesInjected=true;
|
|
369
|
+
if(s.boxBackgroundColor){ popup.style.background=s.boxBackgroundColor; }
|
|
370
|
+
if(s.contentAlign){ main.style.justifyContent = s.contentAlign==='center' ? 'center' : 'flex-start'; }
|
|
371
|
+
if(s.buttonPrimaryColor){
|
|
372
|
+
submitBtn.style.background=s.buttonPrimaryColor; submitBtn.style.border='none'; submitBtn.style.color='#fff';
|
|
373
|
+
startBtn.style.background=s.buttonPrimaryColor; startBtn.style.border='none'; startBtn.style.color='#fff';
|
|
374
|
+
completeBtn.style.background=s.buttonPrimaryColor; completeBtn.style.border='none'; completeBtn.style.color='#fff';
|
|
375
|
+
}
|
|
376
|
+
if(s.buttonSecondaryColor){
|
|
377
|
+
backBtn.style.background='#fff'; backBtn.style.color=s.buttonSecondaryColor; backBtn.style.border='1px solid '+s.buttonSecondaryColor;
|
|
378
|
+
}
|
|
379
|
+
if(s.logo && !document.getElementById('dd-logo')){
|
|
380
|
+
var logoImg=document.createElement('img');
|
|
381
|
+
logoImg.id='dd-logo'; logoImg.src=s.logo; logoImg.alt='Logo';
|
|
382
|
+
if(s.logoSize==='small'){ logoImg.style.maxHeight='30px'; }
|
|
383
|
+
else if(s.logoSize==='medium'){ logoImg.style.maxHeight='50px'; }
|
|
384
|
+
else if(s.logoSize==='large'){ logoImg.style.maxHeight='70px'; }
|
|
385
|
+
if(s.logoPosition==='left'){ logoImg.style.margin='0 16px 20px 0'; logoImg.style.display='block'; logoImg.style.marginLeft='0'; }
|
|
386
|
+
else if(s.logoPosition==='right'){ logoImg.style.margin='0 0 20px 16px'; logoImg.style.display='block'; logoImg.style.marginLeft='auto'; }
|
|
387
|
+
else if(s.logoPosition==='center'){ logoImg.style.margin='0 auto 20px auto'; logoImg.style.display='block'; }
|
|
388
|
+
main.insertBefore(logoImg, document.getElementById('dd-form-wrapper'));
|
|
389
|
+
}
|
|
390
|
+
if(s.startMessage && s.startMessage!==''){ updateButtons('start'); }
|
|
391
|
+
else { updateButtons('in_progress_first'); }
|
|
392
|
+
} else {
|
|
393
|
+
updateButtons('in_progress_first');
|
|
394
|
+
}
|
|
395
|
+
emitJSON('loaded');
|
|
396
|
+
setLoading(false);
|
|
397
|
+
},
|
|
398
|
+
beforeSubmitEvent:function(){
|
|
399
|
+
setLoading(true);
|
|
400
|
+
emitJSON('before_submit');
|
|
401
|
+
},
|
|
232
402
|
afterSubmitEvent:function(p){
|
|
233
|
-
|
|
234
|
-
|
|
403
|
+
var error=p && p.error ? (typeof p.error==='string' ? p.error : String(p.error)) : '';
|
|
404
|
+
if(error){
|
|
405
|
+
setLoading(false);
|
|
406
|
+
if(error.toLowerCase().indexOf('no response')!==-1){
|
|
407
|
+
errorHint.textContent='Please answer the required question to continue.';
|
|
408
|
+
errorHint.style.display='block';
|
|
409
|
+
updateButtons('in_progress_next');
|
|
410
|
+
return;
|
|
411
|
+
}
|
|
412
|
+
errorHint.textContent='An error occurred while submitting. Please try again or close the popup.';
|
|
413
|
+
errorHint.style.display='block';
|
|
414
|
+
return;
|
|
415
|
+
}
|
|
416
|
+
errorHint.style.display='none';
|
|
417
|
+
setLoading(false);
|
|
418
|
+
if(p && p.completed){
|
|
419
|
+
surveyCompletedEmitted=true;
|
|
420
|
+
updateButtons('completed');
|
|
421
|
+
emitJSON('survey_completed', p);
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
if(p && p.total>1 && p.progress>0 && p.progress<p.total){ updateButtons('in_progress_next'); }
|
|
425
|
+
else { updateButtons('in_progress_first'); }
|
|
426
|
+
emitJSON('after_submit', p);
|
|
235
427
|
},
|
|
236
|
-
onBackEvent:function(p){
|
|
237
|
-
|
|
238
|
-
|
|
428
|
+
onBackEvent:function(p){
|
|
429
|
+
if(p && p.progress===0){ updateButtons('in_progress_first'); }
|
|
430
|
+
else { updateButtons('in_progress_next'); }
|
|
431
|
+
emitJSON('back', p);
|
|
432
|
+
}
|
|
433
|
+
}).catch(function(e){ setLoading(false); emit('error:init'); });
|
|
434
|
+
}catch(e){ setLoading(false); emit('error:exception'); }
|
|
239
435
|
return true;
|
|
240
436
|
}
|
|
241
437
|
var s=document.createElement('script'); s.src=${JSON.stringify(cdn)}; s.async=true;
|
|
242
438
|
s.onload=function(){ initMF(); };
|
|
243
|
-
s.onerror=function(){ emit('error:load'); };
|
|
439
|
+
s.onerror=function(){ setLoading(false); emit('error:load'); };
|
|
244
440
|
document.head.appendChild(s);
|
|
245
441
|
var tries=0, t=setInterval(function(){ if(initMF()||++tries>40){ clearInterval(t); } },150);
|
|
246
442
|
})();
|
|
@@ -259,18 +455,28 @@ var ReactNativePopupRenderer = class {
|
|
|
259
455
|
}
|
|
260
456
|
init() {
|
|
261
457
|
}
|
|
262
|
-
show(surveyId, productId,
|
|
458
|
+
show(surveyId, productId, actions, emit, onClose, env = "production", userId, style, sessionId, miniService, analyticsFeedbackSessionId) {
|
|
263
459
|
this.emitFn = emit;
|
|
264
460
|
this.onCloseFn = onClose;
|
|
265
461
|
this.currentSurveyId = surveyId;
|
|
266
462
|
this.partialEmitted = false;
|
|
267
463
|
const { profile, metadata } = buildSurveyIdentity(userId ?? null, sessionId ?? null, miniService ?? null, analyticsFeedbackSessionId ?? null);
|
|
268
|
-
const html = buildSurveyHtml({
|
|
464
|
+
const html = buildSurveyHtml({
|
|
465
|
+
surveyId,
|
|
466
|
+
productId,
|
|
467
|
+
env,
|
|
468
|
+
profile,
|
|
469
|
+
metadata,
|
|
470
|
+
font: style?.font,
|
|
471
|
+
theme: style?.theme,
|
|
472
|
+
position: style?.position,
|
|
473
|
+
actions
|
|
474
|
+
});
|
|
269
475
|
if (this.options.onShow) {
|
|
270
476
|
this.options.onShow({ surveyId, productId, html });
|
|
271
477
|
} else {
|
|
272
478
|
sdkWarn(
|
|
273
|
-
"[Deepdots] ReactNativePopupRenderer
|
|
479
|
+
"[Deepdots] ReactNativePopupRenderer has no onShow: pass { onShow } to new ReactNativePopupRenderer({...}) to mount the survey WebView."
|
|
274
480
|
);
|
|
275
481
|
}
|
|
276
482
|
}
|
|
@@ -361,7 +567,7 @@ var BrowserPopupRenderer = class {
|
|
|
361
567
|
if (!this.container) return;
|
|
362
568
|
this.visible = true;
|
|
363
569
|
const container = this.container;
|
|
364
|
-
void import("./renderPopup-
|
|
570
|
+
void import("./renderPopup-NJK7Z46E.mjs").then(({ renderPopup }) => {
|
|
365
571
|
renderPopup(container, surveyId, productId, actions, emit, onClose, env, userId, style, sessionId, miniService, analyticsFeedbackSessionId);
|
|
366
572
|
});
|
|
367
573
|
}
|
|
@@ -385,7 +591,7 @@ function createDefaultRenderer() {
|
|
|
385
591
|
// src/analytics/analytics-manager.ts
|
|
386
592
|
function createDryRunSink(log = console.log) {
|
|
387
593
|
return (payload) => log(
|
|
388
|
-
"[DeepdotsAnalytics] (dry-run \xB7
|
|
594
|
+
"[DeepdotsAnalytics] (dry-run \xB7 NOT sent \xB7 no init.analytics) POST /sdk/feedback \u2192",
|
|
389
595
|
JSON.stringify(payload, null, 2)
|
|
390
596
|
);
|
|
391
597
|
}
|
|
@@ -627,14 +833,14 @@ function createFeedbackSink(options) {
|
|
|
627
833
|
if (final && options.sendBeaconImpl && small) {
|
|
628
834
|
const payload = typeof Blob !== "undefined" ? new Blob([json], { type: "application/json" }) : json;
|
|
629
835
|
if (options.sendBeaconImpl(url, payload)) {
|
|
630
|
-
options.log?.("[DeepdotsAnalytics] flush
|
|
836
|
+
options.log?.("[DeepdotsAnalytics] final flush via sendBeacon");
|
|
631
837
|
return;
|
|
632
838
|
}
|
|
633
|
-
options.log?.("[DeepdotsAnalytics] sendBeacon
|
|
839
|
+
options.log?.("[DeepdotsAnalytics] sendBeacon rejected the batch; falling back to fetch");
|
|
634
840
|
}
|
|
635
841
|
const f = options.fetchImpl ?? (typeof fetch !== "undefined" ? fetch : void 0);
|
|
636
842
|
if (!f) {
|
|
637
|
-
options.log?.("[DeepdotsAnalytics] no fetch
|
|
843
|
+
options.log?.("[DeepdotsAnalytics] no fetch available; payload not sent", body);
|
|
638
844
|
return;
|
|
639
845
|
}
|
|
640
846
|
const res = await f(url, {
|
|
@@ -647,10 +853,10 @@ function createFeedbackSink(options) {
|
|
|
647
853
|
if (!res.ok) {
|
|
648
854
|
const detail = await safeBodyText(res);
|
|
649
855
|
if (isRetryableStatus(res.status)) {
|
|
650
|
-
throw new Error(`POST /sdk/feedback ${res.status} (
|
|
856
|
+
throw new Error(`POST /sdk/feedback ${res.status} (retryable): ${detail}`);
|
|
651
857
|
}
|
|
652
858
|
options.log?.(
|
|
653
|
-
`[DeepdotsAnalytics] POST /sdk/feedback
|
|
859
|
+
`[DeepdotsAnalytics] POST /sdk/feedback rejected with ${res.status}; batch DISCARDED:`,
|
|
654
860
|
detail
|
|
655
861
|
);
|
|
656
862
|
return;
|
|
@@ -660,7 +866,7 @@ function createFeedbackSink(options) {
|
|
|
660
866
|
const data = await res.json();
|
|
661
867
|
if (data?.sessionId && data.sessionId !== feedbackSessionId) {
|
|
662
868
|
feedbackSessionId = data.sessionId;
|
|
663
|
-
options.log?.("[DeepdotsAnalytics] feedbackSessionId
|
|
869
|
+
options.log?.("[DeepdotsAnalytics] feedbackSessionId cached:", feedbackSessionId);
|
|
664
870
|
options.onSessionId?.(feedbackSessionId);
|
|
665
871
|
}
|
|
666
872
|
} catch {
|
|
@@ -1140,7 +1346,7 @@ var MessageGuard = class {
|
|
|
1140
1346
|
return {
|
|
1141
1347
|
emit: false,
|
|
1142
1348
|
reason: "invalid_channel",
|
|
1143
|
-
detail: `channel "${channel}"
|
|
1349
|
+
detail: `invalid channel "${channel}" (expected ${MESSAGE_CHANNELS.join(" | ")})`
|
|
1144
1350
|
};
|
|
1145
1351
|
}
|
|
1146
1352
|
const entry = this.seen.get(options.id);
|
|
@@ -1152,14 +1358,14 @@ var MessageGuard = class {
|
|
|
1152
1358
|
return {
|
|
1153
1359
|
emit: false,
|
|
1154
1360
|
reason: "channel_conflict",
|
|
1155
|
-
detail: `message_id "${options.id}"
|
|
1361
|
+
detail: `message_id "${options.id}" was already reported on channel "${entry.channel}"; discarding "${channel}"`
|
|
1156
1362
|
};
|
|
1157
1363
|
}
|
|
1158
1364
|
if (entry.stages.has(stage)) {
|
|
1159
1365
|
return {
|
|
1160
1366
|
emit: false,
|
|
1161
1367
|
reason: "duplicate_stage",
|
|
1162
|
-
detail: `stage "${stage}"
|
|
1368
|
+
detail: `stage "${stage}" was already sent for message_id "${options.id}"`
|
|
1163
1369
|
};
|
|
1164
1370
|
}
|
|
1165
1371
|
entry.stages.add(stage);
|
|
@@ -1453,7 +1659,7 @@ var DeepdotsPopups = class {
|
|
|
1453
1659
|
trackMessage(stage, options) {
|
|
1454
1660
|
const verdict = this.messageGuard.evaluate(stage, options);
|
|
1455
1661
|
if (!verdict.emit) {
|
|
1456
|
-
console.warn(`[DeepdotsPopups] trackMessage
|
|
1662
|
+
console.warn(`[DeepdotsPopups] trackMessage discarded (${verdict.reason}): ${verdict.detail}`);
|
|
1457
1663
|
return;
|
|
1458
1664
|
}
|
|
1459
1665
|
this.track("deepdots_message", buildMessageParams(stage, options));
|
|
@@ -2050,7 +2256,7 @@ var DeepdotsPopups = class {
|
|
|
2050
2256
|
}
|
|
2051
2257
|
if (!this.popupContainer) return;
|
|
2052
2258
|
const container = this.popupContainer;
|
|
2053
|
-
void import("./renderPopup-
|
|
2259
|
+
void import("./renderPopup-NJK7Z46E.mjs").then(({ renderPopup }) => {
|
|
2054
2260
|
renderPopup(
|
|
2055
2261
|
container,
|
|
2056
2262
|
surveyId,
|