@datalyr/web 1.2.2 → 1.3.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 +45 -0
- package/dist/datalyr.cjs.js +55 -1
- package/dist/datalyr.cjs.js.map +1 -1
- package/dist/datalyr.esm.js +55 -1
- 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 +55 -1
- 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 +11 -0
- package/dist/index.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/datalyr.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @datalyr/web v1.
|
|
2
|
+
* @datalyr/web v1.3.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
|
|
@@ -3556,6 +3556,60 @@ class Datalyr {
|
|
|
3556
3556
|
this.trackError(error, { event: eventName });
|
|
3557
3557
|
}
|
|
3558
3558
|
}
|
|
3559
|
+
/**
|
|
3560
|
+
* Track an app download click and redirect to the app store.
|
|
3561
|
+
* Fires a $app_download_click event with full attribution data,
|
|
3562
|
+
* then redirects the user to the appropriate store URL.
|
|
3563
|
+
* For Android, encodes attribution params into the Play Store referrer
|
|
3564
|
+
* so the mobile SDK can retrieve them deterministically after install.
|
|
3565
|
+
*/
|
|
3566
|
+
trackAppDownloadClick(options) {
|
|
3567
|
+
if (!this.initialized) {
|
|
3568
|
+
console.warn('[Datalyr] SDK not initialized. Call init() first.');
|
|
3569
|
+
return;
|
|
3570
|
+
}
|
|
3571
|
+
if (!this.shouldTrack())
|
|
3572
|
+
return;
|
|
3573
|
+
// Fire the event with target platform info — attribution data is
|
|
3574
|
+
// automatically merged by createEventPayload via getAttributionData()
|
|
3575
|
+
this.track('$app_download_click', {
|
|
3576
|
+
target_platform: options.targetPlatform,
|
|
3577
|
+
app_store_url: options.appStoreUrl,
|
|
3578
|
+
});
|
|
3579
|
+
// Flush immediately via sendBeacon before page navigates away
|
|
3580
|
+
this.queue.forceFlush();
|
|
3581
|
+
// For Android: append referrer param to Play Store URL with click attribution
|
|
3582
|
+
if (options.targetPlatform === 'android' && options.appStoreUrl.includes('play.google.com')) {
|
|
3583
|
+
const lastTouch = this.attribution.getLastTouch();
|
|
3584
|
+
const referrerParams = new URLSearchParams();
|
|
3585
|
+
if (lastTouch === null || lastTouch === void 0 ? void 0 : lastTouch.clickId)
|
|
3586
|
+
referrerParams.set('dl_click_id', lastTouch.clickId);
|
|
3587
|
+
if (lastTouch === null || lastTouch === void 0 ? void 0 : lastTouch.clickIdType)
|
|
3588
|
+
referrerParams.set('dl_click_id_type', lastTouch.clickIdType);
|
|
3589
|
+
if (lastTouch === null || lastTouch === void 0 ? void 0 : lastTouch.source)
|
|
3590
|
+
referrerParams.set('utm_source', lastTouch.source);
|
|
3591
|
+
if (lastTouch === null || lastTouch === void 0 ? void 0 : lastTouch.medium)
|
|
3592
|
+
referrerParams.set('utm_medium', lastTouch.medium);
|
|
3593
|
+
if (lastTouch === null || lastTouch === void 0 ? void 0 : lastTouch.campaign)
|
|
3594
|
+
referrerParams.set('utm_campaign', lastTouch.campaign);
|
|
3595
|
+
if (lastTouch === null || lastTouch === void 0 ? void 0 : lastTouch.content)
|
|
3596
|
+
referrerParams.set('utm_content', lastTouch.content);
|
|
3597
|
+
if (lastTouch === null || lastTouch === void 0 ? void 0 : lastTouch.term)
|
|
3598
|
+
referrerParams.set('utm_term', lastTouch.term);
|
|
3599
|
+
try {
|
|
3600
|
+
const url = new URL(options.appStoreUrl);
|
|
3601
|
+
url.searchParams.set('referrer', referrerParams.toString());
|
|
3602
|
+
window.location.href = url.toString();
|
|
3603
|
+
}
|
|
3604
|
+
catch (_a) {
|
|
3605
|
+
// If URL parsing fails, redirect without referrer
|
|
3606
|
+
window.location.href = options.appStoreUrl;
|
|
3607
|
+
}
|
|
3608
|
+
}
|
|
3609
|
+
else {
|
|
3610
|
+
window.location.href = options.appStoreUrl;
|
|
3611
|
+
}
|
|
3612
|
+
}
|
|
3559
3613
|
/**
|
|
3560
3614
|
* Identify a user
|
|
3561
3615
|
*/
|