@datalyr/web 1.4.0 → 1.5.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 +2 -2
- package/dist/datalyr.cjs.js +59 -2
- package/dist/datalyr.cjs.js.map +1 -1
- package/dist/datalyr.esm.js +59 -2
- 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 +59 -2
- 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 +48 -0
- package/dist/index.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @datalyr/web
|
|
2
2
|
|
|
3
|
-
Browser SDK for event tracking, user identity, and attribution. Version 1.4.
|
|
3
|
+
Browser SDK for event tracking, user identity, and attribution. Version 1.4.1.
|
|
4
4
|
|
|
5
5
|
## Table of Contents
|
|
6
6
|
|
|
@@ -116,7 +116,7 @@ Every event includes:
|
|
|
116
116
|
workspace_id: 'wk_xxxxx',
|
|
117
117
|
source: 'web',
|
|
118
118
|
timestamp: '2024-01-15T10:30:00Z',
|
|
119
|
-
sdk_version: '1.4.
|
|
119
|
+
sdk_version: '1.4.1',
|
|
120
120
|
sdk_name: 'datalyr-web-sdk'
|
|
121
121
|
}
|
|
122
122
|
```
|
package/dist/datalyr.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @datalyr/web v1.
|
|
2
|
+
* @datalyr/web v1.5.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
|
|
@@ -3707,6 +3707,12 @@ class Datalyr {
|
|
|
3707
3707
|
* the React Native and iOS SDKs.
|
|
3708
3708
|
*/
|
|
3709
3709
|
screen(screenName, properties = {}) {
|
|
3710
|
+
if (!this.initialized) {
|
|
3711
|
+
console.warn('[Datalyr] SDK not initialized. Call init() first.');
|
|
3712
|
+
return;
|
|
3713
|
+
}
|
|
3714
|
+
if (!this.shouldTrack())
|
|
3715
|
+
return;
|
|
3710
3716
|
this.track('pageview', Object.assign({ screen: screenName }, properties));
|
|
3711
3717
|
}
|
|
3712
3718
|
/**
|
|
@@ -3753,6 +3759,57 @@ class Datalyr {
|
|
|
3753
3759
|
getAnonymousId() {
|
|
3754
3760
|
return this.identity.getAnonymousId();
|
|
3755
3761
|
}
|
|
3762
|
+
/**
|
|
3763
|
+
* Get the current visitor ID (alias for getAnonymousId).
|
|
3764
|
+
* Matches the `visitor_id` terminology used in the dashboard, schema,
|
|
3765
|
+
* and integration guides — pass this to Stripe's `client_reference_id`
|
|
3766
|
+
* or webhook metadata for first-party attribution.
|
|
3767
|
+
*/
|
|
3768
|
+
getVisitorId() {
|
|
3769
|
+
return this.identity.getAnonymousId();
|
|
3770
|
+
}
|
|
3771
|
+
/**
|
|
3772
|
+
* Returns a metadata bundle ready to pass to Stripe so the webhook can
|
|
3773
|
+
* deterministically link the payment back to this browser session (90%+
|
|
3774
|
+
* attribution match vs. 70-85% email-only).
|
|
3775
|
+
*
|
|
3776
|
+
* Usage (Stripe Checkout Session):
|
|
3777
|
+
* stripe.checkout.sessions.create({
|
|
3778
|
+
* ...datalyr.getStripeMetadata(),
|
|
3779
|
+
* line_items: [...],
|
|
3780
|
+
* })
|
|
3781
|
+
*
|
|
3782
|
+
* Usage (PaymentIntent / Subscription / Customer):
|
|
3783
|
+
* stripe.paymentIntents.create({
|
|
3784
|
+
* amount, currency,
|
|
3785
|
+
* metadata: datalyr.getStripeMetadata().metadata,
|
|
3786
|
+
* })
|
|
3787
|
+
*
|
|
3788
|
+
* The server-side Datalyr webhook reads `client_reference_id` on Checkout
|
|
3789
|
+
* and `metadata.visitor_id` on every other Stripe object.
|
|
3790
|
+
*/
|
|
3791
|
+
getStripeMetadata() {
|
|
3792
|
+
const visitorId = this.identity.getAnonymousId();
|
|
3793
|
+
return {
|
|
3794
|
+
client_reference_id: visitorId,
|
|
3795
|
+
metadata: { visitor_id: visitorId },
|
|
3796
|
+
};
|
|
3797
|
+
}
|
|
3798
|
+
/**
|
|
3799
|
+
* Returns a metadata object ready to attach to a Whop checkout configuration.
|
|
3800
|
+
* Whop inherits checkout-configuration metadata onto payments and memberships
|
|
3801
|
+
* (https://docs.whop.com/api-reference/checkout-configurations/), so Datalyr
|
|
3802
|
+
* can read `metadata.visitor_id` off every resulting webhook event.
|
|
3803
|
+
*
|
|
3804
|
+
* Usage:
|
|
3805
|
+
* whop.checkoutConfigurations.create({
|
|
3806
|
+
* plan_id,
|
|
3807
|
+
* metadata: datalyr.getWhopCheckoutMetadata(),
|
|
3808
|
+
* })
|
|
3809
|
+
*/
|
|
3810
|
+
getWhopCheckoutMetadata() {
|
|
3811
|
+
return { visitor_id: this.identity.getAnonymousId() };
|
|
3812
|
+
}
|
|
3756
3813
|
/**
|
|
3757
3814
|
* Get the current user ID
|
|
3758
3815
|
*/
|
|
@@ -3929,7 +3986,7 @@ class Datalyr {
|
|
|
3929
3986
|
resolution_method: 'browser_sdk',
|
|
3930
3987
|
resolution_confidence: 1.0,
|
|
3931
3988
|
// SDK metadata
|
|
3932
|
-
sdk_version: '1.4.
|
|
3989
|
+
sdk_version: '1.4.1',
|
|
3933
3990
|
sdk_name: 'datalyr-web-sdk'
|
|
3934
3991
|
};
|
|
3935
3992
|
return payload;
|