@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.
@@ -6729,6 +6729,8 @@
6729
6729
  lowLabel: options.lowLabel || null,
6730
6730
  highLabel: options.highLabel || null,
6731
6731
  customQuestions: options.customQuestions || [],
6732
+ respondentId: options.respondentId || null,
6733
+ email: options.email || null,
6732
6734
  onSubmit: options.onSubmit || null,
6733
6735
  onDismiss: options.onDismiss || null,
6734
6736
  };
@@ -7097,10 +7099,14 @@
7097
7099
  return;
7098
7100
  }
7099
7101
 
7102
+ const respondent = this._getRespondentContext();
7103
+
7100
7104
  const responseData = {
7101
7105
  rating: this.surveyState.score,
7102
7106
  feedback: this.surveyState.feedback,
7103
7107
  answers: this.surveyState.customAnswers,
7108
+ ...(respondent.respondentId && { respondentId: respondent.respondentId }),
7109
+ ...(respondent.email && { email: respondent.email }),
7104
7110
  };
7105
7111
 
7106
7112
  const response = {
@@ -7129,6 +7135,34 @@
7129
7135
  this._showSuccessNotification();
7130
7136
  }
7131
7137
 
7138
+ _getRespondentContext() {
7139
+ const sdkUserContext =
7140
+ typeof this.sdk.getUserContext === 'function'
7141
+ ? this.sdk.getUserContext() || {}
7142
+ : {};
7143
+ const apiUserContext =
7144
+ this.apiService &&
7145
+ typeof this.apiService.getUserContext === 'function'
7146
+ ? this.apiService.getUserContext() || {}
7147
+ : {};
7148
+ const localUserContext = this.options.userContext || {};
7149
+
7150
+ return {
7151
+ respondentId:
7152
+ this.surveyOptions.respondentId ||
7153
+ localUserContext.user_id ||
7154
+ sdkUserContext.user_id ||
7155
+ apiUserContext.user_id ||
7156
+ null,
7157
+ email:
7158
+ this.surveyOptions.email ||
7159
+ localUserContext.email ||
7160
+ sdkUserContext.email ||
7161
+ apiUserContext.email ||
7162
+ null,
7163
+ };
7164
+ }
7165
+
7132
7166
  async _handleDismiss() {
7133
7167
  if (this.surveyOptions.surveyId) {
7134
7168
  try {
@@ -7505,6 +7539,8 @@
7505
7539
  lowLabel: options.lowLabel,
7506
7540
  highLabel: options.highLabel,
7507
7541
  customQuestions: options.customQuestions,
7542
+ respondentId: options.respondentId,
7543
+ email: options.email,
7508
7544
  onSubmit: options.onSubmit,
7509
7545
  onDismiss: options.onDismiss,
7510
7546
  });