@product7/product7-js 0.3.4 → 0.3.5
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/dist/product7-js.js +62 -4
- package/dist/product7-js.js.map +1 -1
- package/dist/product7-js.min.js +1 -1
- package/dist/product7-js.min.js.map +1 -1
- package/package.json +1 -1
- package/src/core/APIService.js +54 -2
- package/src/core/BaseAPIService.js +4 -0
- package/src/core/Product7.js +1 -1
- package/src/widgets/MessengerWidget.js +3 -1
package/dist/product7-js.js
CHANGED
|
@@ -1206,8 +1206,12 @@
|
|
|
1206
1206
|
this.sessionToken = null;
|
|
1207
1207
|
this.sessionExpiry = null;
|
|
1208
1208
|
this.identitySyncedToken = null;
|
|
1209
|
+
this.contactId = null;
|
|
1210
|
+
this.contactEmail = null;
|
|
1211
|
+
this.contactName = null;
|
|
1209
1212
|
this._removeData('product7_session');
|
|
1210
1213
|
this._removeData('product7_metadata');
|
|
1214
|
+
this._removeData('product7_contact');
|
|
1211
1215
|
}
|
|
1212
1216
|
|
|
1213
1217
|
_storeSession() {
|
|
@@ -1592,7 +1596,7 @@
|
|
|
1592
1596
|
|
|
1593
1597
|
if (this.mock) {
|
|
1594
1598
|
await new Promise((r) => setTimeout(r, 300));
|
|
1595
|
-
|
|
1599
|
+
const mockResponse = {
|
|
1596
1600
|
status: true,
|
|
1597
1601
|
data: {
|
|
1598
1602
|
contact_id: 'mock_contact_' + Date.now(),
|
|
@@ -1601,9 +1605,11 @@
|
|
|
1601
1605
|
is_new: true,
|
|
1602
1606
|
},
|
|
1603
1607
|
};
|
|
1608
|
+
this._storeContactIdentity(mockResponse.data, metadata);
|
|
1609
|
+
return mockResponse;
|
|
1604
1610
|
}
|
|
1605
1611
|
|
|
1606
|
-
|
|
1612
|
+
const response = await this._makeRequest('/widget/messenger/identify', {
|
|
1607
1613
|
method: 'POST',
|
|
1608
1614
|
headers: {
|
|
1609
1615
|
'Content-Type': 'application/json',
|
|
@@ -1619,6 +1625,56 @@
|
|
|
1619
1625
|
metadata: metadata.custom_fields || {},
|
|
1620
1626
|
}),
|
|
1621
1627
|
});
|
|
1628
|
+
|
|
1629
|
+
if (response?.status && response?.data) {
|
|
1630
|
+
this._storeContactIdentity(response.data, metadata);
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
return response;
|
|
1634
|
+
}
|
|
1635
|
+
|
|
1636
|
+
_storeContactIdentity(data, metadata = {}) {
|
|
1637
|
+
this.contactId = data.contact_id || null;
|
|
1638
|
+
this.contactEmail = data.email || metadata.email || null;
|
|
1639
|
+
this.contactName = data.name || metadata.name || null;
|
|
1640
|
+
|
|
1641
|
+
try {
|
|
1642
|
+
localStorage.setItem(
|
|
1643
|
+
'product7_contact',
|
|
1644
|
+
JSON.stringify({
|
|
1645
|
+
contactId: this.contactId,
|
|
1646
|
+
contactEmail: this.contactEmail,
|
|
1647
|
+
contactName: this.contactName,
|
|
1648
|
+
})
|
|
1649
|
+
);
|
|
1650
|
+
} catch (e) {
|
|
1651
|
+
/* silent */
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
|
|
1655
|
+
getContactIdentity() {
|
|
1656
|
+
if (this.contactId) {
|
|
1657
|
+
return {
|
|
1658
|
+
contactId: this.contactId,
|
|
1659
|
+
contactEmail: this.contactEmail,
|
|
1660
|
+
contactName: this.contactName,
|
|
1661
|
+
};
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
try {
|
|
1665
|
+
const stored = localStorage.getItem('product7_contact');
|
|
1666
|
+
if (stored) {
|
|
1667
|
+
const parsed = JSON.parse(stored);
|
|
1668
|
+
this.contactId = parsed.contactId;
|
|
1669
|
+
this.contactEmail = parsed.contactEmail;
|
|
1670
|
+
this.contactName = parsed.contactName;
|
|
1671
|
+
return parsed;
|
|
1672
|
+
}
|
|
1673
|
+
} catch (e) {
|
|
1674
|
+
/* silent */
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
return null;
|
|
1622
1678
|
}
|
|
1623
1679
|
|
|
1624
1680
|
async identifyContact(data) {
|
|
@@ -11411,6 +11467,7 @@
|
|
|
11411
11467
|
initialView: options.initialView || 'home',
|
|
11412
11468
|
previewData: options.previewData || null,
|
|
11413
11469
|
featuredContent: options.featuredContent || null,
|
|
11470
|
+
feedbackBoardName: options.feedbackBoardName || null,
|
|
11414
11471
|
feedbackUrl: options.feedbackUrl || null,
|
|
11415
11472
|
changelogUrl: options.changelogUrl || null,
|
|
11416
11473
|
helpUrl: options.helpUrl || null,
|
|
@@ -11462,7 +11519,8 @@
|
|
|
11462
11519
|
const widget = this.sdk.createWidget('button', {
|
|
11463
11520
|
trigger: false,
|
|
11464
11521
|
displayMode: 'modal',
|
|
11465
|
-
boardName:
|
|
11522
|
+
boardName:
|
|
11523
|
+
this.messengerOptions.feedbackBoardName || this.sdk.config.boardName,
|
|
11466
11524
|
primaryColor: this.messengerOptions.primaryColor,
|
|
11467
11525
|
theme: this.messengerOptions.theme,
|
|
11468
11526
|
});
|
|
@@ -14768,7 +14826,7 @@
|
|
|
14768
14826
|
metadata: null,
|
|
14769
14827
|
position: 'right',
|
|
14770
14828
|
theme: 'light',
|
|
14771
|
-
boardName: '
|
|
14829
|
+
boardName: 'feature-requests',
|
|
14772
14830
|
autoShow: true,
|
|
14773
14831
|
debug: false,
|
|
14774
14832
|
mock: false,
|