@datalyr/web 1.4.1 → 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/dist/datalyr.cjs.js +52 -1
- package/dist/datalyr.cjs.js.map +1 -1
- package/dist/datalyr.esm.js +52 -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 +52 -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 +48 -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.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
|
|
@@ -3757,6 +3757,57 @@ class Datalyr {
|
|
|
3757
3757
|
getAnonymousId() {
|
|
3758
3758
|
return this.identity.getAnonymousId();
|
|
3759
3759
|
}
|
|
3760
|
+
/**
|
|
3761
|
+
* Get the current visitor ID (alias for getAnonymousId).
|
|
3762
|
+
* Matches the `visitor_id` terminology used in the dashboard, schema,
|
|
3763
|
+
* and integration guides — pass this to Stripe's `client_reference_id`
|
|
3764
|
+
* or webhook metadata for first-party attribution.
|
|
3765
|
+
*/
|
|
3766
|
+
getVisitorId() {
|
|
3767
|
+
return this.identity.getAnonymousId();
|
|
3768
|
+
}
|
|
3769
|
+
/**
|
|
3770
|
+
* Returns a metadata bundle ready to pass to Stripe so the webhook can
|
|
3771
|
+
* deterministically link the payment back to this browser session (90%+
|
|
3772
|
+
* attribution match vs. 70-85% email-only).
|
|
3773
|
+
*
|
|
3774
|
+
* Usage (Stripe Checkout Session):
|
|
3775
|
+
* stripe.checkout.sessions.create({
|
|
3776
|
+
* ...datalyr.getStripeMetadata(),
|
|
3777
|
+
* line_items: [...],
|
|
3778
|
+
* })
|
|
3779
|
+
*
|
|
3780
|
+
* Usage (PaymentIntent / Subscription / Customer):
|
|
3781
|
+
* stripe.paymentIntents.create({
|
|
3782
|
+
* amount, currency,
|
|
3783
|
+
* metadata: datalyr.getStripeMetadata().metadata,
|
|
3784
|
+
* })
|
|
3785
|
+
*
|
|
3786
|
+
* The server-side Datalyr webhook reads `client_reference_id` on Checkout
|
|
3787
|
+
* and `metadata.visitor_id` on every other Stripe object.
|
|
3788
|
+
*/
|
|
3789
|
+
getStripeMetadata() {
|
|
3790
|
+
const visitorId = this.identity.getAnonymousId();
|
|
3791
|
+
return {
|
|
3792
|
+
client_reference_id: visitorId,
|
|
3793
|
+
metadata: { visitor_id: visitorId },
|
|
3794
|
+
};
|
|
3795
|
+
}
|
|
3796
|
+
/**
|
|
3797
|
+
* Returns a metadata object ready to attach to a Whop checkout configuration.
|
|
3798
|
+
* Whop inherits checkout-configuration metadata onto payments and memberships
|
|
3799
|
+
* (https://docs.whop.com/api-reference/checkout-configurations/), so Datalyr
|
|
3800
|
+
* can read `metadata.visitor_id` off every resulting webhook event.
|
|
3801
|
+
*
|
|
3802
|
+
* Usage:
|
|
3803
|
+
* whop.checkoutConfigurations.create({
|
|
3804
|
+
* plan_id,
|
|
3805
|
+
* metadata: datalyr.getWhopCheckoutMetadata(),
|
|
3806
|
+
* })
|
|
3807
|
+
*/
|
|
3808
|
+
getWhopCheckoutMetadata() {
|
|
3809
|
+
return { visitor_id: this.identity.getAnonymousId() };
|
|
3810
|
+
}
|
|
3760
3811
|
/**
|
|
3761
3812
|
* Get the current user ID
|
|
3762
3813
|
*/
|