shopkit-analytics 1.0.2 → 1.0.3
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/README.md +35 -100
- package/dist/adapters/index.d.mts +2 -1
- package/dist/adapters/index.d.ts +2 -1
- package/dist/adapters/index.js +230 -64
- package/dist/adapters/index.js.map +1 -1
- package/dist/adapters/index.mjs +3 -1
- package/dist/chunk-4RDPDMGW.mjs +68 -0
- package/dist/chunk-4RDPDMGW.mjs.map +1 -0
- package/dist/chunk-NC25KOAF.mjs +156 -0
- package/dist/chunk-NC25KOAF.mjs.map +1 -0
- package/dist/chunk-NGPUKV7E.mjs +46 -0
- package/dist/chunk-NGPUKV7E.mjs.map +1 -0
- package/dist/{chunk-U3UOXFS4.mjs → chunk-NJQ2MOM2.mjs} +206 -116
- package/dist/chunk-NJQ2MOM2.mjs.map +1 -0
- package/dist/chunk-NKDB4KX2.mjs +2 -0
- package/dist/chunk-NKDB4KX2.mjs.map +1 -0
- package/dist/{chunk-BNV3EVHH.mjs → chunk-QCS5UARA.mjs} +2 -2
- package/dist/events/index.js +218 -54
- package/dist/events/index.js.map +1 -1
- package/dist/events/index.mjs +9 -7
- package/dist/experiment/index.d.mts +25 -0
- package/dist/experiment/index.d.ts +25 -0
- package/dist/experiment/index.js +74 -0
- package/dist/experiment/index.js.map +1 -0
- package/dist/experiment/index.mjs +15 -0
- package/dist/experiment/index.mjs.map +1 -0
- package/dist/{index-DS9OI5Mz.d.ts → index-D_8w5bL_.d.ts} +13 -0
- package/dist/{index-Bym1_EAp.d.mts → index-th6sBtE3.d.mts} +13 -0
- package/dist/index.d.mts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +400 -64
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -7
- package/dist/index.mjs.map +1 -1
- package/dist/services/index.d.mts +51 -0
- package/dist/services/index.d.ts +51 -0
- package/dist/services/index.js +180 -0
- package/dist/services/index.js.map +1 -0
- package/dist/services/index.mjs +11 -0
- package/dist/services/index.mjs.map +1 -0
- package/dist/types-C__2IBCj.d.mts +7 -0
- package/dist/types-C__2IBCj.d.ts +7 -0
- package/dist/utils/index.d.mts +19 -0
- package/dist/utils/index.d.ts +19 -0
- package/dist/utils/index.js +93 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/index.mjs +12 -0
- package/dist/utils/index.mjs.map +1 -0
- package/package.json +19 -1
- package/templates/nextjs/README.md +206 -0
- package/templates/nextjs/api-events-route.ts +62 -0
- package/dist/chunk-U3UOXFS4.mjs.map +0 -1
- /package/dist/{chunk-BNV3EVHH.mjs.map → chunk-QCS5UARA.mjs.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -267,10 +267,13 @@ __export(src_exports, {
|
|
|
267
267
|
DEFAULT_CURRENCY: () => DEFAULT_CURRENCY,
|
|
268
268
|
EventNames: () => EventNames,
|
|
269
269
|
EventType: () => EventType,
|
|
270
|
+
FacebookCAPIService: () => FacebookCAPIService,
|
|
270
271
|
GoogleAdapter: () => GoogleAdapter,
|
|
271
272
|
KwikCheckoutAdapter: () => KwikCheckoutAdapter,
|
|
272
273
|
KwikPassAdapter: () => KwikPassAdapter,
|
|
273
274
|
MoengageAdapter: () => MoengageAdapter,
|
|
275
|
+
PRIMA_EXPERIMENT_COOKIES: () => PRIMA_EXPERIMENT_COOKIES,
|
|
276
|
+
PRIMA_EXPERIMENT_COOKIE_NAMES: () => PRIMA_EXPERIMENT_COOKIE_NAMES,
|
|
274
277
|
PixelAdapter: () => PixelAdapter,
|
|
275
278
|
PostHogAdapter: () => PostHogAdapter,
|
|
276
279
|
ShopifyAdapter: () => ShopifyAdapter,
|
|
@@ -278,13 +281,18 @@ __export(src_exports, {
|
|
|
278
281
|
captureAffiliateParams: () => captureAffiliateParams,
|
|
279
282
|
clearAffiliateParams: () => clearAffiliateParams,
|
|
280
283
|
createAdapterLogger: () => createAdapterLogger,
|
|
284
|
+
createFacebookCAPIService: () => createFacebookCAPIService,
|
|
281
285
|
createLogger: () => createLogger,
|
|
282
286
|
default: () => ShopkitAnalytics_default,
|
|
283
287
|
eventPublisher: () => eventPublisher,
|
|
284
288
|
eventSubscriber: () => eventSubscriber,
|
|
289
|
+
generateEventId: () => generateEventId,
|
|
285
290
|
getAffiliateParams: () => getAffiliateParams,
|
|
286
291
|
getAffiliateSource: () => getAffiliateSource,
|
|
292
|
+
getBrowserInfo: () => getBrowserInfo,
|
|
293
|
+
getExperimentParams: () => getExperimentParams,
|
|
287
294
|
hasAffiliateData: () => hasAffiliateData,
|
|
295
|
+
hasExperimentData: () => hasExperimentData,
|
|
288
296
|
initTracking: () => initTracking,
|
|
289
297
|
initializeEventTracking: () => initializeEventTracking,
|
|
290
298
|
logger: () => logger,
|
|
@@ -439,6 +447,43 @@ function createAdapterLogger(adapterName, config = {}) {
|
|
|
439
447
|
return baseLogger.child({ adapter: adapterName });
|
|
440
448
|
}
|
|
441
449
|
|
|
450
|
+
// src/experiment/constants.ts
|
|
451
|
+
var PRIMA_EXPERIMENT_COOKIES = {
|
|
452
|
+
HOME: "_prima_pr_ab_home",
|
|
453
|
+
COLLECTION: "_prima_pr_ab_collection",
|
|
454
|
+
PRODUCT: "_prima_pr_ab_product"
|
|
455
|
+
};
|
|
456
|
+
var PRIMA_EXPERIMENT_COOKIE_NAMES = Object.values(
|
|
457
|
+
PRIMA_EXPERIMENT_COOKIES
|
|
458
|
+
);
|
|
459
|
+
|
|
460
|
+
// src/experiment/experiment-tracker.ts
|
|
461
|
+
function getCookie(name) {
|
|
462
|
+
if (typeof document === "undefined") return null;
|
|
463
|
+
const value = `; ${document.cookie}`;
|
|
464
|
+
const parts = value.split(`; ${name}=`);
|
|
465
|
+
if (parts.length === 2) {
|
|
466
|
+
return parts.pop()?.split(";").shift() || null;
|
|
467
|
+
}
|
|
468
|
+
return null;
|
|
469
|
+
}
|
|
470
|
+
function getExperimentParams() {
|
|
471
|
+
return {
|
|
472
|
+
[PRIMA_EXPERIMENT_COOKIES.HOME]: getCookie(PRIMA_EXPERIMENT_COOKIES.HOME),
|
|
473
|
+
[PRIMA_EXPERIMENT_COOKIES.COLLECTION]: getCookie(
|
|
474
|
+
PRIMA_EXPERIMENT_COOKIES.COLLECTION
|
|
475
|
+
),
|
|
476
|
+
[PRIMA_EXPERIMENT_COOKIES.PRODUCT]: getCookie(
|
|
477
|
+
PRIMA_EXPERIMENT_COOKIES.PRODUCT
|
|
478
|
+
)
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
function hasExperimentData() {
|
|
482
|
+
return PRIMA_EXPERIMENT_COOKIE_NAMES.some(
|
|
483
|
+
(cookieName) => getCookie(cookieName) !== null
|
|
484
|
+
);
|
|
485
|
+
}
|
|
486
|
+
|
|
442
487
|
// src/adapters/base-adapter.ts
|
|
443
488
|
var BaseAdapter = class {
|
|
444
489
|
/**
|
|
@@ -524,6 +569,21 @@ var BaseAdapter = class {
|
|
|
524
569
|
getAffiliateParams() {
|
|
525
570
|
return null;
|
|
526
571
|
}
|
|
572
|
+
/**
|
|
573
|
+
* Get experiment parameters from cookies
|
|
574
|
+
* @returns Experiment parameters
|
|
575
|
+
*/
|
|
576
|
+
getExperimentParams() {
|
|
577
|
+
try {
|
|
578
|
+
return getExperimentParams();
|
|
579
|
+
} catch (error) {
|
|
580
|
+
return {
|
|
581
|
+
_prima_pr_ab_home: null,
|
|
582
|
+
_prima_pr_ab_collection: null,
|
|
583
|
+
_prima_pr_ab_product: null
|
|
584
|
+
};
|
|
585
|
+
}
|
|
586
|
+
}
|
|
527
587
|
/**
|
|
528
588
|
* Enhance event parameters with affiliate data
|
|
529
589
|
* @param params The original parameters
|
|
@@ -538,6 +598,18 @@ var BaseAdapter = class {
|
|
|
538
598
|
...affiliateParams
|
|
539
599
|
};
|
|
540
600
|
}
|
|
601
|
+
/**
|
|
602
|
+
* Enhance event parameters with experiment data
|
|
603
|
+
* @param params The original parameters
|
|
604
|
+
* @returns Parameters enhanced with experiment data
|
|
605
|
+
*/
|
|
606
|
+
enhanceWithExperimentParams(params) {
|
|
607
|
+
const experimentParams = this.getExperimentParams();
|
|
608
|
+
return {
|
|
609
|
+
...params,
|
|
610
|
+
experiment: experimentParams
|
|
611
|
+
};
|
|
612
|
+
}
|
|
541
613
|
};
|
|
542
614
|
|
|
543
615
|
// src/types.ts
|
|
@@ -764,8 +836,9 @@ var PixelAdapter = class extends BaseAdapter {
|
|
|
764
836
|
*/
|
|
765
837
|
trackPageView(event, adapterParams) {
|
|
766
838
|
const eventName = this.getEventName(adapterParams, "PageView");
|
|
767
|
-
const
|
|
768
|
-
const
|
|
839
|
+
const affiliateParams = this.enhanceWithAffiliateParams({});
|
|
840
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
841
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
769
842
|
if (event.eventId) {
|
|
770
843
|
window.fbq?.("track", eventName, enhancedParams, {
|
|
771
844
|
eventID: event.eventId
|
|
@@ -793,7 +866,8 @@ var PixelAdapter = class extends BaseAdapter {
|
|
|
793
866
|
currency: event.currency || "INR"
|
|
794
867
|
};
|
|
795
868
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
796
|
-
const
|
|
869
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
870
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
797
871
|
if (event.eventId) {
|
|
798
872
|
window.fbq?.("track", eventName, enhancedParams, {
|
|
799
873
|
eventID: event.eventId
|
|
@@ -820,7 +894,8 @@ var PixelAdapter = class extends BaseAdapter {
|
|
|
820
894
|
currency: event.currency || "INR"
|
|
821
895
|
};
|
|
822
896
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
823
|
-
const
|
|
897
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
898
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
824
899
|
if (event.eventId) {
|
|
825
900
|
window.fbq?.("track", eventName, enhancedParams, {
|
|
826
901
|
eventID: event.eventId
|
|
@@ -852,7 +927,8 @@ var PixelAdapter = class extends BaseAdapter {
|
|
|
852
927
|
}))
|
|
853
928
|
};
|
|
854
929
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
855
|
-
const
|
|
930
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
931
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
856
932
|
if (event.eventId) {
|
|
857
933
|
window.fbq?.("track", eventName, enhancedParams, {
|
|
858
934
|
eventID: event.eventId
|
|
@@ -884,7 +960,8 @@ var PixelAdapter = class extends BaseAdapter {
|
|
|
884
960
|
}))
|
|
885
961
|
};
|
|
886
962
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
887
|
-
const
|
|
963
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
964
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
888
965
|
if (event.eventId) {
|
|
889
966
|
window.fbq?.("track", eventName, enhancedParams, {
|
|
890
967
|
eventID: event.eventId
|
|
@@ -909,7 +986,8 @@ var PixelAdapter = class extends BaseAdapter {
|
|
|
909
986
|
content_ids: event.content_ids || []
|
|
910
987
|
};
|
|
911
988
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
912
|
-
const
|
|
989
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
990
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
913
991
|
if (event.eventId) {
|
|
914
992
|
window.fbq?.("track", eventName, enhancedParams, {
|
|
915
993
|
eventID: event.eventId
|
|
@@ -941,7 +1019,8 @@ var PixelAdapter = class extends BaseAdapter {
|
|
|
941
1019
|
payment_type: event.paymentType || ""
|
|
942
1020
|
};
|
|
943
1021
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
944
|
-
const
|
|
1022
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1023
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
945
1024
|
if (event.eventId) {
|
|
946
1025
|
window.fbq?.("track", eventName, enhancedParams, {
|
|
947
1026
|
eventID: event.eventId
|
|
@@ -969,7 +1048,8 @@ var PixelAdapter = class extends BaseAdapter {
|
|
|
969
1048
|
currency: event.currency || "INR"
|
|
970
1049
|
};
|
|
971
1050
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
972
|
-
const
|
|
1051
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1052
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
973
1053
|
if (event.eventId) {
|
|
974
1054
|
window.fbq?.("track", eventName, enhancedParams, {
|
|
975
1055
|
eventID: event.eventId
|
|
@@ -997,7 +1077,8 @@ var PixelAdapter = class extends BaseAdapter {
|
|
|
997
1077
|
contents: event.contents || []
|
|
998
1078
|
};
|
|
999
1079
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1000
|
-
const
|
|
1080
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1081
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
1001
1082
|
if (event.eventId) {
|
|
1002
1083
|
window.fbq?.("track", eventName, enhancedParams, {
|
|
1003
1084
|
eventID: event.eventId
|
|
@@ -1167,8 +1248,9 @@ var GoogleAdapter = class extends BaseAdapter {
|
|
|
1167
1248
|
const eventName = this.getEventName(adapterParams, event.type);
|
|
1168
1249
|
const baseParams = this.eventToParams(event);
|
|
1169
1250
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1251
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1170
1252
|
const enhancedParams = this.mergeEventData(
|
|
1171
|
-
|
|
1253
|
+
experimentParams,
|
|
1172
1254
|
adapterParams
|
|
1173
1255
|
);
|
|
1174
1256
|
window.gtag("event", eventName, enhancedParams);
|
|
@@ -1207,7 +1289,8 @@ var GoogleAdapter = class extends BaseAdapter {
|
|
|
1207
1289
|
session_engaged: event.session_engaged
|
|
1208
1290
|
};
|
|
1209
1291
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1210
|
-
const
|
|
1292
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1293
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
1211
1294
|
window.gtag?.("event", eventName, enhancedParams);
|
|
1212
1295
|
}
|
|
1213
1296
|
trackUserEngagement(adapterParams) {
|
|
@@ -1230,7 +1313,8 @@ var GoogleAdapter = class extends BaseAdapter {
|
|
|
1230
1313
|
term: ""
|
|
1231
1314
|
};
|
|
1232
1315
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1233
|
-
const
|
|
1316
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1317
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
1234
1318
|
window.gtag?.("event", eventName, enhancedParams);
|
|
1235
1319
|
}
|
|
1236
1320
|
trackSessionStart(adapterParams) {
|
|
@@ -1255,7 +1339,8 @@ var GoogleAdapter = class extends BaseAdapter {
|
|
|
1255
1339
|
term: ""
|
|
1256
1340
|
};
|
|
1257
1341
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1258
|
-
const
|
|
1342
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1343
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
1259
1344
|
window.gtag?.("event", eventName, enhancedParams);
|
|
1260
1345
|
}
|
|
1261
1346
|
trackFirstVisit(adapterParams) {
|
|
@@ -1282,7 +1367,8 @@ var GoogleAdapter = class extends BaseAdapter {
|
|
|
1282
1367
|
page_term: ""
|
|
1283
1368
|
};
|
|
1284
1369
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1285
|
-
const
|
|
1370
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1371
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
1286
1372
|
window.gtag?.("event", eventName, enhancedParams);
|
|
1287
1373
|
}
|
|
1288
1374
|
trackViewItem(event, adapterParams) {
|
|
@@ -1293,7 +1379,8 @@ var GoogleAdapter = class extends BaseAdapter {
|
|
|
1293
1379
|
items: event.items
|
|
1294
1380
|
};
|
|
1295
1381
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1296
|
-
const
|
|
1382
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1383
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
1297
1384
|
window.gtag?.("event", eventName, enhancedParams);
|
|
1298
1385
|
}
|
|
1299
1386
|
trackScroll(adapterParams) {
|
|
@@ -1313,7 +1400,8 @@ var GoogleAdapter = class extends BaseAdapter {
|
|
|
1313
1400
|
// or dynamically captured
|
|
1314
1401
|
};
|
|
1315
1402
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1316
|
-
const
|
|
1403
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1404
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
1317
1405
|
window.gtag?.("event", eventName, enhancedParams);
|
|
1318
1406
|
}
|
|
1319
1407
|
trackCheckoutPayment(event, adapterParams) {
|
|
@@ -1329,7 +1417,8 @@ var GoogleAdapter = class extends BaseAdapter {
|
|
|
1329
1417
|
}))
|
|
1330
1418
|
};
|
|
1331
1419
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1332
|
-
const
|
|
1420
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1421
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
1333
1422
|
window.gtag?.("event", eventName, enhancedParams);
|
|
1334
1423
|
}
|
|
1335
1424
|
trackViewedProduct(event, adapterParams) {
|
|
@@ -1348,7 +1437,8 @@ var GoogleAdapter = class extends BaseAdapter {
|
|
|
1348
1437
|
view_duration: event.viewDuration
|
|
1349
1438
|
};
|
|
1350
1439
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1351
|
-
const
|
|
1440
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1441
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
1352
1442
|
window.gtag?.("event", eventName, enhancedParams);
|
|
1353
1443
|
}
|
|
1354
1444
|
trackAddToCart(event, adapterParams) {
|
|
@@ -1381,7 +1471,8 @@ var GoogleAdapter = class extends BaseAdapter {
|
|
|
1381
1471
|
user_properties: event.user_properties
|
|
1382
1472
|
};
|
|
1383
1473
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1384
|
-
const
|
|
1474
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1475
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
1385
1476
|
this.logger.debug("Sending add_to_cart event to gtag", {
|
|
1386
1477
|
eventName,
|
|
1387
1478
|
params: enhancedParams
|
|
@@ -1409,7 +1500,8 @@ var GoogleAdapter = class extends BaseAdapter {
|
|
|
1409
1500
|
page_title: document.title
|
|
1410
1501
|
};
|
|
1411
1502
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1412
|
-
const
|
|
1503
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1504
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
1413
1505
|
window.gtag?.("event", eventName, enhancedParams);
|
|
1414
1506
|
}
|
|
1415
1507
|
trackCheckoutStarted(event, adapterParams) {
|
|
@@ -1438,7 +1530,8 @@ var GoogleAdapter = class extends BaseAdapter {
|
|
|
1438
1530
|
}))
|
|
1439
1531
|
};
|
|
1440
1532
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1441
|
-
const
|
|
1533
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1534
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
1442
1535
|
window.gtag?.("event", eventName, enhancedParams);
|
|
1443
1536
|
}
|
|
1444
1537
|
trackFormSubmission(event, adapterParams) {
|
|
@@ -1458,7 +1551,8 @@ var GoogleAdapter = class extends BaseAdapter {
|
|
|
1458
1551
|
page_title: document.title
|
|
1459
1552
|
};
|
|
1460
1553
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1461
|
-
const
|
|
1554
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1555
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
1462
1556
|
window.gtag?.("event", eventName, enhancedParams);
|
|
1463
1557
|
}
|
|
1464
1558
|
trackSearch(event, adapterParams) {
|
|
@@ -1476,7 +1570,8 @@ var GoogleAdapter = class extends BaseAdapter {
|
|
|
1476
1570
|
search_term: event.searchTerm
|
|
1477
1571
|
};
|
|
1478
1572
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1479
|
-
const
|
|
1573
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1574
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
1480
1575
|
window.gtag?.("event", eventName, enhancedParams);
|
|
1481
1576
|
}
|
|
1482
1577
|
/**
|
|
@@ -1498,7 +1593,8 @@ var GoogleAdapter = class extends BaseAdapter {
|
|
|
1498
1593
|
}))
|
|
1499
1594
|
};
|
|
1500
1595
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1501
|
-
const
|
|
1596
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1597
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
1502
1598
|
window.gtag?.("event", eventName, enhancedParams);
|
|
1503
1599
|
}
|
|
1504
1600
|
/**
|
|
@@ -1509,7 +1605,8 @@ var GoogleAdapter = class extends BaseAdapter {
|
|
|
1509
1605
|
const eventName = this.getEventName(adapterParams, event.name);
|
|
1510
1606
|
const baseParams = event.properties || {};
|
|
1511
1607
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1512
|
-
const
|
|
1608
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1609
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
1513
1610
|
window.gtag?.("event", eventName, enhancedParams);
|
|
1514
1611
|
}
|
|
1515
1612
|
/**
|
|
@@ -1531,7 +1628,8 @@ var GoogleAdapter = class extends BaseAdapter {
|
|
|
1531
1628
|
}))
|
|
1532
1629
|
};
|
|
1533
1630
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1534
|
-
const
|
|
1631
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1632
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
1535
1633
|
window.gtag?.("event", eventName, enhancedParams);
|
|
1536
1634
|
}
|
|
1537
1635
|
/**
|
|
@@ -1570,7 +1668,8 @@ var GoogleAdapter = class extends BaseAdapter {
|
|
|
1570
1668
|
user_properties: event.user_properties
|
|
1571
1669
|
};
|
|
1572
1670
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1573
|
-
const
|
|
1671
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1672
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
1574
1673
|
window.gtag?.("event", eventName, enhancedParams);
|
|
1575
1674
|
}
|
|
1576
1675
|
/**
|
|
@@ -1613,7 +1712,8 @@ var GoogleAdapter = class extends BaseAdapter {
|
|
|
1613
1712
|
user_properties: event.user_properties
|
|
1614
1713
|
};
|
|
1615
1714
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1616
|
-
const
|
|
1715
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1716
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
1617
1717
|
window.gtag?.("event", eventName, enhancedParams);
|
|
1618
1718
|
}
|
|
1619
1719
|
/**
|
|
@@ -1638,7 +1738,8 @@ var GoogleAdapter = class extends BaseAdapter {
|
|
|
1638
1738
|
user_properties: event.user_properties
|
|
1639
1739
|
};
|
|
1640
1740
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1641
|
-
const
|
|
1741
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1742
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
1642
1743
|
window.gtag?.("event", eventName, enhancedParams);
|
|
1643
1744
|
}
|
|
1644
1745
|
/**
|
|
@@ -1674,7 +1775,8 @@ var GoogleAdapter = class extends BaseAdapter {
|
|
|
1674
1775
|
user_properties: event.user_properties
|
|
1675
1776
|
};
|
|
1676
1777
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1677
|
-
const
|
|
1778
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1779
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
1678
1780
|
window.gtag?.("event", eventName, enhancedParams);
|
|
1679
1781
|
}
|
|
1680
1782
|
/**
|
|
@@ -1714,7 +1816,8 @@ var GoogleAdapter = class extends BaseAdapter {
|
|
|
1714
1816
|
user_properties: event.user_properties
|
|
1715
1817
|
};
|
|
1716
1818
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1717
|
-
const
|
|
1819
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1820
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
1718
1821
|
window.gtag?.("event", eventName, enhancedParams);
|
|
1719
1822
|
}
|
|
1720
1823
|
/**
|
|
@@ -1723,7 +1826,8 @@ var GoogleAdapter = class extends BaseAdapter {
|
|
|
1723
1826
|
*/
|
|
1724
1827
|
eventToParams(event) {
|
|
1725
1828
|
const { type, timestamp, ...params } = event;
|
|
1726
|
-
|
|
1829
|
+
const affiliateParams = this.enhanceWithAffiliateParams(params);
|
|
1830
|
+
return this.enhanceWithExperimentParams(affiliateParams);
|
|
1727
1831
|
}
|
|
1728
1832
|
};
|
|
1729
1833
|
|
|
@@ -1861,7 +1965,12 @@ var MoengageAdapter = class extends BaseAdapter {
|
|
|
1861
1965
|
default:
|
|
1862
1966
|
const eventName = this.getEventName(adapterParams, event.type);
|
|
1863
1967
|
const baseParams = this.eventToParams(event);
|
|
1864
|
-
const
|
|
1968
|
+
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
1969
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1970
|
+
const enhancedParams = this.mergeEventData(
|
|
1971
|
+
experimentParams,
|
|
1972
|
+
adapterParams
|
|
1973
|
+
);
|
|
1865
1974
|
this.sdk.track_event(eventName, enhancedParams);
|
|
1866
1975
|
break;
|
|
1867
1976
|
}
|
|
@@ -1883,7 +1992,12 @@ var MoengageAdapter = class extends BaseAdapter {
|
|
|
1883
1992
|
page_url: window.location.href,
|
|
1884
1993
|
referrer: event.referrer || document.referrer
|
|
1885
1994
|
};
|
|
1886
|
-
const
|
|
1995
|
+
const affiliateParams = this.enhanceWithAffiliateParams(baseEventData);
|
|
1996
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
1997
|
+
const enhancedEventData = this.mergeEventData(
|
|
1998
|
+
experimentParams,
|
|
1999
|
+
adapterParams
|
|
2000
|
+
);
|
|
1887
2001
|
this.sdk.track_event(eventName, enhancedEventData);
|
|
1888
2002
|
this.logger.debug("PageView event tracked", {
|
|
1889
2003
|
eventName,
|
|
@@ -1905,7 +2019,12 @@ var MoengageAdapter = class extends BaseAdapter {
|
|
|
1905
2019
|
button_text: event.buttonText,
|
|
1906
2020
|
location: event.location
|
|
1907
2021
|
};
|
|
1908
|
-
const
|
|
2022
|
+
const affiliateParams = this.enhanceWithAffiliateParams(baseEventData);
|
|
2023
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
2024
|
+
const enhancedEventData = this.mergeEventData(
|
|
2025
|
+
experimentParams,
|
|
2026
|
+
adapterParams
|
|
2027
|
+
);
|
|
1909
2028
|
this.sdk?.track_event(eventName, enhancedEventData);
|
|
1910
2029
|
}
|
|
1911
2030
|
/**
|
|
@@ -1923,7 +2042,12 @@ var MoengageAdapter = class extends BaseAdapter {
|
|
|
1923
2042
|
form_name: event.formName,
|
|
1924
2043
|
success: event.success
|
|
1925
2044
|
};
|
|
1926
|
-
const
|
|
2045
|
+
const affiliateParams = this.enhanceWithAffiliateParams(baseEventData);
|
|
2046
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
2047
|
+
const enhancedEventData = this.mergeEventData(
|
|
2048
|
+
experimentParams,
|
|
2049
|
+
adapterParams
|
|
2050
|
+
);
|
|
1927
2051
|
this.sdk?.track_event(eventName, enhancedEventData);
|
|
1928
2052
|
}
|
|
1929
2053
|
/**
|
|
@@ -1943,7 +2067,12 @@ var MoengageAdapter = class extends BaseAdapter {
|
|
|
1943
2067
|
currency: event.currency || DEFAULT_CURRENCY,
|
|
1944
2068
|
category: event.category
|
|
1945
2069
|
};
|
|
1946
|
-
const
|
|
2070
|
+
const affiliateParams = this.enhanceWithAffiliateParams(baseEventData);
|
|
2071
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
2072
|
+
const enhancedEventData = this.mergeEventData(
|
|
2073
|
+
experimentParams,
|
|
2074
|
+
adapterParams
|
|
2075
|
+
);
|
|
1947
2076
|
this.sdk?.track_event(eventName, enhancedEventData);
|
|
1948
2077
|
}
|
|
1949
2078
|
/**
|
|
@@ -1966,7 +2095,12 @@ var MoengageAdapter = class extends BaseAdapter {
|
|
|
1966
2095
|
variant: event.variant,
|
|
1967
2096
|
total_value: event.price * quantity
|
|
1968
2097
|
};
|
|
1969
|
-
const
|
|
2098
|
+
const affiliateParams = this.enhanceWithAffiliateParams(baseEventData);
|
|
2099
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
2100
|
+
const enhancedEventData = this.mergeEventData(
|
|
2101
|
+
experimentParams,
|
|
2102
|
+
adapterParams
|
|
2103
|
+
);
|
|
1970
2104
|
this.sdk?.track_event(eventName, enhancedEventData);
|
|
1971
2105
|
}
|
|
1972
2106
|
/**
|
|
@@ -1988,7 +2122,12 @@ var MoengageAdapter = class extends BaseAdapter {
|
|
|
1988
2122
|
variant: event.variant,
|
|
1989
2123
|
total_value: event.price * event.quantity
|
|
1990
2124
|
};
|
|
1991
|
-
const
|
|
2125
|
+
const affiliateParams = this.enhanceWithAffiliateParams(baseEventData);
|
|
2126
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
2127
|
+
const enhancedEventData = this.mergeEventData(
|
|
2128
|
+
experimentParams,
|
|
2129
|
+
adapterParams
|
|
2130
|
+
);
|
|
1992
2131
|
this.sdk?.track_event(eventName, enhancedEventData);
|
|
1993
2132
|
}
|
|
1994
2133
|
/**
|
|
@@ -2013,7 +2152,12 @@ var MoengageAdapter = class extends BaseAdapter {
|
|
|
2013
2152
|
variant: item.variant
|
|
2014
2153
|
}))
|
|
2015
2154
|
};
|
|
2016
|
-
const
|
|
2155
|
+
const affiliateParams = this.enhanceWithAffiliateParams(baseEventData);
|
|
2156
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
2157
|
+
const enhancedEventData = this.mergeEventData(
|
|
2158
|
+
experimentParams,
|
|
2159
|
+
adapterParams
|
|
2160
|
+
);
|
|
2017
2161
|
this.sdk?.track_event(eventName, enhancedEventData);
|
|
2018
2162
|
}
|
|
2019
2163
|
/**
|
|
@@ -2039,7 +2183,12 @@ var MoengageAdapter = class extends BaseAdapter {
|
|
|
2039
2183
|
variant: item.variant
|
|
2040
2184
|
}))
|
|
2041
2185
|
};
|
|
2042
|
-
const
|
|
2186
|
+
const affiliateParams = this.enhanceWithAffiliateParams(baseEventData);
|
|
2187
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
2188
|
+
const enhancedEventData = this.mergeEventData(
|
|
2189
|
+
experimentParams,
|
|
2190
|
+
adapterParams
|
|
2191
|
+
);
|
|
2043
2192
|
this.sdk?.track_event(eventName, enhancedEventData);
|
|
2044
2193
|
}
|
|
2045
2194
|
/**
|
|
@@ -2053,7 +2202,12 @@ var MoengageAdapter = class extends BaseAdapter {
|
|
|
2053
2202
|
search_term: event.searchTerm,
|
|
2054
2203
|
results_count: event.resultsCount
|
|
2055
2204
|
};
|
|
2056
|
-
const
|
|
2205
|
+
const affiliateParams = this.enhanceWithAffiliateParams(baseEventData);
|
|
2206
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
2207
|
+
const enhancedEventData = this.mergeEventData(
|
|
2208
|
+
experimentParams,
|
|
2209
|
+
adapterParams
|
|
2210
|
+
);
|
|
2057
2211
|
this.sdk?.track_event(eventName, enhancedEventData);
|
|
2058
2212
|
}
|
|
2059
2213
|
/**
|
|
@@ -2071,7 +2225,12 @@ var MoengageAdapter = class extends BaseAdapter {
|
|
|
2071
2225
|
method: event.method,
|
|
2072
2226
|
success: event.success
|
|
2073
2227
|
};
|
|
2074
|
-
const
|
|
2228
|
+
const affiliateParams = this.enhanceWithAffiliateParams(baseEventData);
|
|
2229
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
2230
|
+
const enhancedEventData = this.mergeEventData(
|
|
2231
|
+
experimentParams,
|
|
2232
|
+
adapterParams
|
|
2233
|
+
);
|
|
2075
2234
|
this.sdk?.track_event(eventName, enhancedEventData);
|
|
2076
2235
|
if (event.userId && this.getConfig("enableUserIdentification", true)) {
|
|
2077
2236
|
this.sdk?.add_unique_user_id(event.userId);
|
|
@@ -2092,7 +2251,12 @@ var MoengageAdapter = class extends BaseAdapter {
|
|
|
2092
2251
|
method: event.method,
|
|
2093
2252
|
success: event.success
|
|
2094
2253
|
};
|
|
2095
|
-
const
|
|
2254
|
+
const affiliateParams = this.enhanceWithAffiliateParams(baseEventData);
|
|
2255
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
2256
|
+
const enhancedEventData = this.mergeEventData(
|
|
2257
|
+
experimentParams,
|
|
2258
|
+
adapterParams
|
|
2259
|
+
);
|
|
2096
2260
|
this.sdk?.track_event(eventName, enhancedEventData);
|
|
2097
2261
|
if (event.userId && this.getConfig("enableUserIdentification", true)) {
|
|
2098
2262
|
this.sdk?.add_unique_user_id(event.userId);
|
|
@@ -2106,7 +2270,12 @@ var MoengageAdapter = class extends BaseAdapter {
|
|
|
2106
2270
|
trackCustomEvent(event, adapterParams) {
|
|
2107
2271
|
const eventName = this.getEventName(adapterParams, event.name);
|
|
2108
2272
|
const baseEventData = event.properties || {};
|
|
2109
|
-
const
|
|
2273
|
+
const affiliateParams = this.enhanceWithAffiliateParams(baseEventData);
|
|
2274
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
2275
|
+
const enhancedEventData = this.mergeEventData(
|
|
2276
|
+
experimentParams,
|
|
2277
|
+
adapterParams
|
|
2278
|
+
);
|
|
2110
2279
|
this.sdk?.track_event(eventName, enhancedEventData);
|
|
2111
2280
|
}
|
|
2112
2281
|
/**
|
|
@@ -2236,8 +2405,9 @@ var PostHogAdapter = class extends BaseAdapter {
|
|
|
2236
2405
|
const eventName = this.getEventName(adapterParams, event.type);
|
|
2237
2406
|
const baseParams = this.eventToParams(event);
|
|
2238
2407
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
2408
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
2239
2409
|
const enhancedParams = this.mergeEventData(
|
|
2240
|
-
|
|
2410
|
+
experimentParams,
|
|
2241
2411
|
adapterParams
|
|
2242
2412
|
);
|
|
2243
2413
|
window.posthog?.capture(eventName, enhancedParams);
|
|
@@ -2257,7 +2427,8 @@ var PostHogAdapter = class extends BaseAdapter {
|
|
|
2257
2427
|
referrer: event.referrer
|
|
2258
2428
|
};
|
|
2259
2429
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
2260
|
-
const
|
|
2430
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
2431
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
2261
2432
|
window.posthog?.capture(eventName, enhancedParams);
|
|
2262
2433
|
}
|
|
2263
2434
|
/**
|
|
@@ -2275,7 +2446,8 @@ var PostHogAdapter = class extends BaseAdapter {
|
|
|
2275
2446
|
currency: event.currency || "INR"
|
|
2276
2447
|
};
|
|
2277
2448
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
2278
|
-
const
|
|
2449
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
2450
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
2279
2451
|
window.posthog?.capture(eventName, enhancedParams);
|
|
2280
2452
|
}
|
|
2281
2453
|
/**
|
|
@@ -2295,7 +2467,8 @@ var PostHogAdapter = class extends BaseAdapter {
|
|
|
2295
2467
|
variant: event.variant
|
|
2296
2468
|
};
|
|
2297
2469
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
2298
|
-
const
|
|
2470
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
2471
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
2299
2472
|
this.logger.debug("Sending to PostHog with params", {
|
|
2300
2473
|
eventName,
|
|
2301
2474
|
params: enhancedParams
|
|
@@ -2327,7 +2500,8 @@ var PostHogAdapter = class extends BaseAdapter {
|
|
|
2327
2500
|
}))
|
|
2328
2501
|
};
|
|
2329
2502
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
2330
|
-
const
|
|
2503
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
2504
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
2331
2505
|
window.posthog?.capture(eventName, enhancedParams);
|
|
2332
2506
|
}
|
|
2333
2507
|
/**
|
|
@@ -2351,7 +2525,8 @@ var PostHogAdapter = class extends BaseAdapter {
|
|
|
2351
2525
|
}))
|
|
2352
2526
|
};
|
|
2353
2527
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
2354
|
-
const
|
|
2528
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
2529
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
2355
2530
|
window.posthog?.capture(eventName, enhancedParams);
|
|
2356
2531
|
}
|
|
2357
2532
|
/**
|
|
@@ -2367,7 +2542,8 @@ var PostHogAdapter = class extends BaseAdapter {
|
|
|
2367
2542
|
content_ids: event.content_ids
|
|
2368
2543
|
};
|
|
2369
2544
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
2370
|
-
const
|
|
2545
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
2546
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
2371
2547
|
window.posthog?.capture(eventName, enhancedParams);
|
|
2372
2548
|
}
|
|
2373
2549
|
/**
|
|
@@ -2391,7 +2567,8 @@ var PostHogAdapter = class extends BaseAdapter {
|
|
|
2391
2567
|
}))
|
|
2392
2568
|
};
|
|
2393
2569
|
const affiliateParams = this.enhanceWithAffiliateParams(baseParams);
|
|
2394
|
-
const
|
|
2570
|
+
const experimentParams = this.enhanceWithExperimentParams(affiliateParams);
|
|
2571
|
+
const enhancedParams = this.mergeEventData(experimentParams, adapterParams);
|
|
2395
2572
|
window.posthog?.capture(eventName, enhancedParams);
|
|
2396
2573
|
}
|
|
2397
2574
|
/**
|
|
@@ -2511,7 +2688,7 @@ var ShopifyAdapter = class extends BaseAdapter {
|
|
|
2511
2688
|
shopId: `gid://shopify/Shop/${this.shopId}`,
|
|
2512
2689
|
currency: this.currency,
|
|
2513
2690
|
acceptedLanguage: DEFAULT_LANGUAGE,
|
|
2514
|
-
...this.enhanceWithAffiliateParams({})
|
|
2691
|
+
...this.enhanceWithExperimentParams(this.enhanceWithAffiliateParams({}))
|
|
2515
2692
|
};
|
|
2516
2693
|
}
|
|
2517
2694
|
/**
|
|
@@ -2532,17 +2709,19 @@ var ShopifyAdapter = class extends BaseAdapter {
|
|
|
2532
2709
|
eventData: event,
|
|
2533
2710
|
adapterParams: params
|
|
2534
2711
|
});
|
|
2712
|
+
const affiliateParams = this.enhanceWithAffiliateParams(event);
|
|
2713
|
+
const enhancedEvent = this.enhanceWithExperimentParams(affiliateParams);
|
|
2535
2714
|
try {
|
|
2536
2715
|
switch (event.type) {
|
|
2537
2716
|
case "page_view" /* PAGE_VIEW */:
|
|
2538
|
-
const pageViewPayload = this.mergeEventData(
|
|
2717
|
+
const pageViewPayload = this.mergeEventData(enhancedEvent, params);
|
|
2539
2718
|
this.sendPageView(import_hydrogen_react.AnalyticsEventName.PAGE_VIEW, pageViewPayload);
|
|
2540
2719
|
this.logger.debug("Sent PAGE_VIEW event to Shopify Analytics", {
|
|
2541
2720
|
payload: pageViewPayload
|
|
2542
2721
|
});
|
|
2543
2722
|
break;
|
|
2544
2723
|
case "view_content" /* VIEW_CONTENT */:
|
|
2545
|
-
const viewContentPayload = this.mergeEventData(
|
|
2724
|
+
const viewContentPayload = this.mergeEventData(enhancedEvent, params);
|
|
2546
2725
|
this.sendPageView(
|
|
2547
2726
|
import_hydrogen_react.AnalyticsEventName.PRODUCT_VIEW,
|
|
2548
2727
|
viewContentPayload
|
|
@@ -2552,15 +2731,13 @@ var ShopifyAdapter = class extends BaseAdapter {
|
|
|
2552
2731
|
});
|
|
2553
2732
|
break;
|
|
2554
2733
|
case "add_to_cart" /* ADD_TO_CART */:
|
|
2555
|
-
const
|
|
2556
|
-
this.trackAddToCart(
|
|
2734
|
+
const addToCartPayload = this.mergeEventData(enhancedEvent, params);
|
|
2735
|
+
this.trackAddToCart(addToCartPayload);
|
|
2557
2736
|
break;
|
|
2558
2737
|
case "checkout_started" /* CHECKOUT_STARTED */:
|
|
2559
2738
|
case "begin_checkout" /* BEGIN_CHECKOUT */:
|
|
2560
2739
|
const checkoutPayload = this.mergeEventData(
|
|
2561
|
-
{
|
|
2562
|
-
pageType: "checkout"
|
|
2563
|
-
},
|
|
2740
|
+
{ ...enhancedEvent, pageType: "checkout" },
|
|
2564
2741
|
params
|
|
2565
2742
|
);
|
|
2566
2743
|
this.sendPageView(import_hydrogen_react.AnalyticsEventName.PAGE_VIEW, checkoutPayload);
|
|
@@ -2708,9 +2885,10 @@ var KwikPassAdapter = class extends BaseAdapter {
|
|
|
2708
2885
|
});
|
|
2709
2886
|
return;
|
|
2710
2887
|
}
|
|
2888
|
+
const affiliateParams = this.enhanceWithAffiliateParams(event);
|
|
2889
|
+
const enhancedEvent = this.enhanceWithExperimentParams(affiliateParams);
|
|
2711
2890
|
try {
|
|
2712
2891
|
this.logger.debug("Processing event", { eventType: event.type });
|
|
2713
|
-
const enhancedEvent = this.enhanceWithAffiliateParams(event);
|
|
2714
2892
|
switch (event.type) {
|
|
2715
2893
|
case "product_view" /* PRODUCT_VIEW */:
|
|
2716
2894
|
this.trackProductView(enhancedEvent, adapterParams);
|
|
@@ -2844,7 +3022,8 @@ var KwikCheckoutAdapter = class extends BaseAdapter {
|
|
|
2844
3022
|
}
|
|
2845
3023
|
try {
|
|
2846
3024
|
this.logger.debug("Processing event", { eventType: event.type });
|
|
2847
|
-
const
|
|
3025
|
+
const affiliateEnhanced = this.enhanceWithAffiliateParams(event);
|
|
3026
|
+
const enhancedEvent = this.enhanceWithExperimentParams(affiliateEnhanced);
|
|
2848
3027
|
switch (event.type) {
|
|
2849
3028
|
case "started_checkout_gk" /* STARTED_CHECKOUT_GK */:
|
|
2850
3029
|
this.trackStartedCheckoutGK(enhancedEvent, adapterParams);
|
|
@@ -3646,6 +3825,155 @@ var ShopkitAnalytics_default = ShopkitAnalytics;
|
|
|
3646
3825
|
// src/events/index.ts
|
|
3647
3826
|
init_publisher();
|
|
3648
3827
|
init_subscriber();
|
|
3828
|
+
|
|
3829
|
+
// src/services/facebook-capi.ts
|
|
3830
|
+
var FacebookCAPIService = class {
|
|
3831
|
+
constructor(config) {
|
|
3832
|
+
this.baseUrl = "https://graph.facebook.com/v18.0";
|
|
3833
|
+
this.config = config;
|
|
3834
|
+
}
|
|
3835
|
+
/**
|
|
3836
|
+
* Send events to Facebook CAPI
|
|
3837
|
+
*/
|
|
3838
|
+
async sendEvents(events, userInfo) {
|
|
3839
|
+
if (!this.config.accessToken || !this.config.pixelId) {
|
|
3840
|
+
console.warn("Facebook CAPI: Missing access token or pixel ID");
|
|
3841
|
+
return;
|
|
3842
|
+
}
|
|
3843
|
+
const supportedEvents = events.filter(
|
|
3844
|
+
(event) => this.isSupportedEvent(event.type)
|
|
3845
|
+
);
|
|
3846
|
+
if (supportedEvents.length === 0) {
|
|
3847
|
+
console.log("Facebook CAPI: No supported events to send");
|
|
3848
|
+
return;
|
|
3849
|
+
}
|
|
3850
|
+
const capiEvents = supportedEvents.map(
|
|
3851
|
+
(event) => this.convertToFacebookEvent(event, userInfo)
|
|
3852
|
+
);
|
|
3853
|
+
const payload = {
|
|
3854
|
+
data: capiEvents,
|
|
3855
|
+
test_event_code: this.config.testEventCode
|
|
3856
|
+
};
|
|
3857
|
+
try {
|
|
3858
|
+
const response = await fetch(
|
|
3859
|
+
`${this.baseUrl}/${this.config.pixelId}/events?access_token=${this.config.accessToken}`,
|
|
3860
|
+
{
|
|
3861
|
+
method: "POST",
|
|
3862
|
+
headers: {
|
|
3863
|
+
"Content-Type": "application/json"
|
|
3864
|
+
},
|
|
3865
|
+
body: JSON.stringify(payload)
|
|
3866
|
+
}
|
|
3867
|
+
);
|
|
3868
|
+
if (!response.ok) {
|
|
3869
|
+
const errorData = await response.json();
|
|
3870
|
+
console.error("Facebook CAPI Error:", errorData);
|
|
3871
|
+
throw new Error(`Facebook CAPI request failed: ${response.status}`);
|
|
3872
|
+
}
|
|
3873
|
+
const result = await response.json();
|
|
3874
|
+
console.log("Facebook CAPI: Events sent successfully", {
|
|
3875
|
+
events_received: result.events_received,
|
|
3876
|
+
messages: result.messages
|
|
3877
|
+
});
|
|
3878
|
+
} catch (error) {
|
|
3879
|
+
console.error("Facebook CAPI: Failed to send events", error);
|
|
3880
|
+
throw error;
|
|
3881
|
+
}
|
|
3882
|
+
}
|
|
3883
|
+
/**
|
|
3884
|
+
* Check if event type is supported (matches PixelAdapter implementation)
|
|
3885
|
+
*/
|
|
3886
|
+
isSupportedEvent(eventType) {
|
|
3887
|
+
return [
|
|
3888
|
+
"page_view" /* PAGE_VIEW */,
|
|
3889
|
+
"product_view" /* PRODUCT_VIEW */,
|
|
3890
|
+
"add_to_cart" /* ADD_TO_CART */,
|
|
3891
|
+
"search" /* SEARCH */
|
|
3892
|
+
].includes(eventType);
|
|
3893
|
+
}
|
|
3894
|
+
/**
|
|
3895
|
+
* Convert internal event to Facebook CAPI event format
|
|
3896
|
+
* Only handles events implemented in PixelAdapter
|
|
3897
|
+
*/
|
|
3898
|
+
convertToFacebookEvent(event, userInfo) {
|
|
3899
|
+
const baseEvent = {
|
|
3900
|
+
event_name: this.mapEventName(event.type),
|
|
3901
|
+
event_time: Math.floor((event.timestamp || Date.now()) / 1e3),
|
|
3902
|
+
event_id: event.eventId,
|
|
3903
|
+
action_source: "website",
|
|
3904
|
+
user_data: userInfo ? {
|
|
3905
|
+
client_ip_address: userInfo.clientIpAddress,
|
|
3906
|
+
client_user_agent: userInfo.clientUserAgent,
|
|
3907
|
+
fbc: userInfo.fbc,
|
|
3908
|
+
fbp: userInfo.fbp
|
|
3909
|
+
} : void 0
|
|
3910
|
+
};
|
|
3911
|
+
switch (event.type) {
|
|
3912
|
+
case "page_view" /* PAGE_VIEW */:
|
|
3913
|
+
baseEvent.custom_data = {};
|
|
3914
|
+
break;
|
|
3915
|
+
case "product_view" /* PRODUCT_VIEW */:
|
|
3916
|
+
const productEvent = event;
|
|
3917
|
+
baseEvent.custom_data = {
|
|
3918
|
+
content_type: "product_group",
|
|
3919
|
+
content_ids: [productEvent.productId],
|
|
3920
|
+
content_name: productEvent.productName,
|
|
3921
|
+
content_category: productEvent.event_category,
|
|
3922
|
+
value: productEvent.price,
|
|
3923
|
+
currency: productEvent.currency || "INR"
|
|
3924
|
+
};
|
|
3925
|
+
break;
|
|
3926
|
+
case "add_to_cart" /* ADD_TO_CART */:
|
|
3927
|
+
const cartEvent = event;
|
|
3928
|
+
baseEvent.custom_data = {
|
|
3929
|
+
content_type: "product_group",
|
|
3930
|
+
content_ids: [cartEvent.productId],
|
|
3931
|
+
content_name: cartEvent.productName,
|
|
3932
|
+
value: cartEvent.price,
|
|
3933
|
+
currency: cartEvent.currency || "INR"
|
|
3934
|
+
};
|
|
3935
|
+
break;
|
|
3936
|
+
case "search" /* SEARCH */:
|
|
3937
|
+
const searchEvent = event;
|
|
3938
|
+
baseEvent.custom_data = {
|
|
3939
|
+
search_string: searchEvent.searchTerm,
|
|
3940
|
+
content_category: "product",
|
|
3941
|
+
content_ids: searchEvent.content_ids || []
|
|
3942
|
+
};
|
|
3943
|
+
break;
|
|
3944
|
+
default:
|
|
3945
|
+
baseEvent.custom_data = {};
|
|
3946
|
+
break;
|
|
3947
|
+
}
|
|
3948
|
+
return baseEvent;
|
|
3949
|
+
}
|
|
3950
|
+
/**
|
|
3951
|
+
* Map internal event types to Facebook event names (matching PixelAdapter)
|
|
3952
|
+
*/
|
|
3953
|
+
mapEventName(eventType) {
|
|
3954
|
+
const eventMap = {
|
|
3955
|
+
["page_view" /* PAGE_VIEW */]: "PageView",
|
|
3956
|
+
["product_view" /* PRODUCT_VIEW */]: "ViewContent",
|
|
3957
|
+
["add_to_cart" /* ADD_TO_CART */]: "AddToCart",
|
|
3958
|
+
["search" /* SEARCH */]: "Search"
|
|
3959
|
+
};
|
|
3960
|
+
return eventMap[eventType] || "CustomEvent";
|
|
3961
|
+
}
|
|
3962
|
+
};
|
|
3963
|
+
function createFacebookCAPIService(config) {
|
|
3964
|
+
const accessToken = config?.accessToken || process.env.FACEBOOK_CAPI_ACCESS_TOKEN;
|
|
3965
|
+
const pixelId = config?.pixelId || process.env.NEXT_PUBLIC_PIXEL_ID;
|
|
3966
|
+
const testEventCode = config?.testEventCode || process.env.FACEBOOK_TEST_EVENT_CODE;
|
|
3967
|
+
if (!accessToken || !pixelId) {
|
|
3968
|
+
console.warn("Facebook CAPI: Missing access token or pixel ID");
|
|
3969
|
+
return null;
|
|
3970
|
+
}
|
|
3971
|
+
return new FacebookCAPIService({
|
|
3972
|
+
accessToken,
|
|
3973
|
+
pixelId,
|
|
3974
|
+
testEventCode
|
|
3975
|
+
});
|
|
3976
|
+
}
|
|
3649
3977
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3650
3978
|
0 && (module.exports = {
|
|
3651
3979
|
AffiliateTracker,
|
|
@@ -3653,10 +3981,13 @@ init_subscriber();
|
|
|
3653
3981
|
DEFAULT_CURRENCY,
|
|
3654
3982
|
EventNames,
|
|
3655
3983
|
EventType,
|
|
3984
|
+
FacebookCAPIService,
|
|
3656
3985
|
GoogleAdapter,
|
|
3657
3986
|
KwikCheckoutAdapter,
|
|
3658
3987
|
KwikPassAdapter,
|
|
3659
3988
|
MoengageAdapter,
|
|
3989
|
+
PRIMA_EXPERIMENT_COOKIES,
|
|
3990
|
+
PRIMA_EXPERIMENT_COOKIE_NAMES,
|
|
3660
3991
|
PixelAdapter,
|
|
3661
3992
|
PostHogAdapter,
|
|
3662
3993
|
ShopifyAdapter,
|
|
@@ -3664,12 +3995,17 @@ init_subscriber();
|
|
|
3664
3995
|
captureAffiliateParams,
|
|
3665
3996
|
clearAffiliateParams,
|
|
3666
3997
|
createAdapterLogger,
|
|
3998
|
+
createFacebookCAPIService,
|
|
3667
3999
|
createLogger,
|
|
3668
4000
|
eventPublisher,
|
|
3669
4001
|
eventSubscriber,
|
|
4002
|
+
generateEventId,
|
|
3670
4003
|
getAffiliateParams,
|
|
3671
4004
|
getAffiliateSource,
|
|
4005
|
+
getBrowserInfo,
|
|
4006
|
+
getExperimentParams,
|
|
3672
4007
|
hasAffiliateData,
|
|
4008
|
+
hasExperimentData,
|
|
3673
4009
|
initTracking,
|
|
3674
4010
|
initializeEventTracking,
|
|
3675
4011
|
logger,
|