@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/react-native.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-R4B3K2ZW.mjs";
|
|
12
13
|
|
|
13
14
|
// src/react-native/index.tsx
|
|
14
15
|
import { createContext, useContext, useEffect, useRef, useState } from "react";
|
|
@@ -200,6 +201,15 @@ function resolveEnvironment(nodeEnv) {
|
|
|
200
201
|
}
|
|
201
202
|
|
|
202
203
|
// src/ui/surveyHtml.ts
|
|
204
|
+
var POSITION_MAP = {
|
|
205
|
+
center: { justifyContent: "center", alignItems: "center", padding: "0", background: "rgba(0,0,0,0.5)" },
|
|
206
|
+
bottom: { justifyContent: "center", alignItems: "flex-end", padding: "16px", background: "transparent" },
|
|
207
|
+
"bottom-right": { justifyContent: "flex-end", alignItems: "flex-end", padding: "16px", background: "transparent" },
|
|
208
|
+
"bottom-left": { justifyContent: "flex-start", alignItems: "flex-end", padding: "16px", background: "transparent" },
|
|
209
|
+
top: { justifyContent: "center", alignItems: "flex-start", padding: "16px", background: "transparent" },
|
|
210
|
+
"top-right": { justifyContent: "flex-end", alignItems: "flex-start", padding: "16px", background: "transparent" },
|
|
211
|
+
"top-left": { justifyContent: "flex-start", alignItems: "flex-start", padding: "16px", background: "transparent" }
|
|
212
|
+
};
|
|
203
213
|
function buildSurveyHtml(opts) {
|
|
204
214
|
const env = opts.env === "development" ? "dev" : "prod";
|
|
205
215
|
const version = opts.version ?? "2.2.4";
|
|
@@ -210,17 +220,141 @@ function buildSurveyHtml(opts) {
|
|
|
210
220
|
const metaJson = JSON.stringify(opts.metadata ?? []);
|
|
211
221
|
const fontFaceCss = opts.font ? buildFontFaceCss(opts.font.family, opts.font.url) : "";
|
|
212
222
|
const fontFamilyValue = opts.font ? buildFontFamilyValue(opts.font.family) : "-apple-system,system-ui,sans-serif";
|
|
223
|
+
const popupClass = opts.font?.family ? "deepdots-popup deepdots-has-font" : "deepdots-popup";
|
|
224
|
+
const isDark = opts.theme === "dark";
|
|
225
|
+
const popupBg = isDark ? "#1e1e1e" : "#fff";
|
|
226
|
+
const colorScheme = isDark ? "dark" : "light";
|
|
227
|
+
const textPrimary = isDark ? "#f0f0f0" : "#111";
|
|
228
|
+
const pos = POSITION_MAP[opts.position ?? "center"] ?? POSITION_MAP.center;
|
|
229
|
+
const backLabel = JSON.stringify(opts.actions?.back?.label ?? "Back");
|
|
230
|
+
const startLabel = JSON.stringify(opts.actions?.start?.label ?? "Start survey");
|
|
231
|
+
const completeLabel = JSON.stringify(opts.actions?.complete?.label ?? "Complete survey");
|
|
232
|
+
const submitLabel = JSON.stringify(opts.actions?.accept?.label ?? "Send");
|
|
213
233
|
return `<!DOCTYPE html><html><head>
|
|
214
234
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
215
|
-
<meta name="color-scheme" content="
|
|
216
|
-
<style
|
|
235
|
+
<meta name="color-scheme" content="${colorScheme}"/>
|
|
236
|
+
<style>
|
|
237
|
+
${style_default}
|
|
238
|
+
${fontFaceCss}
|
|
239
|
+
html,body{margin:0;padding:0;height:100%;font-family:${fontFamilyValue}}
|
|
240
|
+
body{display:flex;justify-content:${pos.justifyContent};align-items:${pos.alignItems};background:${pos.background};padding:${pos.padding};box-sizing:border-box}
|
|
241
|
+
.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}
|
|
242
|
+
.deepdots-popup-header{display:flex;justify-content:flex-end;align-items:center;width:100%}
|
|
243
|
+
#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}
|
|
244
|
+
.deepdots-popup-container-content{display:flex;flex-direction:column;padding:0 20px 12px 20px;max-height:80vh;overflow:hidden;box-sizing:border-box}
|
|
245
|
+
.deepdots-popup-main{display:flex;flex-direction:column;width:100%;max-height:80vh;overflow-y:auto;overflow-x:hidden;position:relative}
|
|
246
|
+
#dd-form-wrapper{width:100%;flex:1 1 auto}
|
|
247
|
+
#mf{width:100%;box-sizing:border-box;visibility:hidden}
|
|
248
|
+
.deepdots-popup-main *{max-width:100%;box-sizing:border-box}
|
|
249
|
+
#dd-logo{max-height:40px;max-width:100%;object-fit:contain}
|
|
250
|
+
.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}
|
|
251
|
+
.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}
|
|
252
|
+
.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}
|
|
253
|
+
#dd-back{background:transparent;color:#333;border:1px solid #999}
|
|
254
|
+
#dd-start,#dd-complete,#dd-submit{background:#1E293B;color:#fff;border:none}
|
|
255
|
+
#dd-submit:disabled,#dd-start:disabled,#dd-back:disabled,#dd-complete:disabled{opacity:0.6;cursor:not-allowed}
|
|
256
|
+
.mf-spinner{display:none;position:absolute;top:50%;left:50%;transform:translate(-50%,-50%)}
|
|
257
|
+
.mf-spinner-circle{width:28px;height:28px;border:3px solid #e0e6ed;border-top-color:#1E293B;border-radius:50%;animation:ddspin 0.9s linear infinite}
|
|
258
|
+
@keyframes ddspin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}
|
|
259
|
+
@media (max-width:640px){
|
|
260
|
+
.deepdots-popup{width:calc(100% - 24px);max-width:calc(100% - 24px);border-radius:12px}
|
|
261
|
+
.deepdots-popup-footer{flex-direction:column-reverse;gap:12px}
|
|
262
|
+
.dd-nav-btn{width:100%}
|
|
263
|
+
.magicfeedback-checkbox-container,.magicfeedback-radio-container{margin:4px 0;padding:4px 8px}
|
|
264
|
+
.magicfeedback-checkbox label,.magicfeedback-radio-container label{font-size:15px}
|
|
265
|
+
.deepdots-popup input[type="radio"]{margin:6px 0 6px 8px}
|
|
266
|
+
.deepdots-popup input[type="checkbox"]{width:16px;height:16px}
|
|
267
|
+
}
|
|
268
|
+
</style>
|
|
217
269
|
</head><body>
|
|
218
|
-
<div id="
|
|
270
|
+
<div class="${popupClass}" id="dd-popup">
|
|
271
|
+
<div class="deepdots-popup-header">
|
|
272
|
+
<button type="button" id="dd-close" aria-label="Close popup">
|
|
273
|
+
<svg width="28" height="28" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
274
|
+
<path d="M6 6L18 18M6 18L18 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
|
275
|
+
</svg>
|
|
276
|
+
</button>
|
|
277
|
+
</div>
|
|
278
|
+
<div class="deepdots-popup-container-content">
|
|
279
|
+
<div class="deepdots-popup-main" id="dd-main">
|
|
280
|
+
<div id="dd-form-wrapper">
|
|
281
|
+
<div class="mf-spinner" id="dd-spinner" role="status" aria-label="Loading survey"><div class="mf-spinner-circle"></div></div>
|
|
282
|
+
<div id="mf"></div>
|
|
283
|
+
</div>
|
|
284
|
+
<div class="deepdots-error-hint" id="dd-error" role="alert" aria-live="polite"></div>
|
|
285
|
+
<div class="deepdots-popup-footer" id="dd-footer">
|
|
286
|
+
<button type="button" class="dd-nav-btn" id="dd-submit">Send</button>
|
|
287
|
+
<button type="button" class="dd-nav-btn" id="dd-back">Back</button>
|
|
288
|
+
<button type="button" class="dd-nav-btn" id="dd-complete">Complete survey</button>
|
|
289
|
+
<button type="button" class="dd-nav-btn" id="dd-start">Start survey</button>
|
|
290
|
+
</div>
|
|
291
|
+
</div>
|
|
292
|
+
</div>
|
|
293
|
+
</div>
|
|
219
294
|
<script>
|
|
220
295
|
(function(){
|
|
221
296
|
function emit(s){ try{ if(window.ReactNativeWebView){ window.ReactNativeWebView.postMessage(s); } }catch(e){} }
|
|
222
297
|
function emitJSON(n,p){ try{ emit(JSON.stringify({name:n,payload:p||{}})); }catch(e){} }
|
|
223
298
|
window.DeepdotsClose = function(){ emitJSON('popup_close'); };
|
|
299
|
+
|
|
300
|
+
var popup=document.getElementById('dd-popup');
|
|
301
|
+
var main=document.getElementById('dd-main');
|
|
302
|
+
var footer=document.getElementById('dd-footer');
|
|
303
|
+
var spinner=document.getElementById('dd-spinner');
|
|
304
|
+
var formHost=document.getElementById('mf');
|
|
305
|
+
var errorHint=document.getElementById('dd-error');
|
|
306
|
+
var backBtn=document.getElementById('dd-back');
|
|
307
|
+
var startBtn=document.getElementById('dd-start');
|
|
308
|
+
var completeBtn=document.getElementById('dd-complete');
|
|
309
|
+
var submitBtn=document.getElementById('dd-submit');
|
|
310
|
+
|
|
311
|
+
backBtn.textContent=${backLabel};
|
|
312
|
+
startBtn.textContent=${startLabel};
|
|
313
|
+
completeBtn.textContent=${completeLabel};
|
|
314
|
+
submitBtn.textContent=${submitLabel};
|
|
315
|
+
|
|
316
|
+
document.getElementById('dd-close').onclick=function(){ emitJSON('popup_close'); };
|
|
317
|
+
backBtn.onclick=function(){ if(window.DeepdotsForm && window.DeepdotsForm.back){ window.DeepdotsForm.back(); } };
|
|
318
|
+
startBtn.onclick=function(){ if(window.DeepdotsForm && window.DeepdotsForm.startForm){ window.DeepdotsForm.startForm(); } };
|
|
319
|
+
completeBtn.onclick=function(){ emitJSON('popup_close'); };
|
|
320
|
+
var surveyCompletedEmitted=false;
|
|
321
|
+
submitBtn.onclick=function(){
|
|
322
|
+
if(surveyCompletedEmitted) return;
|
|
323
|
+
if(window.DeepdotsForm && window.DeepdotsForm.send){ window.DeepdotsForm.send(); }
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
function updateButtons(state){
|
|
327
|
+
backBtn.style.display='none';
|
|
328
|
+
startBtn.style.display='none';
|
|
329
|
+
submitBtn.style.display='none';
|
|
330
|
+
completeBtn.style.display='none';
|
|
331
|
+
backBtn.style.width='';
|
|
332
|
+
startBtn.style.width='';
|
|
333
|
+
submitBtn.style.width='';
|
|
334
|
+
completeBtn.style.width='';
|
|
335
|
+
if(state==='start'){
|
|
336
|
+
startBtn.style.display='inline-flex';
|
|
337
|
+
startBtn.style.width='100%';
|
|
338
|
+
} else if(state==='in_progress_first'){
|
|
339
|
+
submitBtn.style.display='inline-flex';
|
|
340
|
+
} else if(state==='in_progress_next'){
|
|
341
|
+
backBtn.style.display='inline-flex';
|
|
342
|
+
submitBtn.style.display='inline-flex';
|
|
343
|
+
} else if(state==='completed'){
|
|
344
|
+
completeBtn.style.display='inline-flex';
|
|
345
|
+
completeBtn.style.width='100%';
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
function setLoading(isLoading){
|
|
350
|
+
spinner.style.display=isLoading?'flex':'none';
|
|
351
|
+
if(!isLoading){ formHost.style.visibility='visible'; }
|
|
352
|
+
footer.style.display=isLoading?'none':'flex';
|
|
353
|
+
backBtn.disabled=isLoading; startBtn.disabled=isLoading; completeBtn.disabled=isLoading; submitBtn.disabled=isLoading;
|
|
354
|
+
if(isLoading){ updateButtons(null); }
|
|
355
|
+
}
|
|
356
|
+
setLoading(true);
|
|
357
|
+
|
|
224
358
|
var initialized=false;
|
|
225
359
|
function initMF(){
|
|
226
360
|
if(initialized || !window.magicfeedback) return initialized;
|
|
@@ -229,23 +363,85 @@ function buildSurveyHtml(opts) {
|
|
|
229
363
|
window.magicfeedback.init({ debug:false, env:'${env}' });
|
|
230
364
|
var form = window.magicfeedback.form(${sid}, ${pid}, ${profileJson}, ${metaJson});
|
|
231
365
|
window.DeepdotsForm = form;
|
|
366
|
+
var stylesInjected=false;
|
|
232
367
|
form.generate('mf', {
|
|
233
368
|
addButton:false,
|
|
234
369
|
getMetaData:true,
|
|
235
|
-
onLoadedEvent:function(){
|
|
236
|
-
|
|
370
|
+
onLoadedEvent:function(args){
|
|
371
|
+
var s=args && args.formData ? args.formData.style : null;
|
|
372
|
+
if(s && !stylesInjected){
|
|
373
|
+
stylesInjected=true;
|
|
374
|
+
if(s.boxBackgroundColor){ popup.style.background=s.boxBackgroundColor; }
|
|
375
|
+
if(s.contentAlign){ main.style.justifyContent = s.contentAlign==='center' ? 'center' : 'flex-start'; }
|
|
376
|
+
if(s.buttonPrimaryColor){
|
|
377
|
+
submitBtn.style.background=s.buttonPrimaryColor; submitBtn.style.border='none'; submitBtn.style.color='#fff';
|
|
378
|
+
startBtn.style.background=s.buttonPrimaryColor; startBtn.style.border='none'; startBtn.style.color='#fff';
|
|
379
|
+
completeBtn.style.background=s.buttonPrimaryColor; completeBtn.style.border='none'; completeBtn.style.color='#fff';
|
|
380
|
+
}
|
|
381
|
+
if(s.buttonSecondaryColor){
|
|
382
|
+
backBtn.style.background='#fff'; backBtn.style.color=s.buttonSecondaryColor; backBtn.style.border='1px solid '+s.buttonSecondaryColor;
|
|
383
|
+
}
|
|
384
|
+
if(s.logo && !document.getElementById('dd-logo')){
|
|
385
|
+
var logoImg=document.createElement('img');
|
|
386
|
+
logoImg.id='dd-logo'; logoImg.src=s.logo; logoImg.alt='Logo';
|
|
387
|
+
if(s.logoSize==='small'){ logoImg.style.maxHeight='30px'; }
|
|
388
|
+
else if(s.logoSize==='medium'){ logoImg.style.maxHeight='50px'; }
|
|
389
|
+
else if(s.logoSize==='large'){ logoImg.style.maxHeight='70px'; }
|
|
390
|
+
if(s.logoPosition==='left'){ logoImg.style.margin='0 16px 20px 0'; logoImg.style.display='block'; logoImg.style.marginLeft='0'; }
|
|
391
|
+
else if(s.logoPosition==='right'){ logoImg.style.margin='0 0 20px 16px'; logoImg.style.display='block'; logoImg.style.marginLeft='auto'; }
|
|
392
|
+
else if(s.logoPosition==='center'){ logoImg.style.margin='0 auto 20px auto'; logoImg.style.display='block'; }
|
|
393
|
+
main.insertBefore(logoImg, document.getElementById('dd-form-wrapper'));
|
|
394
|
+
}
|
|
395
|
+
if(s.startMessage && s.startMessage!==''){ updateButtons('start'); }
|
|
396
|
+
else { updateButtons('in_progress_first'); }
|
|
397
|
+
} else {
|
|
398
|
+
updateButtons('in_progress_first');
|
|
399
|
+
}
|
|
400
|
+
emitJSON('loaded');
|
|
401
|
+
setLoading(false);
|
|
402
|
+
},
|
|
403
|
+
beforeSubmitEvent:function(){
|
|
404
|
+
setLoading(true);
|
|
405
|
+
emitJSON('before_submit');
|
|
406
|
+
},
|
|
237
407
|
afterSubmitEvent:function(p){
|
|
238
|
-
|
|
239
|
-
|
|
408
|
+
var error=p && p.error ? (typeof p.error==='string' ? p.error : String(p.error)) : '';
|
|
409
|
+
if(error){
|
|
410
|
+
setLoading(false);
|
|
411
|
+
if(error.toLowerCase().indexOf('no response')!==-1){
|
|
412
|
+
errorHint.textContent='Please answer the required question to continue.';
|
|
413
|
+
errorHint.style.display='block';
|
|
414
|
+
updateButtons('in_progress_next');
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
errorHint.textContent='An error occurred while submitting. Please try again or close the popup.';
|
|
418
|
+
errorHint.style.display='block';
|
|
419
|
+
return;
|
|
420
|
+
}
|
|
421
|
+
errorHint.style.display='none';
|
|
422
|
+
setLoading(false);
|
|
423
|
+
if(p && p.completed){
|
|
424
|
+
surveyCompletedEmitted=true;
|
|
425
|
+
updateButtons('completed');
|
|
426
|
+
emitJSON('survey_completed', p);
|
|
427
|
+
return;
|
|
428
|
+
}
|
|
429
|
+
if(p && p.total>1 && p.progress>0 && p.progress<p.total){ updateButtons('in_progress_next'); }
|
|
430
|
+
else { updateButtons('in_progress_first'); }
|
|
431
|
+
emitJSON('after_submit', p);
|
|
240
432
|
},
|
|
241
|
-
onBackEvent:function(p){
|
|
242
|
-
|
|
243
|
-
|
|
433
|
+
onBackEvent:function(p){
|
|
434
|
+
if(p && p.progress===0){ updateButtons('in_progress_first'); }
|
|
435
|
+
else { updateButtons('in_progress_next'); }
|
|
436
|
+
emitJSON('back', p);
|
|
437
|
+
}
|
|
438
|
+
}).catch(function(e){ setLoading(false); emit('error:init'); });
|
|
439
|
+
}catch(e){ setLoading(false); emit('error:exception'); }
|
|
244
440
|
return true;
|
|
245
441
|
}
|
|
246
442
|
var s=document.createElement('script'); s.src=${JSON.stringify(cdn)}; s.async=true;
|
|
247
443
|
s.onload=function(){ initMF(); };
|
|
248
|
-
s.onerror=function(){ emit('error:load'); };
|
|
444
|
+
s.onerror=function(){ setLoading(false); emit('error:load'); };
|
|
249
445
|
document.head.appendChild(s);
|
|
250
446
|
var tries=0, t=setInterval(function(){ if(initMF()||++tries>40){ clearInterval(t); } },150);
|
|
251
447
|
})();
|
|
@@ -264,18 +460,28 @@ var ReactNativePopupRenderer = class {
|
|
|
264
460
|
}
|
|
265
461
|
init() {
|
|
266
462
|
}
|
|
267
|
-
show(surveyId, productId,
|
|
463
|
+
show(surveyId, productId, actions, emit, onClose, env = "production", userId, style, sessionId, miniService, analyticsFeedbackSessionId) {
|
|
268
464
|
this.emitFn = emit;
|
|
269
465
|
this.onCloseFn = onClose;
|
|
270
466
|
this.currentSurveyId = surveyId;
|
|
271
467
|
this.partialEmitted = false;
|
|
272
468
|
const { profile, metadata } = buildSurveyIdentity(userId ?? null, sessionId ?? null, miniService ?? null, analyticsFeedbackSessionId ?? null);
|
|
273
|
-
const html = buildSurveyHtml({
|
|
469
|
+
const html = buildSurveyHtml({
|
|
470
|
+
surveyId,
|
|
471
|
+
productId,
|
|
472
|
+
env,
|
|
473
|
+
profile,
|
|
474
|
+
metadata,
|
|
475
|
+
font: style?.font,
|
|
476
|
+
theme: style?.theme,
|
|
477
|
+
position: style?.position,
|
|
478
|
+
actions
|
|
479
|
+
});
|
|
274
480
|
if (this.options.onShow) {
|
|
275
481
|
this.options.onShow({ surveyId, productId, html });
|
|
276
482
|
} else {
|
|
277
483
|
sdkWarn(
|
|
278
|
-
"[Deepdots] ReactNativePopupRenderer
|
|
484
|
+
"[Deepdots] ReactNativePopupRenderer has no onShow: pass { onShow } to new ReactNativePopupRenderer({...}) to mount the survey WebView."
|
|
279
485
|
);
|
|
280
486
|
}
|
|
281
487
|
}
|
|
@@ -366,7 +572,7 @@ var BrowserPopupRenderer = class {
|
|
|
366
572
|
if (!this.container) return;
|
|
367
573
|
this.visible = true;
|
|
368
574
|
const container = this.container;
|
|
369
|
-
void import("./renderPopup-
|
|
575
|
+
void import("./renderPopup-ZYXOUBCP.mjs").then(({ renderPopup }) => {
|
|
370
576
|
renderPopup(container, surveyId, productId, actions, emit, onClose, env, userId, style, sessionId, miniService, analyticsFeedbackSessionId);
|
|
371
577
|
});
|
|
372
578
|
}
|
|
@@ -390,7 +596,7 @@ function createDefaultRenderer() {
|
|
|
390
596
|
// src/analytics/analytics-manager.ts
|
|
391
597
|
function createDryRunSink(log = console.log) {
|
|
392
598
|
return (payload) => log(
|
|
393
|
-
"[DeepdotsAnalytics] (dry-run \xB7
|
|
599
|
+
"[DeepdotsAnalytics] (dry-run \xB7 NOT sent \xB7 no init.analytics) POST /sdk/feedback \u2192",
|
|
394
600
|
JSON.stringify(payload, null, 2)
|
|
395
601
|
);
|
|
396
602
|
}
|
|
@@ -632,14 +838,14 @@ function createFeedbackSink(options) {
|
|
|
632
838
|
if (final && options.sendBeaconImpl && small) {
|
|
633
839
|
const payload = typeof Blob !== "undefined" ? new Blob([json], { type: "application/json" }) : json;
|
|
634
840
|
if (options.sendBeaconImpl(url, payload)) {
|
|
635
|
-
options.log?.("[DeepdotsAnalytics] flush
|
|
841
|
+
options.log?.("[DeepdotsAnalytics] final flush via sendBeacon");
|
|
636
842
|
return;
|
|
637
843
|
}
|
|
638
|
-
options.log?.("[DeepdotsAnalytics] sendBeacon
|
|
844
|
+
options.log?.("[DeepdotsAnalytics] sendBeacon rejected the batch; falling back to fetch");
|
|
639
845
|
}
|
|
640
846
|
const f = options.fetchImpl ?? (typeof fetch !== "undefined" ? fetch : void 0);
|
|
641
847
|
if (!f) {
|
|
642
|
-
options.log?.("[DeepdotsAnalytics] no fetch
|
|
848
|
+
options.log?.("[DeepdotsAnalytics] no fetch available; payload not sent", body);
|
|
643
849
|
return;
|
|
644
850
|
}
|
|
645
851
|
const res = await f(url, {
|
|
@@ -652,10 +858,10 @@ function createFeedbackSink(options) {
|
|
|
652
858
|
if (!res.ok) {
|
|
653
859
|
const detail = await safeBodyText(res);
|
|
654
860
|
if (isRetryableStatus(res.status)) {
|
|
655
|
-
throw new Error(`POST /sdk/feedback ${res.status} (
|
|
861
|
+
throw new Error(`POST /sdk/feedback ${res.status} (retryable): ${detail}`);
|
|
656
862
|
}
|
|
657
863
|
options.log?.(
|
|
658
|
-
`[DeepdotsAnalytics] POST /sdk/feedback
|
|
864
|
+
`[DeepdotsAnalytics] POST /sdk/feedback rejected with ${res.status}; batch DISCARDED:`,
|
|
659
865
|
detail
|
|
660
866
|
);
|
|
661
867
|
return;
|
|
@@ -665,7 +871,7 @@ function createFeedbackSink(options) {
|
|
|
665
871
|
const data = await res.json();
|
|
666
872
|
if (data?.sessionId && data.sessionId !== feedbackSessionId) {
|
|
667
873
|
feedbackSessionId = data.sessionId;
|
|
668
|
-
options.log?.("[DeepdotsAnalytics] feedbackSessionId
|
|
874
|
+
options.log?.("[DeepdotsAnalytics] feedbackSessionId cached:", feedbackSessionId);
|
|
669
875
|
options.onSessionId?.(feedbackSessionId);
|
|
670
876
|
}
|
|
671
877
|
} catch {
|
|
@@ -1145,7 +1351,7 @@ var MessageGuard = class {
|
|
|
1145
1351
|
return {
|
|
1146
1352
|
emit: false,
|
|
1147
1353
|
reason: "invalid_channel",
|
|
1148
|
-
detail: `channel "${channel}"
|
|
1354
|
+
detail: `invalid channel "${channel}" (expected ${MESSAGE_CHANNELS.join(" | ")})`
|
|
1149
1355
|
};
|
|
1150
1356
|
}
|
|
1151
1357
|
const entry = this.seen.get(options.id);
|
|
@@ -1157,14 +1363,14 @@ var MessageGuard = class {
|
|
|
1157
1363
|
return {
|
|
1158
1364
|
emit: false,
|
|
1159
1365
|
reason: "channel_conflict",
|
|
1160
|
-
detail: `message_id "${options.id}"
|
|
1366
|
+
detail: `message_id "${options.id}" was already reported on channel "${entry.channel}"; discarding "${channel}"`
|
|
1161
1367
|
};
|
|
1162
1368
|
}
|
|
1163
1369
|
if (entry.stages.has(stage)) {
|
|
1164
1370
|
return {
|
|
1165
1371
|
emit: false,
|
|
1166
1372
|
reason: "duplicate_stage",
|
|
1167
|
-
detail: `stage "${stage}"
|
|
1373
|
+
detail: `stage "${stage}" was already sent for message_id "${options.id}"`
|
|
1168
1374
|
};
|
|
1169
1375
|
}
|
|
1170
1376
|
entry.stages.add(stage);
|
|
@@ -1458,7 +1664,7 @@ var DeepdotsPopups = class {
|
|
|
1458
1664
|
trackMessage(stage, options) {
|
|
1459
1665
|
const verdict = this.messageGuard.evaluate(stage, options);
|
|
1460
1666
|
if (!verdict.emit) {
|
|
1461
|
-
console.warn(`[DeepdotsPopups] trackMessage
|
|
1667
|
+
console.warn(`[DeepdotsPopups] trackMessage discarded (${verdict.reason}): ${verdict.detail}`);
|
|
1462
1668
|
return;
|
|
1463
1669
|
}
|
|
1464
1670
|
this.track("deepdots_message", buildMessageParams(stage, options));
|
|
@@ -2055,7 +2261,7 @@ var DeepdotsPopups = class {
|
|
|
2055
2261
|
}
|
|
2056
2262
|
if (!this.popupContainer) return;
|
|
2057
2263
|
const container = this.popupContainer;
|
|
2058
|
-
void import("./renderPopup-
|
|
2264
|
+
void import("./renderPopup-ZYXOUBCP.mjs").then(({ renderPopup }) => {
|
|
2059
2265
|
renderPopup(
|
|
2060
2266
|
container,
|
|
2061
2267
|
surveyId,
|
|
@@ -2315,9 +2521,10 @@ function DeepdotsProvider({ config, children }) {
|
|
|
2315
2521
|
survey ? /* @__PURE__ */ jsx(Modal, { visible: true, transparent: true, animationType: "slide", children: /* @__PURE__ */ jsx(View, { style: { flex: 1 }, children: /* @__PURE__ */ jsx(
|
|
2316
2522
|
WebView,
|
|
2317
2523
|
{
|
|
2524
|
+
style: { flex: 1 },
|
|
2318
2525
|
originWhitelist: ["*"],
|
|
2319
2526
|
javaScriptEnabled: true,
|
|
2320
|
-
source: { html: survey.html },
|
|
2527
|
+
source: { html: survey.html, baseUrl: "https://sdk.deepdots.com/" },
|
|
2321
2528
|
onMessage: (e) => rendererRef.current?.handleMessage(e.nativeEvent.data)
|
|
2322
2529
|
}
|
|
2323
2530
|
) }) }) : null
|