@magicfeedback/popup-sdk 1.17.2 → 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 +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +307 -126
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -8
- package/dist/index.mjs.map +1 -1
- package/dist/react-native.d.mts +7 -1
- package/dist/react-native.d.ts +7 -1
- package/dist/react-native.js +137 -10
- package/dist/react-native.js.map +1 -1
- package/dist/react-native.mjs +29 -8
- package/dist/react-native.mjs.map +1 -1
- package/dist/{renderPopup-L2Q3KJAZ.mjs → renderPopup-B6VIV4VS.mjs} +12 -6
- package/dist/renderPopup-B6VIV4VS.mjs.map +1 -0
- package/dist/{renderPopup-PQWJSBOY.mjs → renderPopup-BKZPAZZG.mjs} +183 -123
- package/dist/renderPopup-BKZPAZZG.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/chunk-AFRHPS3K.mjs.map +0 -1
- package/dist/chunk-VHTN5UXD.mjs.map +0 -1
- package/dist/renderPopup-L2Q3KJAZ.mjs.map +0 -1
- package/dist/renderPopup-PQWJSBOY.mjs.map +0 -1
package/dist/react-native.d.mts
CHANGED
|
@@ -243,7 +243,13 @@ interface TriggerConfig {
|
|
|
243
243
|
/**
|
|
244
244
|
* Event types emitted by the SDK
|
|
245
245
|
*/
|
|
246
|
-
type DeepdotsEventType = 'popup_shown' | 'popup_clicked' | 'survey_completed'
|
|
246
|
+
type DeepdotsEventType = 'popup_shown' | 'popup_clicked' | 'survey_completed'
|
|
247
|
+
/**
|
|
248
|
+
* Fallo al enviar una página del survey (el popup enseña `errorSubmit`). `data`:
|
|
249
|
+
* `{reason: 'send_failed' | 'no_page' | 'unknown', message}`. No es interacción del
|
|
250
|
+
* usuario: no marca el popup como PARTIAL. También va a analítica como `deepdots_survey_error`.
|
|
251
|
+
*/
|
|
252
|
+
| 'survey_error';
|
|
247
253
|
/**
|
|
248
254
|
* Event payload structure
|
|
249
255
|
*/
|
package/dist/react-native.d.ts
CHANGED
|
@@ -243,7 +243,13 @@ interface TriggerConfig {
|
|
|
243
243
|
/**
|
|
244
244
|
* Event types emitted by the SDK
|
|
245
245
|
*/
|
|
246
|
-
type DeepdotsEventType = 'popup_shown' | 'popup_clicked' | 'survey_completed'
|
|
246
|
+
type DeepdotsEventType = 'popup_shown' | 'popup_clicked' | 'survey_completed'
|
|
247
|
+
/**
|
|
248
|
+
* Fallo al enviar una página del survey (el popup enseña `errorSubmit`). `data`:
|
|
249
|
+
* `{reason: 'send_failed' | 'no_page' | 'unknown', message}`. No es interacción del
|
|
250
|
+
* usuario: no marca el popup como PARTIAL. También va a analítica como `deepdots_survey_error`.
|
|
251
|
+
*/
|
|
252
|
+
| 'survey_error';
|
|
247
253
|
/**
|
|
248
254
|
* Event payload structure
|
|
249
255
|
*/
|
package/dist/react-native.js
CHANGED
|
@@ -557,6 +557,48 @@ function ddSetSurveyBusy(el, busy){
|
|
|
557
557
|
}
|
|
558
558
|
});
|
|
559
559
|
|
|
560
|
+
// src/ui/submitError.ts
|
|
561
|
+
function submitErrorText(error) {
|
|
562
|
+
if (!error) return "";
|
|
563
|
+
if (typeof error === "string") return error;
|
|
564
|
+
const message = error.message;
|
|
565
|
+
return typeof message === "string" ? message : String(error);
|
|
566
|
+
}
|
|
567
|
+
function classifySubmitError(error) {
|
|
568
|
+
const message = submitErrorText(error).slice(0, SURVEY_ERROR_MESSAGE_MAX);
|
|
569
|
+
const code = error && typeof error === "object" ? error.code : void 0;
|
|
570
|
+
if (typeof code === "string" && REASON_BY_CODE[code]) return { reason: REASON_BY_CODE[code], message };
|
|
571
|
+
if (message.toLowerCase().includes("no response")) return { reason: "required", message };
|
|
572
|
+
return { reason: "unknown", message };
|
|
573
|
+
}
|
|
574
|
+
var SURVEY_ERROR_MESSAGE_MAX, REASON_BY_CODE, SUBMIT_ERROR_JS;
|
|
575
|
+
var init_submitError = __esm({
|
|
576
|
+
"src/ui/submitError.ts"() {
|
|
577
|
+
"use strict";
|
|
578
|
+
SURVEY_ERROR_MESSAGE_MAX = 300;
|
|
579
|
+
REASON_BY_CODE = {
|
|
580
|
+
REQUIRED: "required",
|
|
581
|
+
SEND_FAILED: "send_failed",
|
|
582
|
+
NO_PAGE: "no_page"
|
|
583
|
+
};
|
|
584
|
+
SUBMIT_ERROR_JS = `
|
|
585
|
+
function ddClassifySubmitError(error){
|
|
586
|
+
var message='';
|
|
587
|
+
if(error){
|
|
588
|
+
if(typeof error==='string'){ message=error; }
|
|
589
|
+
else if(typeof error.message==='string'){ message=error.message; }
|
|
590
|
+
else { message=String(error); }
|
|
591
|
+
}
|
|
592
|
+
message=message.slice(0, ${SURVEY_ERROR_MESSAGE_MAX});
|
|
593
|
+
var byCode={ REQUIRED:'required', SEND_FAILED:'send_failed', NO_PAGE:'no_page' };
|
|
594
|
+
var code=error && typeof error==='object' ? error.code : undefined;
|
|
595
|
+
if(typeof code==='string' && byCode.hasOwnProperty(code)){ return { reason: byCode[code], message: message }; }
|
|
596
|
+
if(message.toLowerCase().indexOf('no response')!==-1){ return { reason: 'required', message: message }; }
|
|
597
|
+
return { reason: 'unknown', message: message };
|
|
598
|
+
}`;
|
|
599
|
+
}
|
|
600
|
+
});
|
|
601
|
+
|
|
560
602
|
// src/assets/style.css
|
|
561
603
|
var style_default;
|
|
562
604
|
var init_style = __esm({
|
|
@@ -564,7 +606,7 @@ var init_style = __esm({
|
|
|
564
606
|
style_default = `/**
|
|
565
607
|
* NO EDITAR A MANO \u2014 generado por scripts/vendor-survey-css.mjs
|
|
566
608
|
*
|
|
567
|
-
* Copia de @magicfeedback/native@2.2.
|
|
609
|
+
* Copia de @magicfeedback/native@2.2.37 \u2192 dist/styles/magicfeedback-default.css
|
|
568
610
|
* (la hoja can\xF3nica del paquete, la que apunta su campo "style"), con estos cambios locales:
|
|
569
611
|
*
|
|
570
612
|
* 1. Sin el @import de Google Fonts (Nunito): no queremos una petici\xF3n externa desde la
|
|
@@ -1033,6 +1075,36 @@ div.magicfeedback-radio {
|
|
|
1033
1075
|
width: 100%;
|
|
1034
1076
|
}
|
|
1035
1077
|
|
|
1078
|
+
/* Single choice in a row (assets.direction "row"): one equal box per
|
|
1079
|
+
option. The "other" text field wraps to its own line below. Stacked
|
|
1080
|
+
(phone, or too narrow) it is the usual vertical list again. */
|
|
1081
|
+
.magicfeedback-radio--row {
|
|
1082
|
+
flex-direction: row;
|
|
1083
|
+
flex-wrap: wrap;
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
.magicfeedback-radio--row > .magicfeedback-radio-container {
|
|
1087
|
+
flex: 1 1 0;
|
|
1088
|
+
min-width: 0;
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
.magicfeedback-radio--row > .magicfeedback-extra-option {
|
|
1092
|
+
flex-basis: 100%;
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
.magicfeedback-radio--row.magicfeedback-radio--stacked {
|
|
1096
|
+
flex-direction: column;
|
|
1097
|
+
flex-wrap: nowrap;
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
.magicfeedback-radio--row.magicfeedback-radio--stacked > .magicfeedback-radio-container {
|
|
1101
|
+
flex: none;
|
|
1102
|
+
}
|
|
1103
|
+
|
|
1104
|
+
.magicfeedback-radio--row .magicfeedback-radio-container label {
|
|
1105
|
+
overflow-wrap: anywhere;
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1036
1108
|
.magicfeedback-checkbox-container,
|
|
1037
1109
|
.magicfeedback-radio-container {
|
|
1038
1110
|
display: flex;
|
|
@@ -1256,6 +1328,34 @@ div.magicfeedback-radio {
|
|
|
1256
1328
|
overflow-wrap: anywhere;
|
|
1257
1329
|
}
|
|
1258
1330
|
|
|
1331
|
+
/* assets.minMaxPlaceholderPosition: the caption above or below the row. */
|
|
1332
|
+
.magicfeedback-rating-number-scale-labels--top {
|
|
1333
|
+
margin-top: 0;
|
|
1334
|
+
margin-bottom: var(--mf-space-sm);
|
|
1335
|
+
}
|
|
1336
|
+
|
|
1337
|
+
.magicfeedback-rating-number-scale-labels--bottom {
|
|
1338
|
+
margin-top: var(--mf-space-sm);
|
|
1339
|
+
margin-bottom: 0;
|
|
1340
|
+
}
|
|
1341
|
+
|
|
1342
|
+
/* Row with a text per number: the text sits above each chip (below with
|
|
1343
|
+
numberPlaceholdersPosition "bottom"). The option is a column laid out
|
|
1344
|
+
inline; this only spaces and styles the text. */
|
|
1345
|
+
.magicfeedback-rating-number-option--captioned {
|
|
1346
|
+
gap: var(--mf-space-xs);
|
|
1347
|
+
}
|
|
1348
|
+
|
|
1349
|
+
.magicfeedback-rating-number-option-caption {
|
|
1350
|
+
font-size: var(--mf-font-size-sm);
|
|
1351
|
+
font-weight: var(--mf-font-weight-semibold);
|
|
1352
|
+
color: var(--mf-text-secondary);
|
|
1353
|
+
text-align: center;
|
|
1354
|
+
line-height: 1.25;
|
|
1355
|
+
overflow-wrap: anywhere;
|
|
1356
|
+
cursor: pointer;
|
|
1357
|
+
}
|
|
1358
|
+
|
|
1259
1359
|
.magicfeedback-rating-number-scale-label:last-child {
|
|
1260
1360
|
text-align: end;
|
|
1261
1361
|
}
|
|
@@ -3506,14 +3606,15 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
3506
3606
|
autofocusOnOpen();
|
|
3507
3607
|
}
|
|
3508
3608
|
};
|
|
3609
|
+
let lastReportedError = null;
|
|
3509
3610
|
generateOptions.beforeSubmitEvent = () => {
|
|
3510
3611
|
setLoading(true);
|
|
3511
3612
|
};
|
|
3512
3613
|
generateOptions.afterSubmitEvent = ({ error, completed, total, progress, followup }) => {
|
|
3513
|
-
|
|
3514
|
-
if (errText) {
|
|
3614
|
+
if (error) {
|
|
3515
3615
|
setLoading(false);
|
|
3516
|
-
|
|
3616
|
+
const { reason, message } = classifySubmitError(error);
|
|
3617
|
+
if (reason === "required") {
|
|
3517
3618
|
errorHint.textContent = labels.errorRequired;
|
|
3518
3619
|
errorHint.style.display = "block";
|
|
3519
3620
|
updateNavButtons();
|
|
@@ -3521,7 +3622,11 @@ async function renderPopup(container, surveyId, productId, actions, emit, onClos
|
|
|
3521
3622
|
}
|
|
3522
3623
|
errorHint.textContent = labels.errorSubmit;
|
|
3523
3624
|
errorHint.style.display = "block";
|
|
3524
|
-
sdkWarn("[Deepdots] survey submit error:",
|
|
3625
|
+
sdkWarn("[Deepdots] survey submit error:", reason, message);
|
|
3626
|
+
if (error !== lastReportedError) {
|
|
3627
|
+
lastReportedError = error;
|
|
3628
|
+
emit("survey_error", surveyId, { reason, message });
|
|
3629
|
+
}
|
|
3525
3630
|
return;
|
|
3526
3631
|
}
|
|
3527
3632
|
errorHint.style.display = "none";
|
|
@@ -3565,6 +3670,7 @@ var init_renderPopup = __esm({
|
|
|
3565
3670
|
init_logger();
|
|
3566
3671
|
init_labels();
|
|
3567
3672
|
init_reveal();
|
|
3673
|
+
init_submitError();
|
|
3568
3674
|
import_native = __toESM(require("@magicfeedback/native"));
|
|
3569
3675
|
init_style();
|
|
3570
3676
|
init_reveal();
|
|
@@ -3782,6 +3888,7 @@ init_labels();
|
|
|
3782
3888
|
init_reveal();
|
|
3783
3889
|
init_surveyPalette();
|
|
3784
3890
|
init_busy();
|
|
3891
|
+
init_submitError();
|
|
3785
3892
|
init_style();
|
|
3786
3893
|
var REVEAL_JS = `
|
|
3787
3894
|
function ddCreateReveal(popup, onReveal, timeoutMs){
|
|
@@ -3825,7 +3932,7 @@ function trimmedOrNull(value) {
|
|
|
3825
3932
|
}
|
|
3826
3933
|
function buildSurveyHtml(opts) {
|
|
3827
3934
|
const env = opts.env === "development" ? "dev" : "prod";
|
|
3828
|
-
const version = opts.version ?? "2.2.
|
|
3935
|
+
const version = opts.version ?? "2.2.37";
|
|
3829
3936
|
const cdn = `https://cdn.jsdelivr.net/npm/@magicfeedback/native@${version}/dist/magicfeedback-sdk.browser.js`;
|
|
3830
3937
|
const sid = jsonForScript(opts.surveyId);
|
|
3831
3938
|
const pid = jsonForScript(opts.productId);
|
|
@@ -3997,6 +4104,7 @@ ${customCss}
|
|
|
3997
4104
|
(function(){
|
|
3998
4105
|
function emit(s){ try{ if(window.ReactNativeWebView){ window.ReactNativeWebView.postMessage(s); } }catch(e){} }
|
|
3999
4106
|
function emitJSON(n,p){ try{ emit(JSON.stringify({name:n,payload:p||{}})); }catch(e){} }
|
|
4107
|
+
var ddLastReportedError=null;
|
|
4000
4108
|
window.DeepdotsClose = function(){ emitJSON('popup_close'); };
|
|
4001
4109
|
var chromeOn=${chrome ? "true" : "false"};
|
|
4002
4110
|
|
|
@@ -4177,6 +4285,7 @@ ${customCss}
|
|
|
4177
4285
|
|
|
4178
4286
|
${PRIMARY_COLOR_JS}
|
|
4179
4287
|
${BUSY_JS}
|
|
4288
|
+
${SUBMIT_ERROR_JS}
|
|
4180
4289
|
${REVEAL_JS}
|
|
4181
4290
|
// Foco en la primera pregunta si es de escribir. Al navegar lo pone @magicfeedback/native
|
|
4182
4291
|
// (autofocus:'navigation'); la apertura la decide el popup, que es quien sabe cu\xE1ndo se revela.
|
|
@@ -4328,10 +4437,10 @@ ${REVEAL_JS}
|
|
|
4328
4437
|
emitJSON('before_submit');
|
|
4329
4438
|
},
|
|
4330
4439
|
afterSubmitEvent:function(p){
|
|
4331
|
-
|
|
4332
|
-
if(error){
|
|
4440
|
+
if(p && p.error){
|
|
4333
4441
|
setLoading(false);
|
|
4334
|
-
|
|
4442
|
+
var ddErr=ddClassifySubmitError(p.error);
|
|
4443
|
+
if(ddErr.reason==='required'){
|
|
4335
4444
|
// La p\xE1gina no ha cambiado: el estado de navegaci\xF3n se queda como estaba.
|
|
4336
4445
|
errorHint.textContent=DD_LABELS_ACTIVE.errorRequired;
|
|
4337
4446
|
errorHint.style.display='block';
|
|
@@ -4340,6 +4449,11 @@ ${REVEAL_JS}
|
|
|
4340
4449
|
}
|
|
4341
4450
|
errorHint.textContent=DD_LABELS_ACTIVE.errorSubmit;
|
|
4342
4451
|
errorHint.style.display='block';
|
|
4452
|
+
// Un solo aviso por fallo: native repite el mismo objeto al cerrar el survey.
|
|
4453
|
+
if(p.error!==ddLastReportedError){
|
|
4454
|
+
ddLastReportedError=p.error;
|
|
4455
|
+
emitJSON('survey_error', ddErr);
|
|
4456
|
+
}
|
|
4343
4457
|
return;
|
|
4344
4458
|
}
|
|
4345
4459
|
errorHint.style.display='none';
|
|
@@ -4464,8 +4578,9 @@ var ReactNativePopupRenderer = class {
|
|
|
4464
4578
|
const surveyId = this.currentSurveyId;
|
|
4465
4579
|
if (!surveyId || !this.emitFn) return;
|
|
4466
4580
|
let name;
|
|
4581
|
+
let payload;
|
|
4467
4582
|
try {
|
|
4468
|
-
name = JSON.parse(raw)
|
|
4583
|
+
({ name, payload } = JSON.parse(raw));
|
|
4469
4584
|
} catch {
|
|
4470
4585
|
name = raw;
|
|
4471
4586
|
}
|
|
@@ -4486,6 +4601,9 @@ var ReactNativePopupRenderer = class {
|
|
|
4486
4601
|
case "survey_completed":
|
|
4487
4602
|
this.emitFn("survey_completed", surveyId);
|
|
4488
4603
|
break;
|
|
4604
|
+
case "survey_error":
|
|
4605
|
+
this.emitFn("survey_error", surveyId, { reason: payload?.reason, message: payload?.message });
|
|
4606
|
+
break;
|
|
4489
4607
|
case "popup_close":
|
|
4490
4608
|
this.onCloseFn?.();
|
|
4491
4609
|
break;
|
|
@@ -6948,6 +7066,15 @@ var DeepdotsPopups = class {
|
|
|
6948
7066
|
emitEvent(type, surveyId, data) {
|
|
6949
7067
|
const event = { type, surveyId, timestamp: Date.now(), data };
|
|
6950
7068
|
this.log("Event emitted", event);
|
|
7069
|
+
if (type === "survey_error") {
|
|
7070
|
+
const popupId = data?.popupId || this.surveyToPopupId.get(surveyId);
|
|
7071
|
+
this.track("deepdots_survey_error", {
|
|
7072
|
+
survey_id: surveyId,
|
|
7073
|
+
...popupId ? { popup_id: popupId } : {},
|
|
7074
|
+
reason: data?.reason,
|
|
7075
|
+
message: data?.message
|
|
7076
|
+
});
|
|
7077
|
+
}
|
|
6951
7078
|
const isPartialClick = type === "popup_clicked" && data?.action === "partial";
|
|
6952
7079
|
if (isPartialClick) {
|
|
6953
7080
|
this.markSurveyProgress(surveyId, "PARTIAL");
|