@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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @datalyr/web v1.4.1
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
@@ -3759,6 +3759,57 @@ class Datalyr {
3759
3759
  getAnonymousId() {
3760
3760
  return this.identity.getAnonymousId();
3761
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
+ }
3762
3813
  /**
3763
3814
  * Get the current user ID
3764
3815
  */