@product7/feedback-sdk 1.5.1 → 1.5.2
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/package.json
CHANGED
package/src/core/FeedbackSDK.js
CHANGED
|
@@ -176,6 +176,8 @@ export class FeedbackSDK {
|
|
|
176
176
|
lowLabel: options.lowLabel,
|
|
177
177
|
highLabel: options.highLabel,
|
|
178
178
|
customQuestions: options.customQuestions,
|
|
179
|
+
respondentId: options.respondentId,
|
|
180
|
+
email: options.email,
|
|
179
181
|
onSubmit: options.onSubmit,
|
|
180
182
|
onDismiss: options.onDismiss,
|
|
181
183
|
});
|
|
@@ -13,6 +13,8 @@ export class SurveyWidget extends BaseWidget {
|
|
|
13
13
|
lowLabel: options.lowLabel || null,
|
|
14
14
|
highLabel: options.highLabel || null,
|
|
15
15
|
customQuestions: options.customQuestions || [],
|
|
16
|
+
respondentId: options.respondentId || null,
|
|
17
|
+
email: options.email || null,
|
|
16
18
|
onSubmit: options.onSubmit || null,
|
|
17
19
|
onDismiss: options.onDismiss || null,
|
|
18
20
|
};
|
|
@@ -381,10 +383,14 @@ export class SurveyWidget extends BaseWidget {
|
|
|
381
383
|
return;
|
|
382
384
|
}
|
|
383
385
|
|
|
386
|
+
const respondent = this._getRespondentContext();
|
|
387
|
+
|
|
384
388
|
const responseData = {
|
|
385
389
|
rating: this.surveyState.score,
|
|
386
390
|
feedback: this.surveyState.feedback,
|
|
387
391
|
answers: this.surveyState.customAnswers,
|
|
392
|
+
...(respondent.respondentId && { respondentId: respondent.respondentId }),
|
|
393
|
+
...(respondent.email && { email: respondent.email }),
|
|
388
394
|
};
|
|
389
395
|
|
|
390
396
|
const response = {
|
|
@@ -413,6 +419,34 @@ export class SurveyWidget extends BaseWidget {
|
|
|
413
419
|
this._showSuccessNotification();
|
|
414
420
|
}
|
|
415
421
|
|
|
422
|
+
_getRespondentContext() {
|
|
423
|
+
const sdkUserContext =
|
|
424
|
+
typeof this.sdk.getUserContext === 'function'
|
|
425
|
+
? this.sdk.getUserContext() || {}
|
|
426
|
+
: {};
|
|
427
|
+
const apiUserContext =
|
|
428
|
+
this.apiService &&
|
|
429
|
+
typeof this.apiService.getUserContext === 'function'
|
|
430
|
+
? this.apiService.getUserContext() || {}
|
|
431
|
+
: {};
|
|
432
|
+
const localUserContext = this.options.userContext || {};
|
|
433
|
+
|
|
434
|
+
return {
|
|
435
|
+
respondentId:
|
|
436
|
+
this.surveyOptions.respondentId ||
|
|
437
|
+
localUserContext.user_id ||
|
|
438
|
+
sdkUserContext.user_id ||
|
|
439
|
+
apiUserContext.user_id ||
|
|
440
|
+
null,
|
|
441
|
+
email:
|
|
442
|
+
this.surveyOptions.email ||
|
|
443
|
+
localUserContext.email ||
|
|
444
|
+
sdkUserContext.email ||
|
|
445
|
+
apiUserContext.email ||
|
|
446
|
+
null,
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
|
|
416
450
|
async _handleDismiss() {
|
|
417
451
|
if (this.surveyOptions.surveyId) {
|
|
418
452
|
try {
|
package/types/index.d.ts
CHANGED
|
@@ -78,6 +78,8 @@ declare module '@product7/feedback-sdk' {
|
|
|
78
78
|
lowLabel?: string | null;
|
|
79
79
|
highLabel?: string | null;
|
|
80
80
|
customQuestions?: SurveyQuestion[];
|
|
81
|
+
respondentId?: string | null;
|
|
82
|
+
email?: string | null;
|
|
81
83
|
theme?: 'light' | 'dark';
|
|
82
84
|
onSubmit?: (response: SurveyWidgetResponse) => void;
|
|
83
85
|
onDismiss?: () => void;
|