@blotoutio/providers-twitter-sdk 0.36.2 → 0.38.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 +14 -10
  2. package/index.js +14 -10
  3. package/index.mjs +14 -10
  4. package/package.json +1 -1
package/index.cjs.js CHANGED
@@ -29,9 +29,8 @@ const init = ({ manifest }) => {
29
29
  if (!manifest.variables || manifest.variables['enableBrowser'] !== '1') {
30
30
  return;
31
31
  }
32
- const firstLoad = !window.twq;
33
32
  snippet();
34
- if (!firstLoad || !window.twq) {
33
+ if (!window.twq) {
35
34
  return;
36
35
  }
37
36
  window.twq('config', manifest.variables['pixelId']);
@@ -73,24 +72,29 @@ const getEventId = (event, conversions) => {
73
72
  if (!event) {
74
73
  return null;
75
74
  }
75
+ let mapping = [];
76
76
  try {
77
- const mapping = conversions ? JSON.parse(conversions) : [];
78
- return ((_b = (_a = mapping.find((item) => item.event === event)) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : null);
77
+ if (conversions) {
78
+ mapping = JSON.parse(conversions);
79
+ }
79
80
  }
80
81
  catch (e) {
81
- console.error(e);
82
+ mapping = [];
82
83
  }
84
+ return ((_b = (_a = mapping.find((item) => item.event === event)) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : null);
83
85
  };
84
86
  const tag = ({ data, eventName, manifestVariables, eventId }) => {
85
87
  const payload = {
86
- sdkVersion: "0.36.2" ,
88
+ sdkVersion: "0.38.0" ,
87
89
  };
88
90
  if (window.twq && manifestVariables['enableBrowser'] === '1') {
89
91
  const twitterEventId = getEventId(eventName, manifestVariables['mappedConversions']);
90
- window.twq('event', `tw-${manifestVariables['pixelId']}-${twitterEventId}`, {
91
- ...prepareData(data),
92
- conversion_id: eventId,
93
- });
92
+ if (twitterEventId) {
93
+ window.twq('event', `tw-${manifestVariables['pixelId']}-${twitterEventId}`, {
94
+ ...prepareData(data),
95
+ conversion_id: eventId,
96
+ });
97
+ }
94
98
  }
95
99
  return payload;
96
100
  };
package/index.js CHANGED
@@ -30,9 +30,8 @@ var ProvidersTwitterSdk = (function () {
30
30
  if (!manifest.variables || manifest.variables['enableBrowser'] !== '1') {
31
31
  return;
32
32
  }
33
- const firstLoad = !window.twq;
34
33
  snippet();
35
- if (!firstLoad || !window.twq) {
34
+ if (!window.twq) {
36
35
  return;
37
36
  }
38
37
  window.twq('config', manifest.variables['pixelId']);
@@ -74,24 +73,29 @@ var ProvidersTwitterSdk = (function () {
74
73
  if (!event) {
75
74
  return null;
76
75
  }
76
+ let mapping = [];
77
77
  try {
78
- const mapping = conversions ? JSON.parse(conversions) : [];
79
- return ((_b = (_a = mapping.find((item) => item.event === event)) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : null);
78
+ if (conversions) {
79
+ mapping = JSON.parse(conversions);
80
+ }
80
81
  }
81
82
  catch (e) {
82
- console.error(e);
83
+ mapping = [];
83
84
  }
85
+ return ((_b = (_a = mapping.find((item) => item.event === event)) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : null);
84
86
  };
85
87
  const tag = ({ data, eventName, manifestVariables, eventId }) => {
86
88
  const payload = {
87
- sdkVersion: "0.36.2" ,
89
+ sdkVersion: "0.38.0" ,
88
90
  };
89
91
  if (window.twq && manifestVariables['enableBrowser'] === '1') {
90
92
  const twitterEventId = getEventId(eventName, manifestVariables['mappedConversions']);
91
- window.twq('event', `tw-${manifestVariables['pixelId']}-${twitterEventId}`, {
92
- ...prepareData(data),
93
- conversion_id: eventId,
94
- });
93
+ if (twitterEventId) {
94
+ window.twq('event', `tw-${manifestVariables['pixelId']}-${twitterEventId}`, {
95
+ ...prepareData(data),
96
+ conversion_id: eventId,
97
+ });
98
+ }
95
99
  }
96
100
  return payload;
97
101
  };
package/index.mjs CHANGED
@@ -27,9 +27,8 @@ const init = ({ manifest }) => {
27
27
  if (!manifest.variables || manifest.variables['enableBrowser'] !== '1') {
28
28
  return;
29
29
  }
30
- const firstLoad = !window.twq;
31
30
  snippet();
32
- if (!firstLoad || !window.twq) {
31
+ if (!window.twq) {
33
32
  return;
34
33
  }
35
34
  window.twq('config', manifest.variables['pixelId']);
@@ -71,24 +70,29 @@ const getEventId = (event, conversions) => {
71
70
  if (!event) {
72
71
  return null;
73
72
  }
73
+ let mapping = [];
74
74
  try {
75
- const mapping = conversions ? JSON.parse(conversions) : [];
76
- return ((_b = (_a = mapping.find((item) => item.event === event)) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : null);
75
+ if (conversions) {
76
+ mapping = JSON.parse(conversions);
77
+ }
77
78
  }
78
79
  catch (e) {
79
- console.error(e);
80
+ mapping = [];
80
81
  }
82
+ return ((_b = (_a = mapping.find((item) => item.event === event)) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : null);
81
83
  };
82
84
  const tag = ({ data, eventName, manifestVariables, eventId }) => {
83
85
  const payload = {
84
- sdkVersion: "0.36.2" ,
86
+ sdkVersion: "0.38.0" ,
85
87
  };
86
88
  if (window.twq && manifestVariables['enableBrowser'] === '1') {
87
89
  const twitterEventId = getEventId(eventName, manifestVariables['mappedConversions']);
88
- window.twq('event', `tw-${manifestVariables['pixelId']}-${twitterEventId}`, {
89
- ...prepareData(data),
90
- conversion_id: eventId,
91
- });
90
+ if (twitterEventId) {
91
+ window.twq('event', `tw-${manifestVariables['pixelId']}-${twitterEventId}`, {
92
+ ...prepareData(data),
93
+ conversion_id: eventId,
94
+ });
95
+ }
92
96
  }
93
97
  return payload;
94
98
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-twitter-sdk",
3
- "version": "0.36.2",
3
+ "version": "0.38.0",
4
4
  "description": "Twitter Browser SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",