@blotoutio/providers-tatari-sdk 1.55.2 → 1.56.1

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 CHANGED
@@ -70,6 +70,11 @@ const logger = {
70
70
  },
71
71
  };
72
72
 
73
+ const getIsNewCustomerFlag = async (getData) => {
74
+ const { isNewCustomer } = await new Promise((resolve) => getData(['isNewCustomer'], resolve));
75
+ return isNewCustomer ? isNewCustomer === 'true' : undefined;
76
+ };
77
+
73
78
  const initSnippet = (token) => {
74
79
  var _a;
75
80
  if (typeof window == 'undefined' ||
@@ -137,8 +142,8 @@ const getEventData = (data) => {
137
142
  }
138
143
  return eventData;
139
144
  };
140
- const handleTag = ({ data, eventName, manifestVariables, }) => {
141
- var _a, _b;
145
+ const handleTag = async ({ data, eventName, manifestVariables, getEdgeData, }) => {
146
+ var _a, _b, _c;
142
147
  if (typeof window == 'undefined' ||
143
148
  !eventName ||
144
149
  !(manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['token']) ||
@@ -162,14 +167,30 @@ const handleTag = ({ data, eventName, manifestVariables, }) => {
162
167
  }
163
168
  const eventData = getEventData(data);
164
169
  (_b = window.tatari) === null || _b === void 0 ? void 0 : _b.track(conversionEventName, eventData);
170
+ if (eventName === 'Purchase' &&
171
+ getEdgeData &&
172
+ (mapping.has('Purchase_NC') || mapping.has('Purchase_RC'))) {
173
+ try {
174
+ const isNewCustomer = await getIsNewCustomerFlag(getEdgeData);
175
+ if (typeof isNewCustomer === 'boolean') {
176
+ const ncRcEventName = mapping.get(isNewCustomer ? 'Purchase_NC' : 'Purchase_RC');
177
+ if (ncRcEventName) {
178
+ (_c = window.tatari) === null || _c === void 0 ? void 0 : _c.track(ncRcEventName, eventData);
179
+ }
180
+ }
181
+ }
182
+ catch (error) {
183
+ logger.error('Could not determine NC/RC flag', error);
184
+ }
185
+ }
165
186
  };
166
187
 
167
- const tag = ({ data, eventName, manifestVariables }) => {
188
+ const tag = ({ data, eventName, manifestVariables, getEdgeData, }) => {
168
189
  const payload = {
169
- sdkVersion: "1.55.2" ,
190
+ sdkVersion: "1.56.1" ,
170
191
  };
171
192
  if (window.tatari && manifestVariables['enableBrowser'] === '1') {
172
- handleTag({ data, eventName, manifestVariables });
193
+ handleTag({ data, eventName, manifestVariables, getEdgeData });
173
194
  }
174
195
  return payload;
175
196
  };
package/index.js CHANGED
@@ -71,6 +71,11 @@ var ProvidersTatariSdk = (function () {
71
71
  },
72
72
  };
73
73
 
74
+ const getIsNewCustomerFlag = async (getData) => {
75
+ const { isNewCustomer } = await new Promise((resolve) => getData(['isNewCustomer'], resolve));
76
+ return isNewCustomer ? isNewCustomer === 'true' : undefined;
77
+ };
78
+
74
79
  const initSnippet = (token) => {
75
80
  var _a;
76
81
  if (typeof window == 'undefined' ||
@@ -138,8 +143,8 @@ var ProvidersTatariSdk = (function () {
138
143
  }
139
144
  return eventData;
140
145
  };
141
- const handleTag = ({ data, eventName, manifestVariables, }) => {
142
- var _a, _b;
146
+ const handleTag = async ({ data, eventName, manifestVariables, getEdgeData, }) => {
147
+ var _a, _b, _c;
143
148
  if (typeof window == 'undefined' ||
144
149
  !eventName ||
145
150
  !(manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['token']) ||
@@ -163,14 +168,30 @@ var ProvidersTatariSdk = (function () {
163
168
  }
164
169
  const eventData = getEventData(data);
165
170
  (_b = window.tatari) === null || _b === void 0 ? void 0 : _b.track(conversionEventName, eventData);
171
+ if (eventName === 'Purchase' &&
172
+ getEdgeData &&
173
+ (mapping.has('Purchase_NC') || mapping.has('Purchase_RC'))) {
174
+ try {
175
+ const isNewCustomer = await getIsNewCustomerFlag(getEdgeData);
176
+ if (typeof isNewCustomer === 'boolean') {
177
+ const ncRcEventName = mapping.get(isNewCustomer ? 'Purchase_NC' : 'Purchase_RC');
178
+ if (ncRcEventName) {
179
+ (_c = window.tatari) === null || _c === void 0 ? void 0 : _c.track(ncRcEventName, eventData);
180
+ }
181
+ }
182
+ }
183
+ catch (error) {
184
+ logger.error('Could not determine NC/RC flag', error);
185
+ }
186
+ }
166
187
  };
167
188
 
168
- const tag = ({ data, eventName, manifestVariables }) => {
189
+ const tag = ({ data, eventName, manifestVariables, getEdgeData, }) => {
169
190
  const payload = {
170
- sdkVersion: "1.55.2" ,
191
+ sdkVersion: "1.56.1" ,
171
192
  };
172
193
  if (window.tatari && manifestVariables['enableBrowser'] === '1') {
173
- handleTag({ data, eventName, manifestVariables });
194
+ handleTag({ data, eventName, manifestVariables, getEdgeData });
174
195
  }
175
196
  return payload;
176
197
  };
package/index.mjs CHANGED
@@ -68,6 +68,11 @@ const logger = {
68
68
  },
69
69
  };
70
70
 
71
+ const getIsNewCustomerFlag = async (getData) => {
72
+ const { isNewCustomer } = await new Promise((resolve) => getData(['isNewCustomer'], resolve));
73
+ return isNewCustomer ? isNewCustomer === 'true' : undefined;
74
+ };
75
+
71
76
  const initSnippet = (token) => {
72
77
  var _a;
73
78
  if (typeof window == 'undefined' ||
@@ -135,8 +140,8 @@ const getEventData = (data) => {
135
140
  }
136
141
  return eventData;
137
142
  };
138
- const handleTag = ({ data, eventName, manifestVariables, }) => {
139
- var _a, _b;
143
+ const handleTag = async ({ data, eventName, manifestVariables, getEdgeData, }) => {
144
+ var _a, _b, _c;
140
145
  if (typeof window == 'undefined' ||
141
146
  !eventName ||
142
147
  !(manifestVariables === null || manifestVariables === void 0 ? void 0 : manifestVariables['token']) ||
@@ -160,14 +165,30 @@ const handleTag = ({ data, eventName, manifestVariables, }) => {
160
165
  }
161
166
  const eventData = getEventData(data);
162
167
  (_b = window.tatari) === null || _b === void 0 ? void 0 : _b.track(conversionEventName, eventData);
168
+ if (eventName === 'Purchase' &&
169
+ getEdgeData &&
170
+ (mapping.has('Purchase_NC') || mapping.has('Purchase_RC'))) {
171
+ try {
172
+ const isNewCustomer = await getIsNewCustomerFlag(getEdgeData);
173
+ if (typeof isNewCustomer === 'boolean') {
174
+ const ncRcEventName = mapping.get(isNewCustomer ? 'Purchase_NC' : 'Purchase_RC');
175
+ if (ncRcEventName) {
176
+ (_c = window.tatari) === null || _c === void 0 ? void 0 : _c.track(ncRcEventName, eventData);
177
+ }
178
+ }
179
+ }
180
+ catch (error) {
181
+ logger.error('Could not determine NC/RC flag', error);
182
+ }
183
+ }
163
184
  };
164
185
 
165
- const tag = ({ data, eventName, manifestVariables }) => {
186
+ const tag = ({ data, eventName, manifestVariables, getEdgeData, }) => {
166
187
  const payload = {
167
- sdkVersion: "1.55.2" ,
188
+ sdkVersion: "1.56.1" ,
168
189
  };
169
190
  if (window.tatari && manifestVariables['enableBrowser'] === '1') {
170
- handleTag({ data, eventName, manifestVariables });
191
+ handleTag({ data, eventName, manifestVariables, getEdgeData });
171
192
  }
172
193
  return payload;
173
194
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blotoutio/providers-tatari-sdk",
3
- "version": "1.55.2",
3
+ "version": "1.56.1",
4
4
  "description": "tatari Browser SDK for EdgeTag",
5
5
  "author": "Blotout",
6
6
  "license": "MIT",