@magicfeedback/popup-sdk 1.17.1 → 1.18.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 +10 -1
- package/dist/assets/assets/style.css +59 -1
- package/dist/{chunk-VHTN5UXD.mjs → chunk-7ZVOPIWE.mjs} +98 -2
- package/dist/chunk-7ZVOPIWE.mjs.map +1 -0
- package/dist/{chunk-AFRHPS3K.mjs → chunk-DNBFTJCA.mjs} +98 -2
- package/dist/chunk-DNBFTJCA.mjs.map +1 -0
- package/dist/index.d.mts +14 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +327 -130
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +44 -10
- package/dist/index.mjs.map +1 -1
- package/dist/react-native.d.mts +13 -1
- package/dist/react-native.d.ts +13 -1
- package/dist/react-native.js +157 -14
- package/dist/react-native.js.map +1 -1
- package/dist/react-native.mjs +44 -10
- package/dist/react-native.mjs.map +1 -1
- package/dist/{renderPopup-S3RU3Y6J.mjs → renderPopup-B6VIV4VS.mjs} +15 -7
- package/dist/renderPopup-B6VIV4VS.mjs.map +1 -0
- package/dist/{renderPopup-YCAQ3ODC.mjs → renderPopup-BKZPAZZG.mjs} +186 -124
- package/dist/renderPopup-BKZPAZZG.mjs.map +1 -0
- package/package.json +4 -2
- package/dist/chunk-AFRHPS3K.mjs.map +0 -1
- package/dist/chunk-VHTN5UXD.mjs.map +0 -1
- package/dist/renderPopup-S3RU3Y6J.mjs.map +0 -1
- package/dist/renderPopup-YCAQ3ODC.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
REVEAL_TIMEOUT_MS,
|
|
8
8
|
RTL_LOCALES,
|
|
9
9
|
STORAGE_KEYS,
|
|
10
|
+
SUBMIT_ERROR_JS,
|
|
10
11
|
SUPPORTED_LANGUAGES,
|
|
11
12
|
TrackingManager,
|
|
12
13
|
buildFontFaceCss,
|
|
@@ -21,7 +22,7 @@ import {
|
|
|
21
22
|
sdkWarn,
|
|
22
23
|
setLogger,
|
|
23
24
|
style_default
|
|
24
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-DNBFTJCA.mjs";
|
|
25
26
|
|
|
26
27
|
// src/types/index.ts
|
|
27
28
|
var POPUP_TRIGGER_CONDITION_STATUSES = [
|
|
@@ -254,7 +255,7 @@ function trimmedOrNull(value) {
|
|
|
254
255
|
}
|
|
255
256
|
function buildSurveyHtml(opts) {
|
|
256
257
|
const env = opts.env === "development" ? "dev" : "prod";
|
|
257
|
-
const version = opts.version ?? "2.2.
|
|
258
|
+
const version = opts.version ?? "2.2.37";
|
|
258
259
|
const cdn = `https://cdn.jsdelivr.net/npm/@magicfeedback/native@${version}/dist/magicfeedback-sdk.browser.js`;
|
|
259
260
|
const sid = jsonForScript(opts.surveyId);
|
|
260
261
|
const pid = jsonForScript(opts.productId);
|
|
@@ -426,6 +427,7 @@ ${customCss}
|
|
|
426
427
|
(function(){
|
|
427
428
|
function emit(s){ try{ if(window.ReactNativeWebView){ window.ReactNativeWebView.postMessage(s); } }catch(e){} }
|
|
428
429
|
function emitJSON(n,p){ try{ emit(JSON.stringify({name:n,payload:p||{}})); }catch(e){} }
|
|
430
|
+
var ddLastReportedError=null;
|
|
429
431
|
window.DeepdotsClose = function(){ emitJSON('popup_close'); };
|
|
430
432
|
var chromeOn=${chrome ? "true" : "false"};
|
|
431
433
|
|
|
@@ -606,6 +608,7 @@ ${customCss}
|
|
|
606
608
|
|
|
607
609
|
${PRIMARY_COLOR_JS}
|
|
608
610
|
${BUSY_JS}
|
|
611
|
+
${SUBMIT_ERROR_JS}
|
|
609
612
|
${REVEAL_JS}
|
|
610
613
|
// Foco en la primera pregunta si es de escribir. Al navegar lo pone @magicfeedback/native
|
|
611
614
|
// (autofocus:'navigation'); la apertura la decide el popup, que es quien sabe cu\xE1ndo se revela.
|
|
@@ -757,10 +760,10 @@ ${REVEAL_JS}
|
|
|
757
760
|
emitJSON('before_submit');
|
|
758
761
|
},
|
|
759
762
|
afterSubmitEvent:function(p){
|
|
760
|
-
|
|
761
|
-
if(error){
|
|
763
|
+
if(p && p.error){
|
|
762
764
|
setLoading(false);
|
|
763
|
-
|
|
765
|
+
var ddErr=ddClassifySubmitError(p.error);
|
|
766
|
+
if(ddErr.reason==='required'){
|
|
764
767
|
// La p\xE1gina no ha cambiado: el estado de navegaci\xF3n se queda como estaba.
|
|
765
768
|
errorHint.textContent=DD_LABELS_ACTIVE.errorRequired;
|
|
766
769
|
errorHint.style.display='block';
|
|
@@ -769,6 +772,11 @@ ${REVEAL_JS}
|
|
|
769
772
|
}
|
|
770
773
|
errorHint.textContent=DD_LABELS_ACTIVE.errorSubmit;
|
|
771
774
|
errorHint.style.display='block';
|
|
775
|
+
// Un solo aviso por fallo: native repite el mismo objeto al cerrar el survey.
|
|
776
|
+
if(p.error!==ddLastReportedError){
|
|
777
|
+
ddLastReportedError=p.error;
|
|
778
|
+
emitJSON('survey_error', ddErr);
|
|
779
|
+
}
|
|
772
780
|
return;
|
|
773
781
|
}
|
|
774
782
|
errorHint.style.display='none';
|
|
@@ -891,8 +899,9 @@ var ReactNativePopupRenderer = class {
|
|
|
891
899
|
const surveyId = this.currentSurveyId;
|
|
892
900
|
if (!surveyId || !this.emitFn) return;
|
|
893
901
|
let name;
|
|
902
|
+
let payload;
|
|
894
903
|
try {
|
|
895
|
-
name = JSON.parse(raw)
|
|
904
|
+
({ name, payload } = JSON.parse(raw));
|
|
896
905
|
} catch {
|
|
897
906
|
name = raw;
|
|
898
907
|
}
|
|
@@ -913,6 +922,9 @@ var ReactNativePopupRenderer = class {
|
|
|
913
922
|
case "survey_completed":
|
|
914
923
|
this.emitFn("survey_completed", surveyId);
|
|
915
924
|
break;
|
|
925
|
+
case "survey_error":
|
|
926
|
+
this.emitFn("survey_error", surveyId, { reason: payload?.reason, message: payload?.message });
|
|
927
|
+
break;
|
|
916
928
|
case "popup_close":
|
|
917
929
|
this.onCloseFn?.();
|
|
918
930
|
break;
|
|
@@ -930,7 +942,7 @@ function createReactNativeRenderer() {
|
|
|
930
942
|
}
|
|
931
943
|
|
|
932
944
|
// src/ui/preload.ts
|
|
933
|
-
var defaultLoader = () => import("./renderPopup-
|
|
945
|
+
var defaultLoader = () => import("./renderPopup-BKZPAZZG.mjs");
|
|
934
946
|
var pending = null;
|
|
935
947
|
function preloadRenderPopup(loader = defaultLoader) {
|
|
936
948
|
if (pending) return pending;
|
|
@@ -1003,9 +1015,18 @@ var BrowserPopupRenderer = class {
|
|
|
1003
1015
|
if (!this.container) return;
|
|
1004
1016
|
this.visible = true;
|
|
1005
1017
|
const container = this.container;
|
|
1006
|
-
void import("./renderPopup-
|
|
1007
|
-
|
|
1008
|
-
|
|
1018
|
+
void import("./renderPopup-BKZPAZZG.mjs").then(
|
|
1019
|
+
({ renderPopup }) => {
|
|
1020
|
+
renderPopup(container, surveyId, productId, actions, emit, onClose, env, userId, style, sessionId, miniService, analyticsFeedbackSessionId, options);
|
|
1021
|
+
},
|
|
1022
|
+
(error) => {
|
|
1023
|
+
this.visible = false;
|
|
1024
|
+
sdkWarn("[Deepdots] popup renderer failed to load:", error);
|
|
1025
|
+
}
|
|
1026
|
+
);
|
|
1027
|
+
}
|
|
1028
|
+
isShowing() {
|
|
1029
|
+
return this.visible;
|
|
1009
1030
|
}
|
|
1010
1031
|
hide() {
|
|
1011
1032
|
this.visible = false;
|
|
@@ -2948,6 +2969,10 @@ var DeepdotsPopups = class {
|
|
|
2948
2969
|
});
|
|
2949
2970
|
}
|
|
2950
2971
|
showDefinition(def) {
|
|
2972
|
+
if (this.renderer.isShowing?.()) {
|
|
2973
|
+
this.debug("Popup skipped: another popup is already open", def.id);
|
|
2974
|
+
return;
|
|
2975
|
+
}
|
|
2951
2976
|
this.log("Showing popup (definition)", def);
|
|
2952
2977
|
this.surveyToPopupId.set(def.surveyId, def.id);
|
|
2953
2978
|
this.lastShown.set(def.id, Date.now());
|
|
@@ -3354,6 +3379,15 @@ var DeepdotsPopups = class {
|
|
|
3354
3379
|
emitEvent(type, surveyId, data) {
|
|
3355
3380
|
const event = { type, surveyId, timestamp: Date.now(), data };
|
|
3356
3381
|
this.log("Event emitted", event);
|
|
3382
|
+
if (type === "survey_error") {
|
|
3383
|
+
const popupId = data?.popupId || this.surveyToPopupId.get(surveyId);
|
|
3384
|
+
this.track("deepdots_survey_error", {
|
|
3385
|
+
survey_id: surveyId,
|
|
3386
|
+
...popupId ? { popup_id: popupId } : {},
|
|
3387
|
+
reason: data?.reason,
|
|
3388
|
+
message: data?.message
|
|
3389
|
+
});
|
|
3390
|
+
}
|
|
3357
3391
|
const isPartialClick = type === "popup_clicked" && data?.action === "partial";
|
|
3358
3392
|
if (isPartialClick) {
|
|
3359
3393
|
this.markSurveyProgress(surveyId, "PARTIAL");
|