@blotoutio/providers-tiktok-sdk 0.10.0 → 0.10.2

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 (2) hide show
  1. package/index.js +13 -6
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,6 +1,11 @@
1
1
  var ProvidersTiktokSdk = (function () {
2
2
  'use strict';
3
3
 
4
+ const E164Pattern = /^\+[1-9]\d{10,14}$/;
5
+ const validatePhoneNumber = (value) => {
6
+ return E164Pattern.test(value.split(' ').join(''));
7
+ };
8
+
4
9
  /* eslint-enable */
5
10
  const snippet = () => {
6
11
  if (!window || !document || window.ttq) {
@@ -88,7 +93,8 @@ var ProvidersTiktokSdk = (function () {
88
93
  identifyData[item] = data[item];
89
94
  }
90
95
  });
91
- if ('phone' in identifyData) {
96
+ if ('phone' in identifyData &&
97
+ validatePhoneNumber(identifyData['phone'])) {
92
98
  identifyData['phone_number'] = identifyData['phone'];
93
99
  delete identifyData['phone'];
94
100
  }
@@ -97,7 +103,7 @@ var ProvidersTiktokSdk = (function () {
97
103
  });
98
104
  }
99
105
  else if (customerData.length && !cacheMiss.length) {
100
- if ('phone' in identifyData) {
106
+ if ('phone' in identifyData && validatePhoneNumber(identifyData['phone'])) {
101
107
  identifyData['phone_number'] = identifyData['phone'];
102
108
  delete identifyData['phone'];
103
109
  }
@@ -212,11 +218,12 @@ var ProvidersTiktokSdk = (function () {
212
218
  window.ttq.instance(manifestVariables['pixelId']).track(tiktokEventName, Object.assign(Object.assign({}, prepareData(data)), { event_id: eventId }));
213
219
  }
214
220
  return {
215
- sdkVersion: "0.10.0" ,
221
+ sdkVersion: "0.10.2" ,
216
222
  };
217
223
  };
218
224
 
219
225
  const user = ({ data, manifestVariables }) => {
226
+ var _a;
220
227
  if (!window || !window.ttq || !data) {
221
228
  return;
222
229
  }
@@ -224,9 +231,9 @@ var ProvidersTiktokSdk = (function () {
224
231
  if (data['email']) {
225
232
  userData.email = data['email'];
226
233
  }
227
- const phone = data['phone'];
228
- if (phone) {
229
- userData.phone_number = phone.startsWith('+') ? phone : `+${phone}`;
234
+ const phone = (_a = data['phone']) !== null && _a !== void 0 ? _a : '';
235
+ if (phone && validatePhoneNumber(phone)) {
236
+ userData.phone_number = phone;
230
237
  }
231
238
  if (Object.keys(userData).length) {
232
239
  window.ttq.instance(manifestVariables['pixelId']).identify(Object.assign({}, userData));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-tiktok-sdk",
3
- "version": "0.10.0",
3
+ "version": "0.10.2",
4
4
  "description": "Tiktok Browser SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",