@product7/feedback-sdk 1.3.5 → 1.3.7

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@product7/feedback-sdk",
3
- "version": "1.3.5",
3
+ "version": "1.3.7",
4
4
  "description": "JavaScript SDK for integrating Product7 feedback widgets into any website",
5
5
  "main": "dist/feedback-sdk.js",
6
6
  "module": "src/index.js",
@@ -210,20 +210,7 @@ async _handleIdentifyContact(contactData) {
210
210
  }
211
211
  this.messengerState.userContext.name = contactData.name;
212
212
  this.messengerState.userContext.email = contactData.email;
213
- this.messengerState.isIdentified = true; // ADD THIS LINE
214
-
215
- // Process pending message
216
- const pendingMessage = this.messengerState.pendingMessage;
217
- if (pendingMessage) {
218
- this.messengerState.pendingMessage = null;
219
- await this.startNewConversation(
220
- pendingMessage.content,
221
- '',
222
- pendingMessage.attachments
223
- );
224
- } else {
225
- this.messengerState.setView('chat');
226
- }
213
+ this.messengerState.isIdentified = true;
227
214
  }
228
215
 
229
216
  return response;
@@ -164,45 +164,62 @@ export class PreChatFormView {
164
164
  }
165
165
  }
166
166
 
167
- async _handleSubmit() {
168
- const nameInput = this.element.querySelector('#messenger-prechat-name');
169
- const emailInput = this.element.querySelector('#messenger-prechat-email');
170
- const submitBtn = this.element.querySelector('.messenger-prechat-submit');
171
- const submitText = submitBtn.querySelector('.messenger-prechat-submit-text');
172
- const submitLoading = submitBtn.querySelector('.messenger-prechat-submit-loading');
173
-
174
- const name = nameInput.value.trim();
175
- const email = emailInput.value.trim();
176
-
177
- this._isSubmitting = true;
178
- submitBtn.disabled = true;
179
- submitText.style.display = 'none';
180
- submitLoading.style.display = 'inline-flex';
181
-
182
- try {
183
- if (this.options.onIdentifyContact) {
184
- await this.options.onIdentifyContact({ name, email });
185
- }
167
+ async _handleSubmit() {
168
+ const nameInput = this.element.querySelector('#messenger-prechat-name');
169
+ const emailInput = this.element.querySelector('#messenger-prechat-email');
170
+ const submitBtn = this.element.querySelector('.messenger-prechat-submit');
171
+ const submitText = submitBtn.querySelector('.messenger-prechat-submit-text');
172
+ const submitLoading = submitBtn.querySelector('.messenger-prechat-submit-loading');
173
+
174
+ const name = nameInput.value.trim();
175
+ const email = emailInput.value.trim();
176
+
177
+ this._isSubmitting = true;
178
+ submitBtn.disabled = true;
179
+ submitText.style.display = 'none';
180
+ submitLoading.style.display = 'inline-flex';
181
+
182
+ try {
183
+ // Call identification API
184
+ if (this.options.onIdentifyContact) {
185
+ await this.options.onIdentifyContact({ name, email });
186
+ }
186
187
 
187
- if (!this.state.userContext) {
188
- this.state.userContext = {};
189
- }
190
- this.state.userContext.name = name;
191
- this.state.userContext.email = email;
188
+ // Update state
189
+ if (!this.state.userContext) {
190
+ this.state.userContext = {};
191
+ }
192
+ this.state.userContext.name = name;
193
+ this.state.userContext.email = email;
194
+ this.state.isIdentified = true;
192
195
 
193
- this._isSubmitting = false;
196
+ this._isSubmitting = false;
194
197
 
198
+ // Process pending message if exists
199
+ const pendingMessage = this.state.pendingMessage;
200
+ if (pendingMessage && this.options.onStartConversation) {
201
+ this.state.pendingMessage = null;
202
+ this.state.setView('chat');
203
+
204
+ // Start conversation with pending message
205
+ await this.options.onStartConversation(
206
+ pendingMessage.content,
207
+ pendingMessage.attachments
208
+ );
209
+ } else {
210
+ // No pending message, just go to chat
195
211
  this.state.setView('chat');
196
- } catch (error) {
197
- console.error('[PreChatFormView] Error submitting form:', error);
198
- this._showError('messenger-email-error', 'Something went wrong. Please try again.');
199
-
200
- this._isSubmitting = false;
201
- submitBtn.disabled = false;
202
- submitText.style.display = 'inline';
203
- submitLoading.style.display = 'none';
204
212
  }
213
+ } catch (error) {
214
+ console.error('[PreChatFormView] Error submitting form:', error);
215
+ this._showError('messenger-email-error', 'Something went wrong. Please try again.');
216
+
217
+ this._isSubmitting = false;
218
+ submitBtn.disabled = false;
219
+ submitText.style.display = 'inline';
220
+ submitLoading.style.display = 'none';
205
221
  }
222
+ }
206
223
 
207
224
  destroy() {
208
225
  if (this.element && this.element.parentNode) {