@rovenue/react-native-sdk 0.24.0 → 0.27.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/FunnelCheckRequests.kt +78 -0
- package/android/src/main/java/dev/rovenue/sdkrn/RovenueFunnelExpoView.kt +22 -1
- package/android/src/main/java/dev/rovenue/sdkrn/RovenueModule.kt +38 -8
- package/dist/chunk-D2LZIJZP.js +7 -0
- package/dist/{chunk-ETC46J2X.js.map → chunk-D2LZIJZP.js.map} +1 -1
- package/dist/index.cjs +81 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +123 -10
- package/dist/index.d.ts +123 -10
- package/dist/index.js +80 -9
- 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/RovenueFunnelExpoView.swift +22 -1
- package/ios/RovenueModule.swift +118 -10
- package/package.json +1 -1
- package/dist/chunk-ETC46J2X.js +0 -7
package/dist/index.d.mts
CHANGED
|
@@ -236,7 +236,7 @@ interface TrackParams {
|
|
|
236
236
|
*/
|
|
237
237
|
declare function track(eventType: string, params?: TrackParams): Promise<void>;
|
|
238
238
|
|
|
239
|
-
declare const ERROR_KINDS: readonly ["NetworkUnavailable", "Timeout", "RateLimited", "ServerError", "InvalidApiKey", "Forbidden", "NotFound", "InvalidRequest", "Conflict", "InvalidArgument", "SandboxKeyInRelease", "InsufficientCredits", "FunnelTokenNotFound", "FunnelTokenExpired", "FunnelTokenAlreadyClaimed", "FunnelConfigUnsupported", "FunnelInvalid", "SubscriberUnresolvable", "PurchaseCanceled", "ProductNotAvailable", "AlreadyOwned", "PaymentDeclined", "StoreServiceUnavailable", "Ineligible", "ReceiptInvalid", "StoreProblem", "Storage", "Internal"];
|
|
239
|
+
declare const ERROR_KINDS: readonly ["NetworkUnavailable", "Timeout", "RateLimited", "ServerError", "InvalidApiKey", "Forbidden", "NotFound", "InvalidRequest", "Conflict", "InvalidArgument", "SandboxKeyInRelease", "InsufficientCredits", "FunnelTokenNotFound", "FunnelTokenExpired", "FunnelTokenAlreadyClaimed", "FunnelConfigUnsupported", "FunnelInvalid", "SubscriberUnresolvable", "IdentityTokenInvalid", "PurchaseCanceled", "ProductNotAvailable", "AlreadyOwned", "PaymentDeclined", "StoreServiceUnavailable", "Ineligible", "ReceiptInvalid", "StoreProblem", "Storage", "Internal"];
|
|
240
240
|
type ErrorKind = (typeof ERROR_KINDS)[number];
|
|
241
241
|
interface ErrorExtras {
|
|
242
242
|
serverCode?: string;
|
|
@@ -370,20 +370,29 @@ declare function configure(opts: RovenueConfig): void;
|
|
|
370
370
|
*/
|
|
371
371
|
declare function currentUser(): Promise<User>;
|
|
372
372
|
/**
|
|
373
|
-
* Link the anonymous device identity to `appUserId`.
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
*
|
|
373
|
+
* Link the anonymous device identity to `appUserId`.
|
|
374
|
+
*
|
|
375
|
+
* `identityToken` vouches for `appUserId`: your backend mints it with the
|
|
376
|
+
* secret key (`POST /v1/identity-tokens`) for the signed-in user and hands
|
|
377
|
+
* it to the app. It is valid for 15 minutes; fetch a fresh one for each
|
|
378
|
+
* identify.
|
|
379
|
+
*
|
|
380
|
+
* The local write always succeeds; the `POST /v1/identify` to the server is
|
|
381
|
+
* best-effort — if it fails (offline/5xx) the link is retried automatically
|
|
382
|
+
* later with the same token, not surfaced as an error here. `IDENTITY_CHANGED` fires after the bind and
|
|
377
383
|
* an entitlements refresh attempt: after a delivered bind the native core
|
|
378
384
|
* fetches entitlements once (firing `ENTITLEMENTS_CHANGED` when it lands)
|
|
379
385
|
* and this promise resolves after that fetch. When the bind is not
|
|
380
386
|
* delivered (offline, server error, refused) it fires right after the
|
|
381
387
|
* local link. Rejects on
|
|
382
|
-
* validation failure (
|
|
383
|
-
*
|
|
384
|
-
*
|
|
388
|
+
* validation failure (a blank id or token), with `IdentityTokenInvalid` when
|
|
389
|
+
* the server refuses the token (expired, or minted for another user, project
|
|
390
|
+
* or environment: the bind is dropped, so identify again with a fresh
|
|
391
|
+
* token), and with `SubscriberUnresolvable` when the server cannot resolve
|
|
392
|
+
* this install's subscriber (corrupt merge history) — the local link stands,
|
|
393
|
+
* unsynced, until the data is repaired.
|
|
385
394
|
*/
|
|
386
|
-
declare function identify(appUserId: string): Promise<void>;
|
|
395
|
+
declare function identify(appUserId: string, identityToken: string): Promise<void>;
|
|
387
396
|
/**
|
|
388
397
|
* Log out the current user: mints a fresh anonymous `rovenueId` and drops
|
|
389
398
|
* `appUserId`, so the next identity starts clean — including a new Apple
|
|
@@ -495,6 +504,69 @@ declare function restorePurchases(): Promise<PurchaseResult>;
|
|
|
495
504
|
declare function preloadPlacement(placementId: string, locale?: string): Promise<void>;
|
|
496
505
|
declare function setFallbackPlacements(json: string): Promise<number>;
|
|
497
506
|
|
|
507
|
+
/**
|
|
508
|
+
* The photo a `photo_upload` question was answered with — normalised and
|
|
509
|
+
* stored on the device (an upright JPEG with no metadata). Rovenue never
|
|
510
|
+
* receives it. Call {@link releasePhoto} once you are done with the file;
|
|
511
|
+
* an unreleased one is deleted 7 days after it was picked.
|
|
512
|
+
*/
|
|
513
|
+
interface FunnelPhotoRef {
|
|
514
|
+
/** The file, a `file://` URI. Valid until {@link releasePhoto} or for 7 days. */
|
|
515
|
+
localUri: string;
|
|
516
|
+
/** Pixel width, after normalisation. */
|
|
517
|
+
width: number;
|
|
518
|
+
/** Pixel height, after normalisation. */
|
|
519
|
+
height: number;
|
|
520
|
+
/** The file's size in bytes. */
|
|
521
|
+
byteSize: number;
|
|
522
|
+
/** Always `image/jpeg`. */
|
|
523
|
+
mimeType: string;
|
|
524
|
+
}
|
|
525
|
+
/** What the SDK asks your photo checker (`onCheck`). */
|
|
526
|
+
interface FunnelCheckRequest {
|
|
527
|
+
/** The check block's answer key. */
|
|
528
|
+
checkKey: string;
|
|
529
|
+
/** The checker's step ids, in order. */
|
|
530
|
+
steps: string[];
|
|
531
|
+
/** The photo to judge, on the device. */
|
|
532
|
+
photo: FunnelPhotoRef;
|
|
533
|
+
/** The funnel's content locale (BCP-47), for any copy the checker returns. */
|
|
534
|
+
locale: string;
|
|
535
|
+
/** 1-based: completed checks for this block so far, plus one. */
|
|
536
|
+
attempt: number;
|
|
537
|
+
}
|
|
538
|
+
/** Your checker's final answer for a photo check. */
|
|
539
|
+
interface FunnelCheckOutcome {
|
|
540
|
+
/** `pass` or `fail`. */
|
|
541
|
+
result: "pass" | "fail";
|
|
542
|
+
/** Plain text the funnel can show (`{{<checkKey>}}`). */
|
|
543
|
+
label?: string;
|
|
544
|
+
/** Why it failed, in plain text (`{{<checkKey>.reason}}`). */
|
|
545
|
+
reason?: string;
|
|
546
|
+
/** Each step id's final status (`pass` | `fail`). */
|
|
547
|
+
steps?: Record<string, string>;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Your photo checker. Resolve the outcome; resolving `null` / `undefined`,
|
|
551
|
+
* or rejecting, applies the check's `whenUnavailable`. The native SDK bounds
|
|
552
|
+
* it by the check's `timeoutMs` (then the result is `timeout` and a late
|
|
553
|
+
* answer is ignored).
|
|
554
|
+
*
|
|
555
|
+
* On Android a presented funnel (`presentFunnel`) is its own activity, and
|
|
556
|
+
* React Native pauses JS timers while the app's activity is covered: a
|
|
557
|
+
* `setTimeout` inside the handler fires only after the funnel closes. Network
|
|
558
|
+
* calls (`fetch`) and promises run as usual — call your checker service
|
|
559
|
+
* directly rather than through a timer.
|
|
560
|
+
*/
|
|
561
|
+
type FunnelCheckHandler = (request: FunnelCheckRequest) => Promise<FunnelCheckOutcome | null | undefined> | FunnelCheckOutcome | null | undefined;
|
|
562
|
+
/**
|
|
563
|
+
* Deletes a photo a funnel stored on the device, once you are done with it:
|
|
564
|
+
* the `localUri` of a {@link FunnelPhotoRef} from `onPhotoSelected` or a
|
|
565
|
+
* presentation's `photos`. Anything outside the SDK's photo store is
|
|
566
|
+
* ignored. Resolves whether a stored photo was deleted.
|
|
567
|
+
*/
|
|
568
|
+
declare function releasePhoto(localUri: string): Promise<boolean>;
|
|
569
|
+
|
|
498
570
|
/** How a presented funnel covers the app. */
|
|
499
571
|
type FunnelPresentationStyle = "fullScreen" | "modal" | "sheet";
|
|
500
572
|
/** How a full-screen funnel enters; Reduce Motion / animations off make each a fade. */
|
|
@@ -546,6 +618,17 @@ interface PresentFunnelOptions {
|
|
|
546
618
|
actionId: string;
|
|
547
619
|
paramsJson: string;
|
|
548
620
|
}) => void;
|
|
621
|
+
/**
|
|
622
|
+
* Values for the funnel's declared externals (an ad's scene, a campaign):
|
|
623
|
+
* trimmed, 512 characters at most, undeclared names dropped. A fresh value
|
|
624
|
+
* overrides a restored one and preselects a `defaultFrom` question. Never
|
|
625
|
+
* pass personal data: values are written to the on-device session state.
|
|
626
|
+
*/
|
|
627
|
+
values?: Record<string, string>;
|
|
628
|
+
/** A `photo_upload` question was answered: its key and the photo on the device. */
|
|
629
|
+
onPhotoSelected?: (questionKey: string, photo: FunnelPhotoRef) => void;
|
|
630
|
+
/** Your photo checker; without it a check applies its `whenUnavailable`. */
|
|
631
|
+
onCheck?: FunnelCheckHandler;
|
|
549
632
|
}
|
|
550
633
|
/** What `presentFunnel` resolves with. */
|
|
551
634
|
interface FunnelPresentResult {
|
|
@@ -559,6 +642,12 @@ interface FunnelPresentResult {
|
|
|
559
642
|
lastError?: RovenueError;
|
|
560
643
|
/** Why nothing was presented: `alreadyPresented`, `noPresenter`, or the placement's unavailable reason. */
|
|
561
644
|
reason?: string;
|
|
645
|
+
/**
|
|
646
|
+
* The photos the visitor answered `photo_upload` questions with, by
|
|
647
|
+
* question key — files on the device, kept until `releasePhoto` or 7
|
|
648
|
+
* days. Empty when there were none.
|
|
649
|
+
*/
|
|
650
|
+
photos: Record<string, FunnelPhotoRef>;
|
|
562
651
|
}
|
|
563
652
|
/**
|
|
564
653
|
* Present the funnel a placement serves — natively, the way the funnel's
|
|
@@ -572,6 +661,10 @@ interface FunnelPresentResult {
|
|
|
572
661
|
* a time: a second call while one is up resolves `unavailable` with reason
|
|
573
662
|
* `alreadyPresented`.
|
|
574
663
|
*
|
|
664
|
+
* A funnel with a photo check calls `onCheck` and waits for its answer, up
|
|
665
|
+
* to the check's timeout; the photos the visitor gave come back in
|
|
666
|
+
* `photos` — call `releasePhoto` with each once you are done with it.
|
|
667
|
+
*
|
|
575
668
|
* @example
|
|
576
669
|
* const { result, purchased } = await presentFunnel({ placement: "paywall" });
|
|
577
670
|
*/
|
|
@@ -676,6 +769,13 @@ declare function setLogHandler(fn: ((entry: LogEntry) => void) | null): void;
|
|
|
676
769
|
interface FunnelClaimResult {
|
|
677
770
|
subscriberId: string;
|
|
678
771
|
funnelAnswers: Record<string, unknown>;
|
|
772
|
+
/**
|
|
773
|
+
* The question keys an app value preselected and the visitor left
|
|
774
|
+
* unchanged (the claim's `funnel_preselected`), so a default can be told
|
|
775
|
+
* from a choice. Empty when nothing was preselected or the server
|
|
776
|
+
* predates the field.
|
|
777
|
+
*/
|
|
778
|
+
funnelPreselected: string[];
|
|
679
779
|
}
|
|
680
780
|
interface ClaimInstallParams {
|
|
681
781
|
platform: "ios" | "android";
|
|
@@ -819,6 +919,18 @@ type RovenueFunnelViewProps = {
|
|
|
819
919
|
onPurchase?: (packageIdentifier: string) => void;
|
|
820
920
|
/** The funnel asked for purchases to be restored. */
|
|
821
921
|
onRestore?: () => void;
|
|
922
|
+
/** Values for the funnel's declared externals (an ad's scene, a
|
|
923
|
+
* campaign): trimmed, 512 characters at most, undeclared names dropped.
|
|
924
|
+
* A fresh value overrides a restored one and preselects a `defaultFrom`
|
|
925
|
+
* question. A changed value resolves again. Never pass personal data:
|
|
926
|
+
* values are written to the on-device session state. */
|
|
927
|
+
values?: Record<string, string>;
|
|
928
|
+
/** A `photo_upload` question was answered: its key and the photo on the
|
|
929
|
+
* device. Call `releasePhoto` once you are done with the file. */
|
|
930
|
+
onPhotoSelected?: (questionKey: string, photo: FunnelPhotoRef) => void;
|
|
931
|
+
/** Your photo checker; without it a check applies its `whenUnavailable`.
|
|
932
|
+
* Presence is decided when the funnel resolves. */
|
|
933
|
+
onCheck?: FunnelCheckHandler;
|
|
822
934
|
};
|
|
823
935
|
/**
|
|
824
936
|
* Hosts the platform's native funnel renderer for a placement.
|
|
@@ -851,6 +963,7 @@ declare const Rovenue: {
|
|
|
851
963
|
readonly setFallbackPlacements: typeof setFallbackPlacements;
|
|
852
964
|
readonly preloadPlacement: typeof preloadPlacement;
|
|
853
965
|
readonly presentFunnel: typeof presentFunnel;
|
|
966
|
+
readonly releasePhoto: typeof releasePhoto;
|
|
854
967
|
readonly track: typeof track;
|
|
855
968
|
readonly refreshRemoteConfig: typeof refreshRemoteConfig;
|
|
856
969
|
readonly getRemoteConfig: typeof getRemoteConfig;
|
|
@@ -890,4 +1003,4 @@ declare const Rovenue: {
|
|
|
890
1003
|
readonly addChangeListener: (cb: (event: ChangeEvent) => void) => (() => void);
|
|
891
1004
|
};
|
|
892
1005
|
|
|
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 };
|
|
1006
|
+
export { type AttributionProvider, type ChangeEvent, type ClaimInstallParams, ERROR_KINDS, EVENT_WIRE_VERSION, type Entitlement, type ErrorExtras, type ErrorKind, type EventEnvelope, type ExperimentAssignment, type FunnelCheckHandler, type FunnelCheckOutcome, type FunnelCheckRequest, type FunnelClaimResult, type FunnelCustomAction, type FunnelDraftIssue, type FunnelLoadedEvent, type FunnelPhotoRef, 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, releasePhoto, serializeEnvelope, stripUndefined, useCurrentUser, useEntitlement, useEntitlements, useExperiment, useFlag, useRemoteConfig, useVirtualCurrencies, useVirtualCurrency };
|
package/dist/index.d.ts
CHANGED
|
@@ -236,7 +236,7 @@ interface TrackParams {
|
|
|
236
236
|
*/
|
|
237
237
|
declare function track(eventType: string, params?: TrackParams): Promise<void>;
|
|
238
238
|
|
|
239
|
-
declare const ERROR_KINDS: readonly ["NetworkUnavailable", "Timeout", "RateLimited", "ServerError", "InvalidApiKey", "Forbidden", "NotFound", "InvalidRequest", "Conflict", "InvalidArgument", "SandboxKeyInRelease", "InsufficientCredits", "FunnelTokenNotFound", "FunnelTokenExpired", "FunnelTokenAlreadyClaimed", "FunnelConfigUnsupported", "FunnelInvalid", "SubscriberUnresolvable", "PurchaseCanceled", "ProductNotAvailable", "AlreadyOwned", "PaymentDeclined", "StoreServiceUnavailable", "Ineligible", "ReceiptInvalid", "StoreProblem", "Storage", "Internal"];
|
|
239
|
+
declare const ERROR_KINDS: readonly ["NetworkUnavailable", "Timeout", "RateLimited", "ServerError", "InvalidApiKey", "Forbidden", "NotFound", "InvalidRequest", "Conflict", "InvalidArgument", "SandboxKeyInRelease", "InsufficientCredits", "FunnelTokenNotFound", "FunnelTokenExpired", "FunnelTokenAlreadyClaimed", "FunnelConfigUnsupported", "FunnelInvalid", "SubscriberUnresolvable", "IdentityTokenInvalid", "PurchaseCanceled", "ProductNotAvailable", "AlreadyOwned", "PaymentDeclined", "StoreServiceUnavailable", "Ineligible", "ReceiptInvalid", "StoreProblem", "Storage", "Internal"];
|
|
240
240
|
type ErrorKind = (typeof ERROR_KINDS)[number];
|
|
241
241
|
interface ErrorExtras {
|
|
242
242
|
serverCode?: string;
|
|
@@ -370,20 +370,29 @@ declare function configure(opts: RovenueConfig): void;
|
|
|
370
370
|
*/
|
|
371
371
|
declare function currentUser(): Promise<User>;
|
|
372
372
|
/**
|
|
373
|
-
* Link the anonymous device identity to `appUserId`.
|
|
374
|
-
*
|
|
375
|
-
*
|
|
376
|
-
*
|
|
373
|
+
* Link the anonymous device identity to `appUserId`.
|
|
374
|
+
*
|
|
375
|
+
* `identityToken` vouches for `appUserId`: your backend mints it with the
|
|
376
|
+
* secret key (`POST /v1/identity-tokens`) for the signed-in user and hands
|
|
377
|
+
* it to the app. It is valid for 15 minutes; fetch a fresh one for each
|
|
378
|
+
* identify.
|
|
379
|
+
*
|
|
380
|
+
* The local write always succeeds; the `POST /v1/identify` to the server is
|
|
381
|
+
* best-effort — if it fails (offline/5xx) the link is retried automatically
|
|
382
|
+
* later with the same token, not surfaced as an error here. `IDENTITY_CHANGED` fires after the bind and
|
|
377
383
|
* an entitlements refresh attempt: after a delivered bind the native core
|
|
378
384
|
* fetches entitlements once (firing `ENTITLEMENTS_CHANGED` when it lands)
|
|
379
385
|
* and this promise resolves after that fetch. When the bind is not
|
|
380
386
|
* delivered (offline, server error, refused) it fires right after the
|
|
381
387
|
* local link. Rejects on
|
|
382
|
-
* validation failure (
|
|
383
|
-
*
|
|
384
|
-
*
|
|
388
|
+
* validation failure (a blank id or token), with `IdentityTokenInvalid` when
|
|
389
|
+
* the server refuses the token (expired, or minted for another user, project
|
|
390
|
+
* or environment: the bind is dropped, so identify again with a fresh
|
|
391
|
+
* token), and with `SubscriberUnresolvable` when the server cannot resolve
|
|
392
|
+
* this install's subscriber (corrupt merge history) — the local link stands,
|
|
393
|
+
* unsynced, until the data is repaired.
|
|
385
394
|
*/
|
|
386
|
-
declare function identify(appUserId: string): Promise<void>;
|
|
395
|
+
declare function identify(appUserId: string, identityToken: string): Promise<void>;
|
|
387
396
|
/**
|
|
388
397
|
* Log out the current user: mints a fresh anonymous `rovenueId` and drops
|
|
389
398
|
* `appUserId`, so the next identity starts clean — including a new Apple
|
|
@@ -495,6 +504,69 @@ declare function restorePurchases(): Promise<PurchaseResult>;
|
|
|
495
504
|
declare function preloadPlacement(placementId: string, locale?: string): Promise<void>;
|
|
496
505
|
declare function setFallbackPlacements(json: string): Promise<number>;
|
|
497
506
|
|
|
507
|
+
/**
|
|
508
|
+
* The photo a `photo_upload` question was answered with — normalised and
|
|
509
|
+
* stored on the device (an upright JPEG with no metadata). Rovenue never
|
|
510
|
+
* receives it. Call {@link releasePhoto} once you are done with the file;
|
|
511
|
+
* an unreleased one is deleted 7 days after it was picked.
|
|
512
|
+
*/
|
|
513
|
+
interface FunnelPhotoRef {
|
|
514
|
+
/** The file, a `file://` URI. Valid until {@link releasePhoto} or for 7 days. */
|
|
515
|
+
localUri: string;
|
|
516
|
+
/** Pixel width, after normalisation. */
|
|
517
|
+
width: number;
|
|
518
|
+
/** Pixel height, after normalisation. */
|
|
519
|
+
height: number;
|
|
520
|
+
/** The file's size in bytes. */
|
|
521
|
+
byteSize: number;
|
|
522
|
+
/** Always `image/jpeg`. */
|
|
523
|
+
mimeType: string;
|
|
524
|
+
}
|
|
525
|
+
/** What the SDK asks your photo checker (`onCheck`). */
|
|
526
|
+
interface FunnelCheckRequest {
|
|
527
|
+
/** The check block's answer key. */
|
|
528
|
+
checkKey: string;
|
|
529
|
+
/** The checker's step ids, in order. */
|
|
530
|
+
steps: string[];
|
|
531
|
+
/** The photo to judge, on the device. */
|
|
532
|
+
photo: FunnelPhotoRef;
|
|
533
|
+
/** The funnel's content locale (BCP-47), for any copy the checker returns. */
|
|
534
|
+
locale: string;
|
|
535
|
+
/** 1-based: completed checks for this block so far, plus one. */
|
|
536
|
+
attempt: number;
|
|
537
|
+
}
|
|
538
|
+
/** Your checker's final answer for a photo check. */
|
|
539
|
+
interface FunnelCheckOutcome {
|
|
540
|
+
/** `pass` or `fail`. */
|
|
541
|
+
result: "pass" | "fail";
|
|
542
|
+
/** Plain text the funnel can show (`{{<checkKey>}}`). */
|
|
543
|
+
label?: string;
|
|
544
|
+
/** Why it failed, in plain text (`{{<checkKey>.reason}}`). */
|
|
545
|
+
reason?: string;
|
|
546
|
+
/** Each step id's final status (`pass` | `fail`). */
|
|
547
|
+
steps?: Record<string, string>;
|
|
548
|
+
}
|
|
549
|
+
/**
|
|
550
|
+
* Your photo checker. Resolve the outcome; resolving `null` / `undefined`,
|
|
551
|
+
* or rejecting, applies the check's `whenUnavailable`. The native SDK bounds
|
|
552
|
+
* it by the check's `timeoutMs` (then the result is `timeout` and a late
|
|
553
|
+
* answer is ignored).
|
|
554
|
+
*
|
|
555
|
+
* On Android a presented funnel (`presentFunnel`) is its own activity, and
|
|
556
|
+
* React Native pauses JS timers while the app's activity is covered: a
|
|
557
|
+
* `setTimeout` inside the handler fires only after the funnel closes. Network
|
|
558
|
+
* calls (`fetch`) and promises run as usual — call your checker service
|
|
559
|
+
* directly rather than through a timer.
|
|
560
|
+
*/
|
|
561
|
+
type FunnelCheckHandler = (request: FunnelCheckRequest) => Promise<FunnelCheckOutcome | null | undefined> | FunnelCheckOutcome | null | undefined;
|
|
562
|
+
/**
|
|
563
|
+
* Deletes a photo a funnel stored on the device, once you are done with it:
|
|
564
|
+
* the `localUri` of a {@link FunnelPhotoRef} from `onPhotoSelected` or a
|
|
565
|
+
* presentation's `photos`. Anything outside the SDK's photo store is
|
|
566
|
+
* ignored. Resolves whether a stored photo was deleted.
|
|
567
|
+
*/
|
|
568
|
+
declare function releasePhoto(localUri: string): Promise<boolean>;
|
|
569
|
+
|
|
498
570
|
/** How a presented funnel covers the app. */
|
|
499
571
|
type FunnelPresentationStyle = "fullScreen" | "modal" | "sheet";
|
|
500
572
|
/** How a full-screen funnel enters; Reduce Motion / animations off make each a fade. */
|
|
@@ -546,6 +618,17 @@ interface PresentFunnelOptions {
|
|
|
546
618
|
actionId: string;
|
|
547
619
|
paramsJson: string;
|
|
548
620
|
}) => void;
|
|
621
|
+
/**
|
|
622
|
+
* Values for the funnel's declared externals (an ad's scene, a campaign):
|
|
623
|
+
* trimmed, 512 characters at most, undeclared names dropped. A fresh value
|
|
624
|
+
* overrides a restored one and preselects a `defaultFrom` question. Never
|
|
625
|
+
* pass personal data: values are written to the on-device session state.
|
|
626
|
+
*/
|
|
627
|
+
values?: Record<string, string>;
|
|
628
|
+
/** A `photo_upload` question was answered: its key and the photo on the device. */
|
|
629
|
+
onPhotoSelected?: (questionKey: string, photo: FunnelPhotoRef) => void;
|
|
630
|
+
/** Your photo checker; without it a check applies its `whenUnavailable`. */
|
|
631
|
+
onCheck?: FunnelCheckHandler;
|
|
549
632
|
}
|
|
550
633
|
/** What `presentFunnel` resolves with. */
|
|
551
634
|
interface FunnelPresentResult {
|
|
@@ -559,6 +642,12 @@ interface FunnelPresentResult {
|
|
|
559
642
|
lastError?: RovenueError;
|
|
560
643
|
/** Why nothing was presented: `alreadyPresented`, `noPresenter`, or the placement's unavailable reason. */
|
|
561
644
|
reason?: string;
|
|
645
|
+
/**
|
|
646
|
+
* The photos the visitor answered `photo_upload` questions with, by
|
|
647
|
+
* question key — files on the device, kept until `releasePhoto` or 7
|
|
648
|
+
* days. Empty when there were none.
|
|
649
|
+
*/
|
|
650
|
+
photos: Record<string, FunnelPhotoRef>;
|
|
562
651
|
}
|
|
563
652
|
/**
|
|
564
653
|
* Present the funnel a placement serves — natively, the way the funnel's
|
|
@@ -572,6 +661,10 @@ interface FunnelPresentResult {
|
|
|
572
661
|
* a time: a second call while one is up resolves `unavailable` with reason
|
|
573
662
|
* `alreadyPresented`.
|
|
574
663
|
*
|
|
664
|
+
* A funnel with a photo check calls `onCheck` and waits for its answer, up
|
|
665
|
+
* to the check's timeout; the photos the visitor gave come back in
|
|
666
|
+
* `photos` — call `releasePhoto` with each once you are done with it.
|
|
667
|
+
*
|
|
575
668
|
* @example
|
|
576
669
|
* const { result, purchased } = await presentFunnel({ placement: "paywall" });
|
|
577
670
|
*/
|
|
@@ -676,6 +769,13 @@ declare function setLogHandler(fn: ((entry: LogEntry) => void) | null): void;
|
|
|
676
769
|
interface FunnelClaimResult {
|
|
677
770
|
subscriberId: string;
|
|
678
771
|
funnelAnswers: Record<string, unknown>;
|
|
772
|
+
/**
|
|
773
|
+
* The question keys an app value preselected and the visitor left
|
|
774
|
+
* unchanged (the claim's `funnel_preselected`), so a default can be told
|
|
775
|
+
* from a choice. Empty when nothing was preselected or the server
|
|
776
|
+
* predates the field.
|
|
777
|
+
*/
|
|
778
|
+
funnelPreselected: string[];
|
|
679
779
|
}
|
|
680
780
|
interface ClaimInstallParams {
|
|
681
781
|
platform: "ios" | "android";
|
|
@@ -819,6 +919,18 @@ type RovenueFunnelViewProps = {
|
|
|
819
919
|
onPurchase?: (packageIdentifier: string) => void;
|
|
820
920
|
/** The funnel asked for purchases to be restored. */
|
|
821
921
|
onRestore?: () => void;
|
|
922
|
+
/** Values for the funnel's declared externals (an ad's scene, a
|
|
923
|
+
* campaign): trimmed, 512 characters at most, undeclared names dropped.
|
|
924
|
+
* A fresh value overrides a restored one and preselects a `defaultFrom`
|
|
925
|
+
* question. A changed value resolves again. Never pass personal data:
|
|
926
|
+
* values are written to the on-device session state. */
|
|
927
|
+
values?: Record<string, string>;
|
|
928
|
+
/** A `photo_upload` question was answered: its key and the photo on the
|
|
929
|
+
* device. Call `releasePhoto` once you are done with the file. */
|
|
930
|
+
onPhotoSelected?: (questionKey: string, photo: FunnelPhotoRef) => void;
|
|
931
|
+
/** Your photo checker; without it a check applies its `whenUnavailable`.
|
|
932
|
+
* Presence is decided when the funnel resolves. */
|
|
933
|
+
onCheck?: FunnelCheckHandler;
|
|
822
934
|
};
|
|
823
935
|
/**
|
|
824
936
|
* Hosts the platform's native funnel renderer for a placement.
|
|
@@ -851,6 +963,7 @@ declare const Rovenue: {
|
|
|
851
963
|
readonly setFallbackPlacements: typeof setFallbackPlacements;
|
|
852
964
|
readonly preloadPlacement: typeof preloadPlacement;
|
|
853
965
|
readonly presentFunnel: typeof presentFunnel;
|
|
966
|
+
readonly releasePhoto: typeof releasePhoto;
|
|
854
967
|
readonly track: typeof track;
|
|
855
968
|
readonly refreshRemoteConfig: typeof refreshRemoteConfig;
|
|
856
969
|
readonly getRemoteConfig: typeof getRemoteConfig;
|
|
@@ -890,4 +1003,4 @@ declare const Rovenue: {
|
|
|
890
1003
|
readonly addChangeListener: (cb: (event: ChangeEvent) => void) => (() => void);
|
|
891
1004
|
};
|
|
892
1005
|
|
|
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 };
|
|
1006
|
+
export { type AttributionProvider, type ChangeEvent, type ClaimInstallParams, ERROR_KINDS, EVENT_WIRE_VERSION, type Entitlement, type ErrorExtras, type ErrorKind, type EventEnvelope, type ExperimentAssignment, type FunnelCheckHandler, type FunnelCheckOutcome, type FunnelCheckRequest, type FunnelClaimResult, type FunnelCustomAction, type FunnelDraftIssue, type FunnelLoadedEvent, type FunnelPhotoRef, 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, releasePhoto, 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-D2LZIJZP.js";
|
|
4
4
|
|
|
5
5
|
// src/events.ts
|
|
6
6
|
var EVENT_WIRE_VERSION = 1;
|
|
@@ -51,6 +51,10 @@ var ERROR_KINDS = [
|
|
|
51
51
|
// The server cannot resolve this device's subscriber (corrupt merge
|
|
52
52
|
// chain, backend SUBSCRIBER_UNRESOLVABLE). Terminal: not retryable.
|
|
53
53
|
"SubscriberUnresolvable",
|
|
54
|
+
// The server refused the identity token identify() sent (backend
|
|
55
|
+
// IDENTITY_TOKEN_INVALID, 401): expired, or minted for another user,
|
|
56
|
+
// project or environment. Not retryable: identify again with a fresh token.
|
|
57
|
+
"IdentityTokenInvalid",
|
|
54
58
|
"PurchaseCanceled",
|
|
55
59
|
"ProductNotAvailable",
|
|
56
60
|
"AlreadyOwned",
|
|
@@ -523,8 +527,8 @@ async function call2(fn) {
|
|
|
523
527
|
async function currentUser() {
|
|
524
528
|
return call2(() => getNative().currentUser());
|
|
525
529
|
}
|
|
526
|
-
async function identify(appUserId) {
|
|
527
|
-
return call2(() => getNative().identify(appUserId));
|
|
530
|
+
async function identify(appUserId, identityToken) {
|
|
531
|
+
return call2(() => getNative().identify(appUserId, identityToken));
|
|
528
532
|
}
|
|
529
533
|
async function logOut() {
|
|
530
534
|
return call2(() => getNative().logOut());
|
|
@@ -677,6 +681,47 @@ async function setFallbackPlacements(json) {
|
|
|
677
681
|
return call6(() => getNative().setFallbackPlacements(json));
|
|
678
682
|
}
|
|
679
683
|
|
|
684
|
+
// src/api/funnel-photos.ts
|
|
685
|
+
async function releasePhoto(localUri) {
|
|
686
|
+
return getNative().releasePhoto(localUri);
|
|
687
|
+
}
|
|
688
|
+
function photoFrom(dto) {
|
|
689
|
+
return {
|
|
690
|
+
localUri: dto.localUri,
|
|
691
|
+
width: Number(dto.width),
|
|
692
|
+
height: Number(dto.height),
|
|
693
|
+
byteSize: Number(dto.byteSize),
|
|
694
|
+
mimeType: dto.mimeType
|
|
695
|
+
};
|
|
696
|
+
}
|
|
697
|
+
function photosFrom(dto) {
|
|
698
|
+
const out = {};
|
|
699
|
+
for (const [key, photo] of Object.entries(dto ?? {})) out[key] = photoFrom(photo);
|
|
700
|
+
return out;
|
|
701
|
+
}
|
|
702
|
+
function outcomeJson(outcome) {
|
|
703
|
+
if (typeof outcome !== "object" || outcome === null) return null;
|
|
704
|
+
const o = outcome;
|
|
705
|
+
if (typeof o.result !== "string") return null;
|
|
706
|
+
const steps = {};
|
|
707
|
+
if (typeof o.steps === "object" && o.steps !== null) {
|
|
708
|
+
for (const [id, status] of Object.entries(o.steps)) {
|
|
709
|
+
if (typeof status === "string") steps[id] = status;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
return JSON.stringify({
|
|
713
|
+
result: o.result,
|
|
714
|
+
...typeof o.label === "string" ? { label: o.label } : {},
|
|
715
|
+
...typeof o.reason === "string" ? { reason: o.reason } : {},
|
|
716
|
+
steps
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
function answerCheckRequest(requestId, request, handler) {
|
|
720
|
+
const native = getNative();
|
|
721
|
+
const run = async () => handler ? handler({ ...request, photo: photoFrom(request.photo), attempt: Number(request.attempt) }) : null;
|
|
722
|
+
run().then((outcome) => native.resolveFunnelCheckRequest(requestId, outcomeJson(outcome))).catch(() => native.resolveFunnelCheckRequest(requestId, null));
|
|
723
|
+
}
|
|
724
|
+
|
|
680
725
|
// src/api/present-funnel.ts
|
|
681
726
|
var FUNNEL_PRESENT_EVENT = "onFunnelPresentEvent";
|
|
682
727
|
var presentationSerial = 0;
|
|
@@ -713,6 +758,12 @@ async function presentFunnel(options) {
|
|
|
713
758
|
case "customAction":
|
|
714
759
|
options.onCustomAction?.({ actionId: event.actionId, paramsJson: event.paramsJson });
|
|
715
760
|
break;
|
|
761
|
+
case "photoSelected":
|
|
762
|
+
options.onPhotoSelected?.(event.questionKey, photoFrom(event.photo));
|
|
763
|
+
break;
|
|
764
|
+
case "checkRequest":
|
|
765
|
+
answerCheckRequest(event.requestId, event.request, options.onCheck);
|
|
766
|
+
break;
|
|
716
767
|
}
|
|
717
768
|
});
|
|
718
769
|
try {
|
|
@@ -725,15 +776,19 @@ async function presentFunnel(options) {
|
|
|
725
776
|
onPurchase: Boolean(options.onPurchase),
|
|
726
777
|
onRestore: Boolean(options.onRestore),
|
|
727
778
|
onUrl: Boolean(options.onUrl),
|
|
728
|
-
onCustomAction: Boolean(options.onCustomAction)
|
|
729
|
-
|
|
779
|
+
onCustomAction: Boolean(options.onCustomAction),
|
|
780
|
+
onPhotoSelected: Boolean(options.onPhotoSelected),
|
|
781
|
+
onCheck: Boolean(options.onCheck)
|
|
782
|
+
},
|
|
783
|
+
options.values ?? {}
|
|
730
784
|
);
|
|
731
785
|
return {
|
|
732
786
|
result: dto.result,
|
|
733
787
|
purchased: dto.purchased,
|
|
734
788
|
...dto.customerInfo ? { customerInfo: dto.customerInfo } : {},
|
|
735
789
|
...dto.lastError ? { lastError: toError(dto.lastError) } : {},
|
|
736
|
-
...dto.reason ? { reason: dto.reason } : {}
|
|
790
|
+
...dto.reason ? { reason: dto.reason } : {},
|
|
791
|
+
photos: photosFrom(dto.photos)
|
|
737
792
|
};
|
|
738
793
|
} catch (e) {
|
|
739
794
|
throw fromNativeError(e);
|
|
@@ -850,7 +905,13 @@ function parse(n) {
|
|
|
850
905
|
funnelAnswers = JSON.parse(n.funnelAnswersJson);
|
|
851
906
|
} catch {
|
|
852
907
|
}
|
|
853
|
-
|
|
908
|
+
let funnelPreselected = [];
|
|
909
|
+
try {
|
|
910
|
+
const keys = JSON.parse(n.funnelPreselectedJson ?? "[]");
|
|
911
|
+
if (Array.isArray(keys)) funnelPreselected = keys.filter((k) => typeof k === "string");
|
|
912
|
+
} catch {
|
|
913
|
+
}
|
|
914
|
+
return { subscriberId: n.subscriberId, funnelAnswers, funnelPreselected };
|
|
854
915
|
}
|
|
855
916
|
async function claimFunnelToken(token) {
|
|
856
917
|
return call10(async () => parse(await getNative().claimFunnelToken(token)));
|
|
@@ -946,6 +1007,7 @@ var NativeFunnelView = requireNativeViewManager(MODULE_NAME, VIEW_NAME);
|
|
|
946
1007
|
// src/funnel-view/RovenueFunnelView.tsx
|
|
947
1008
|
import { jsx } from "react/jsx-runtime";
|
|
948
1009
|
var styles = StyleSheet.create({ fill: { flex: 1 } });
|
|
1010
|
+
var EMPTY_VALUES = {};
|
|
949
1011
|
function parseParams(json) {
|
|
950
1012
|
try {
|
|
951
1013
|
const parsed = JSON.parse(json);
|
|
@@ -994,7 +1056,10 @@ function RovenueFunnelView(props) {
|
|
|
994
1056
|
onUrl,
|
|
995
1057
|
onCustomAction,
|
|
996
1058
|
onPurchase,
|
|
997
|
-
onRestore
|
|
1059
|
+
onRestore,
|
|
1060
|
+
values,
|
|
1061
|
+
onPhotoSelected,
|
|
1062
|
+
onCheck
|
|
998
1063
|
} = props;
|
|
999
1064
|
return /* @__PURE__ */ jsx(
|
|
1000
1065
|
NativeFunnelView,
|
|
@@ -1003,6 +1068,8 @@ function RovenueFunnelView(props) {
|
|
|
1003
1068
|
funnelIdentifier: placementIdentifier,
|
|
1004
1069
|
locale,
|
|
1005
1070
|
hasUrlHandler: onUrl !== void 0,
|
|
1071
|
+
hasCheckHandler: onCheck !== void 0,
|
|
1072
|
+
values: values ?? EMPTY_VALUES,
|
|
1006
1073
|
onFunnelLoaded: (e) => onLoaded?.(loadedFrom(e.nativeEvent)),
|
|
1007
1074
|
onFunnelUnavailable: (e) => onUnavailable?.(unavailableFrom(e.nativeEvent)),
|
|
1008
1075
|
onFunnelFailed: (e) => onError?.(mapNativeError(e.nativeEvent.code, e.nativeEvent.message)),
|
|
@@ -1015,7 +1082,9 @@ function RovenueFunnelView(props) {
|
|
|
1015
1082
|
params: parseParams(e.nativeEvent.params)
|
|
1016
1083
|
}),
|
|
1017
1084
|
onPurchaseRequested: (e) => onPurchase?.(e.nativeEvent.packageId),
|
|
1018
|
-
onRestoreRequested: () => onRestore?.()
|
|
1085
|
+
onRestoreRequested: () => onRestore?.(),
|
|
1086
|
+
onPhotoSelectedEvent: (e) => onPhotoSelected?.(e.nativeEvent.questionKey, photoFrom(e.nativeEvent.photo)),
|
|
1087
|
+
onCheckRequested: (e) => answerCheckRequest(e.nativeEvent.requestId, e.nativeEvent.request, onCheck)
|
|
1019
1088
|
}
|
|
1020
1089
|
);
|
|
1021
1090
|
}
|
|
@@ -1042,6 +1111,7 @@ var Rovenue = {
|
|
|
1042
1111
|
setFallbackPlacements,
|
|
1043
1112
|
preloadPlacement,
|
|
1044
1113
|
presentFunnel,
|
|
1114
|
+
releasePhoto,
|
|
1045
1115
|
track,
|
|
1046
1116
|
refreshRemoteConfig,
|
|
1047
1117
|
getRemoteConfig,
|
|
@@ -1095,6 +1165,7 @@ export {
|
|
|
1095
1165
|
extractFunnelToken,
|
|
1096
1166
|
mapNativeError,
|
|
1097
1167
|
presentFunnel,
|
|
1168
|
+
releasePhoto,
|
|
1098
1169
|
serializeEnvelope,
|
|
1099
1170
|
stripUndefined,
|
|
1100
1171
|
useCurrentUser,
|