@blotoutio/providers-facebook-sdk 0.8.3 → 0.8.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/index.js +15 -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,13 @@ 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
|
+
else {
|
|
86
|
+
content['id'] = item.id || item.variantId;
|
|
87
|
+
}
|
|
81
88
|
}
|
|
82
89
|
if (item.quantity) {
|
|
83
90
|
content['quantity'] = item.quantity;
|
|
@@ -88,17 +95,19 @@ var ProvidersFacebookSdk = (function () {
|
|
|
88
95
|
if (item.category) {
|
|
89
96
|
content['category'] = item.category;
|
|
90
97
|
}
|
|
98
|
+
if (item.title) {
|
|
99
|
+
content['title'] = item.title;
|
|
100
|
+
}
|
|
91
101
|
return content;
|
|
92
102
|
});
|
|
93
103
|
}
|
|
94
|
-
payload['app'] = 'Blotout';
|
|
95
104
|
return payload;
|
|
96
105
|
};
|
|
97
106
|
const tag = ({ data, eventName, manifestVariables, eventId }) => {
|
|
98
107
|
if (!window.fbq || manifestVariables['enableBrowser'] !== '1') {
|
|
99
108
|
return;
|
|
100
109
|
}
|
|
101
|
-
window.fbq('track', eventName, prepareData(data), {
|
|
110
|
+
window.fbq('track', eventName, prepareData(data, manifestVariables['variantId'] === '1'), {
|
|
102
111
|
eventID: eventId,
|
|
103
112
|
});
|
|
104
113
|
};
|