@datalyr/web 1.2.2 → 1.4.0
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 +590 -290
- package/dist/datalyr.cjs.js +60 -4
- package/dist/datalyr.cjs.js.map +1 -1
- package/dist/datalyr.esm.js +60 -4
- 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 +60 -4
- package/dist/datalyr.js.map +1 -1
- package/dist/datalyr.min.js +1 -1
- package/dist/datalyr.min.js.map +1 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.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
|
+
* @datalyr/web v1.4.0
|
|
3
3
|
* Datalyr Web SDK - Modern attribution tracking for web applications
|
|
4
4
|
* (c) 2026 Datalyr Inc.
|
|
5
5
|
* Released under the MIT License
|
|
@@ -3558,6 +3558,60 @@ class Datalyr {
|
|
|
3558
3558
|
this.trackError(error, { event: eventName });
|
|
3559
3559
|
}
|
|
3560
3560
|
}
|
|
3561
|
+
/**
|
|
3562
|
+
* Track an app download click and redirect to the app store.
|
|
3563
|
+
* Fires a $app_download_click event with full attribution data,
|
|
3564
|
+
* then redirects the user to the appropriate store URL.
|
|
3565
|
+
* For Android, encodes attribution params into the Play Store referrer
|
|
3566
|
+
* so the mobile SDK can retrieve them deterministically after install.
|
|
3567
|
+
*/
|
|
3568
|
+
trackAppDownloadClick(options) {
|
|
3569
|
+
if (!this.initialized) {
|
|
3570
|
+
console.warn('[Datalyr] SDK not initialized. Call init() first.');
|
|
3571
|
+
return;
|
|
3572
|
+
}
|
|
3573
|
+
if (!this.shouldTrack())
|
|
3574
|
+
return;
|
|
3575
|
+
// Fire the event with target platform info — attribution data is
|
|
3576
|
+
// automatically merged by createEventPayload via getAttributionData()
|
|
3577
|
+
this.track('$app_download_click', {
|
|
3578
|
+
target_platform: options.targetPlatform,
|
|
3579
|
+
app_store_url: options.appStoreUrl,
|
|
3580
|
+
});
|
|
3581
|
+
// Flush immediately via sendBeacon before page navigates away
|
|
3582
|
+
this.queue.forceFlush();
|
|
3583
|
+
// For Android: append referrer param to Play Store URL with click attribution
|
|
3584
|
+
if (options.targetPlatform === 'android' && options.appStoreUrl.includes('play.google.com')) {
|
|
3585
|
+
const lastTouch = this.attribution.getLastTouch();
|
|
3586
|
+
const referrerParams = new URLSearchParams();
|
|
3587
|
+
if (lastTouch === null || lastTouch === void 0 ? void 0 : lastTouch.clickId)
|
|
3588
|
+
referrerParams.set('dl_click_id', lastTouch.clickId);
|
|
3589
|
+
if (lastTouch === null || lastTouch === void 0 ? void 0 : lastTouch.clickIdType)
|
|
3590
|
+
referrerParams.set('dl_click_id_type', lastTouch.clickIdType);
|
|
3591
|
+
if (lastTouch === null || lastTouch === void 0 ? void 0 : lastTouch.source)
|
|
3592
|
+
referrerParams.set('utm_source', lastTouch.source);
|
|
3593
|
+
if (lastTouch === null || lastTouch === void 0 ? void 0 : lastTouch.medium)
|
|
3594
|
+
referrerParams.set('utm_medium', lastTouch.medium);
|
|
3595
|
+
if (lastTouch === null || lastTouch === void 0 ? void 0 : lastTouch.campaign)
|
|
3596
|
+
referrerParams.set('utm_campaign', lastTouch.campaign);
|
|
3597
|
+
if (lastTouch === null || lastTouch === void 0 ? void 0 : lastTouch.content)
|
|
3598
|
+
referrerParams.set('utm_content', lastTouch.content);
|
|
3599
|
+
if (lastTouch === null || lastTouch === void 0 ? void 0 : lastTouch.term)
|
|
3600
|
+
referrerParams.set('utm_term', lastTouch.term);
|
|
3601
|
+
try {
|
|
3602
|
+
const url = new URL(options.appStoreUrl);
|
|
3603
|
+
url.searchParams.set('referrer', referrerParams.toString());
|
|
3604
|
+
window.location.href = url.toString();
|
|
3605
|
+
}
|
|
3606
|
+
catch (_a) {
|
|
3607
|
+
// If URL parsing fails, redirect without referrer
|
|
3608
|
+
window.location.href = options.appStoreUrl;
|
|
3609
|
+
}
|
|
3610
|
+
}
|
|
3611
|
+
else {
|
|
3612
|
+
window.location.href = options.appStoreUrl;
|
|
3613
|
+
}
|
|
3614
|
+
}
|
|
3561
3615
|
/**
|
|
3562
3616
|
* Identify a user
|
|
3563
3617
|
*/
|
|
@@ -3648,10 +3702,12 @@ class Datalyr {
|
|
|
3648
3702
|
}
|
|
3649
3703
|
}
|
|
3650
3704
|
/**
|
|
3651
|
-
* Track a screen view (for SPAs)
|
|
3705
|
+
* Track a screen view (for SPAs).
|
|
3706
|
+
* Fires a `pageview` event with a `screen` property, consistent with
|
|
3707
|
+
* the React Native and iOS SDKs.
|
|
3652
3708
|
*/
|
|
3653
3709
|
screen(screenName, properties = {}) {
|
|
3654
|
-
this.track('
|
|
3710
|
+
this.track('pageview', Object.assign({ screen: screenName }, properties));
|
|
3655
3711
|
}
|
|
3656
3712
|
/**
|
|
3657
3713
|
* Associate user with a group/account
|
|
@@ -3873,7 +3929,7 @@ class Datalyr {
|
|
|
3873
3929
|
resolution_method: 'browser_sdk',
|
|
3874
3930
|
resolution_confidence: 1.0,
|
|
3875
3931
|
// SDK metadata
|
|
3876
|
-
sdk_version: '1.
|
|
3932
|
+
sdk_version: '1.4.0',
|
|
3877
3933
|
sdk_name: 'datalyr-web-sdk'
|
|
3878
3934
|
};
|
|
3879
3935
|
return payload;
|