@blotoutio/providers-pinterest-sdk 0.30.0 → 0.31.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 +25 -7
- package/index.js +25 -7
- package/index.mjs +25 -7
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -64,7 +64,22 @@ const getPinterestEventName = (name) => {
|
|
|
64
64
|
}
|
|
65
65
|
return name;
|
|
66
66
|
};
|
|
67
|
-
const
|
|
67
|
+
const getProductIds = (item, productIdMapping) => {
|
|
68
|
+
var _a, _b;
|
|
69
|
+
if (productIdMapping === '1') {
|
|
70
|
+
return {
|
|
71
|
+
productId: (_a = item['variantId']) !== null && _a !== void 0 ? _a : item['id'],
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
if (productIdMapping === '2') {
|
|
75
|
+
return { productId: (_b = item['sku']) !== null && _b !== void 0 ? _b : item['id'] };
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
productId: item['id'],
|
|
79
|
+
productVariantId: item['variantId'],
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
const prepareData = (data, idMapping) => {
|
|
68
83
|
const payload = {};
|
|
69
84
|
if (data['currency']) {
|
|
70
85
|
payload['currency'] = data['currency'];
|
|
@@ -93,8 +108,9 @@ const prepareData = (data) => {
|
|
|
93
108
|
if (data['contents'] && Array.isArray(data['contents'])) {
|
|
94
109
|
payload['line_items'] = data['contents'].map((item) => {
|
|
95
110
|
const product = {};
|
|
96
|
-
|
|
97
|
-
|
|
111
|
+
const { productId, productVariantId } = getProductIds(item, idMapping);
|
|
112
|
+
if (productId) {
|
|
113
|
+
product.product_id = productId;
|
|
98
114
|
}
|
|
99
115
|
if (item.category) {
|
|
100
116
|
product.product_category = item.category;
|
|
@@ -105,8 +121,8 @@ const prepareData = (data) => {
|
|
|
105
121
|
if (item.quantity) {
|
|
106
122
|
product.product_quantity = item.quantity;
|
|
107
123
|
}
|
|
108
|
-
if (
|
|
109
|
-
product.product_variant_id = item.
|
|
124
|
+
if (productVariantId) {
|
|
125
|
+
product.product_variant_id = item.productVariantId;
|
|
110
126
|
}
|
|
111
127
|
if (item.brand) {
|
|
112
128
|
product.product_brand = item.brand;
|
|
@@ -132,7 +148,9 @@ const tag = ({ data, eventName, manifestVariables, eventId }) => {
|
|
|
132
148
|
const name = data['skipTransformation']
|
|
133
149
|
? eventName
|
|
134
150
|
: getPinterestEventName(eventName);
|
|
135
|
-
const eventData = data['skipTransformation']
|
|
151
|
+
const eventData = data['skipTransformation']
|
|
152
|
+
? data
|
|
153
|
+
: prepareData(data, manifestVariables['productIdMapping']);
|
|
136
154
|
delete eventData['skipTransformation'];
|
|
137
155
|
window.pintrk('track', name, {
|
|
138
156
|
...eventData,
|
|
@@ -140,7 +158,7 @@ const tag = ({ data, eventName, manifestVariables, eventId }) => {
|
|
|
140
158
|
});
|
|
141
159
|
}
|
|
142
160
|
return {
|
|
143
|
-
sdkVersion: "0.
|
|
161
|
+
sdkVersion: "0.31.0" ,
|
|
144
162
|
};
|
|
145
163
|
};
|
|
146
164
|
|
package/index.js
CHANGED
|
@@ -65,7 +65,22 @@ var ProvidersPinterestSdk = (function () {
|
|
|
65
65
|
}
|
|
66
66
|
return name;
|
|
67
67
|
};
|
|
68
|
-
const
|
|
68
|
+
const getProductIds = (item, productIdMapping) => {
|
|
69
|
+
var _a, _b;
|
|
70
|
+
if (productIdMapping === '1') {
|
|
71
|
+
return {
|
|
72
|
+
productId: (_a = item['variantId']) !== null && _a !== void 0 ? _a : item['id'],
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
if (productIdMapping === '2') {
|
|
76
|
+
return { productId: (_b = item['sku']) !== null && _b !== void 0 ? _b : item['id'] };
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
productId: item['id'],
|
|
80
|
+
productVariantId: item['variantId'],
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
const prepareData = (data, idMapping) => {
|
|
69
84
|
const payload = {};
|
|
70
85
|
if (data['currency']) {
|
|
71
86
|
payload['currency'] = data['currency'];
|
|
@@ -94,8 +109,9 @@ var ProvidersPinterestSdk = (function () {
|
|
|
94
109
|
if (data['contents'] && Array.isArray(data['contents'])) {
|
|
95
110
|
payload['line_items'] = data['contents'].map((item) => {
|
|
96
111
|
const product = {};
|
|
97
|
-
|
|
98
|
-
|
|
112
|
+
const { productId, productVariantId } = getProductIds(item, idMapping);
|
|
113
|
+
if (productId) {
|
|
114
|
+
product.product_id = productId;
|
|
99
115
|
}
|
|
100
116
|
if (item.category) {
|
|
101
117
|
product.product_category = item.category;
|
|
@@ -106,8 +122,8 @@ var ProvidersPinterestSdk = (function () {
|
|
|
106
122
|
if (item.quantity) {
|
|
107
123
|
product.product_quantity = item.quantity;
|
|
108
124
|
}
|
|
109
|
-
if (
|
|
110
|
-
product.product_variant_id = item.
|
|
125
|
+
if (productVariantId) {
|
|
126
|
+
product.product_variant_id = item.productVariantId;
|
|
111
127
|
}
|
|
112
128
|
if (item.brand) {
|
|
113
129
|
product.product_brand = item.brand;
|
|
@@ -133,7 +149,9 @@ var ProvidersPinterestSdk = (function () {
|
|
|
133
149
|
const name = data['skipTransformation']
|
|
134
150
|
? eventName
|
|
135
151
|
: getPinterestEventName(eventName);
|
|
136
|
-
const eventData = data['skipTransformation']
|
|
152
|
+
const eventData = data['skipTransformation']
|
|
153
|
+
? data
|
|
154
|
+
: prepareData(data, manifestVariables['productIdMapping']);
|
|
137
155
|
delete eventData['skipTransformation'];
|
|
138
156
|
window.pintrk('track', name, {
|
|
139
157
|
...eventData,
|
|
@@ -141,7 +159,7 @@ var ProvidersPinterestSdk = (function () {
|
|
|
141
159
|
});
|
|
142
160
|
}
|
|
143
161
|
return {
|
|
144
|
-
sdkVersion: "0.
|
|
162
|
+
sdkVersion: "0.31.0" ,
|
|
145
163
|
};
|
|
146
164
|
};
|
|
147
165
|
|
package/index.mjs
CHANGED
|
@@ -62,7 +62,22 @@ const getPinterestEventName = (name) => {
|
|
|
62
62
|
}
|
|
63
63
|
return name;
|
|
64
64
|
};
|
|
65
|
-
const
|
|
65
|
+
const getProductIds = (item, productIdMapping) => {
|
|
66
|
+
var _a, _b;
|
|
67
|
+
if (productIdMapping === '1') {
|
|
68
|
+
return {
|
|
69
|
+
productId: (_a = item['variantId']) !== null && _a !== void 0 ? _a : item['id'],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (productIdMapping === '2') {
|
|
73
|
+
return { productId: (_b = item['sku']) !== null && _b !== void 0 ? _b : item['id'] };
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
productId: item['id'],
|
|
77
|
+
productVariantId: item['variantId'],
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
const prepareData = (data, idMapping) => {
|
|
66
81
|
const payload = {};
|
|
67
82
|
if (data['currency']) {
|
|
68
83
|
payload['currency'] = data['currency'];
|
|
@@ -91,8 +106,9 @@ const prepareData = (data) => {
|
|
|
91
106
|
if (data['contents'] && Array.isArray(data['contents'])) {
|
|
92
107
|
payload['line_items'] = data['contents'].map((item) => {
|
|
93
108
|
const product = {};
|
|
94
|
-
|
|
95
|
-
|
|
109
|
+
const { productId, productVariantId } = getProductIds(item, idMapping);
|
|
110
|
+
if (productId) {
|
|
111
|
+
product.product_id = productId;
|
|
96
112
|
}
|
|
97
113
|
if (item.category) {
|
|
98
114
|
product.product_category = item.category;
|
|
@@ -103,8 +119,8 @@ const prepareData = (data) => {
|
|
|
103
119
|
if (item.quantity) {
|
|
104
120
|
product.product_quantity = item.quantity;
|
|
105
121
|
}
|
|
106
|
-
if (
|
|
107
|
-
product.product_variant_id = item.
|
|
122
|
+
if (productVariantId) {
|
|
123
|
+
product.product_variant_id = item.productVariantId;
|
|
108
124
|
}
|
|
109
125
|
if (item.brand) {
|
|
110
126
|
product.product_brand = item.brand;
|
|
@@ -130,7 +146,9 @@ const tag = ({ data, eventName, manifestVariables, eventId }) => {
|
|
|
130
146
|
const name = data['skipTransformation']
|
|
131
147
|
? eventName
|
|
132
148
|
: getPinterestEventName(eventName);
|
|
133
|
-
const eventData = data['skipTransformation']
|
|
149
|
+
const eventData = data['skipTransformation']
|
|
150
|
+
? data
|
|
151
|
+
: prepareData(data, manifestVariables['productIdMapping']);
|
|
134
152
|
delete eventData['skipTransformation'];
|
|
135
153
|
window.pintrk('track', name, {
|
|
136
154
|
...eventData,
|
|
@@ -138,7 +156,7 @@ const tag = ({ data, eventName, manifestVariables, eventId }) => {
|
|
|
138
156
|
});
|
|
139
157
|
}
|
|
140
158
|
return {
|
|
141
|
-
sdkVersion: "0.
|
|
159
|
+
sdkVersion: "0.31.0" ,
|
|
142
160
|
};
|
|
143
161
|
};
|
|
144
162
|
|