@blotoutio/providers-app-lovin-sdk 1.45.0 → 1.46.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.
Files changed (4) hide show
  1. package/index.cjs.js +74 -32
  2. package/index.js +74 -32
  3. package/index.mjs +74 -32
  4. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -114,13 +114,35 @@ const getItems = (contents, defaultCategoryId, categories) => contents.map((item
114
114
  image_url: item.image,
115
115
  item_variant_id: item.variantId,
116
116
  item_brand: item.brand,
117
- item_category_id: categoryId || defaultCategoryId || '',
117
+ item_category_id: Number(categoryId) || Number(defaultCategoryId) || 0,
118
118
  };
119
119
  });
120
- const getEventData = ({ eventName, userId, data, defaultCategory, categoryMapping, }) => {
120
+ const getEventData = ({ eventName, userData, data, defaultCategory, categoryMapping, }) => {
121
+ var _a, _b;
121
122
  const categories = getCategories(categoryMapping);
122
123
  const defaultCategoryId = getParsedCategoryId(defaultCategory);
123
124
  switch (eventName) {
125
+ case 'PageView': {
126
+ return {
127
+ name: 'page_view',
128
+ data: {
129
+ user_data: userData,
130
+ },
131
+ };
132
+ }
133
+ case 'ViewContent': {
134
+ return {
135
+ name: 'view_item',
136
+ data: {
137
+ currency: data.currency,
138
+ items: data.contents
139
+ ? getItems(data.contents, defaultCategoryId, categories)
140
+ : [],
141
+ value: data.value,
142
+ user_data: userData,
143
+ },
144
+ };
145
+ }
124
146
  case 'AddToCart': {
125
147
  return {
126
148
  name: 'add_to_cart',
@@ -130,35 +152,48 @@ const getEventData = ({ eventName, userId, data, defaultCategory, categoryMappin
130
152
  ? getItems(data.contents, defaultCategoryId, categories)
131
153
  : [],
132
154
  value: data.value,
155
+ user_data: userData,
133
156
  },
134
157
  };
135
158
  }
136
- case 'InitiateCheckout': {
159
+ case 'RemoveFromCart': {
137
160
  return {
138
- name: 'begin_checkout',
161
+ name: 'remove_from_cart',
139
162
  data: {
140
163
  currency: data.currency,
141
164
  items: data.contents
142
165
  ? getItems(data.contents, defaultCategoryId, categories)
143
166
  : [],
144
167
  value: data.value,
168
+ user_data: userData,
145
169
  },
146
170
  };
147
171
  }
148
- case 'Lead': {
172
+ case 'InitiateCheckout': {
149
173
  return {
150
- name: 'generate_lead',
174
+ name: 'begin_checkout',
151
175
  data: {
152
176
  currency: data.currency,
153
- user_id: userId,
177
+ items: data.contents
178
+ ? getItems(data.contents, defaultCategoryId, categories)
179
+ : [],
154
180
  value: data.value,
181
+ user_data: userData,
155
182
  },
156
183
  };
157
184
  }
158
- case 'PageView': {
185
+ case 'AddPaymentInfo': {
159
186
  return {
160
- name: 'page_view',
161
- data: {},
187
+ name: 'add_payment_info',
188
+ data: {
189
+ currency: data.currency,
190
+ items: data.contents
191
+ ? getItems(data.contents, defaultCategoryId, categories)
192
+ : [],
193
+ value: data.value,
194
+ payment_type: 'other',
195
+ user_data: userData,
196
+ },
162
197
  };
163
198
  }
164
199
  case 'Purchase': {
@@ -170,20 +205,25 @@ const getEventData = ({ eventName, userId, data, defaultCategory, categoryMappin
170
205
  ? getItems(data.contents, defaultCategoryId, categories)
171
206
  : [],
172
207
  transaction_id: data.orderId,
173
- user_id: userId,
174
208
  value: data.value,
209
+ shipping: ((_a = data.orderCosts) === null || _a === void 0 ? void 0 : _a.shippingValue) || 0,
210
+ tax: ((_b = data.orderCosts) === null || _b === void 0 ? void 0 : _b.taxValue) || 0,
211
+ user_data: userData,
212
+ ...(userData.is_new_customer !== undefined && {
213
+ measurement: {
214
+ is_new_customer: userData.is_new_customer,
215
+ },
216
+ }),
175
217
  },
176
218
  };
177
219
  }
178
- case 'RemoveFromCart': {
220
+ case 'Lead': {
179
221
  return {
180
- name: 'remove_from_cart',
222
+ name: 'generate_lead',
181
223
  data: {
182
224
  currency: data.currency,
183
- items: data.contents
184
- ? getItems(data.contents, defaultCategoryId, categories)
185
- : [],
186
225
  value: data.value,
226
+ user_data: userData,
187
227
  },
188
228
  };
189
229
  }
@@ -192,6 +232,10 @@ const getEventData = ({ eventName, userId, data, defaultCategory, categoryMappin
192
232
  name: 'search',
193
233
  data: {
194
234
  search_term: data.search,
235
+ results: data.contents
236
+ ? getItems(data.contents, defaultCategoryId, categories)
237
+ : [],
238
+ user_data: userData,
195
239
  },
196
240
  };
197
241
  }
@@ -199,19 +243,7 @@ const getEventData = ({ eventName, userId, data, defaultCategory, categoryMappin
199
243
  return {
200
244
  name: 'sign_up',
201
245
  data: {
202
- user_id: userId,
203
- },
204
- };
205
- }
206
- case 'ViewContent': {
207
- return {
208
- name: 'view_item',
209
- data: {
210
- currency: data.currency,
211
- items: data.contents
212
- ? getItems(data.contents, defaultCategoryId, categories)
213
- : [],
214
- value: data.value,
246
+ user_data: userData,
215
247
  },
216
248
  };
217
249
  }
@@ -221,7 +253,7 @@ const getEventData = ({ eventName, userId, data, defaultCategory, categoryMappin
221
253
  data: {
222
254
  currency: data.currency,
223
255
  value: data.value,
224
- user_id: userId,
256
+ user_data: userData,
225
257
  },
226
258
  };
227
259
  }
@@ -230,15 +262,25 @@ const getEventData = ({ eventName, userId, data, defaultCategory, categoryMappin
230
262
 
231
263
  const tag = ({ data, eventName, eventId, manifestVariables, userId, }) => {
232
264
  const payload = {
233
- sdkVersion: "1.45.0" ,
265
+ sdkVersion: "1.46.0" ,
234
266
  };
235
267
  if (window.axon && manifestVariables['enableBrowser'] === '1') {
236
268
  try {
237
269
  const defaultCategory = manifestVariables['defaultCategory'];
238
270
  const categoryMapping = manifestVariables['categoryMapping'];
271
+ const userData = { user_id: userId };
272
+ if (data === null || data === void 0 ? void 0 : data['email']) {
273
+ userData.email = data['email'];
274
+ }
275
+ if (data === null || data === void 0 ? void 0 : data['phone']) {
276
+ userData.phone = data['phone'];
277
+ }
278
+ if ((data === null || data === void 0 ? void 0 : data['is_new_customer']) !== undefined) {
279
+ userData.is_new_customer = data['is_new_customer'];
280
+ }
239
281
  const event = getEventData({
240
282
  eventName,
241
- userId,
283
+ userData,
242
284
  data,
243
285
  defaultCategory,
244
286
  categoryMapping,
package/index.js CHANGED
@@ -115,13 +115,35 @@ var ProvidersAppLovinSdk = (function () {
115
115
  image_url: item.image,
116
116
  item_variant_id: item.variantId,
117
117
  item_brand: item.brand,
118
- item_category_id: categoryId || defaultCategoryId || '',
118
+ item_category_id: Number(categoryId) || Number(defaultCategoryId) || 0,
119
119
  };
120
120
  });
121
- const getEventData = ({ eventName, userId, data, defaultCategory, categoryMapping, }) => {
121
+ const getEventData = ({ eventName, userData, data, defaultCategory, categoryMapping, }) => {
122
+ var _a, _b;
122
123
  const categories = getCategories(categoryMapping);
123
124
  const defaultCategoryId = getParsedCategoryId(defaultCategory);
124
125
  switch (eventName) {
126
+ case 'PageView': {
127
+ return {
128
+ name: 'page_view',
129
+ data: {
130
+ user_data: userData,
131
+ },
132
+ };
133
+ }
134
+ case 'ViewContent': {
135
+ return {
136
+ name: 'view_item',
137
+ data: {
138
+ currency: data.currency,
139
+ items: data.contents
140
+ ? getItems(data.contents, defaultCategoryId, categories)
141
+ : [],
142
+ value: data.value,
143
+ user_data: userData,
144
+ },
145
+ };
146
+ }
125
147
  case 'AddToCart': {
126
148
  return {
127
149
  name: 'add_to_cart',
@@ -131,35 +153,48 @@ var ProvidersAppLovinSdk = (function () {
131
153
  ? getItems(data.contents, defaultCategoryId, categories)
132
154
  : [],
133
155
  value: data.value,
156
+ user_data: userData,
134
157
  },
135
158
  };
136
159
  }
137
- case 'InitiateCheckout': {
160
+ case 'RemoveFromCart': {
138
161
  return {
139
- name: 'begin_checkout',
162
+ name: 'remove_from_cart',
140
163
  data: {
141
164
  currency: data.currency,
142
165
  items: data.contents
143
166
  ? getItems(data.contents, defaultCategoryId, categories)
144
167
  : [],
145
168
  value: data.value,
169
+ user_data: userData,
146
170
  },
147
171
  };
148
172
  }
149
- case 'Lead': {
173
+ case 'InitiateCheckout': {
150
174
  return {
151
- name: 'generate_lead',
175
+ name: 'begin_checkout',
152
176
  data: {
153
177
  currency: data.currency,
154
- user_id: userId,
178
+ items: data.contents
179
+ ? getItems(data.contents, defaultCategoryId, categories)
180
+ : [],
155
181
  value: data.value,
182
+ user_data: userData,
156
183
  },
157
184
  };
158
185
  }
159
- case 'PageView': {
186
+ case 'AddPaymentInfo': {
160
187
  return {
161
- name: 'page_view',
162
- data: {},
188
+ name: 'add_payment_info',
189
+ data: {
190
+ currency: data.currency,
191
+ items: data.contents
192
+ ? getItems(data.contents, defaultCategoryId, categories)
193
+ : [],
194
+ value: data.value,
195
+ payment_type: 'other',
196
+ user_data: userData,
197
+ },
163
198
  };
164
199
  }
165
200
  case 'Purchase': {
@@ -171,20 +206,25 @@ var ProvidersAppLovinSdk = (function () {
171
206
  ? getItems(data.contents, defaultCategoryId, categories)
172
207
  : [],
173
208
  transaction_id: data.orderId,
174
- user_id: userId,
175
209
  value: data.value,
210
+ shipping: ((_a = data.orderCosts) === null || _a === void 0 ? void 0 : _a.shippingValue) || 0,
211
+ tax: ((_b = data.orderCosts) === null || _b === void 0 ? void 0 : _b.taxValue) || 0,
212
+ user_data: userData,
213
+ ...(userData.is_new_customer !== undefined && {
214
+ measurement: {
215
+ is_new_customer: userData.is_new_customer,
216
+ },
217
+ }),
176
218
  },
177
219
  };
178
220
  }
179
- case 'RemoveFromCart': {
221
+ case 'Lead': {
180
222
  return {
181
- name: 'remove_from_cart',
223
+ name: 'generate_lead',
182
224
  data: {
183
225
  currency: data.currency,
184
- items: data.contents
185
- ? getItems(data.contents, defaultCategoryId, categories)
186
- : [],
187
226
  value: data.value,
227
+ user_data: userData,
188
228
  },
189
229
  };
190
230
  }
@@ -193,6 +233,10 @@ var ProvidersAppLovinSdk = (function () {
193
233
  name: 'search',
194
234
  data: {
195
235
  search_term: data.search,
236
+ results: data.contents
237
+ ? getItems(data.contents, defaultCategoryId, categories)
238
+ : [],
239
+ user_data: userData,
196
240
  },
197
241
  };
198
242
  }
@@ -200,19 +244,7 @@ var ProvidersAppLovinSdk = (function () {
200
244
  return {
201
245
  name: 'sign_up',
202
246
  data: {
203
- user_id: userId,
204
- },
205
- };
206
- }
207
- case 'ViewContent': {
208
- return {
209
- name: 'view_item',
210
- data: {
211
- currency: data.currency,
212
- items: data.contents
213
- ? getItems(data.contents, defaultCategoryId, categories)
214
- : [],
215
- value: data.value,
247
+ user_data: userData,
216
248
  },
217
249
  };
218
250
  }
@@ -222,7 +254,7 @@ var ProvidersAppLovinSdk = (function () {
222
254
  data: {
223
255
  currency: data.currency,
224
256
  value: data.value,
225
- user_id: userId,
257
+ user_data: userData,
226
258
  },
227
259
  };
228
260
  }
@@ -231,15 +263,25 @@ var ProvidersAppLovinSdk = (function () {
231
263
 
232
264
  const tag = ({ data, eventName, eventId, manifestVariables, userId, }) => {
233
265
  const payload = {
234
- sdkVersion: "1.45.0" ,
266
+ sdkVersion: "1.46.0" ,
235
267
  };
236
268
  if (window.axon && manifestVariables['enableBrowser'] === '1') {
237
269
  try {
238
270
  const defaultCategory = manifestVariables['defaultCategory'];
239
271
  const categoryMapping = manifestVariables['categoryMapping'];
272
+ const userData = { user_id: userId };
273
+ if (data === null || data === void 0 ? void 0 : data['email']) {
274
+ userData.email = data['email'];
275
+ }
276
+ if (data === null || data === void 0 ? void 0 : data['phone']) {
277
+ userData.phone = data['phone'];
278
+ }
279
+ if ((data === null || data === void 0 ? void 0 : data['is_new_customer']) !== undefined) {
280
+ userData.is_new_customer = data['is_new_customer'];
281
+ }
240
282
  const event = getEventData({
241
283
  eventName,
242
- userId,
284
+ userData,
243
285
  data,
244
286
  defaultCategory,
245
287
  categoryMapping,
package/index.mjs CHANGED
@@ -112,13 +112,35 @@ const getItems = (contents, defaultCategoryId, categories) => contents.map((item
112
112
  image_url: item.image,
113
113
  item_variant_id: item.variantId,
114
114
  item_brand: item.brand,
115
- item_category_id: categoryId || defaultCategoryId || '',
115
+ item_category_id: Number(categoryId) || Number(defaultCategoryId) || 0,
116
116
  };
117
117
  });
118
- const getEventData = ({ eventName, userId, data, defaultCategory, categoryMapping, }) => {
118
+ const getEventData = ({ eventName, userData, data, defaultCategory, categoryMapping, }) => {
119
+ var _a, _b;
119
120
  const categories = getCategories(categoryMapping);
120
121
  const defaultCategoryId = getParsedCategoryId(defaultCategory);
121
122
  switch (eventName) {
123
+ case 'PageView': {
124
+ return {
125
+ name: 'page_view',
126
+ data: {
127
+ user_data: userData,
128
+ },
129
+ };
130
+ }
131
+ case 'ViewContent': {
132
+ return {
133
+ name: 'view_item',
134
+ data: {
135
+ currency: data.currency,
136
+ items: data.contents
137
+ ? getItems(data.contents, defaultCategoryId, categories)
138
+ : [],
139
+ value: data.value,
140
+ user_data: userData,
141
+ },
142
+ };
143
+ }
122
144
  case 'AddToCart': {
123
145
  return {
124
146
  name: 'add_to_cart',
@@ -128,35 +150,48 @@ const getEventData = ({ eventName, userId, data, defaultCategory, categoryMappin
128
150
  ? getItems(data.contents, defaultCategoryId, categories)
129
151
  : [],
130
152
  value: data.value,
153
+ user_data: userData,
131
154
  },
132
155
  };
133
156
  }
134
- case 'InitiateCheckout': {
157
+ case 'RemoveFromCart': {
135
158
  return {
136
- name: 'begin_checkout',
159
+ name: 'remove_from_cart',
137
160
  data: {
138
161
  currency: data.currency,
139
162
  items: data.contents
140
163
  ? getItems(data.contents, defaultCategoryId, categories)
141
164
  : [],
142
165
  value: data.value,
166
+ user_data: userData,
143
167
  },
144
168
  };
145
169
  }
146
- case 'Lead': {
170
+ case 'InitiateCheckout': {
147
171
  return {
148
- name: 'generate_lead',
172
+ name: 'begin_checkout',
149
173
  data: {
150
174
  currency: data.currency,
151
- user_id: userId,
175
+ items: data.contents
176
+ ? getItems(data.contents, defaultCategoryId, categories)
177
+ : [],
152
178
  value: data.value,
179
+ user_data: userData,
153
180
  },
154
181
  };
155
182
  }
156
- case 'PageView': {
183
+ case 'AddPaymentInfo': {
157
184
  return {
158
- name: 'page_view',
159
- data: {},
185
+ name: 'add_payment_info',
186
+ data: {
187
+ currency: data.currency,
188
+ items: data.contents
189
+ ? getItems(data.contents, defaultCategoryId, categories)
190
+ : [],
191
+ value: data.value,
192
+ payment_type: 'other',
193
+ user_data: userData,
194
+ },
160
195
  };
161
196
  }
162
197
  case 'Purchase': {
@@ -168,20 +203,25 @@ const getEventData = ({ eventName, userId, data, defaultCategory, categoryMappin
168
203
  ? getItems(data.contents, defaultCategoryId, categories)
169
204
  : [],
170
205
  transaction_id: data.orderId,
171
- user_id: userId,
172
206
  value: data.value,
207
+ shipping: ((_a = data.orderCosts) === null || _a === void 0 ? void 0 : _a.shippingValue) || 0,
208
+ tax: ((_b = data.orderCosts) === null || _b === void 0 ? void 0 : _b.taxValue) || 0,
209
+ user_data: userData,
210
+ ...(userData.is_new_customer !== undefined && {
211
+ measurement: {
212
+ is_new_customer: userData.is_new_customer,
213
+ },
214
+ }),
173
215
  },
174
216
  };
175
217
  }
176
- case 'RemoveFromCart': {
218
+ case 'Lead': {
177
219
  return {
178
- name: 'remove_from_cart',
220
+ name: 'generate_lead',
179
221
  data: {
180
222
  currency: data.currency,
181
- items: data.contents
182
- ? getItems(data.contents, defaultCategoryId, categories)
183
- : [],
184
223
  value: data.value,
224
+ user_data: userData,
185
225
  },
186
226
  };
187
227
  }
@@ -190,6 +230,10 @@ const getEventData = ({ eventName, userId, data, defaultCategory, categoryMappin
190
230
  name: 'search',
191
231
  data: {
192
232
  search_term: data.search,
233
+ results: data.contents
234
+ ? getItems(data.contents, defaultCategoryId, categories)
235
+ : [],
236
+ user_data: userData,
193
237
  },
194
238
  };
195
239
  }
@@ -197,19 +241,7 @@ const getEventData = ({ eventName, userId, data, defaultCategory, categoryMappin
197
241
  return {
198
242
  name: 'sign_up',
199
243
  data: {
200
- user_id: userId,
201
- },
202
- };
203
- }
204
- case 'ViewContent': {
205
- return {
206
- name: 'view_item',
207
- data: {
208
- currency: data.currency,
209
- items: data.contents
210
- ? getItems(data.contents, defaultCategoryId, categories)
211
- : [],
212
- value: data.value,
244
+ user_data: userData,
213
245
  },
214
246
  };
215
247
  }
@@ -219,7 +251,7 @@ const getEventData = ({ eventName, userId, data, defaultCategory, categoryMappin
219
251
  data: {
220
252
  currency: data.currency,
221
253
  value: data.value,
222
- user_id: userId,
254
+ user_data: userData,
223
255
  },
224
256
  };
225
257
  }
@@ -228,15 +260,25 @@ const getEventData = ({ eventName, userId, data, defaultCategory, categoryMappin
228
260
 
229
261
  const tag = ({ data, eventName, eventId, manifestVariables, userId, }) => {
230
262
  const payload = {
231
- sdkVersion: "1.45.0" ,
263
+ sdkVersion: "1.46.0" ,
232
264
  };
233
265
  if (window.axon && manifestVariables['enableBrowser'] === '1') {
234
266
  try {
235
267
  const defaultCategory = manifestVariables['defaultCategory'];
236
268
  const categoryMapping = manifestVariables['categoryMapping'];
269
+ const userData = { user_id: userId };
270
+ if (data === null || data === void 0 ? void 0 : data['email']) {
271
+ userData.email = data['email'];
272
+ }
273
+ if (data === null || data === void 0 ? void 0 : data['phone']) {
274
+ userData.phone = data['phone'];
275
+ }
276
+ if ((data === null || data === void 0 ? void 0 : data['is_new_customer']) !== undefined) {
277
+ userData.is_new_customer = data['is_new_customer'];
278
+ }
237
279
  const event = getEventData({
238
280
  eventName,
239
- userId,
281
+ userData,
240
282
  data,
241
283
  defaultCategory,
242
284
  categoryMapping,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-app-lovin-sdk",
3
- "version": "1.45.0",
3
+ "version": "1.46.0",
4
4
  "description": "App Lovin Browser SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",