react-native-revnix 1.5.0 → 1.6.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/client.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { AdRevenue, AliasResult, CustomerEntitlements, IdentifyResult, IdentifyStrategy, IdentityInfo, LastDeepLink, MmpAttribution, PaywallInteraction, PlacementResolution, RegisterPurchaseInput, RegisterPurchaseResult, RevnixAttribution, RevnixConfig } from "./types.js";
2
+ export declare function paywallImageUrls(value: unknown): string[];
2
3
  export declare class RevnixClient {
3
4
  private readonly apiKey;
4
5
  private readonly baseUrl;
@@ -56,6 +57,9 @@ export declare class RevnixClient {
56
57
  * /v1/installs uses, and independent of the device header (which an app
57
58
  * can turn off entirely). */
58
59
  private freshInstall;
60
+ private eventFlush;
61
+ private eventTimer;
62
+ private eventRetryAt;
59
63
  constructor(config: RevnixConfig);
60
64
  /** The id every call is made as: the stored identified/canonical id, or a
61
65
  * generated-and-persisted anonymous id (rvx_anon_…) on first launch. */
@@ -105,7 +109,8 @@ export declare class RevnixClient {
105
109
  private postPurchase;
106
110
  /** C7: retry purchases that failed to register and were persisted locally.
107
111
  * Runs automatically at construction; call again when connectivity returns.
108
- * Idempotent and safe to call repeatedly. */
112
+ * Idempotent and safe to call repeatedly. Purchases queued more than 30
113
+ * days ago are dropped with a diagnostic. */
109
114
  retryPendingPurchases(): Promise<void>;
110
115
  private freshEntitlements;
111
116
  private inflightEntitlements;
@@ -150,12 +155,22 @@ export declare class RevnixClient {
150
155
  * RevnixAuthError locally, before any network call, like identify(). */
151
156
  getIdentity(): Promise<IdentityInfo>;
152
157
  /** Resolve a named in-app location to the currently published offering —
153
- * the one-line paywall call. REV-157: reads the network first and caches
154
- * the result; if that read FAILS (offline / incident) it falls back to the
155
- * last cached resolution with `stale: true`, so the paywall renders the
156
- * last published version rather than not at all. Throws only when there
157
- * is nothing cached. */
158
+ * the one-line paywall call. Served instantly from a cache under 24 h old
159
+ * that was fetched for this customer since the last `setAttributes` or
160
+ * purchase, refreshed in the background. Otherwise reads the network and
161
+ * caches the result; if that read FAILS (offline / incident) it falls back
162
+ * to the last cached resolution with `stale: true`, so the paywall renders
163
+ * the last published version rather than not at all. Throws only when
164
+ * there is nothing cached. A deliberate rejection seen by the background
165
+ * refresh drops the cache, so the next resolve throws it. */
158
166
  resolvePlacement(placementKey: string): Promise<PlacementResolution>;
167
+ /** Fetch these placements now so the next `resolvePlacement` answers from
168
+ * the cache. Never throws; failures report to `onDiagnostic`. Paywall
169
+ * images are warmed by `prefetchPaywallImages` from
170
+ * `react-native-revnix/ui`. */
171
+ preload(placementKeys: string[]): Promise<void>;
172
+ private refreshPlacement;
173
+ private fetchPlacement;
159
174
  /** REV-157: the last resolution cached for `placementKey`, with NO network
160
175
  * call — for an instant, offline-safe paywall at launch. Always
161
176
  * `stale: true`; follow with resolvePlacement() to revalidate. Null if
@@ -207,7 +222,8 @@ export declare class RevnixClient {
207
222
  * - `restore` — restore purchases was tapped
208
223
  * - `error` — the paywall itself failed (config, products, render)
209
224
  *
210
- * Fire-and-forget like the other beacons: never blocks, never throws.
225
+ * Queued and sent in batches (see `flushEvents`): resolves once queued,
226
+ * never throws.
211
227
  *
212
228
  * `viewId` is the id `logPaywallShown` returned for THIS display. Passing
213
229
  * it is what threads the whole life of one impression together and puts
@@ -233,15 +249,28 @@ export declare class RevnixClient {
233
249
  message?: string;
234
250
  /** Idempotency key for this occurrence; defaults to `viewId`. */
235
251
  eventId?: string;
236
- }): void;
252
+ }): Promise<void>;
237
253
  /** Reports one ad impression's payout (POST /v1/ad-revenue).
238
254
  * Fire-and-forget like the other beacons: never blocks, never throws. */
239
255
  logAdRevenue(input: AdRevenue): void;
240
256
  /** Reports one custom in-app event (POST /v1/events), not for purchases.
241
- * Fire-and-forget like the other beacons: never blocks, never throws. */
257
+ * Queued and sent in batches (see `flushEvents`): resolves once queued,
258
+ * never throws. */
242
259
  track(event: string, properties?: Record<string, string | number | boolean>, options?: {
243
260
  eventId?: string;
244
- }): void;
261
+ }): Promise<void>;
262
+ /** Send every queued `track` and paywall interaction event now. Events are
263
+ * otherwise sent in batches: at 20 queued, 10 s after the first, when the
264
+ * app goes to the background, and on the next launch. Never throws; a
265
+ * transient failure keeps the events and holds further sends for 30 s. */
266
+ flushEvents(): Promise<void>;
267
+ private readEvents;
268
+ private mutateEvents;
269
+ private enqueueEvent;
270
+ private armEventTimer;
271
+ private startEventFlush;
272
+ private runEventFlush;
273
+ private removeEvents;
245
274
  /** PT11: forward an MMP's attribution callback (Adjust, AppsFlyer, …) so
246
275
  * Revnix credits revenue to the right network/campaign. */
247
276
  setAttribution(attribution: MmpAttribution): void;
@@ -361,6 +390,7 @@ export declare class RevnixClient {
361
390
  * cold start to ONE paywall. Never throws past its caller's catch. */
362
391
  private triggerImplicit;
363
392
  private consumePreviousSessionMs;
393
+ private subscribeLifecycle;
364
394
  /** REV-272: the launch-time moments, plus the foreground listener that
365
395
  * `session_start` is built on.
366
396
  *
@@ -405,7 +435,12 @@ export declare class RevnixClient {
405
435
  private readPlacementMap;
406
436
  private readPlacementCache;
407
437
  private writePlacementCache;
408
- private queueLock;
438
+ private deletePlacementCache;
439
+ private mutatePlacements;
440
+ private placementsInvalidatedAt;
441
+ private invalidatePlacements;
442
+ private storageLock;
443
+ private withStorageLock;
409
444
  private mutateQueue;
410
445
  private readPurchaseQueue;
411
446
  private writePurchaseQueue;