@rovenue/web-sdk 0.0.0-stage → 0.16.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/LICENSE +21 -0
- package/dist/chunk-4DE2IREA.cjs +9 -0
- package/dist/chunk-4DE2IREA.cjs.map +1 -0
- package/dist/chunk-V6TY7KAL.js +7 -0
- package/dist/chunk-V6TY7KAL.js.map +1 -0
- package/dist/index.cjs +373 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +222 -0
- package/dist/index.d.ts +222 -0
- package/dist/index.js +368 -0
- package/dist/index.js.map +1 -0
- package/dist/react.cjs +108 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +67 -0
- package/dist/react.d.ts +67 -0
- package/dist/react.js +102 -0
- package/dist/react.js.map +1 -0
- package/package.json +57 -4
- package/README.md +0 -3
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
interface SdkStorage {
|
|
2
|
+
get(key: string): string | null;
|
|
3
|
+
set(key: string, value: string): void;
|
|
4
|
+
remove(key: string): void;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* In-memory storage. The default, and the fallback whenever a real store is
|
|
8
|
+
* unavailable.
|
|
9
|
+
*
|
|
10
|
+
* Nothing here throws: a viewer whose browser refuses storage must still get
|
|
11
|
+
* a working SDK, just one that forgets between page loads.
|
|
12
|
+
*/
|
|
13
|
+
declare function createMemoryStorage(): SdkStorage;
|
|
14
|
+
/**
|
|
15
|
+
* Storage backed by `localStorage` where it works, memory where it does not.
|
|
16
|
+
*
|
|
17
|
+
* `localStorage` fails in three different ways and only the first is caught
|
|
18
|
+
* by asking whether it is defined:
|
|
19
|
+
*
|
|
20
|
+
* 1. **Absent** — server-side rendering. This is why the probe runs on
|
|
21
|
+
* first use and never at module scope: an access during import throws
|
|
22
|
+
* before any consumer could guard it.
|
|
23
|
+
* 2. **Present but throwing** — Safari private mode, and browsers with
|
|
24
|
+
* site data blocked. `typeof localStorage` is `"object"` and the first
|
|
25
|
+
* write raises.
|
|
26
|
+
* 3. **Present and full** — a quota error on a write, long after the probe
|
|
27
|
+
* said everything was fine. So every operation is guarded, not just the
|
|
28
|
+
* probe: a store that passed once can still fail later.
|
|
29
|
+
*
|
|
30
|
+
* A failed write drops the value and returns. Losing a cached entitlement is
|
|
31
|
+
* a lost convenience; taking the host application down over it is not a
|
|
32
|
+
* trade the SDK gets to make on the developer's behalf.
|
|
33
|
+
*/
|
|
34
|
+
declare function createStorage(): SdkStorage;
|
|
35
|
+
|
|
36
|
+
interface Identity {
|
|
37
|
+
/** The permanent wire identity for this browser. */
|
|
38
|
+
rovenueId(): string;
|
|
39
|
+
/** The host application's own name for this person, if it set one. */
|
|
40
|
+
appUserScope(): string | null;
|
|
41
|
+
identify(appUserId: string): void;
|
|
42
|
+
/** Forgets both, and mints a fresh rovenueId. */
|
|
43
|
+
logOut(): void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
declare class RovenueApiError extends Error {
|
|
47
|
+
readonly status: number;
|
|
48
|
+
readonly code: string;
|
|
49
|
+
constructor(status: number, code: string, message: string);
|
|
50
|
+
}
|
|
51
|
+
interface HttpClient {
|
|
52
|
+
get<T>(path: string): Promise<T>;
|
|
53
|
+
post<T>(path: string, body: unknown, init?: {
|
|
54
|
+
idempotencyKey?: string;
|
|
55
|
+
keepalive?: boolean;
|
|
56
|
+
}): Promise<T>;
|
|
57
|
+
/** Absolute base, e.g. `https://api.example/v1/web/pk_live_x`. */
|
|
58
|
+
readonly baseUrl: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface CachedEntitlements {
|
|
62
|
+
entitlements: Record<string, unknown>;
|
|
63
|
+
/** Epoch millis of the response this came from. */
|
|
64
|
+
fetchedAt: number;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Wire format version the server expects (EVENT_WIRE_VERSION). */
|
|
68
|
+
declare const EVENT_WIRE_VERSION = 1;
|
|
69
|
+
interface TrackInput {
|
|
70
|
+
eventType: string;
|
|
71
|
+
occurredAt?: string;
|
|
72
|
+
subscriberId?: string;
|
|
73
|
+
productId?: string;
|
|
74
|
+
amount?: string;
|
|
75
|
+
currency?: string;
|
|
76
|
+
eventSourceUrl?: string;
|
|
77
|
+
}
|
|
78
|
+
interface QueuedEvent extends TrackInput {
|
|
79
|
+
version: typeof EVENT_WIRE_VERSION;
|
|
80
|
+
eventId: string;
|
|
81
|
+
occurredAt: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface RovenueOptions {
|
|
85
|
+
/** The project's PUBLIC api key. Visible in the browser by design. */
|
|
86
|
+
apiKey: string;
|
|
87
|
+
/** Base URL of the Rovenue API, without a trailing path. */
|
|
88
|
+
apiUrl: string;
|
|
89
|
+
/** Injected for tests and for hosts that wrap fetch. */
|
|
90
|
+
fetchImpl?: typeof fetch;
|
|
91
|
+
/**
|
|
92
|
+
* Where the rovenueId, the entitlement cache and the event queue persist.
|
|
93
|
+
*
|
|
94
|
+
* Defaults to {@link createStorage}, which uses `localStorage` where it
|
|
95
|
+
* works and falls back to memory where it does not — including during
|
|
96
|
+
* server rendering. Defaulting to memory instead would silently mint a new
|
|
97
|
+
* subscriber on every page load, orphaning the cache and the queue with it,
|
|
98
|
+
* and would only be correct for developers who read the docs.
|
|
99
|
+
*/
|
|
100
|
+
storage?: SdkStorage;
|
|
101
|
+
}
|
|
102
|
+
interface EntitlementsResponse {
|
|
103
|
+
entitlements: Record<string, unknown>;
|
|
104
|
+
}
|
|
105
|
+
interface CheckoutResult {
|
|
106
|
+
sessionId: string;
|
|
107
|
+
url: string;
|
|
108
|
+
}
|
|
109
|
+
/** One package slot of an offering, as GET /v1/offerings serves it. */
|
|
110
|
+
interface WebPackage {
|
|
111
|
+
/** The package slot id — what {@link Rovenue.checkout} takes as `packageIdentifier`. */
|
|
112
|
+
packageIdentifier: string;
|
|
113
|
+
/** The product's own identifier. Not accepted by checkout(). */
|
|
114
|
+
identifier: string;
|
|
115
|
+
/** The product type, e.g. `SUBSCRIPTION`. Web checkout sells subscriptions only. */
|
|
116
|
+
type: string;
|
|
117
|
+
/** The product's display name as configured in the dashboard. */
|
|
118
|
+
displayName: string;
|
|
119
|
+
/** The package's position within its offering, ascending. */
|
|
120
|
+
order: number;
|
|
121
|
+
/** Whether the dashboard marked this package as the one to highlight. */
|
|
122
|
+
isPromoted: boolean;
|
|
123
|
+
/** Identifiers of the accesses (entitlements) a purchase grants. */
|
|
124
|
+
accessIds: string[];
|
|
125
|
+
/** The product's store identifiers, keyed by store (e.g. `stripe`). */
|
|
126
|
+
storeIds: Record<string, string>;
|
|
127
|
+
/** Free-form metadata set on this package slot in the offering. */
|
|
128
|
+
metadata: unknown;
|
|
129
|
+
}
|
|
130
|
+
/** An offering — `identifier` is what {@link Rovenue.checkout} takes as `offeringIdentifier`. */
|
|
131
|
+
interface WebOffering {
|
|
132
|
+
/** The offering's identifier — pass it to checkout() as `offeringIdentifier`. */
|
|
133
|
+
identifier: string;
|
|
134
|
+
/** Whether this is the project's default (current) offering. */
|
|
135
|
+
isDefault: boolean;
|
|
136
|
+
/** The offering's package slots, in display order. */
|
|
137
|
+
packages: WebPackage[];
|
|
138
|
+
/** Free-form offering metadata from the dashboard. */
|
|
139
|
+
metadata: unknown;
|
|
140
|
+
}
|
|
141
|
+
/** The body of GET /v1/offerings. */
|
|
142
|
+
interface WebOfferingsResponse {
|
|
143
|
+
/** The project's offerings, as served to this subscriber. */
|
|
144
|
+
offerings: WebOffering[];
|
|
145
|
+
}
|
|
146
|
+
interface Rovenue {
|
|
147
|
+
/** The wire identity for this browser. */
|
|
148
|
+
rovenueId(): string;
|
|
149
|
+
/** Client-local. Merging subscribers is a server-side, secret-key operation. */
|
|
150
|
+
identify(appUserId: string): void;
|
|
151
|
+
/** Flushes queued events under the current identity, then rotates it. */
|
|
152
|
+
logOut(): Promise<void>;
|
|
153
|
+
getEntitlements(): Promise<Record<string, unknown>>;
|
|
154
|
+
/**
|
|
155
|
+
* Last-known entitlements, or null if nothing has been fetched yet.
|
|
156
|
+
*
|
|
157
|
+
* Synchronous and network-free, so a first paint can render the truth the
|
|
158
|
+
* server gave last time instead of a flash of the paywall a subscriber has
|
|
159
|
+
* already paid to remove. It is a cache, never an authorization decision:
|
|
160
|
+
* the storage behind it is viewer-editable.
|
|
161
|
+
*/
|
|
162
|
+
getCachedEntitlements(): Record<string, unknown> | null;
|
|
163
|
+
/** The cache entry with its timestamp, for callers that need staleness. */
|
|
164
|
+
getCachedEntitlementsEntry(): CachedEntitlements | null;
|
|
165
|
+
/**
|
|
166
|
+
* Queues an event for at-least-once delivery.
|
|
167
|
+
*
|
|
168
|
+
* Returns immediately: the event is persisted and sent by the queue, which
|
|
169
|
+
* retries across page loads and flushes when the tab is hidden or closing.
|
|
170
|
+
*/
|
|
171
|
+
track(input: TrackInput): void;
|
|
172
|
+
/** Attempts every queued event once. Called automatically on unload. */
|
|
173
|
+
flushEvents(): Promise<void>;
|
|
174
|
+
/**
|
|
175
|
+
* Registers the unload listeners that flush queued events.
|
|
176
|
+
*
|
|
177
|
+
* Not called by configure(): configure() also runs during server
|
|
178
|
+
* rendering, where there is nothing to listen to. The React provider calls
|
|
179
|
+
* this in an effect; a non-React host calls it once after construction.
|
|
180
|
+
*/
|
|
181
|
+
startEventQueue(): void;
|
|
182
|
+
stopEventQueue(): void;
|
|
183
|
+
/**
|
|
184
|
+
* Records that a subscriber was shown an experiment variant.
|
|
185
|
+
*
|
|
186
|
+
* Assignment alone is invisible to the analytics: a visitor bucketed into
|
|
187
|
+
* an arm but missing from `exposure_events` still contributes revenue while
|
|
188
|
+
* being absent from the denominator, which biases conversion rates and
|
|
189
|
+
* breaks the sample-ratio check. The native path fires this immediately
|
|
190
|
+
* after the draw; so does the web one.
|
|
191
|
+
*/
|
|
192
|
+
recordExposure(input: {
|
|
193
|
+
experimentId: string;
|
|
194
|
+
variantId: string;
|
|
195
|
+
placementId?: string;
|
|
196
|
+
}): Promise<void>;
|
|
197
|
+
getOfferings(): Promise<WebOfferingsResponse>;
|
|
198
|
+
getPlacement(identifier: string): Promise<unknown>;
|
|
199
|
+
/**
|
|
200
|
+
* Starts a Stripe Checkout and returns the URL to send the browser to.
|
|
201
|
+
*
|
|
202
|
+
* The caller names a package, never a price: the amount is resolved
|
|
203
|
+
* server-side from the offering, so a page that lies about what something
|
|
204
|
+
* costs changes nothing about what is charged.
|
|
205
|
+
*
|
|
206
|
+
* Redirect URLs must be on one of the key's allowed origins (exact scheme,
|
|
207
|
+
* host and port) or a verified custom domain over https.
|
|
208
|
+
*/
|
|
209
|
+
checkout(input: {
|
|
210
|
+
offeringIdentifier: string;
|
|
211
|
+
packageIdentifier: string;
|
|
212
|
+
successUrl: string;
|
|
213
|
+
cancelUrl: string;
|
|
214
|
+
idempotencyKey?: string;
|
|
215
|
+
}): Promise<CheckoutResult>;
|
|
216
|
+
/** Escape hatch for endpoints without a typed wrapper yet. */
|
|
217
|
+
readonly http: HttpClient;
|
|
218
|
+
readonly identity: Identity;
|
|
219
|
+
}
|
|
220
|
+
declare function configure(options: RovenueOptions): Rovenue;
|
|
221
|
+
|
|
222
|
+
export { type CachedEntitlements, type CheckoutResult, type EntitlementsResponse, type QueuedEvent, type Rovenue, RovenueApiError, type RovenueOptions, type SdkStorage, type TrackInput, type WebOffering, type WebOfferingsResponse, type WebPackage, configure, createMemoryStorage, createStorage };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
interface SdkStorage {
|
|
2
|
+
get(key: string): string | null;
|
|
3
|
+
set(key: string, value: string): void;
|
|
4
|
+
remove(key: string): void;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* In-memory storage. The default, and the fallback whenever a real store is
|
|
8
|
+
* unavailable.
|
|
9
|
+
*
|
|
10
|
+
* Nothing here throws: a viewer whose browser refuses storage must still get
|
|
11
|
+
* a working SDK, just one that forgets between page loads.
|
|
12
|
+
*/
|
|
13
|
+
declare function createMemoryStorage(): SdkStorage;
|
|
14
|
+
/**
|
|
15
|
+
* Storage backed by `localStorage` where it works, memory where it does not.
|
|
16
|
+
*
|
|
17
|
+
* `localStorage` fails in three different ways and only the first is caught
|
|
18
|
+
* by asking whether it is defined:
|
|
19
|
+
*
|
|
20
|
+
* 1. **Absent** — server-side rendering. This is why the probe runs on
|
|
21
|
+
* first use and never at module scope: an access during import throws
|
|
22
|
+
* before any consumer could guard it.
|
|
23
|
+
* 2. **Present but throwing** — Safari private mode, and browsers with
|
|
24
|
+
* site data blocked. `typeof localStorage` is `"object"` and the first
|
|
25
|
+
* write raises.
|
|
26
|
+
* 3. **Present and full** — a quota error on a write, long after the probe
|
|
27
|
+
* said everything was fine. So every operation is guarded, not just the
|
|
28
|
+
* probe: a store that passed once can still fail later.
|
|
29
|
+
*
|
|
30
|
+
* A failed write drops the value and returns. Losing a cached entitlement is
|
|
31
|
+
* a lost convenience; taking the host application down over it is not a
|
|
32
|
+
* trade the SDK gets to make on the developer's behalf.
|
|
33
|
+
*/
|
|
34
|
+
declare function createStorage(): SdkStorage;
|
|
35
|
+
|
|
36
|
+
interface Identity {
|
|
37
|
+
/** The permanent wire identity for this browser. */
|
|
38
|
+
rovenueId(): string;
|
|
39
|
+
/** The host application's own name for this person, if it set one. */
|
|
40
|
+
appUserScope(): string | null;
|
|
41
|
+
identify(appUserId: string): void;
|
|
42
|
+
/** Forgets both, and mints a fresh rovenueId. */
|
|
43
|
+
logOut(): void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
declare class RovenueApiError extends Error {
|
|
47
|
+
readonly status: number;
|
|
48
|
+
readonly code: string;
|
|
49
|
+
constructor(status: number, code: string, message: string);
|
|
50
|
+
}
|
|
51
|
+
interface HttpClient {
|
|
52
|
+
get<T>(path: string): Promise<T>;
|
|
53
|
+
post<T>(path: string, body: unknown, init?: {
|
|
54
|
+
idempotencyKey?: string;
|
|
55
|
+
keepalive?: boolean;
|
|
56
|
+
}): Promise<T>;
|
|
57
|
+
/** Absolute base, e.g. `https://api.example/v1/web/pk_live_x`. */
|
|
58
|
+
readonly baseUrl: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
interface CachedEntitlements {
|
|
62
|
+
entitlements: Record<string, unknown>;
|
|
63
|
+
/** Epoch millis of the response this came from. */
|
|
64
|
+
fetchedAt: number;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Wire format version the server expects (EVENT_WIRE_VERSION). */
|
|
68
|
+
declare const EVENT_WIRE_VERSION = 1;
|
|
69
|
+
interface TrackInput {
|
|
70
|
+
eventType: string;
|
|
71
|
+
occurredAt?: string;
|
|
72
|
+
subscriberId?: string;
|
|
73
|
+
productId?: string;
|
|
74
|
+
amount?: string;
|
|
75
|
+
currency?: string;
|
|
76
|
+
eventSourceUrl?: string;
|
|
77
|
+
}
|
|
78
|
+
interface QueuedEvent extends TrackInput {
|
|
79
|
+
version: typeof EVENT_WIRE_VERSION;
|
|
80
|
+
eventId: string;
|
|
81
|
+
occurredAt: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface RovenueOptions {
|
|
85
|
+
/** The project's PUBLIC api key. Visible in the browser by design. */
|
|
86
|
+
apiKey: string;
|
|
87
|
+
/** Base URL of the Rovenue API, without a trailing path. */
|
|
88
|
+
apiUrl: string;
|
|
89
|
+
/** Injected for tests and for hosts that wrap fetch. */
|
|
90
|
+
fetchImpl?: typeof fetch;
|
|
91
|
+
/**
|
|
92
|
+
* Where the rovenueId, the entitlement cache and the event queue persist.
|
|
93
|
+
*
|
|
94
|
+
* Defaults to {@link createStorage}, which uses `localStorage` where it
|
|
95
|
+
* works and falls back to memory where it does not — including during
|
|
96
|
+
* server rendering. Defaulting to memory instead would silently mint a new
|
|
97
|
+
* subscriber on every page load, orphaning the cache and the queue with it,
|
|
98
|
+
* and would only be correct for developers who read the docs.
|
|
99
|
+
*/
|
|
100
|
+
storage?: SdkStorage;
|
|
101
|
+
}
|
|
102
|
+
interface EntitlementsResponse {
|
|
103
|
+
entitlements: Record<string, unknown>;
|
|
104
|
+
}
|
|
105
|
+
interface CheckoutResult {
|
|
106
|
+
sessionId: string;
|
|
107
|
+
url: string;
|
|
108
|
+
}
|
|
109
|
+
/** One package slot of an offering, as GET /v1/offerings serves it. */
|
|
110
|
+
interface WebPackage {
|
|
111
|
+
/** The package slot id — what {@link Rovenue.checkout} takes as `packageIdentifier`. */
|
|
112
|
+
packageIdentifier: string;
|
|
113
|
+
/** The product's own identifier. Not accepted by checkout(). */
|
|
114
|
+
identifier: string;
|
|
115
|
+
/** The product type, e.g. `SUBSCRIPTION`. Web checkout sells subscriptions only. */
|
|
116
|
+
type: string;
|
|
117
|
+
/** The product's display name as configured in the dashboard. */
|
|
118
|
+
displayName: string;
|
|
119
|
+
/** The package's position within its offering, ascending. */
|
|
120
|
+
order: number;
|
|
121
|
+
/** Whether the dashboard marked this package as the one to highlight. */
|
|
122
|
+
isPromoted: boolean;
|
|
123
|
+
/** Identifiers of the accesses (entitlements) a purchase grants. */
|
|
124
|
+
accessIds: string[];
|
|
125
|
+
/** The product's store identifiers, keyed by store (e.g. `stripe`). */
|
|
126
|
+
storeIds: Record<string, string>;
|
|
127
|
+
/** Free-form metadata set on this package slot in the offering. */
|
|
128
|
+
metadata: unknown;
|
|
129
|
+
}
|
|
130
|
+
/** An offering — `identifier` is what {@link Rovenue.checkout} takes as `offeringIdentifier`. */
|
|
131
|
+
interface WebOffering {
|
|
132
|
+
/** The offering's identifier — pass it to checkout() as `offeringIdentifier`. */
|
|
133
|
+
identifier: string;
|
|
134
|
+
/** Whether this is the project's default (current) offering. */
|
|
135
|
+
isDefault: boolean;
|
|
136
|
+
/** The offering's package slots, in display order. */
|
|
137
|
+
packages: WebPackage[];
|
|
138
|
+
/** Free-form offering metadata from the dashboard. */
|
|
139
|
+
metadata: unknown;
|
|
140
|
+
}
|
|
141
|
+
/** The body of GET /v1/offerings. */
|
|
142
|
+
interface WebOfferingsResponse {
|
|
143
|
+
/** The project's offerings, as served to this subscriber. */
|
|
144
|
+
offerings: WebOffering[];
|
|
145
|
+
}
|
|
146
|
+
interface Rovenue {
|
|
147
|
+
/** The wire identity for this browser. */
|
|
148
|
+
rovenueId(): string;
|
|
149
|
+
/** Client-local. Merging subscribers is a server-side, secret-key operation. */
|
|
150
|
+
identify(appUserId: string): void;
|
|
151
|
+
/** Flushes queued events under the current identity, then rotates it. */
|
|
152
|
+
logOut(): Promise<void>;
|
|
153
|
+
getEntitlements(): Promise<Record<string, unknown>>;
|
|
154
|
+
/**
|
|
155
|
+
* Last-known entitlements, or null if nothing has been fetched yet.
|
|
156
|
+
*
|
|
157
|
+
* Synchronous and network-free, so a first paint can render the truth the
|
|
158
|
+
* server gave last time instead of a flash of the paywall a subscriber has
|
|
159
|
+
* already paid to remove. It is a cache, never an authorization decision:
|
|
160
|
+
* the storage behind it is viewer-editable.
|
|
161
|
+
*/
|
|
162
|
+
getCachedEntitlements(): Record<string, unknown> | null;
|
|
163
|
+
/** The cache entry with its timestamp, for callers that need staleness. */
|
|
164
|
+
getCachedEntitlementsEntry(): CachedEntitlements | null;
|
|
165
|
+
/**
|
|
166
|
+
* Queues an event for at-least-once delivery.
|
|
167
|
+
*
|
|
168
|
+
* Returns immediately: the event is persisted and sent by the queue, which
|
|
169
|
+
* retries across page loads and flushes when the tab is hidden or closing.
|
|
170
|
+
*/
|
|
171
|
+
track(input: TrackInput): void;
|
|
172
|
+
/** Attempts every queued event once. Called automatically on unload. */
|
|
173
|
+
flushEvents(): Promise<void>;
|
|
174
|
+
/**
|
|
175
|
+
* Registers the unload listeners that flush queued events.
|
|
176
|
+
*
|
|
177
|
+
* Not called by configure(): configure() also runs during server
|
|
178
|
+
* rendering, where there is nothing to listen to. The React provider calls
|
|
179
|
+
* this in an effect; a non-React host calls it once after construction.
|
|
180
|
+
*/
|
|
181
|
+
startEventQueue(): void;
|
|
182
|
+
stopEventQueue(): void;
|
|
183
|
+
/**
|
|
184
|
+
* Records that a subscriber was shown an experiment variant.
|
|
185
|
+
*
|
|
186
|
+
* Assignment alone is invisible to the analytics: a visitor bucketed into
|
|
187
|
+
* an arm but missing from `exposure_events` still contributes revenue while
|
|
188
|
+
* being absent from the denominator, which biases conversion rates and
|
|
189
|
+
* breaks the sample-ratio check. The native path fires this immediately
|
|
190
|
+
* after the draw; so does the web one.
|
|
191
|
+
*/
|
|
192
|
+
recordExposure(input: {
|
|
193
|
+
experimentId: string;
|
|
194
|
+
variantId: string;
|
|
195
|
+
placementId?: string;
|
|
196
|
+
}): Promise<void>;
|
|
197
|
+
getOfferings(): Promise<WebOfferingsResponse>;
|
|
198
|
+
getPlacement(identifier: string): Promise<unknown>;
|
|
199
|
+
/**
|
|
200
|
+
* Starts a Stripe Checkout and returns the URL to send the browser to.
|
|
201
|
+
*
|
|
202
|
+
* The caller names a package, never a price: the amount is resolved
|
|
203
|
+
* server-side from the offering, so a page that lies about what something
|
|
204
|
+
* costs changes nothing about what is charged.
|
|
205
|
+
*
|
|
206
|
+
* Redirect URLs must be on one of the key's allowed origins (exact scheme,
|
|
207
|
+
* host and port) or a verified custom domain over https.
|
|
208
|
+
*/
|
|
209
|
+
checkout(input: {
|
|
210
|
+
offeringIdentifier: string;
|
|
211
|
+
packageIdentifier: string;
|
|
212
|
+
successUrl: string;
|
|
213
|
+
cancelUrl: string;
|
|
214
|
+
idempotencyKey?: string;
|
|
215
|
+
}): Promise<CheckoutResult>;
|
|
216
|
+
/** Escape hatch for endpoints without a typed wrapper yet. */
|
|
217
|
+
readonly http: HttpClient;
|
|
218
|
+
readonly identity: Identity;
|
|
219
|
+
}
|
|
220
|
+
declare function configure(options: RovenueOptions): Rovenue;
|
|
221
|
+
|
|
222
|
+
export { type CachedEntitlements, type CheckoutResult, type EntitlementsResponse, type QueuedEvent, type Rovenue, RovenueApiError, type RovenueOptions, type SdkStorage, type TrackInput, type WebOffering, type WebOfferingsResponse, type WebPackage, configure, createMemoryStorage, createStorage };
|