Subscribes to identity and entitlement changes (ChangeEvent);
returns the function that unsubscribes. The React hooks stay current
through this. A listener runs synchronously, inside the call that made
the change; one that throws is ignored. Read getCachedEntitlements()
on ENTITLEMENTS_CHANGED rather than calling getEntitlements(), which
can fire the event again.
Opens Stripe's customer portal for the current subscriber and returns the URL to send the browser to (cancel, change card, invoices).
The customer is always the one the server has on record for this
rovenueId — nothing here names it. returnUrl follows checkout()'s rule:
one of the key's allowed origins (exact scheme, host and port) or a
verified custom domain over https.
Throws a RovenueApiError: 404 with code
STRIPE_CUSTOMER_NOT_FOUND when the subscriber has no Stripe
billing, 409 with code STRIPE_PORTAL_NOT_CONFIGURED when the
connected Stripe account has no customer portal settings, 400
RETURN_URL_NOT_ALLOWED, 503 STRIPE_NOT_CONNECTED.
Starts a Stripe Checkout and returns the URL to send the browser to.
The caller names a package, never a price: the amount is resolved server-side from the offering, so a page that lies about what something costs changes nothing about what is charged.
Redirect URLs must be on one of the key's allowed origins (exact scheme, host and port) or a verified custom domain over https.
allowPromotionCodes: true shows Stripe Checkout's promotion-code
field; the codes are the connected Stripe account's own promotion codes.
Attempts every queued event once. Called automatically on unload.
Last-known entitlements, or null if nothing has been fetched yet.
Synchronous and network-free, so a first paint can render the truth the server gave last time instead of a flash of the paywall a subscriber has already paid to remove. It is a cache, never an authorization decision: the storage behind it is viewer-editable.
The cache entry with its timestamp, for callers that need staleness.
Binds this browser to appUserId on the server, then sets the local
identity. Posts /identify with the identity token your backend minted
for that user (POST /v1/identity-tokens, secret key, valid 15 minutes).
The local identity changes only after the server answers 2xx. Any other outcome rejects and leaves the previous identity as it was: a RovenueApiError with 400 (no token), 401 IDENTITY_TOKEN_INVALID (bad or expired token), or another status; a network failure rejects with the underlying error. Identify again with a fresh token.
Flushes queued events under the current identity, then rotates it. The flush is given LOGOUT_FLUSH_TIMEOUT_MS; events not delivered by then are dropped, never sent as the next identity.
Records that a subscriber was shown an experiment variant.
Assignment alone is invisible to the analytics: a visitor bucketed into
an arm but missing from exposure_events still contributes revenue while
being absent from the denominator, which biases conversion rates and
breaks the sample-ratio check. The native path fires this immediately
after the draw; so does the web one.
The wire identity for this browser.
Registers the unload listeners that flush queued events.
Not called by configure(): configure() also runs during server rendering, where there is nothing to listen to. The React provider calls this in an effect; a non-React host calls it once after construction.
Queues an event for at-least-once delivery.
Returns immediately: the event is persisted and sent by the queue, which retries across page loads and flushes when the tab is hidden or closing.
Escape hatch for endpoints without a typed wrapper yet.