@datalyr/web 1.2.1 → 1.2.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.
- package/dist/datalyr.cjs.js +47 -3
- package/dist/datalyr.cjs.js.map +1 -1
- package/dist/datalyr.esm.js +47 -3
- package/dist/datalyr.esm.js.map +1 -1
- package/dist/datalyr.esm.min.js +1 -1
- package/dist/datalyr.esm.min.js.map +1 -1
- package/dist/datalyr.js +47 -3
- package/dist/datalyr.js.map +1 -1
- package/dist/datalyr.min.js +1 -1
- package/dist/datalyr.min.js.map +1 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/datalyr.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @datalyr/web v1.2.
|
|
2
|
+
* @datalyr/web v1.2.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
|
|
@@ -731,8 +731,36 @@ function getRootDomain() {
|
|
|
731
731
|
// Handle .co.uk, .com.au, etc
|
|
732
732
|
const tld = parts[parts.length - 1];
|
|
733
733
|
const sld = parts[parts.length - 2];
|
|
734
|
-
// Common two-part TLDs
|
|
735
|
-
|
|
734
|
+
// Common two-part TLDs (country-specific domains)
|
|
735
|
+
// Note: The CookieStorage.getAutoDomain() probe method handles unknown TLDs dynamically,
|
|
736
|
+
// but this list provides faster resolution for known patterns
|
|
737
|
+
const twoPartTlds = [
|
|
738
|
+
// United Kingdom
|
|
739
|
+
'co.uk', 'org.uk', 'net.uk', 'ac.uk', 'gov.uk', 'me.uk',
|
|
740
|
+
// Australia
|
|
741
|
+
'com.au', 'net.au', 'org.au', 'edu.au', 'gov.au',
|
|
742
|
+
// New Zealand
|
|
743
|
+
'co.nz', 'net.nz', 'org.nz', 'govt.nz',
|
|
744
|
+
// Japan
|
|
745
|
+
'co.jp', 'ne.jp', 'or.jp', 'ac.jp', 'go.jp',
|
|
746
|
+
// India
|
|
747
|
+
'co.in', 'net.in', 'org.in', 'gov.in', 'ac.in',
|
|
748
|
+
// South Africa
|
|
749
|
+
'co.za', 'net.za', 'org.za', 'gov.za',
|
|
750
|
+
// Brazil
|
|
751
|
+
'com.br', 'net.br', 'org.br', 'gov.br', 'edu.br',
|
|
752
|
+
// South Korea
|
|
753
|
+
'co.kr', 'ne.kr', 'or.kr', 'go.kr', 'ac.kr',
|
|
754
|
+
// China
|
|
755
|
+
'com.cn', 'net.cn', 'org.cn', 'gov.cn', 'edu.cn',
|
|
756
|
+
// Other Asia-Pacific
|
|
757
|
+
'co.id', 'co.th', 'com.sg', 'com.my', 'com.ph', 'com.vn',
|
|
758
|
+
'com.tw', 'com.hk',
|
|
759
|
+
// Latin America
|
|
760
|
+
'com.mx', 'com.ar', 'com.co', 'com.pe', 'com.cl',
|
|
761
|
+
// Europe
|
|
762
|
+
'co.il', 'co.at', 'co.hu', 'co.pl'
|
|
763
|
+
];
|
|
736
764
|
const lastTwo = `${sld}.${tld}`;
|
|
737
765
|
if (twoPartTlds.includes(lastTwo) && parts.length >= 3) {
|
|
738
766
|
return '.' + parts.slice(-3).join('.');
|
|
@@ -804,6 +832,22 @@ class IdentityManager {
|
|
|
804
832
|
* Get or create anonymous ID (device/browser identifier)
|
|
805
833
|
*/
|
|
806
834
|
getOrCreateAnonymousId() {
|
|
835
|
+
// 0. Check URL parameter first (cross-domain linking via _dl_vid)
|
|
836
|
+
// This enables tracking continuity when users navigate between different root domains
|
|
837
|
+
try {
|
|
838
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
839
|
+
const urlVisitorId = urlParams.get('_dl_vid');
|
|
840
|
+
if (urlVisitorId && urlVisitorId.startsWith('anon_')) {
|
|
841
|
+
// Valid visitor ID from URL - use it and persist
|
|
842
|
+
this.setRootDomainCookie('__dl_visitor_id', urlVisitorId);
|
|
843
|
+
storage.set('dl_anonymous_id', urlVisitorId);
|
|
844
|
+
return urlVisitorId;
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
catch (e) {
|
|
848
|
+
// URL parsing failed - continue with cookie/localStorage checks
|
|
849
|
+
console.warn('[Datalyr] Failed to parse URL for _dl_vid:', e);
|
|
850
|
+
}
|
|
807
851
|
// 1. Check root domain cookie first (works across subdomains)
|
|
808
852
|
let anonymousId = cookies.get('__dl_visitor_id');
|
|
809
853
|
if (anonymousId) {
|