@magicfeedback/popup-sdk 1.22.0 → 1.23.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 +8 -2
- package/dist/2.2.47-BYEZ6PUX.mjs +2428 -0
- package/dist/2.2.47-BYEZ6PUX.mjs.map +1 -0
- package/dist/2.2.47-ZZQRJNYY.mjs +2428 -0
- package/dist/2.2.47-ZZQRJNYY.mjs.map +1 -0
- package/dist/assets/assets/style.css +8 -1
- package/dist/assets/assets/survey-css/2.2.47.css +2420 -0
- package/dist/{chunk-36KEHE2P.mjs → chunk-7PNQVCOR.mjs} +156 -5
- package/dist/chunk-7PNQVCOR.mjs.map +1 -0
- package/dist/{chunk-7PVEXIUG.mjs → chunk-HDCZ2QGX.mjs} +156 -5
- package/dist/chunk-HDCZ2QGX.mjs.map +1 -0
- package/dist/{chunk-4MUHUL7W.mjs → chunk-OXAYYIUH.mjs} +156 -5
- package/dist/chunk-OXAYYIUH.mjs.map +1 -0
- package/dist/index.d.mts +36 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.js +4028 -1312
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +128 -61
- package/dist/index.mjs.map +1 -1
- package/dist/index.native.d.mts +36 -0
- package/dist/index.native.d.ts +36 -0
- package/dist/index.native.js +4028 -1312
- package/dist/index.native.js.map +1 -1
- package/dist/index.native.mjs +128 -61
- package/dist/index.native.mjs.map +1 -1
- package/dist/react-native.d.mts +25 -0
- package/dist/react-native.d.ts +25 -0
- package/dist/react-native.js +2826 -182
- package/dist/react-native.js.map +1 -1
- package/dist/react-native.mjs +128 -61
- package/dist/react-native.mjs.map +1 -1
- package/dist/{renderPopup-I3LIC3W3.mjs → renderPopup-I565DNZX.mjs} +21 -29
- package/dist/renderPopup-I565DNZX.mjs.map +1 -0
- package/dist/{renderPopup-5VVYPKXP.mjs → renderPopup-KWAMONIN.mjs} +1213 -1149
- package/dist/renderPopup-KWAMONIN.mjs.map +1 -0
- package/dist/{renderPopup-VS5XFGTI.mjs → renderPopup-USTJXQJ6.mjs} +1213 -1149
- package/dist/renderPopup-USTJXQJ6.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/chunk-36KEHE2P.mjs.map +0 -1
- package/dist/chunk-4MUHUL7W.mjs.map +0 -1
- package/dist/chunk-7PVEXIUG.mjs.map +0 -1
- package/dist/renderPopup-5VVYPKXP.mjs.map +0 -1
- package/dist/renderPopup-I3LIC3W3.mjs.map +0 -1
- package/dist/renderPopup-VS5XFGTI.mjs.map +0 -1
package/dist/index.native.mjs
CHANGED
|
@@ -6,10 +6,12 @@ import {
|
|
|
6
6
|
InMemoryStorage,
|
|
7
7
|
LABELS,
|
|
8
8
|
PRIMARY_COLOR_JS,
|
|
9
|
+
PROGRESS_VIEW_JS,
|
|
9
10
|
RESOLVE_LOCALE_JS,
|
|
10
11
|
REVEAL_TIMEOUT_MS,
|
|
11
12
|
RTL_LOCALES,
|
|
12
13
|
SDK_IDENTIFIER,
|
|
14
|
+
SMALL_CARD_MOBILE_MAX_PX,
|
|
13
15
|
STORAGE_KEYS,
|
|
14
16
|
SUBMIT_ERROR_JS,
|
|
15
17
|
SUPPORTED_LANGUAGES,
|
|
@@ -26,13 +28,14 @@ import {
|
|
|
26
28
|
normalizeAppearance,
|
|
27
29
|
resolveActionLabels,
|
|
28
30
|
resolveLocale,
|
|
31
|
+
resolvePlacement,
|
|
29
32
|
sdkLog,
|
|
30
33
|
sdkWarn,
|
|
31
34
|
setLogger,
|
|
32
35
|
style_default,
|
|
33
36
|
surveySdkCssUrls,
|
|
34
37
|
surveySdkUrls
|
|
35
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-OXAYYIUH.mjs";
|
|
36
39
|
import "./chunk-3QS3WKRC.mjs";
|
|
37
40
|
|
|
38
41
|
// src/index.native.ts
|
|
@@ -165,6 +168,20 @@ function registerReactNativeDefaults(rn) {
|
|
|
165
168
|
}
|
|
166
169
|
}
|
|
167
170
|
|
|
171
|
+
// src/core/local-dev-host.ts
|
|
172
|
+
function isLocalDevHost(hostname) {
|
|
173
|
+
if (!hostname) return false;
|
|
174
|
+
const h = hostname.toLowerCase().replace(/^\[|\]$/g, "");
|
|
175
|
+
return h === "localhost" || h.endsWith(".localhost") || h === "0.0.0.0" || h === "::1" || /^127(\.\d{1,3}){3}$/.test(h);
|
|
176
|
+
}
|
|
177
|
+
function currentHostname() {
|
|
178
|
+
try {
|
|
179
|
+
return typeof location !== "undefined" && typeof location.hostname === "string" ? location.hostname : void 0;
|
|
180
|
+
} catch {
|
|
181
|
+
return void 0;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
168
185
|
// src/types/index.ts
|
|
169
186
|
var POPUP_TRIGGER_CONDITION_STATUSES = [
|
|
170
187
|
"SHOWED",
|
|
@@ -378,15 +395,6 @@ function ddCreateReveal(popup, onReveal, timeoutMs){
|
|
|
378
395
|
timer=setTimeout(reveal, timeoutMs);
|
|
379
396
|
return { reveal: reveal, whenPainted: revealWhenPainted };
|
|
380
397
|
}`;
|
|
381
|
-
var POSITION_MAP = {
|
|
382
|
-
center: { justifyContent: "center", alignItems: "center", padding: "0", background: "rgba(0,0,0,0.5)" },
|
|
383
|
-
bottom: { justifyContent: "center", alignItems: "flex-end", padding: "16px", background: "transparent" },
|
|
384
|
-
"bottom-right": { justifyContent: "flex-end", alignItems: "flex-end", padding: "16px", background: "transparent" },
|
|
385
|
-
"bottom-left": { justifyContent: "flex-start", alignItems: "flex-end", padding: "16px", background: "transparent" },
|
|
386
|
-
top: { justifyContent: "center", alignItems: "flex-start", padding: "16px", background: "transparent" },
|
|
387
|
-
"top-right": { justifyContent: "flex-end", alignItems: "flex-start", padding: "16px", background: "transparent" },
|
|
388
|
-
"top-left": { justifyContent: "flex-start", alignItems: "flex-start", padding: "16px", background: "transparent" }
|
|
389
|
-
};
|
|
390
398
|
function jsonForScript(value) {
|
|
391
399
|
return JSON.stringify(value ?? null).replace(/</g, "\\u003C").replace(/\u2028/g, "\\u2028").replace(/\u2029/g, "\\u2029");
|
|
392
400
|
}
|
|
@@ -415,7 +423,7 @@ function buildSurveyHtml(opts) {
|
|
|
415
423
|
const textPrimary = isDark ? "#f0f0f0" : "#111";
|
|
416
424
|
const textMuted = isDark ? "#9ca3af" : "#6b7280";
|
|
417
425
|
const trackBg = isDark ? "#3f3f46" : "#e5e7eb";
|
|
418
|
-
const pos =
|
|
426
|
+
const pos = resolvePlacement({ position: opts.position, size: opts.size, blockPage: opts.blockPage });
|
|
419
427
|
const chrome = opts.chrome !== false;
|
|
420
428
|
const bodyBg = chrome ? pos.background : "transparent";
|
|
421
429
|
const bodyPadding = chrome ? pos.padding : "0";
|
|
@@ -423,12 +431,12 @@ function buildSurveyHtml(opts) {
|
|
|
423
431
|
const cardBg = chrome ? popupBg : "transparent";
|
|
424
432
|
const cardShadow = chrome ? "0 4px 6px rgba(0,0,0,0.1)" : "none";
|
|
425
433
|
const cardRadius = chrome ? "8px" : "0";
|
|
426
|
-
const cardMaxWidth = chrome ?
|
|
434
|
+
const cardMaxWidth = chrome ? `${pos.cardMaxWidthPx}px` : "none";
|
|
427
435
|
const cardWidth = chrome ? "90%" : "100%";
|
|
428
436
|
const cardMinHeight = chrome ? "200px" : "0";
|
|
429
437
|
const cardHeight = chrome ? "auto" : "100%";
|
|
430
438
|
const cardMaxHeight = chrome ? "90vh" : "100%";
|
|
431
|
-
const mobileCard = chrome ? `.deepdots-popup{width:calc(100% - 24px);max-width:calc(100% - 24px);border-radius:12px;padding:calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)) 16px}` : `.deepdots-popup{width:100%;max-width:100%;border-radius:0;padding:16px}`;
|
|
439
|
+
const mobileCard = chrome ? `.deepdots-popup{width:calc(100% - 24px);max-width:${pos.size === "small" ? `min(${SMALL_CARD_MOBILE_MAX_PX}px, calc(100% - 24px))` : "calc(100% - 24px)"};border-radius:12px;padding:calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)) 16px}` : `.deepdots-popup{width:100%;max-width:100%;border-radius:0;padding:16px}`;
|
|
432
440
|
const titleJson = jsonForScript(opts.title ?? "");
|
|
433
441
|
const customCss = (opts.surveyCss ?? "").replace(/<\/\s*style/gi, "<\\/style");
|
|
434
442
|
const progressPref = opts.showProgressBar === void 0 ? "null" : String(opts.showProgressBar);
|
|
@@ -512,7 +520,7 @@ body.dd-ready #dd-popup{visibility:visible}
|
|
|
512
520
|
.deepdots-load-error{display:none;width:100%;text-align:center;padding:24px 0;font-size:15px;color:var(--dd-text-primary,${textPrimary})}
|
|
513
521
|
.deepdots-success{display:none;width:100%;text-align:center;padding:24px 0;color:var(--dd-text-primary,${textPrimary})}
|
|
514
522
|
.deepdots-success img{max-width:100%;height:auto;margin:0 auto 16px auto;display:block}
|
|
515
|
-
.deepdots-success p{margin:0;font-size:16px;font-weight:600;line-height:1.4}
|
|
523
|
+
.deepdots-success p{margin:0;font-size:16px;font-weight:600;line-height:1.4;color:var(--dd-success-text,var(--mf-text-secondary))}
|
|
516
524
|
.deepdots-popup-footer{display:flex;flex-direction:row-reverse;justify-content:space-between;align-items:center;gap:4px;margin-top:auto;width:100%;padding-top:12px}
|
|
517
525
|
.dd-nav-btn{display:none;border:none;min-height:44px;padding:12px 24px;border-radius:999px;cursor:pointer;font-size:15px;font-weight:600;align-items:center;justify-content:center;text-align:center}
|
|
518
526
|
/* Secundario como bot\xF3n de texto: sin borde ni fondo, para que el primario sea la \xFAnica CTA. */
|
|
@@ -640,13 +648,17 @@ ${customCss}
|
|
|
640
648
|
var progressEnabled=progressPref===true;
|
|
641
649
|
var progressShowUnit=true;
|
|
642
650
|
var progressUnit='fraction';
|
|
651
|
+
// DD-210: qu\xE9 cuenta la barra (style.progressMode).
|
|
652
|
+
var progressMode='current';
|
|
653
|
+
${PROGRESS_VIEW_JS}
|
|
643
654
|
var onStartPage=false;
|
|
644
655
|
|
|
645
656
|
function updateProgress(p){
|
|
646
657
|
var total=p&&typeof p.total==='number'?p.total:0;
|
|
647
658
|
var progress=p&&typeof p.progress==='number'?p.progress:0;
|
|
648
|
-
//
|
|
649
|
-
|
|
659
|
+
// Reglas en ddProgressView (espejo de progressView.ts, MagicSurvey y el SDK nativo).
|
|
660
|
+
var view=ddProgressView({progress:progress,total:total,completed:!!(p&&p.completed),mode:progressMode,unit:progressUnit},DD_LABELS_ACTIVE);
|
|
661
|
+
if(!progressEnabled||onStartPage||!view.visible){
|
|
650
662
|
progressEl.style.display='none';
|
|
651
663
|
// Sin barra, el hueco cabecera\u2192pregunta lo pone el contenido.
|
|
652
664
|
content.style.paddingTop='16px';
|
|
@@ -655,22 +667,11 @@ ${customCss}
|
|
|
655
667
|
progressEl.style.display='flex';
|
|
656
668
|
// Con barra, el hueco inferior ya lo pone el bloque de progreso: no duplicarlo.
|
|
657
669
|
content.style.paddingTop='0';
|
|
658
|
-
|
|
659
|
-
// suman +0.5 y avanzan media casilla) y la etiqueta redondea hacia abajo, porque una
|
|
660
|
-
// follow-up es un paso DENTRO de la misma pregunta, no la siguiente.
|
|
661
|
-
var current=Math.min(total,Math.max(1,progress+1));
|
|
662
|
-
var pct=Math.min(100,Math.max(0,(current/total)*100));
|
|
663
|
-
progressBar.style.width=pct+'%';
|
|
664
|
-
var label=Math.min(total,Math.max(1,Math.floor(progress)+1));
|
|
670
|
+
progressBar.style.width=view.percent+'%';
|
|
665
671
|
progressLabel.style.display=progressShowUnit?'block':'none';
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
} else {
|
|
670
|
-
progressCurrent.textContent=DD_LABELS_ACTIVE.question+' '+label;
|
|
671
|
-
progressTotal.textContent=' '+DD_LABELS_ACTIVE.of+' '+total;
|
|
672
|
-
}
|
|
673
|
-
progressFollowUp.style.display=p&&p.followup?'inline-block':'none';
|
|
672
|
+
progressCurrent.textContent=view.current;
|
|
673
|
+
progressTotal.textContent=view.rest;
|
|
674
|
+
progressFollowUp.style.display=p&&p.followup&&!p.completed?'inline-block':'none';
|
|
674
675
|
}
|
|
675
676
|
|
|
676
677
|
backBtn.textContent=${backLabel};
|
|
@@ -768,6 +769,8 @@ function ddApplyChromeContrast(bg){
|
|
|
768
769
|
el.style.setProperty('--dd-text-primary', pal.textPrimary);
|
|
769
770
|
el.style.setProperty('--dd-text-muted', pal.textMuted);
|
|
770
771
|
el.style.setProperty('--dd-progress-track', pal.progressTrack);
|
|
772
|
+
// DD-248: el gracias va fuera del contenedor del survey, donde el gris del survey es el claro.
|
|
773
|
+
if(dark){ el.style.setProperty('--dd-success-text', pal.textPrimary); } else { el.style.removeProperty('--dd-success-text'); }
|
|
771
774
|
var meta=document.querySelector('meta[name="color-scheme"]');
|
|
772
775
|
if(meta){ meta.setAttribute('content', pal.colorScheme); }
|
|
773
776
|
}
|
|
@@ -895,6 +898,7 @@ ${REVEAL_JS}
|
|
|
895
898
|
if(progressPref===null){ progressEnabled=s.showProgressBar===true; }
|
|
896
899
|
if(s.showProgressUnit!==undefined){ progressShowUnit=s.showProgressUnit!==false; }
|
|
897
900
|
if(s.progressUnit){ progressUnit=s.progressUnit; }
|
|
901
|
+
if(s.progressMode){ progressMode=s.progressMode; }
|
|
898
902
|
// Fondo, textos, botones y barra: Style + theme + modo de la app (DD-247, DD-241).
|
|
899
903
|
ddApplyAppearanceColors(s);
|
|
900
904
|
if(s.contentAlign){ main.style.justifyContent = s.contentAlign==='center' ? 'center' : 'flex-start'; }
|
|
@@ -1060,6 +1064,8 @@ var ReactNativePopupRenderer = class {
|
|
|
1060
1064
|
font: style?.font,
|
|
1061
1065
|
theme: style?.theme,
|
|
1062
1066
|
position: style?.position,
|
|
1067
|
+
size: style?.size,
|
|
1068
|
+
blockPage: style?.blockPage,
|
|
1063
1069
|
actions,
|
|
1064
1070
|
// renderChrome:false (init) → HTML sin tarjeta/overlay: el host lo envuelve en su Modal.
|
|
1065
1071
|
chrome: renderChrome,
|
|
@@ -1161,7 +1167,7 @@ function logRnSurveySdkChoice(choice, debug) {
|
|
|
1161
1167
|
}
|
|
1162
1168
|
|
|
1163
1169
|
// src/ui/preload.ts
|
|
1164
|
-
var defaultLoader = () => import("./renderPopup-
|
|
1170
|
+
var defaultLoader = () => import("./renderPopup-USTJXQJ6.mjs");
|
|
1165
1171
|
var pending = null;
|
|
1166
1172
|
function preloadRenderPopup(loader = defaultLoader) {
|
|
1167
1173
|
if (pending) return pending;
|
|
@@ -1234,7 +1240,7 @@ var BrowserPopupRenderer = class {
|
|
|
1234
1240
|
if (!this.container) return;
|
|
1235
1241
|
this.visible = true;
|
|
1236
1242
|
const container = this.container;
|
|
1237
|
-
void import("./renderPopup-
|
|
1243
|
+
void import("./renderPopup-USTJXQJ6.mjs").then(
|
|
1238
1244
|
({ renderPopup }) => {
|
|
1239
1245
|
renderPopup(container, surveyId, productId, actions, emit, onClose, env, userId, style, sessionId, miniService, analyticsFeedbackSessionId, options);
|
|
1240
1246
|
},
|
|
@@ -2122,6 +2128,35 @@ var ContactManager = class {
|
|
|
2122
2128
|
var STACK_MAX = 8e3;
|
|
2123
2129
|
var QUEUE_KEY = "deepdots.crash.queue";
|
|
2124
2130
|
var MAX_QUEUED = 20;
|
|
2131
|
+
var BENIGN_ERROR_PATTERNS = [
|
|
2132
|
+
/ResizeObserver loop completed with undelivered notifications/i,
|
|
2133
|
+
/ResizeObserver loop limit exceeded/i
|
|
2134
|
+
];
|
|
2135
|
+
var NON_FATAL_ERROR_PATTERNS = [
|
|
2136
|
+
/auth\/network-request-failed/i,
|
|
2137
|
+
// IndexedDB cerrándose (pestaña en segundo plano, otra pestaña actualiza la versión, logout).
|
|
2138
|
+
/connection is closing/i
|
|
2139
|
+
];
|
|
2140
|
+
function errorText(error) {
|
|
2141
|
+
if (error && typeof error === "object") {
|
|
2142
|
+
const e = error;
|
|
2143
|
+
return [e.name, e.code, e.message].filter((v) => typeof v === "string").join(" ");
|
|
2144
|
+
}
|
|
2145
|
+
return String(error ?? "");
|
|
2146
|
+
}
|
|
2147
|
+
var matches = (text, patterns) => patterns.some((p) => p.test(text));
|
|
2148
|
+
function isBenignError(error) {
|
|
2149
|
+
return matches(errorText(error), BENIGN_ERROR_PATTERNS);
|
|
2150
|
+
}
|
|
2151
|
+
function isNonFatalNoise(error) {
|
|
2152
|
+
return matches(errorText(error), NON_FATAL_ERROR_PATTERNS);
|
|
2153
|
+
}
|
|
2154
|
+
function reclassify(r) {
|
|
2155
|
+
const text = `${r.crashType} ${r.message}`;
|
|
2156
|
+
if (matches(text, BENIGN_ERROR_PATTERNS)) return null;
|
|
2157
|
+
if (matches(text, NON_FATAL_ERROR_PATTERNS)) return { ...r, fatal: false, severity: "warning" };
|
|
2158
|
+
return r;
|
|
2159
|
+
}
|
|
2125
2160
|
function crashRecordToParams(r) {
|
|
2126
2161
|
const params = {
|
|
2127
2162
|
crashed_at: r.crashedAt,
|
|
@@ -2179,7 +2214,8 @@ var CrashReporter = class {
|
|
|
2179
2214
|
/** API pública del host: reporta un error (app viva) → emite el evento ya. */
|
|
2180
2215
|
reportError(error, options = {}) {
|
|
2181
2216
|
if (!this.isEnabled()) return;
|
|
2182
|
-
|
|
2217
|
+
if (isBenignError(error)) return;
|
|
2218
|
+
const severity = isNonFatalNoise(error) ? "warning" : options.severity ?? "error";
|
|
2183
2219
|
const handled = options.handled ?? true;
|
|
2184
2220
|
const fatal = severity === "fatal";
|
|
2185
2221
|
const record = this.buildRecord(error, severity, handled, fatal, options.context);
|
|
@@ -2187,6 +2223,11 @@ var CrashReporter = class {
|
|
|
2187
2223
|
}
|
|
2188
2224
|
/** Captura un error no manejado (fatal) → persiste a disco para replay en el siguiente arranque. */
|
|
2189
2225
|
captureUnhandled(error) {
|
|
2226
|
+
if (isBenignError(error)) return;
|
|
2227
|
+
if (isNonFatalNoise(error)) {
|
|
2228
|
+
this.persist(this.buildRecord(error, "warning", false, false));
|
|
2229
|
+
return;
|
|
2230
|
+
}
|
|
2190
2231
|
this.persist(this.buildRecord(error, "fatal", false, true));
|
|
2191
2232
|
}
|
|
2192
2233
|
/** Persiste un crash no capturado a disco para reenviarlo en el siguiente arranque. */
|
|
@@ -2222,7 +2263,7 @@ var CrashReporter = class {
|
|
|
2222
2263
|
} catch {
|
|
2223
2264
|
}
|
|
2224
2265
|
}
|
|
2225
|
-
return queue;
|
|
2266
|
+
return queue.map(reclassify).filter((r) => r !== null);
|
|
2226
2267
|
}
|
|
2227
2268
|
/** Instala los handlers globales de errores no capturados (no-op sin `window`). Idempotente. */
|
|
2228
2269
|
install() {
|
|
@@ -2415,6 +2456,7 @@ var ANALYTICS_BACKGROUND_RESUME_WINDOW_MS = 5 * 6e4;
|
|
|
2415
2456
|
var RESERVED_EVENT_PREFIX = "deepdots_";
|
|
2416
2457
|
var CUSTOM_EVENT_PREFIX = "deepdots_event_";
|
|
2417
2458
|
var MAX_PENDING_TRIGGERS = 20;
|
|
2459
|
+
var CONTACT_SYNC_TIMEOUT_MS = 1500;
|
|
2418
2460
|
function triggerDelayMs(delaySeconds) {
|
|
2419
2461
|
const n = typeof delaySeconds === "number" ? delaySeconds : Number(delaySeconds);
|
|
2420
2462
|
return Number.isFinite(n) && n > 0 ? Math.round(n * 1e3) : 0;
|
|
@@ -2487,6 +2529,8 @@ var DeepdotsPopups = class {
|
|
|
2487
2529
|
this.engagement = null;
|
|
2488
2530
|
/** Atributos internos del usuario identificado → POST /sdk/popups/contact. Null si no hay userId. */
|
|
2489
2531
|
this.contact = null;
|
|
2532
|
+
/** DD-561: contact POST of `init()`, awaited (with a cap) by the popups GET. Null if none. */
|
|
2533
|
+
this.contactSync = null;
|
|
2490
2534
|
/** Storage resuelto en init() (inyectado por el host o localStorage). Reusado al cambiar de usuario. */
|
|
2491
2535
|
this.storage = null;
|
|
2492
2536
|
/** Marca si ya se inició la navegación manual (setScreen) — para RN sin History API. */
|
|
@@ -2574,19 +2618,24 @@ var DeepdotsPopups = class {
|
|
|
2574
2618
|
post: (body) => this.postContact(body)
|
|
2575
2619
|
});
|
|
2576
2620
|
if (config.contactAttributes) {
|
|
2577
|
-
|
|
2621
|
+
this.contactSync = this.setContactAttributes(config.contactAttributes);
|
|
2578
2622
|
}
|
|
2579
2623
|
}
|
|
2580
2624
|
this.log("tracking \xB7 user_id:", this.tracking.getUserId(), "\xB7 new_user:", this.tracking.isNewUser(), "\xB7 enabled:", this.tracking.isTrackingEnabled());
|
|
2581
|
-
|
|
2625
|
+
const localDev = (config.platform ?? "web") === "web" && !config.trackLocalhost && isLocalDevHost(currentHostname());
|
|
2626
|
+
const analyticsKeys = localDev ? void 0 : config.analytics;
|
|
2627
|
+
if (localDev && config.analytics) {
|
|
2628
|
+
this.log("analytics \xB7 localhost: no se env\xEDa (trackLocalhost: true para enviar)");
|
|
2629
|
+
}
|
|
2630
|
+
this.analyticsIntegration = analyticsKeys?.integration;
|
|
2582
2631
|
const resumable = this.readResumableSession();
|
|
2583
2632
|
if (resumable) {
|
|
2584
2633
|
this.analyticsFeedbackSessionId = resumable.sessionId;
|
|
2585
2634
|
this.suspended = { at: resumable.at, userId: resumable.userId, windowMs: ANALYTICS_RESUME_WINDOW_MS };
|
|
2586
2635
|
}
|
|
2587
|
-
const analyticsSink =
|
|
2636
|
+
const analyticsSink = analyticsKeys ? createFeedbackSink({
|
|
2588
2637
|
baseUrl: this.baseUrl,
|
|
2589
|
-
keys:
|
|
2638
|
+
keys: analyticsKeys,
|
|
2590
2639
|
log: (...a) => this.log(...a),
|
|
2591
2640
|
initialSessionId: resumable?.sessionId,
|
|
2592
2641
|
// En móvil (RN) la app puede morir con el lote de cierre sin entregar: se
|
|
@@ -2634,7 +2683,7 @@ var DeepdotsPopups = class {
|
|
|
2634
2683
|
});
|
|
2635
2684
|
this.installCrashHandlers();
|
|
2636
2685
|
this.geoEnabled = config.geolocation ?? true;
|
|
2637
|
-
this.geoWanted = this.geoEnabled && !!
|
|
2686
|
+
this.geoWanted = this.geoEnabled && !!analyticsKeys;
|
|
2638
2687
|
this.resolveGeo();
|
|
2639
2688
|
this.navObserver = new NavigationObserver();
|
|
2640
2689
|
this.navObserver.onVisit(
|
|
@@ -3492,38 +3541,38 @@ var DeepdotsPopups = class {
|
|
|
3492
3541
|
this.debug("No language available for lang comparison", { popupId: def.id, langs });
|
|
3493
3542
|
return true;
|
|
3494
3543
|
}
|
|
3495
|
-
const
|
|
3544
|
+
const matches2 = langs.some(
|
|
3496
3545
|
(lang) => typeof lang === "string" && currentLang.startsWith(lang.toLowerCase())
|
|
3497
3546
|
);
|
|
3498
|
-
if (!
|
|
3547
|
+
if (!matches2) {
|
|
3499
3548
|
this.debug("Lang mismatch for popup", { popupId: def.id, langs, currentLang });
|
|
3500
3549
|
}
|
|
3501
|
-
return
|
|
3550
|
+
return matches2;
|
|
3502
3551
|
}
|
|
3503
3552
|
/** `segments.path`: rutas donde el popup PUEDE mostrarse. Sin lista, en todas. */
|
|
3504
3553
|
matchesSegmentsPath(def, pathUrl) {
|
|
3505
3554
|
const paths = def.segments?.path;
|
|
3506
3555
|
if (!Array.isArray(paths) || paths.length === 0) return true;
|
|
3507
|
-
const
|
|
3508
|
-
if (!
|
|
3556
|
+
const location2 = this.resolveCurrentLocation(pathUrl);
|
|
3557
|
+
if (!location2) {
|
|
3509
3558
|
this.debug("No window.location available for path comparison", { popupId: def.id, paths });
|
|
3510
3559
|
return true;
|
|
3511
3560
|
}
|
|
3512
|
-
const
|
|
3513
|
-
const match = this.matchesPathCandidate(rawCandidate,
|
|
3561
|
+
const matches2 = paths.some((rawCandidate) => {
|
|
3562
|
+
const match = this.matchesPathCandidate(rawCandidate, location2);
|
|
3514
3563
|
this.debug("Path comparison", {
|
|
3515
3564
|
popupId: def.id,
|
|
3516
3565
|
candidate: rawCandidate,
|
|
3517
|
-
currentPath:
|
|
3518
|
-
currentHref:
|
|
3566
|
+
currentPath: location2.path,
|
|
3567
|
+
currentHref: location2.href,
|
|
3519
3568
|
match
|
|
3520
3569
|
});
|
|
3521
3570
|
return match;
|
|
3522
3571
|
});
|
|
3523
|
-
if (!
|
|
3524
|
-
this.debug("No path match for popup", { popupId: def.id, paths, currentPath:
|
|
3572
|
+
if (!matches2) {
|
|
3573
|
+
this.debug("No path match for popup", { popupId: def.id, paths, currentPath: location2.path });
|
|
3525
3574
|
}
|
|
3526
|
-
return
|
|
3575
|
+
return matches2;
|
|
3527
3576
|
}
|
|
3528
3577
|
/**
|
|
3529
3578
|
* `segments.excludedPaths`: rutas donde el popup NO debe mostrarse. Gana sobre
|
|
@@ -3533,18 +3582,18 @@ var DeepdotsPopups = class {
|
|
|
3533
3582
|
isPathExcluded(def, pathUrl) {
|
|
3534
3583
|
const excluded = def.segments?.excludedPaths;
|
|
3535
3584
|
if (!Array.isArray(excluded) || excluded.length === 0) return false;
|
|
3536
|
-
const
|
|
3537
|
-
if (!
|
|
3585
|
+
const location2 = this.resolveCurrentLocation(pathUrl);
|
|
3586
|
+
if (!location2) {
|
|
3538
3587
|
this.debug("No window.location available for excluded path comparison", { popupId: def.id, excluded });
|
|
3539
3588
|
return false;
|
|
3540
3589
|
}
|
|
3541
|
-
const hit = excluded.find((rawCandidate) => this.matchesPathCandidate(rawCandidate,
|
|
3590
|
+
const hit = excluded.find((rawCandidate) => this.matchesPathCandidate(rawCandidate, location2));
|
|
3542
3591
|
if (hit !== void 0) {
|
|
3543
3592
|
this.debug("Popup excluded by path", {
|
|
3544
3593
|
popupId: def.id,
|
|
3545
3594
|
candidate: hit,
|
|
3546
|
-
currentPath:
|
|
3547
|
-
currentHref:
|
|
3595
|
+
currentPath: location2.path,
|
|
3596
|
+
currentHref: location2.href
|
|
3548
3597
|
});
|
|
3549
3598
|
return true;
|
|
3550
3599
|
}
|
|
@@ -3560,17 +3609,17 @@ var DeepdotsPopups = class {
|
|
|
3560
3609
|
* y no puede tumbar la evaluación del trigger entero (mismo fallo que hubo con
|
|
3561
3610
|
* `segments.lang`).
|
|
3562
3611
|
*/
|
|
3563
|
-
matchesPathCandidate(rawCandidate,
|
|
3612
|
+
matchesPathCandidate(rawCandidate, location2) {
|
|
3564
3613
|
if (typeof rawCandidate !== "string") return false;
|
|
3565
3614
|
const candidate = this.normalizeUrl(rawCandidate);
|
|
3566
3615
|
if (!candidate) return false;
|
|
3567
3616
|
if (candidate.startsWith("http://") || candidate.startsWith("https://")) {
|
|
3568
|
-
return
|
|
3617
|
+
return location2.href === candidate;
|
|
3569
3618
|
}
|
|
3570
3619
|
if (candidate.startsWith("/")) {
|
|
3571
|
-
return
|
|
3620
|
+
return location2.href.includes(candidate);
|
|
3572
3621
|
}
|
|
3573
|
-
return
|
|
3622
|
+
return location2.path === candidate;
|
|
3574
3623
|
}
|
|
3575
3624
|
/** href + pathname normalizados de la ruta a evaluar, o null si no hay `window.location`. */
|
|
3576
3625
|
resolveCurrentLocation(pathUrl) {
|
|
@@ -3736,6 +3785,7 @@ var DeepdotsPopups = class {
|
|
|
3736
3785
|
this.log("Missing apiKey or baseUrl. Skipping popups fetch.");
|
|
3737
3786
|
return [];
|
|
3738
3787
|
}
|
|
3788
|
+
if (this.contactSync) await this.waitForContactSync();
|
|
3739
3789
|
const filter = userId ? { where: { userId } } : null;
|
|
3740
3790
|
const query = filter ? `?filter=${encodeURIComponent(JSON.stringify(filter))}` : "";
|
|
3741
3791
|
const endpoint = `${baseUrl}/sdk/${encodeURIComponent(apiKey)}/popups${query}`;
|
|
@@ -3758,6 +3808,23 @@ var DeepdotsPopups = class {
|
|
|
3758
3808
|
return null;
|
|
3759
3809
|
}
|
|
3760
3810
|
}
|
|
3811
|
+
/**
|
|
3812
|
+
* DD-561: espera al POST de contact de `init()` antes del GET de popups, como mucho
|
|
3813
|
+
* `CONTACT_SYNC_TIMEOUT_MS`. Sin atributos nuevos la promesa ya está resuelta y no hay espera.
|
|
3814
|
+
* Nunca rechaza.
|
|
3815
|
+
*/
|
|
3816
|
+
async waitForContactSync() {
|
|
3817
|
+
const pending2 = this.contactSync;
|
|
3818
|
+
this.contactSync = null;
|
|
3819
|
+
if (!pending2) return;
|
|
3820
|
+
let timer;
|
|
3821
|
+
const timeout = new Promise((resolve) => {
|
|
3822
|
+
timer = setTimeout(() => resolve("timeout"), CONTACT_SYNC_TIMEOUT_MS);
|
|
3823
|
+
});
|
|
3824
|
+
const result = await Promise.race([pending2.then(() => "done", () => "done"), timeout]);
|
|
3825
|
+
if (timer) clearTimeout(timer);
|
|
3826
|
+
if (result === "timeout") this.log("contact \xB7 POST still pending, fetching popups anyway");
|
|
3827
|
+
}
|
|
3761
3828
|
/**
|
|
3762
3829
|
* Envía los atributos de contact a la API (`POST /sdk/popups/contact`). Rechaza si no se
|
|
3763
3830
|
* pudo enviar (sin red o respuesta no-2xx), para que `ContactManager` no guarde la caché
|