@blotoutio/providers-facebook-sdk 0.8.2 → 0.8.4
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/index.js +13 -6
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -41,8 +41,10 @@ var ProvidersFacebookSdk = (function () {
|
|
|
41
41
|
});
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
const prepareData = (data) => {
|
|
45
|
-
const payload = {
|
|
44
|
+
const prepareData = (data, useVariantId) => {
|
|
45
|
+
const payload = {
|
|
46
|
+
app: 'Blotout',
|
|
47
|
+
};
|
|
46
48
|
if (data['value']) {
|
|
47
49
|
payload['value'] = data['value'];
|
|
48
50
|
}
|
|
@@ -76,8 +78,11 @@ var ProvidersFacebookSdk = (function () {
|
|
|
76
78
|
if (data['contents'] && Array.isArray(data['contents'])) {
|
|
77
79
|
payload['contents'] = data['contents'].map((item) => {
|
|
78
80
|
const content = {};
|
|
79
|
-
if (item.id) {
|
|
80
|
-
|
|
81
|
+
if (item.id || item.variantId) {
|
|
82
|
+
if (item.variantId && useVariantId) {
|
|
83
|
+
content['id'] = item.variantId;
|
|
84
|
+
}
|
|
85
|
+
content['id'] = item.id || item.variantId;
|
|
81
86
|
}
|
|
82
87
|
if (item.quantity) {
|
|
83
88
|
content['quantity'] = item.quantity;
|
|
@@ -88,17 +93,19 @@ var ProvidersFacebookSdk = (function () {
|
|
|
88
93
|
if (item.category) {
|
|
89
94
|
content['category'] = item.category;
|
|
90
95
|
}
|
|
96
|
+
if (item.title) {
|
|
97
|
+
content['title'] = item.title;
|
|
98
|
+
}
|
|
91
99
|
return content;
|
|
92
100
|
});
|
|
93
101
|
}
|
|
94
|
-
payload['app'] = 'Blotout';
|
|
95
102
|
return payload;
|
|
96
103
|
};
|
|
97
104
|
const tag = ({ data, eventName, manifestVariables, eventId }) => {
|
|
98
105
|
if (!window.fbq || manifestVariables['enableBrowser'] !== '1') {
|
|
99
106
|
return;
|
|
100
107
|
}
|
|
101
|
-
window.fbq('track', eventName, prepareData(data), {
|
|
108
|
+
window.fbq('track', eventName, prepareData(data, manifestVariables['variantId'] === '1'), {
|
|
102
109
|
eventID: eventId,
|
|
103
110
|
});
|
|
104
111
|
};
|