@datalyr/web 1.7.1 → 1.7.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @datalyr/web v1.7.1
2
+ * @datalyr/web v1.7.2
3
3
  * Datalyr Web SDK - Modern attribution tracking for web applications
4
4
  * (c) 2026 Datalyr Inc.
5
5
  * Released under the MIT License
@@ -1359,7 +1359,7 @@ class AttributionManager {
1359
1359
  'msclkid', // Microsoft/Bing
1360
1360
  'twclid', // Twitter/X
1361
1361
  'li_fat_id', // LinkedIn
1362
- 'sclid', // Snapchat
1362
+ 'sclid', // Snapchat (canonical internal name — see CLICK_ID_ALIASES)
1363
1363
  'dclid', // Google Display/DoubleClick
1364
1364
  'epik', // Pinterest
1365
1365
  'rdt_cid', // Reddit
@@ -1367,6 +1367,15 @@ class AttributionManager {
1367
1367
  'irclid', // Impact Radius
1368
1368
  'ko_click_id' // Klaviyo
1369
1369
  ];
1370
+ // Real ad-platform URL params whose value we store under a canonical internal
1371
+ // name. Snapchat appends &ScCid= (alias `sccid`) to the landing URL — it does
1372
+ // NOT use `sclid`. Query-param lookup is case-sensitive, so capture the real
1373
+ // params and normalize to `sclid`, which ingest / the MV / server-side
1374
+ // attribution all key on. Without this, real Snap ad clicks captured nothing.
1375
+ this.CLICK_ID_ALIASES = {
1376
+ ScCid: 'sclid',
1377
+ sccid: 'sclid',
1378
+ };
1370
1379
  // Default tracked params matching dl.js
1371
1380
  this.DEFAULT_TRACKED_PARAMS = [
1372
1381
  'lyr', // Datalyr partner tracking
@@ -1423,6 +1432,18 @@ class AttributionManager {
1423
1432
  attribution[clickId] = value;
1424
1433
  }
1425
1434
  }
1435
+ // Aliased click IDs (e.g. Snap's ScCid/sccid → canonical sclid). Param lookup
1436
+ // above is case-sensitive and uses canonical names, so check the real params here.
1437
+ for (const [param, canonical] of Object.entries(this.CLICK_ID_ALIASES)) {
1438
+ const value = params[param];
1439
+ if (value && !attribution[canonical]) {
1440
+ if (!attribution.clickId) {
1441
+ attribution.clickId = value;
1442
+ attribution.clickIdType = canonical;
1443
+ }
1444
+ attribution[canonical] = value;
1445
+ }
1446
+ }
1426
1447
  // Capture custom tracked parameters
1427
1448
  for (const param of this.trackedParams) {
1428
1449
  const value = params[param];
@@ -1547,6 +1568,9 @@ class AttributionManager {
1547
1568
  // TikTok cookies
1548
1569
  adCookies._ttp = cookies.get('_ttp');
1549
1570
  adCookies._ttc = cookies.get('_ttc');
1571
+ // Snapchat first-party cookie (Snap Pixel sets _scid). Flows to the server as
1572
+ // cookies._scid and is sent on the Snap CAPI event as sc_cookie1 (raw).
1573
+ adCookies._scid = cookies.get('_scid');
1550
1574
  // Generate _fbp if missing (Facebook browser ID)
1551
1575
  if (!adCookies._fbp && (this.hasClickId('fbclid') || adCookies._fbc)) {
1552
1576
  const timestamp = Date.now();