Rovenue Web SDK
    Preparing search index...

    Interface Rovenue

    interface Rovenue {
        http: HttpClient;
        identity: Identity;
        addChangeListener(listener: (event: ChangeEvent) => void): () => void;
        billingPortal(input: { returnUrl: string }): Promise<BillingPortalResult>;
        checkout(
            input: {
                allowPromotionCodes?: boolean;
                cancelUrl: string;
                idempotencyKey?: string;
                offeringIdentifier: string;
                packageIdentifier: string;
                successUrl: string;
            },
        ): Promise<CheckoutResult>;
        flushEvents(): Promise<void>;
        getCachedEntitlements(): Record<string, unknown> | null;
        getCachedEntitlementsEntry(): CachedEntitlements | null;
        getEntitlements(): Promise<Record<string, unknown>>;
        getOfferings(): Promise<WebOfferingsResponse>;
        getPlacement(identifier: string): Promise<unknown>;
        identify(appUserId: string, opts: { identityToken: string }): Promise<void>;
        logOut(): Promise<void>;
        recordExposure(
            input: {
                experimentId: string;
                placementId?: string;
                variantId: string;
            },
        ): Promise<void>;
        rovenueId(): string;
        startEventQueue(): void;
        stopEventQueue(): void;
        track(input: TrackInput): void;
    }
    Index
    http: HttpClient

    Escape hatch for endpoints without a typed wrapper yet.

    identity: Identity
    • 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.

      Parameters

      Returns () => void

    • 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.

      Parameters

      • input: { returnUrl: string }

      Returns Promise<BillingPortalResult>

    • 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.

      Parameters

      • input: {
            allowPromotionCodes?: boolean;
            cancelUrl: string;
            idempotencyKey?: string;
            offeringIdentifier: string;
            packageIdentifier: string;
            successUrl: string;
        }

      Returns Promise<CheckoutResult>

    • Attempts every queued event once. Called automatically on unload.

      Returns Promise<void>

    • 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.

      Returns Record<string, unknown> | null

    • The cache entry with its timestamp, for callers that need staleness.

      Returns CachedEntitlements | null

    • Returns Promise<Record<string, unknown>>

    • Parameters

      • identifier: string

      Returns Promise<unknown>

    • 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.

      Parameters

      • appUserId: string
      • opts: { identityToken: string }

      Returns Promise<void>

    • 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.

      Returns Promise<void>

    • 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.

      Parameters

      • input: { experimentId: string; placementId?: string; variantId: string }

      Returns Promise<void>

    • The wire identity for this browser.

      Returns string

    • 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.

      Returns void

    • Returns void

    • 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.

      Parameters

      Returns void