pb-sxp-ui 1.16.15 → 1.16.16

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.
@@ -151,16 +151,15 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
151
151
  Object.defineProperty(img, 'src', {
152
152
  set(value) {
153
153
  originalSrcDescriptor.set.call(this, value);
154
- img.onload = function () {
155
- if (value.includes('https://www.facebook.com/privacy_sandbox/pixel/register/trigger/')) {
156
- const url = new URL(value);
157
- const params = Object.fromEntries(url.searchParams.entries());
158
- bffCollectEvent({
159
- eventName: params === null || params === void 0 ? void 0 : params.ev,
160
- eventSource: 'Meta Pixel'
161
- });
162
- }
163
- };
154
+ if (value.includes('https://www.facebook.com/privacy_sandbox/pixel/register/trigger/')) {
155
+ const url = new URL(value);
156
+ const params = Object.fromEntries(url.searchParams.entries());
157
+ bffCollectEvent({
158
+ eventName: params === null || params === void 0 ? void 0 : params.ev,
159
+ eventSource: 'Meta Pixel'
160
+ });
161
+ }
162
+ ;
164
163
  },
165
164
  get() {
166
165
  return originalSrcDescriptor.get.call(this);
@@ -196,24 +195,22 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
196
195
  var _a, _b;
197
196
  try {
198
197
  const parsedData = yield parseBeaconData(data);
199
- if (success) {
200
- if (urlString.includes('https://tr.snapchat.com/p')) {
201
- (_b = (_a = parsedData === null || parsedData === void 0 ? void 0 : parsedData.req) === null || _a === void 0 ? void 0 : _a.forEach) === null || _b === void 0 ? void 0 : _b.call(_a, (item) => {
202
- var _a, _b;
203
- if ((_a = item === null || item === void 0 ? void 0 : item.t) === null || _a === void 0 ? void 0 : _a.ev) {
204
- bffCollectEvent({
205
- eventName: (_b = item === null || item === void 0 ? void 0 : item.t) === null || _b === void 0 ? void 0 : _b.ev,
206
- eventSource: 'Snapchat Pixel'
207
- });
208
- }
209
- });
210
- }
211
- else if (urlString.includes('https://analytics.tiktok.com/api/v2/pixel') && (parsedData === null || parsedData === void 0 ? void 0 : parsedData.event)) {
212
- bffCollectEvent({
213
- eventName: parsedData.event,
214
- eventSource: 'TikTok Pixel'
215
- });
216
- }
198
+ if (urlString.includes('https://tr.snapchat.com/p')) {
199
+ (_b = (_a = parsedData === null || parsedData === void 0 ? void 0 : parsedData.req) === null || _a === void 0 ? void 0 : _a.forEach) === null || _b === void 0 ? void 0 : _b.call(_a, (item) => {
200
+ var _a, _b;
201
+ if ((_a = item === null || item === void 0 ? void 0 : item.t) === null || _a === void 0 ? void 0 : _a.ev) {
202
+ bffCollectEvent({
203
+ eventName: (_b = item === null || item === void 0 ? void 0 : item.t) === null || _b === void 0 ? void 0 : _b.ev,
204
+ eventSource: 'Snapchat Pixel'
205
+ });
206
+ }
207
+ });
208
+ }
209
+ else if (urlString.includes('https://analytics.tiktok.com/api/v2/pixel') && (parsedData === null || parsedData === void 0 ? void 0 : parsedData.event)) {
210
+ bffCollectEvent({
211
+ eventName: parsedData.event,
212
+ eventSource: 'TikTok Pixel'
213
+ });
217
214
  }
218
215
  }
219
216
  catch (error) {
@@ -232,6 +229,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
232
229
  window.fetch = function (input, init) {
233
230
  var arguments_1 = arguments;
234
231
  return __awaiter(this, void 0, void 0, function* () {
232
+ var _a;
235
233
  let url;
236
234
  try {
237
235
  url = typeof input === 'string'
@@ -248,15 +246,37 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
248
246
  return _originalFetch.apply(this, arguments_1);
249
247
  }
250
248
  try {
251
- const response = yield _originalFetch.apply(this, arguments_1);
249
+ const response = _originalFetch.apply(this, arguments_1);
252
250
  const urlObj = new URL(url);
253
251
  const params = Object.fromEntries(urlObj.searchParams.entries());
252
+ const body = (_a = arguments_1[1]) === null || _a === void 0 ? void 0 : _a.body;
254
253
  if (params === null || params === void 0 ? void 0 : params.en) {
255
254
  bffCollectEvent({
256
255
  eventName: params === null || params === void 0 ? void 0 : params.en,
257
256
  eventSource: 'Google Analytics'
258
257
  });
259
258
  }
259
+ else if (body) {
260
+ function extractAllEnValuesSplit(queryString) {
261
+ if (typeof queryString !== 'string') {
262
+ return [];
263
+ }
264
+ const matches = [];
265
+ const regex = /en=([^&\r\n]*)/g;
266
+ let match;
267
+ while ((match = regex.exec(queryString)) !== null) {
268
+ matches.push(decodeURIComponent(match[1]));
269
+ }
270
+ return matches;
271
+ }
272
+ const enValues = extractAllEnValuesSplit(body);
273
+ enValues === null || enValues === void 0 ? void 0 : enValues.forEach((en) => {
274
+ bffCollectEvent({
275
+ eventName: en,
276
+ eventSource: 'Google Analytics'
277
+ });
278
+ });
279
+ }
260
280
  return response;
261
281
  }
262
282
  catch (error) {
@@ -154,16 +154,15 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
154
154
  Object.defineProperty(img, 'src', {
155
155
  set(value) {
156
156
  originalSrcDescriptor.set.call(this, value);
157
- img.onload = function () {
158
- if (value.includes('https://www.facebook.com/privacy_sandbox/pixel/register/trigger/')) {
159
- const url = new URL(value);
160
- const params = Object.fromEntries(url.searchParams.entries());
161
- bffCollectEvent({
162
- eventName: params === null || params === void 0 ? void 0 : params.ev,
163
- eventSource: 'Meta Pixel'
164
- });
165
- }
166
- };
157
+ if (value.includes('https://www.facebook.com/privacy_sandbox/pixel/register/trigger/')) {
158
+ const url = new URL(value);
159
+ const params = Object.fromEntries(url.searchParams.entries());
160
+ bffCollectEvent({
161
+ eventName: params === null || params === void 0 ? void 0 : params.ev,
162
+ eventSource: 'Meta Pixel'
163
+ });
164
+ }
165
+ ;
167
166
  },
168
167
  get() {
169
168
  return originalSrcDescriptor.get.call(this);
@@ -199,24 +198,22 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
199
198
  var _a, _b;
200
199
  try {
201
200
  const parsedData = yield parseBeaconData(data);
202
- if (success) {
203
- if (urlString.includes('https://tr.snapchat.com/p')) {
204
- (_b = (_a = parsedData === null || parsedData === void 0 ? void 0 : parsedData.req) === null || _a === void 0 ? void 0 : _a.forEach) === null || _b === void 0 ? void 0 : _b.call(_a, (item) => {
205
- var _a, _b;
206
- if ((_a = item === null || item === void 0 ? void 0 : item.t) === null || _a === void 0 ? void 0 : _a.ev) {
207
- bffCollectEvent({
208
- eventName: (_b = item === null || item === void 0 ? void 0 : item.t) === null || _b === void 0 ? void 0 : _b.ev,
209
- eventSource: 'Snapchat Pixel'
210
- });
211
- }
212
- });
213
- }
214
- else if (urlString.includes('https://analytics.tiktok.com/api/v2/pixel') && (parsedData === null || parsedData === void 0 ? void 0 : parsedData.event)) {
215
- bffCollectEvent({
216
- eventName: parsedData.event,
217
- eventSource: 'TikTok Pixel'
218
- });
219
- }
201
+ if (urlString.includes('https://tr.snapchat.com/p')) {
202
+ (_b = (_a = parsedData === null || parsedData === void 0 ? void 0 : parsedData.req) === null || _a === void 0 ? void 0 : _a.forEach) === null || _b === void 0 ? void 0 : _b.call(_a, (item) => {
203
+ var _a, _b;
204
+ if ((_a = item === null || item === void 0 ? void 0 : item.t) === null || _a === void 0 ? void 0 : _a.ev) {
205
+ bffCollectEvent({
206
+ eventName: (_b = item === null || item === void 0 ? void 0 : item.t) === null || _b === void 0 ? void 0 : _b.ev,
207
+ eventSource: 'Snapchat Pixel'
208
+ });
209
+ }
210
+ });
211
+ }
212
+ else if (urlString.includes('https://analytics.tiktok.com/api/v2/pixel') && (parsedData === null || parsedData === void 0 ? void 0 : parsedData.event)) {
213
+ bffCollectEvent({
214
+ eventName: parsedData.event,
215
+ eventSource: 'TikTok Pixel'
216
+ });
220
217
  }
221
218
  }
222
219
  catch (error) {
@@ -235,6 +232,7 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
235
232
  window.fetch = function (input, init) {
236
233
  var arguments_1 = arguments;
237
234
  return tslib_1.__awaiter(this, void 0, void 0, function* () {
235
+ var _a;
238
236
  let url;
239
237
  try {
240
238
  url = typeof input === 'string'
@@ -251,15 +249,37 @@ const SxpDataSourceProvider = ({ render, dataSources, utmVal, enableReportEvent
251
249
  return _originalFetch.apply(this, arguments_1);
252
250
  }
253
251
  try {
254
- const response = yield _originalFetch.apply(this, arguments_1);
252
+ const response = _originalFetch.apply(this, arguments_1);
255
253
  const urlObj = new URL(url);
256
254
  const params = Object.fromEntries(urlObj.searchParams.entries());
255
+ const body = (_a = arguments_1[1]) === null || _a === void 0 ? void 0 : _a.body;
257
256
  if (params === null || params === void 0 ? void 0 : params.en) {
258
257
  bffCollectEvent({
259
258
  eventName: params === null || params === void 0 ? void 0 : params.en,
260
259
  eventSource: 'Google Analytics'
261
260
  });
262
261
  }
262
+ else if (body) {
263
+ function extractAllEnValuesSplit(queryString) {
264
+ if (typeof queryString !== 'string') {
265
+ return [];
266
+ }
267
+ const matches = [];
268
+ const regex = /en=([^&\r\n]*)/g;
269
+ let match;
270
+ while ((match = regex.exec(queryString)) !== null) {
271
+ matches.push(decodeURIComponent(match[1]));
272
+ }
273
+ return matches;
274
+ }
275
+ const enValues = extractAllEnValuesSplit(body);
276
+ enValues === null || enValues === void 0 ? void 0 : enValues.forEach((en) => {
277
+ bffCollectEvent({
278
+ eventName: en,
279
+ eventSource: 'Google Analytics'
280
+ });
281
+ });
282
+ }
263
283
  return response;
264
284
  }
265
285
  catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pb-sxp-ui",
3
- "version": "1.16.15",
3
+ "version": "1.16.16",
4
4
  "description": "React enterprise-class UI components",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",