@product7/product7-js 0.4.1 → 0.4.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/README.md CHANGED
@@ -39,7 +39,9 @@ await sdk.identify({
39
39
  user_id: 'user_123',
40
40
  email: 'user@example.com',
41
41
  name: 'Jane Doe',
42
- custom_fields: { plan: 'pro' },
42
+ avatar: 'https://example.com/avatar.png', // optional
43
+ attributes: { plan: 'pro', role: 'admin' }, // optional, for segmentation
44
+ company: { id: 'company_123', name: 'Acme Inc' }, // optional
43
45
  });
44
46
 
45
47
  const widget = sdk.createFeedbackWidget({ position: 'bottom-right' });
@@ -132,10 +134,16 @@ new Product7({
132
134
 
133
135
  ```javascript
134
136
  await sdk.identify({
135
- user_id: 'user_123', // required: user_id or email
137
+ user_id: 'user_123', // required: user_id or email
136
138
  email: 'user@example.com',
137
139
  name: 'Jane Doe',
138
- custom_fields: { plan: 'pro' },
140
+ avatar: 'https://...', // optional
141
+ attributes: { plan: 'pro', role: 'admin' }, // optional, for segmentation
142
+ company: { // optional
143
+ id: 'company_123',
144
+ name: 'Acme Inc',
145
+ monthly_spend: 99.99,
146
+ },
139
147
  });
140
148
  ```
141
149
 
package/dist/README.md CHANGED
@@ -39,7 +39,9 @@ await sdk.identify({
39
39
  user_id: 'user_123',
40
40
  email: 'user@example.com',
41
41
  name: 'Jane Doe',
42
- custom_fields: { plan: 'pro' },
42
+ avatar: 'https://example.com/avatar.png', // optional
43
+ attributes: { plan: 'pro', role: 'admin' }, // optional, for segmentation
44
+ company: { id: 'company_123', name: 'Acme Inc' }, // optional
43
45
  });
44
46
 
45
47
  const widget = sdk.createFeedbackWidget({ position: 'bottom-right' });
@@ -132,10 +134,16 @@ new Product7({
132
134
 
133
135
  ```javascript
134
136
  await sdk.identify({
135
- user_id: 'user_123', // required: user_id or email
137
+ user_id: 'user_123', // required: user_id or email
136
138
  email: 'user@example.com',
137
139
  name: 'Jane Doe',
138
- custom_fields: { plan: 'pro' },
140
+ avatar: 'https://...', // optional
141
+ attributes: { plan: 'pro', role: 'admin' }, // optional, for segmentation
142
+ company: { // optional
143
+ id: 'company_123',
144
+ name: 'Acme Inc',
145
+ monthly_spend: 99.99,
146
+ },
139
147
  });
140
148
  ```
141
149
 
@@ -8301,7 +8301,7 @@
8301
8301
  if (this._soundUrl) {
8302
8302
  await this._playFile();
8303
8303
  } else {
8304
- this._playSynthetic();
8304
+ await this._playSynthetic();
8305
8305
  }
8306
8306
  } catch {
8307
8307
  /* autoplay policy or context suspended — silent fail */
@@ -8325,12 +8325,12 @@
8325
8325
  * • Second tone: 1100 Hz, 60–160 ms
8326
8326
  * Sounds like a gentle message ping.
8327
8327
  */
8328
- _playSynthetic() {
8328
+ async _playSynthetic() {
8329
8329
  const ctx = this._getAudioContext();
8330
8330
  if (!ctx) return;
8331
8331
 
8332
8332
  if (ctx.state === 'suspended') {
8333
- ctx.resume().catch(() => {});
8333
+ await ctx.resume();
8334
8334
  }
8335
8335
 
8336
8336
  const now = ctx.currentTime;
@@ -11529,7 +11529,7 @@
11529
11529
  : true;
11530
11530
 
11531
11531
  this._notificationSound = new NotificationSound({
11532
- soundUrl: typeof notificationSoundOption === 'string' ? notificationSoundOption : null,
11532
+ soundUrl: typeof notificationSoundOption === 'string' ? notificationSoundOption : undefined,
11533
11533
  volume: options.notificationVolume ?? 0.4,
11534
11534
  });
11535
11535
 
@@ -11863,14 +11863,8 @@
11863
11863
 
11864
11864
  const isOwnMessage = message.sender_type === 'customer';
11865
11865
 
11866
- if (!isOwnMessage) {
11867
- const panelOpenOnThisConversation =
11868
- this.messengerState.isOpen &&
11869
- this.messengerState.activeConversationId === conversation_id;
11870
-
11871
- if (!panelOpenOnThisConversation) {
11872
- this._notificationSound.play();
11873
- }
11866
+ if (!isOwnMessage && this.messengerState.isIdentified) {
11867
+ this._notificationSound.play();
11874
11868
  }
11875
11869
 
11876
11870
  if (