@blotoutio/providers-tiktok-sdk 0.30.1 → 0.32.0
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.cjs.js +13 -12
- package/index.js +13 -12
- package/index.mjs +13 -12
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -78,6 +78,16 @@ const init = ({ manifest, userId }) => {
|
|
|
78
78
|
});
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
+
const getProductIdFromMapping = (item, productIdMapping) => {
|
|
82
|
+
if (productIdMapping === '1' && item['variantId']) {
|
|
83
|
+
return item['variantId'];
|
|
84
|
+
}
|
|
85
|
+
if (productIdMapping === '2' && item['sku']) {
|
|
86
|
+
return item['sku'];
|
|
87
|
+
}
|
|
88
|
+
return item['id'];
|
|
89
|
+
};
|
|
90
|
+
|
|
81
91
|
const getEventName = (event, manifestVariables) => {
|
|
82
92
|
if (event === 'PageView') {
|
|
83
93
|
return 'Pageview';
|
|
@@ -88,15 +98,6 @@ const getEventName = (event, manifestVariables) => {
|
|
|
88
98
|
}
|
|
89
99
|
return event;
|
|
90
100
|
};
|
|
91
|
-
const getProductId = (item, productIdMapping) => {
|
|
92
|
-
if (productIdMapping === '1' && item['variantId']) {
|
|
93
|
-
return item['variantId'];
|
|
94
|
-
}
|
|
95
|
-
if (productIdMapping === '2' && item['sku']) {
|
|
96
|
-
return item['sku'];
|
|
97
|
-
}
|
|
98
|
-
return item['id'];
|
|
99
|
-
};
|
|
100
101
|
const prepareData = (data, productIdMapping) => {
|
|
101
102
|
const payload = {};
|
|
102
103
|
if (data['search']) {
|
|
@@ -125,7 +126,7 @@ const prepareData = (data, productIdMapping) => {
|
|
|
125
126
|
payload['content_type'] = data['contents'][0].type;
|
|
126
127
|
payload['contents'] = data['contents'].map((item) => {
|
|
127
128
|
const content = {};
|
|
128
|
-
const contentId =
|
|
129
|
+
const contentId = getProductIdFromMapping(item, productIdMapping);
|
|
129
130
|
if (contentId) {
|
|
130
131
|
content['content_id'] = contentId;
|
|
131
132
|
}
|
|
@@ -154,7 +155,7 @@ const prepareData = (data, productIdMapping) => {
|
|
|
154
155
|
if (data['contents'][0].quantity) {
|
|
155
156
|
payload['quantity'] = data['contents'][0].quantity;
|
|
156
157
|
}
|
|
157
|
-
const contentId =
|
|
158
|
+
const contentId = getProductIdFromMapping(data['contents'][0], productIdMapping);
|
|
158
159
|
if (contentId) {
|
|
159
160
|
payload['content_id'] = contentId;
|
|
160
161
|
}
|
|
@@ -186,7 +187,7 @@ const tag = ({ data, eventName, manifestVariables, eventId }) => {
|
|
|
186
187
|
});
|
|
187
188
|
}
|
|
188
189
|
return {
|
|
189
|
-
sdkVersion: "0.
|
|
190
|
+
sdkVersion: "0.32.0" ,
|
|
190
191
|
};
|
|
191
192
|
};
|
|
192
193
|
|
package/index.js
CHANGED
|
@@ -79,6 +79,16 @@ var ProvidersTiktokSdk = (function () {
|
|
|
79
79
|
});
|
|
80
80
|
};
|
|
81
81
|
|
|
82
|
+
const getProductIdFromMapping = (item, productIdMapping) => {
|
|
83
|
+
if (productIdMapping === '1' && item['variantId']) {
|
|
84
|
+
return item['variantId'];
|
|
85
|
+
}
|
|
86
|
+
if (productIdMapping === '2' && item['sku']) {
|
|
87
|
+
return item['sku'];
|
|
88
|
+
}
|
|
89
|
+
return item['id'];
|
|
90
|
+
};
|
|
91
|
+
|
|
82
92
|
const getEventName = (event, manifestVariables) => {
|
|
83
93
|
if (event === 'PageView') {
|
|
84
94
|
return 'Pageview';
|
|
@@ -89,15 +99,6 @@ var ProvidersTiktokSdk = (function () {
|
|
|
89
99
|
}
|
|
90
100
|
return event;
|
|
91
101
|
};
|
|
92
|
-
const getProductId = (item, productIdMapping) => {
|
|
93
|
-
if (productIdMapping === '1' && item['variantId']) {
|
|
94
|
-
return item['variantId'];
|
|
95
|
-
}
|
|
96
|
-
if (productIdMapping === '2' && item['sku']) {
|
|
97
|
-
return item['sku'];
|
|
98
|
-
}
|
|
99
|
-
return item['id'];
|
|
100
|
-
};
|
|
101
102
|
const prepareData = (data, productIdMapping) => {
|
|
102
103
|
const payload = {};
|
|
103
104
|
if (data['search']) {
|
|
@@ -126,7 +127,7 @@ var ProvidersTiktokSdk = (function () {
|
|
|
126
127
|
payload['content_type'] = data['contents'][0].type;
|
|
127
128
|
payload['contents'] = data['contents'].map((item) => {
|
|
128
129
|
const content = {};
|
|
129
|
-
const contentId =
|
|
130
|
+
const contentId = getProductIdFromMapping(item, productIdMapping);
|
|
130
131
|
if (contentId) {
|
|
131
132
|
content['content_id'] = contentId;
|
|
132
133
|
}
|
|
@@ -155,7 +156,7 @@ var ProvidersTiktokSdk = (function () {
|
|
|
155
156
|
if (data['contents'][0].quantity) {
|
|
156
157
|
payload['quantity'] = data['contents'][0].quantity;
|
|
157
158
|
}
|
|
158
|
-
const contentId =
|
|
159
|
+
const contentId = getProductIdFromMapping(data['contents'][0], productIdMapping);
|
|
159
160
|
if (contentId) {
|
|
160
161
|
payload['content_id'] = contentId;
|
|
161
162
|
}
|
|
@@ -187,7 +188,7 @@ var ProvidersTiktokSdk = (function () {
|
|
|
187
188
|
});
|
|
188
189
|
}
|
|
189
190
|
return {
|
|
190
|
-
sdkVersion: "0.
|
|
191
|
+
sdkVersion: "0.32.0" ,
|
|
191
192
|
};
|
|
192
193
|
};
|
|
193
194
|
|
package/index.mjs
CHANGED
|
@@ -76,6 +76,16 @@ const init = ({ manifest, userId }) => {
|
|
|
76
76
|
});
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
+
const getProductIdFromMapping = (item, productIdMapping) => {
|
|
80
|
+
if (productIdMapping === '1' && item['variantId']) {
|
|
81
|
+
return item['variantId'];
|
|
82
|
+
}
|
|
83
|
+
if (productIdMapping === '2' && item['sku']) {
|
|
84
|
+
return item['sku'];
|
|
85
|
+
}
|
|
86
|
+
return item['id'];
|
|
87
|
+
};
|
|
88
|
+
|
|
79
89
|
const getEventName = (event, manifestVariables) => {
|
|
80
90
|
if (event === 'PageView') {
|
|
81
91
|
return 'Pageview';
|
|
@@ -86,15 +96,6 @@ const getEventName = (event, manifestVariables) => {
|
|
|
86
96
|
}
|
|
87
97
|
return event;
|
|
88
98
|
};
|
|
89
|
-
const getProductId = (item, productIdMapping) => {
|
|
90
|
-
if (productIdMapping === '1' && item['variantId']) {
|
|
91
|
-
return item['variantId'];
|
|
92
|
-
}
|
|
93
|
-
if (productIdMapping === '2' && item['sku']) {
|
|
94
|
-
return item['sku'];
|
|
95
|
-
}
|
|
96
|
-
return item['id'];
|
|
97
|
-
};
|
|
98
99
|
const prepareData = (data, productIdMapping) => {
|
|
99
100
|
const payload = {};
|
|
100
101
|
if (data['search']) {
|
|
@@ -123,7 +124,7 @@ const prepareData = (data, productIdMapping) => {
|
|
|
123
124
|
payload['content_type'] = data['contents'][0].type;
|
|
124
125
|
payload['contents'] = data['contents'].map((item) => {
|
|
125
126
|
const content = {};
|
|
126
|
-
const contentId =
|
|
127
|
+
const contentId = getProductIdFromMapping(item, productIdMapping);
|
|
127
128
|
if (contentId) {
|
|
128
129
|
content['content_id'] = contentId;
|
|
129
130
|
}
|
|
@@ -152,7 +153,7 @@ const prepareData = (data, productIdMapping) => {
|
|
|
152
153
|
if (data['contents'][0].quantity) {
|
|
153
154
|
payload['quantity'] = data['contents'][0].quantity;
|
|
154
155
|
}
|
|
155
|
-
const contentId =
|
|
156
|
+
const contentId = getProductIdFromMapping(data['contents'][0], productIdMapping);
|
|
156
157
|
if (contentId) {
|
|
157
158
|
payload['content_id'] = contentId;
|
|
158
159
|
}
|
|
@@ -184,7 +185,7 @@ const tag = ({ data, eventName, manifestVariables, eventId }) => {
|
|
|
184
185
|
});
|
|
185
186
|
}
|
|
186
187
|
return {
|
|
187
|
-
sdkVersion: "0.
|
|
188
|
+
sdkVersion: "0.32.0" ,
|
|
188
189
|
};
|
|
189
190
|
};
|
|
190
191
|
|