@rovenue/react-native-sdk 0.23.1 → 0.24.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/android/src/main/java/dev/rovenue/sdkrn/RovenueModule.kt +95 -1
- package/dist/chunk-ETC46J2X.js +7 -0
- package/dist/{chunk-GQB7N5CJ.js.map → chunk-ETC46J2X.js.map} +1 -1
- package/dist/index.cjs +76 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +104 -6
- package/dist/index.d.ts +104 -6
- package/dist/index.js +75 -1
- package/dist/index.js.map +1 -1
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.d.mts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/ios/PrivacyInfo.xcprivacy +17 -0
- package/ios/RovenueModule.swift +107 -1
- package/package.json +1 -1
- package/dist/chunk-GQB7N5CJ.js +0 -7
package/dist/index.d.mts
CHANGED
|
@@ -478,8 +478,105 @@ declare function restorePurchases(): Promise<PurchaseResult>;
|
|
|
478
478
|
* `1` — an integrator who bundles a stale/mismatched export must see this
|
|
479
479
|
* loudly, at call time.
|
|
480
480
|
*/
|
|
481
|
+
/**
|
|
482
|
+
* Fetch a placement and warm everything its first screen draws — the
|
|
483
|
+
* placement response, the first screen's images and video posters, the
|
|
484
|
+
* store prices of its packages and its fonts — so even the first open of
|
|
485
|
+
* `<RovenueFunnelView placementId=…>` draws complete and at once. Call it at
|
|
486
|
+
* app start for the placement that shows your paywall.
|
|
487
|
+
*
|
|
488
|
+
* Never rejects: an unavailable placement or a network failure is logged
|
|
489
|
+
* natively and the open loads as it would have without it. Nothing is
|
|
490
|
+
* presented, so no funnel event is sent.
|
|
491
|
+
*
|
|
492
|
+
* @param placementId the placement identifier.
|
|
493
|
+
* @param locale the locale the funnel will open in; the device's when omitted.
|
|
494
|
+
*/
|
|
495
|
+
declare function preloadPlacement(placementId: string, locale?: string): Promise<void>;
|
|
481
496
|
declare function setFallbackPlacements(json: string): Promise<number>;
|
|
482
497
|
|
|
498
|
+
/** How a presented funnel covers the app. */
|
|
499
|
+
type FunnelPresentationStyle = "fullScreen" | "modal" | "sheet";
|
|
500
|
+
/** How a full-screen funnel enters; Reduce Motion / animations off make each a fade. */
|
|
501
|
+
type FunnelPresentationEnter = "bottom" | "side" | "fade" | "none";
|
|
502
|
+
/** A sheet height: the first page's content (`fit`, capped at `large`), half the screen, or nearly all of it. */
|
|
503
|
+
type FunnelSheetDetent = "fit" | "medium" | "large";
|
|
504
|
+
/**
|
|
505
|
+
* A present call's partial override of how the funnel's editor settings
|
|
506
|
+
* present it. A field left out keeps the funnel's own; a style changed here
|
|
507
|
+
* with no `dismissible` takes that style's default.
|
|
508
|
+
*/
|
|
509
|
+
interface FunnelPresentationOverride {
|
|
510
|
+
style?: FunnelPresentationStyle;
|
|
511
|
+
enter?: FunnelPresentationEnter;
|
|
512
|
+
detents?: FunnelSheetDetent[];
|
|
513
|
+
dismissible?: boolean;
|
|
514
|
+
closeOnPurchase?: boolean;
|
|
515
|
+
}
|
|
516
|
+
/** What `presentFunnel` takes. Every callback is optional. */
|
|
517
|
+
interface PresentFunnelOptions {
|
|
518
|
+
/** The placement identifier. */
|
|
519
|
+
placement: string;
|
|
520
|
+
/** The locale to resolve text in; the device's when omitted. */
|
|
521
|
+
locale?: string;
|
|
522
|
+
/** Overrides the funnel's own presentation, field by field. */
|
|
523
|
+
style?: FunnelPresentationOverride;
|
|
524
|
+
/**
|
|
525
|
+
* Perform the purchase of this package yourself; resolve whether it went
|
|
526
|
+
* through. Without it the SDK purchases. While it runs the funnel cannot
|
|
527
|
+
* be swiped or backed away.
|
|
528
|
+
*/
|
|
529
|
+
onPurchase?: (packageId: string) => Promise<{
|
|
530
|
+
purchased: boolean;
|
|
531
|
+
}>;
|
|
532
|
+
/** Perform a restore yourself; resolve whether it restored anything. */
|
|
533
|
+
onRestore?: () => Promise<{
|
|
534
|
+
purchased: boolean;
|
|
535
|
+
}>;
|
|
536
|
+
/**
|
|
537
|
+
* Observe a failed purchase or restore the SDK performed. The funnel stays
|
|
538
|
+
* open; a cancelled store sheet is not reported, nor is a failure of your
|
|
539
|
+
* own `onPurchase` / `onRestore`.
|
|
540
|
+
*/
|
|
541
|
+
onPurchaseError?: (error: RovenueError) => void;
|
|
542
|
+
/** A URL the funnel opens; without it, an http(s) URL opens in the browser. */
|
|
543
|
+
onUrl?: (url: string) => void;
|
|
544
|
+
/** A custom action the funnel runs: its id and its params as JSON. */
|
|
545
|
+
onCustomAction?: (action: {
|
|
546
|
+
actionId: string;
|
|
547
|
+
paramsJson: string;
|
|
548
|
+
}) => void;
|
|
549
|
+
}
|
|
550
|
+
/** What `presentFunnel` resolves with. */
|
|
551
|
+
interface FunnelPresentResult {
|
|
552
|
+
/** How it ended: finished (or closed after a purchase), closed by the visitor, or never presented. */
|
|
553
|
+
result: "completed" | "dismissed" | "unavailable";
|
|
554
|
+
/** Whether a purchase or restore succeeded while it was presented. */
|
|
555
|
+
purchased: boolean;
|
|
556
|
+
/** The entitlements and balances after the purchase; set whenever `purchased` is true. */
|
|
557
|
+
customerInfo?: PurchaseResult;
|
|
558
|
+
/** The last purchase or restore failure the SDK saw. */
|
|
559
|
+
lastError?: RovenueError;
|
|
560
|
+
/** Why nothing was presented: `alreadyPresented`, `noPresenter`, or the placement's unavailable reason. */
|
|
561
|
+
reason?: string;
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Present the funnel a placement serves — natively, the way the funnel's
|
|
565
|
+
* editor settings say (full screen, modal or sheet) — and resolve when it
|
|
566
|
+
* ends. The placement is resolved first (instantly after
|
|
567
|
+
* `preloadPlacement`); nothing is presented when it serves no funnel.
|
|
568
|
+
*
|
|
569
|
+
* The SDK performs purchases and restores itself unless you pass
|
|
570
|
+
* `onPurchase` / `onRestore`, and closes after a successful one when the
|
|
571
|
+
* funnel is set to "Close after purchase". Only one funnel is presented at
|
|
572
|
+
* a time: a second call while one is up resolves `unavailable` with reason
|
|
573
|
+
* `alreadyPresented`.
|
|
574
|
+
*
|
|
575
|
+
* @example
|
|
576
|
+
* const { result, purchased } = await presentFunnel({ placement: "paywall" });
|
|
577
|
+
*/
|
|
578
|
+
declare function presentFunnel(options: PresentFunnelOptions): Promise<FunnelPresentResult>;
|
|
579
|
+
|
|
483
580
|
/** Force an immediate fetch of the latest Remote Config from the server. */
|
|
484
581
|
declare function refreshRemoteConfig(): Promise<void>;
|
|
485
582
|
/** The whole `{ flags, experiments }` bundle, fetched from the local cache. */
|
|
@@ -496,11 +593,10 @@ declare function getExperiment(key: string): Promise<ExperimentAssignment | null
|
|
|
496
593
|
declare function getExperiments(): Promise<ExperimentAssignment[]>;
|
|
497
594
|
|
|
498
595
|
/**
|
|
499
|
-
*
|
|
500
|
-
*
|
|
501
|
-
*
|
|
502
|
-
*
|
|
503
|
-
* `AppState` changes, so most apps never need to call it directly.
|
|
596
|
+
* Override the SDK's foreground state. Not needed: the native SDK observes
|
|
597
|
+
* the app lifecycle itself — polling and the attribute/session flush run
|
|
598
|
+
* while the app is in front and pause in the background. A manual call is
|
|
599
|
+
* honoured until the next lifecycle transition.
|
|
504
600
|
*/
|
|
505
601
|
declare function setForeground(foreground: boolean): void;
|
|
506
602
|
/**
|
|
@@ -753,6 +849,8 @@ declare const Rovenue: {
|
|
|
753
849
|
readonly purchase: typeof purchase;
|
|
754
850
|
readonly restorePurchases: typeof restorePurchases;
|
|
755
851
|
readonly setFallbackPlacements: typeof setFallbackPlacements;
|
|
852
|
+
readonly preloadPlacement: typeof preloadPlacement;
|
|
853
|
+
readonly presentFunnel: typeof presentFunnel;
|
|
756
854
|
readonly track: typeof track;
|
|
757
855
|
readonly refreshRemoteConfig: typeof refreshRemoteConfig;
|
|
758
856
|
readonly getRemoteConfig: typeof getRemoteConfig;
|
|
@@ -792,4 +890,4 @@ declare const Rovenue: {
|
|
|
792
890
|
readonly addChangeListener: (cb: (event: ChangeEvent) => void) => (() => void);
|
|
793
891
|
};
|
|
794
892
|
|
|
795
|
-
export { type AttributionProvider, type ChangeEvent, type ClaimInstallParams, ERROR_KINDS, EVENT_WIRE_VERSION, type Entitlement, type ErrorExtras, type ErrorKind, type EventEnvelope, type ExperimentAssignment, type FunnelClaimResult, type FunnelCustomAction, type FunnelDraftIssue, type FunnelLoadedEvent, type FunnelScreenEvent, type FunnelUnavailableEvent, type FunnelUnavailableReason, type IdentityContext, type LogEntry, type Offering, type Offerings, type Package, type ProductType, type PurchaseResult, type RemoteConfig, Rovenue, type RovenueConfig, RovenueError, RovenueFunnelView, type RovenueFunnelViewProps, type StoreProduct, type TrackParams, type User, type VirtualCurrencyGrant, extractFunnelToken, mapNativeError, serializeEnvelope, stripUndefined, useCurrentUser, useEntitlement, useEntitlements, useExperiment, useFlag, useRemoteConfig, useVirtualCurrencies, useVirtualCurrency };
|
|
893
|
+
export { type AttributionProvider, type ChangeEvent, type ClaimInstallParams, ERROR_KINDS, EVENT_WIRE_VERSION, type Entitlement, type ErrorExtras, type ErrorKind, type EventEnvelope, type ExperimentAssignment, type FunnelClaimResult, type FunnelCustomAction, type FunnelDraftIssue, type FunnelLoadedEvent, type FunnelPresentResult, type FunnelPresentationEnter, type FunnelPresentationOverride, type FunnelPresentationStyle, type FunnelScreenEvent, type FunnelSheetDetent, type FunnelUnavailableEvent, type FunnelUnavailableReason, type IdentityContext, type LogEntry, type Offering, type Offerings, type Package, type PresentFunnelOptions, type ProductType, type PurchaseResult, type RemoteConfig, Rovenue, type RovenueConfig, RovenueError, RovenueFunnelView, type RovenueFunnelViewProps, type StoreProduct, type TrackParams, type User, type VirtualCurrencyGrant, extractFunnelToken, mapNativeError, presentFunnel, serializeEnvelope, stripUndefined, useCurrentUser, useEntitlement, useEntitlements, useExperiment, useFlag, useRemoteConfig, useVirtualCurrencies, useVirtualCurrency };
|
package/dist/index.d.ts
CHANGED
|
@@ -478,8 +478,105 @@ declare function restorePurchases(): Promise<PurchaseResult>;
|
|
|
478
478
|
* `1` — an integrator who bundles a stale/mismatched export must see this
|
|
479
479
|
* loudly, at call time.
|
|
480
480
|
*/
|
|
481
|
+
/**
|
|
482
|
+
* Fetch a placement and warm everything its first screen draws — the
|
|
483
|
+
* placement response, the first screen's images and video posters, the
|
|
484
|
+
* store prices of its packages and its fonts — so even the first open of
|
|
485
|
+
* `<RovenueFunnelView placementId=…>` draws complete and at once. Call it at
|
|
486
|
+
* app start for the placement that shows your paywall.
|
|
487
|
+
*
|
|
488
|
+
* Never rejects: an unavailable placement or a network failure is logged
|
|
489
|
+
* natively and the open loads as it would have without it. Nothing is
|
|
490
|
+
* presented, so no funnel event is sent.
|
|
491
|
+
*
|
|
492
|
+
* @param placementId the placement identifier.
|
|
493
|
+
* @param locale the locale the funnel will open in; the device's when omitted.
|
|
494
|
+
*/
|
|
495
|
+
declare function preloadPlacement(placementId: string, locale?: string): Promise<void>;
|
|
481
496
|
declare function setFallbackPlacements(json: string): Promise<number>;
|
|
482
497
|
|
|
498
|
+
/** How a presented funnel covers the app. */
|
|
499
|
+
type FunnelPresentationStyle = "fullScreen" | "modal" | "sheet";
|
|
500
|
+
/** How a full-screen funnel enters; Reduce Motion / animations off make each a fade. */
|
|
501
|
+
type FunnelPresentationEnter = "bottom" | "side" | "fade" | "none";
|
|
502
|
+
/** A sheet height: the first page's content (`fit`, capped at `large`), half the screen, or nearly all of it. */
|
|
503
|
+
type FunnelSheetDetent = "fit" | "medium" | "large";
|
|
504
|
+
/**
|
|
505
|
+
* A present call's partial override of how the funnel's editor settings
|
|
506
|
+
* present it. A field left out keeps the funnel's own; a style changed here
|
|
507
|
+
* with no `dismissible` takes that style's default.
|
|
508
|
+
*/
|
|
509
|
+
interface FunnelPresentationOverride {
|
|
510
|
+
style?: FunnelPresentationStyle;
|
|
511
|
+
enter?: FunnelPresentationEnter;
|
|
512
|
+
detents?: FunnelSheetDetent[];
|
|
513
|
+
dismissible?: boolean;
|
|
514
|
+
closeOnPurchase?: boolean;
|
|
515
|
+
}
|
|
516
|
+
/** What `presentFunnel` takes. Every callback is optional. */
|
|
517
|
+
interface PresentFunnelOptions {
|
|
518
|
+
/** The placement identifier. */
|
|
519
|
+
placement: string;
|
|
520
|
+
/** The locale to resolve text in; the device's when omitted. */
|
|
521
|
+
locale?: string;
|
|
522
|
+
/** Overrides the funnel's own presentation, field by field. */
|
|
523
|
+
style?: FunnelPresentationOverride;
|
|
524
|
+
/**
|
|
525
|
+
* Perform the purchase of this package yourself; resolve whether it went
|
|
526
|
+
* through. Without it the SDK purchases. While it runs the funnel cannot
|
|
527
|
+
* be swiped or backed away.
|
|
528
|
+
*/
|
|
529
|
+
onPurchase?: (packageId: string) => Promise<{
|
|
530
|
+
purchased: boolean;
|
|
531
|
+
}>;
|
|
532
|
+
/** Perform a restore yourself; resolve whether it restored anything. */
|
|
533
|
+
onRestore?: () => Promise<{
|
|
534
|
+
purchased: boolean;
|
|
535
|
+
}>;
|
|
536
|
+
/**
|
|
537
|
+
* Observe a failed purchase or restore the SDK performed. The funnel stays
|
|
538
|
+
* open; a cancelled store sheet is not reported, nor is a failure of your
|
|
539
|
+
* own `onPurchase` / `onRestore`.
|
|
540
|
+
*/
|
|
541
|
+
onPurchaseError?: (error: RovenueError) => void;
|
|
542
|
+
/** A URL the funnel opens; without it, an http(s) URL opens in the browser. */
|
|
543
|
+
onUrl?: (url: string) => void;
|
|
544
|
+
/** A custom action the funnel runs: its id and its params as JSON. */
|
|
545
|
+
onCustomAction?: (action: {
|
|
546
|
+
actionId: string;
|
|
547
|
+
paramsJson: string;
|
|
548
|
+
}) => void;
|
|
549
|
+
}
|
|
550
|
+
/** What `presentFunnel` resolves with. */
|
|
551
|
+
interface FunnelPresentResult {
|
|
552
|
+
/** How it ended: finished (or closed after a purchase), closed by the visitor, or never presented. */
|
|
553
|
+
result: "completed" | "dismissed" | "unavailable";
|
|
554
|
+
/** Whether a purchase or restore succeeded while it was presented. */
|
|
555
|
+
purchased: boolean;
|
|
556
|
+
/** The entitlements and balances after the purchase; set whenever `purchased` is true. */
|
|
557
|
+
customerInfo?: PurchaseResult;
|
|
558
|
+
/** The last purchase or restore failure the SDK saw. */
|
|
559
|
+
lastError?: RovenueError;
|
|
560
|
+
/** Why nothing was presented: `alreadyPresented`, `noPresenter`, or the placement's unavailable reason. */
|
|
561
|
+
reason?: string;
|
|
562
|
+
}
|
|
563
|
+
/**
|
|
564
|
+
* Present the funnel a placement serves — natively, the way the funnel's
|
|
565
|
+
* editor settings say (full screen, modal or sheet) — and resolve when it
|
|
566
|
+
* ends. The placement is resolved first (instantly after
|
|
567
|
+
* `preloadPlacement`); nothing is presented when it serves no funnel.
|
|
568
|
+
*
|
|
569
|
+
* The SDK performs purchases and restores itself unless you pass
|
|
570
|
+
* `onPurchase` / `onRestore`, and closes after a successful one when the
|
|
571
|
+
* funnel is set to "Close after purchase". Only one funnel is presented at
|
|
572
|
+
* a time: a second call while one is up resolves `unavailable` with reason
|
|
573
|
+
* `alreadyPresented`.
|
|
574
|
+
*
|
|
575
|
+
* @example
|
|
576
|
+
* const { result, purchased } = await presentFunnel({ placement: "paywall" });
|
|
577
|
+
*/
|
|
578
|
+
declare function presentFunnel(options: PresentFunnelOptions): Promise<FunnelPresentResult>;
|
|
579
|
+
|
|
483
580
|
/** Force an immediate fetch of the latest Remote Config from the server. */
|
|
484
581
|
declare function refreshRemoteConfig(): Promise<void>;
|
|
485
582
|
/** The whole `{ flags, experiments }` bundle, fetched from the local cache. */
|
|
@@ -496,11 +593,10 @@ declare function getExperiment(key: string): Promise<ExperimentAssignment | null
|
|
|
496
593
|
declare function getExperiments(): Promise<ExperimentAssignment[]>;
|
|
497
594
|
|
|
498
595
|
/**
|
|
499
|
-
*
|
|
500
|
-
*
|
|
501
|
-
*
|
|
502
|
-
*
|
|
503
|
-
* `AppState` changes, so most apps never need to call it directly.
|
|
596
|
+
* Override the SDK's foreground state. Not needed: the native SDK observes
|
|
597
|
+
* the app lifecycle itself — polling and the attribute/session flush run
|
|
598
|
+
* while the app is in front and pause in the background. A manual call is
|
|
599
|
+
* honoured until the next lifecycle transition.
|
|
504
600
|
*/
|
|
505
601
|
declare function setForeground(foreground: boolean): void;
|
|
506
602
|
/**
|
|
@@ -753,6 +849,8 @@ declare const Rovenue: {
|
|
|
753
849
|
readonly purchase: typeof purchase;
|
|
754
850
|
readonly restorePurchases: typeof restorePurchases;
|
|
755
851
|
readonly setFallbackPlacements: typeof setFallbackPlacements;
|
|
852
|
+
readonly preloadPlacement: typeof preloadPlacement;
|
|
853
|
+
readonly presentFunnel: typeof presentFunnel;
|
|
756
854
|
readonly track: typeof track;
|
|
757
855
|
readonly refreshRemoteConfig: typeof refreshRemoteConfig;
|
|
758
856
|
readonly getRemoteConfig: typeof getRemoteConfig;
|
|
@@ -792,4 +890,4 @@ declare const Rovenue: {
|
|
|
792
890
|
readonly addChangeListener: (cb: (event: ChangeEvent) => void) => (() => void);
|
|
793
891
|
};
|
|
794
892
|
|
|
795
|
-
export { type AttributionProvider, type ChangeEvent, type ClaimInstallParams, ERROR_KINDS, EVENT_WIRE_VERSION, type Entitlement, type ErrorExtras, type ErrorKind, type EventEnvelope, type ExperimentAssignment, type FunnelClaimResult, type FunnelCustomAction, type FunnelDraftIssue, type FunnelLoadedEvent, type FunnelScreenEvent, type FunnelUnavailableEvent, type FunnelUnavailableReason, type IdentityContext, type LogEntry, type Offering, type Offerings, type Package, type ProductType, type PurchaseResult, type RemoteConfig, Rovenue, type RovenueConfig, RovenueError, RovenueFunnelView, type RovenueFunnelViewProps, type StoreProduct, type TrackParams, type User, type VirtualCurrencyGrant, extractFunnelToken, mapNativeError, serializeEnvelope, stripUndefined, useCurrentUser, useEntitlement, useEntitlements, useExperiment, useFlag, useRemoteConfig, useVirtualCurrencies, useVirtualCurrency };
|
|
893
|
+
export { type AttributionProvider, type ChangeEvent, type ClaimInstallParams, ERROR_KINDS, EVENT_WIRE_VERSION, type Entitlement, type ErrorExtras, type ErrorKind, type EventEnvelope, type ExperimentAssignment, type FunnelClaimResult, type FunnelCustomAction, type FunnelDraftIssue, type FunnelLoadedEvent, type FunnelPresentResult, type FunnelPresentationEnter, type FunnelPresentationOverride, type FunnelPresentationStyle, type FunnelScreenEvent, type FunnelSheetDetent, type FunnelUnavailableEvent, type FunnelUnavailableReason, type IdentityContext, type LogEntry, type Offering, type Offerings, type Package, type PresentFunnelOptions, type ProductType, type PurchaseResult, type RemoteConfig, Rovenue, type RovenueConfig, RovenueError, RovenueFunnelView, type RovenueFunnelViewProps, type StoreProduct, type TrackParams, type User, type VirtualCurrencyGrant, extractFunnelToken, mapNativeError, presentFunnel, serializeEnvelope, stripUndefined, useCurrentUser, useEntitlement, useEntitlements, useExperiment, useFlag, useRemoteConfig, useVirtualCurrencies, useVirtualCurrency };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SDK_VERSION
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-ETC46J2X.js";
|
|
4
4
|
|
|
5
5
|
// src/events.ts
|
|
6
6
|
var EVENT_WIRE_VERSION = 1;
|
|
@@ -667,10 +667,81 @@ async function call6(fn) {
|
|
|
667
667
|
throw fromNativeError(e);
|
|
668
668
|
}
|
|
669
669
|
}
|
|
670
|
+
async function preloadPlacement(placementId, locale) {
|
|
671
|
+
try {
|
|
672
|
+
await getNative().preloadPlacement(placementId, locale ?? null);
|
|
673
|
+
} catch {
|
|
674
|
+
}
|
|
675
|
+
}
|
|
670
676
|
async function setFallbackPlacements(json) {
|
|
671
677
|
return call6(() => getNative().setFallbackPlacements(json));
|
|
672
678
|
}
|
|
673
679
|
|
|
680
|
+
// src/api/present-funnel.ts
|
|
681
|
+
var FUNNEL_PRESENT_EVENT = "onFunnelPresentEvent";
|
|
682
|
+
var presentationSerial = 0;
|
|
683
|
+
function toError(dto) {
|
|
684
|
+
const mapped = fromNativeError(Object.assign(new Error(dto.message), { code: dto.kind }));
|
|
685
|
+
if (mapped instanceof RovenueError) {
|
|
686
|
+
return new RovenueError(mapped.kind, dto.message, {
|
|
687
|
+
serverCode: dto.serverCode ?? void 0,
|
|
688
|
+
httpStatus: dto.httpStatus ?? void 0,
|
|
689
|
+
retryable: dto.retryable
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
return new RovenueError("Internal", dto.message);
|
|
693
|
+
}
|
|
694
|
+
async function presentFunnel(options) {
|
|
695
|
+
const native = getNative();
|
|
696
|
+
presentationSerial += 1;
|
|
697
|
+
const presentationId = `p${Date.now().toString(36)}${presentationSerial}`;
|
|
698
|
+
const subscription3 = getEmitter().addListener(FUNNEL_PRESENT_EVENT, (event) => {
|
|
699
|
+
if (event.presentationId !== presentationId) return;
|
|
700
|
+
switch (event.type) {
|
|
701
|
+
case "purchaseRequest":
|
|
702
|
+
case "restoreRequest": {
|
|
703
|
+
const run = event.type === "purchaseRequest" ? options.onPurchase?.(event.packageId) : options.onRestore?.();
|
|
704
|
+
Promise.resolve(run).then((answer) => native.resolveFunnelPurchaseRequest(event.requestId, Boolean(answer?.purchased))).catch(() => native.resolveFunnelPurchaseRequest(event.requestId, false));
|
|
705
|
+
break;
|
|
706
|
+
}
|
|
707
|
+
case "purchaseError":
|
|
708
|
+
options.onPurchaseError?.(toError(event.error));
|
|
709
|
+
break;
|
|
710
|
+
case "url":
|
|
711
|
+
options.onUrl?.(event.url);
|
|
712
|
+
break;
|
|
713
|
+
case "customAction":
|
|
714
|
+
options.onCustomAction?.({ actionId: event.actionId, paramsJson: event.paramsJson });
|
|
715
|
+
break;
|
|
716
|
+
}
|
|
717
|
+
});
|
|
718
|
+
try {
|
|
719
|
+
const dto = await native.presentFunnel(
|
|
720
|
+
presentationId,
|
|
721
|
+
options.placement,
|
|
722
|
+
options.locale ?? null,
|
|
723
|
+
options.style ? JSON.stringify(options.style) : null,
|
|
724
|
+
{
|
|
725
|
+
onPurchase: Boolean(options.onPurchase),
|
|
726
|
+
onRestore: Boolean(options.onRestore),
|
|
727
|
+
onUrl: Boolean(options.onUrl),
|
|
728
|
+
onCustomAction: Boolean(options.onCustomAction)
|
|
729
|
+
}
|
|
730
|
+
);
|
|
731
|
+
return {
|
|
732
|
+
result: dto.result,
|
|
733
|
+
purchased: dto.purchased,
|
|
734
|
+
...dto.customerInfo ? { customerInfo: dto.customerInfo } : {},
|
|
735
|
+
...dto.lastError ? { lastError: toError(dto.lastError) } : {},
|
|
736
|
+
...dto.reason ? { reason: dto.reason } : {}
|
|
737
|
+
};
|
|
738
|
+
} catch (e) {
|
|
739
|
+
throw fromNativeError(e);
|
|
740
|
+
} finally {
|
|
741
|
+
subscription3.remove();
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
|
|
674
745
|
// src/api/events.ts
|
|
675
746
|
function isoNow2() {
|
|
676
747
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -969,6 +1040,8 @@ var Rovenue = {
|
|
|
969
1040
|
purchase,
|
|
970
1041
|
restorePurchases,
|
|
971
1042
|
setFallbackPlacements,
|
|
1043
|
+
preloadPlacement,
|
|
1044
|
+
presentFunnel,
|
|
972
1045
|
track,
|
|
973
1046
|
refreshRemoteConfig,
|
|
974
1047
|
getRemoteConfig,
|
|
@@ -1021,6 +1094,7 @@ export {
|
|
|
1021
1094
|
SDK_VERSION,
|
|
1022
1095
|
extractFunnelToken,
|
|
1023
1096
|
mapNativeError,
|
|
1097
|
+
presentFunnel,
|
|
1024
1098
|
serializeEnvelope,
|
|
1025
1099
|
stripUndefined,
|
|
1026
1100
|
useCurrentUser,
|