@virex-tech/paywallo-sdk 2.4.1 → 2.5.1
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/PaywalloSdk.podspec +1 -1
- package/README.md +45 -4
- package/android/build.gradle +0 -1
- package/android/src/main/java/com/paywallo/sdk/PaywalloFBBridgeModule.kt +7 -0
- package/android/src/main/java/com/paywallo/sdk/PaywalloSdkPackage.kt +1 -2
- package/dist/index.d.mts +298 -176
- package/dist/index.d.ts +298 -176
- package/dist/index.js +977 -912
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +925 -862
- package/dist/index.mjs.map +1 -1
- package/ios/PaywalloFBBridge.m +3 -0
- package/ios/PaywalloFBBridge.swift +20 -0
- package/package.json +4 -1
- package/android/src/main/java/com/paywallo/sdk/PaywalloDeviceModule.kt +0 -148
- package/ios/PaywalloDevice.m +0 -8
- package/ios/PaywalloDevice.swift +0 -119
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import React__default from 'react';
|
|
3
3
|
|
|
4
|
+
interface SessionState {
|
|
5
|
+
sessionId: string | null;
|
|
6
|
+
startedAt: Date | null;
|
|
7
|
+
isActive: boolean;
|
|
8
|
+
duration: number;
|
|
9
|
+
}
|
|
10
|
+
interface SessionConfig {
|
|
11
|
+
sessionTimeoutMs?: number;
|
|
12
|
+
trackAppState?: boolean;
|
|
13
|
+
}
|
|
14
|
+
type EmergencyPaywallHandler = (paywallId: string) => Promise<void>;
|
|
15
|
+
|
|
4
16
|
type EntranceAnimationType = "none" | "fade" | "slide-up" | "slide-down" | "slide-left" | "slide-right" | "scale" | "bounce";
|
|
5
17
|
type LoopAnimationType = "none" | "pulse" | "glow" | "float" | "shake" | "bounce";
|
|
6
18
|
type InteractionAnimationType = "none" | "scale-down" | "opacity" | "highlight";
|
|
@@ -304,7 +316,6 @@ interface PaywallErrorStrings$1 {
|
|
|
304
316
|
}
|
|
305
317
|
interface PaywalloConfig {
|
|
306
318
|
appKey: string;
|
|
307
|
-
apiUrl?: string;
|
|
308
319
|
debug?: boolean;
|
|
309
320
|
environment?: Environment;
|
|
310
321
|
errorStrings?: PaywallErrorStrings$1;
|
|
@@ -362,33 +373,6 @@ interface ConditionalFlagContext {
|
|
|
362
373
|
distinctId?: string;
|
|
363
374
|
}
|
|
364
375
|
|
|
365
|
-
interface PreloadResult {
|
|
366
|
-
success: boolean;
|
|
367
|
-
error?: Error;
|
|
368
|
-
}
|
|
369
|
-
interface PaywalloContextValue {
|
|
370
|
-
config: PaywalloConfig | null;
|
|
371
|
-
isInitialized: boolean;
|
|
372
|
-
isReady: boolean;
|
|
373
|
-
initError: Error | null;
|
|
374
|
-
distinctId: string | null;
|
|
375
|
-
subscription: Subscription | null;
|
|
376
|
-
products: Map<string, Product>;
|
|
377
|
-
isLoadingProducts: boolean;
|
|
378
|
-
presentPaywall: (placement: string) => Promise<PaywallResult>;
|
|
379
|
-
presentCampaign: (placement: string, context?: Record<string, unknown>) => Promise<CampaignResult>;
|
|
380
|
-
preloadCampaign: (placement: string, context?: Record<string, unknown>) => Promise<PreloadResult>;
|
|
381
|
-
hasActiveSubscription: () => Promise<boolean>;
|
|
382
|
-
getSubscription: () => Promise<Subscription | null>;
|
|
383
|
-
restorePurchases: () => Promise<{
|
|
384
|
-
success: boolean;
|
|
385
|
-
error?: Error;
|
|
386
|
-
}>;
|
|
387
|
-
getPaywallConfig: (placement: string) => Promise<PaywallConfig | null>;
|
|
388
|
-
refreshProducts: (productIds: string[]) => Promise<void>;
|
|
389
|
-
}
|
|
390
|
-
declare const PaywalloContext: React.Context<PaywalloContextValue | null>;
|
|
391
|
-
|
|
392
376
|
/**
|
|
393
377
|
* Shared context resolved once per batch and hoisted out of every individual
|
|
394
378
|
* event in the V2 ingest envelope. The provider is called at flush time so
|
|
@@ -411,6 +395,7 @@ interface EventContext {
|
|
|
411
395
|
device_model?: string;
|
|
412
396
|
timezone?: string;
|
|
413
397
|
locale?: string;
|
|
398
|
+
country?: string;
|
|
414
399
|
carrier?: string;
|
|
415
400
|
screen_width?: number;
|
|
416
401
|
screen_height?: number;
|
|
@@ -565,122 +550,6 @@ declare class ApiClient {
|
|
|
565
550
|
private flagDeps;
|
|
566
551
|
}
|
|
567
552
|
|
|
568
|
-
type NetworkState = "online" | "offline" | "unknown";
|
|
569
|
-
type NetworkListener = (state: NetworkState) => void;
|
|
570
|
-
interface NetworkMonitorConfig {
|
|
571
|
-
debug: boolean;
|
|
572
|
-
checkInterval: number;
|
|
573
|
-
checkUrl: string;
|
|
574
|
-
}
|
|
575
|
-
|
|
576
|
-
declare class NetworkMonitorClass {
|
|
577
|
-
private config;
|
|
578
|
-
private listeners;
|
|
579
|
-
private currentState;
|
|
580
|
-
private appStateSubscription;
|
|
581
|
-
private initialized;
|
|
582
|
-
private checkIntervalId;
|
|
583
|
-
initialize(config?: Partial<NetworkMonitorConfig>): Promise<void>;
|
|
584
|
-
private setupFallbackDetection;
|
|
585
|
-
private setupAppStateListener;
|
|
586
|
-
private checkConnectivity;
|
|
587
|
-
private updateState;
|
|
588
|
-
private notifyListeners;
|
|
589
|
-
isOnline(): boolean;
|
|
590
|
-
getState(): NetworkState;
|
|
591
|
-
isInitialized(): boolean;
|
|
592
|
-
addListener(listener: NetworkListener): () => void;
|
|
593
|
-
removeListener(listener: NetworkListener): void;
|
|
594
|
-
forceCheck(): Promise<NetworkState>;
|
|
595
|
-
dispose(): void;
|
|
596
|
-
private log;
|
|
597
|
-
setDebug(debug: boolean): void;
|
|
598
|
-
}
|
|
599
|
-
declare const networkMonitor: NetworkMonitorClass;
|
|
600
|
-
|
|
601
|
-
/**
|
|
602
|
-
* Guard usado pelo SessionManager.startSession() — aguarda distinctId ficar
|
|
603
|
-
* disponível antes de criar a sessão. Raiz dos 55% users com total_sessions=0
|
|
604
|
-
* era session.startSession rodando em paralelo com identity.initialize() e
|
|
605
|
-
* batendo em distinctId vazio. Agora sessão só inicia depois da identity
|
|
606
|
-
* estar pronta; este guard é uma defesa extra caso alguém chame startSession
|
|
607
|
-
* manualmente antes do init terminar.
|
|
608
|
-
*/
|
|
609
|
-
type DistinctIdProvider = () => string;
|
|
610
|
-
|
|
611
|
-
/**
|
|
612
|
-
* Attribution data captured at first touch (UTM params, click IDs, referrer).
|
|
613
|
-
* `capturedAt` is ISO 8601 UTC — generated automatically by `capture()`.
|
|
614
|
-
*/
|
|
615
|
-
interface AttributionCapture {
|
|
616
|
-
readonly utmSource?: string;
|
|
617
|
-
readonly utmMedium?: string;
|
|
618
|
-
readonly utmCampaign?: string;
|
|
619
|
-
readonly utmContent?: string;
|
|
620
|
-
readonly utmTerm?: string;
|
|
621
|
-
readonly fbclid?: string;
|
|
622
|
-
readonly gclid?: string;
|
|
623
|
-
readonly ttclid?: string;
|
|
624
|
-
readonly tiktokCampaignId?: string;
|
|
625
|
-
readonly tiktokAdgroupId?: string;
|
|
626
|
-
readonly tiktokAdId?: string;
|
|
627
|
-
readonly installReferrerRaw?: string;
|
|
628
|
-
readonly installReferrerSource?: string;
|
|
629
|
-
readonly referrer?: string;
|
|
630
|
-
readonly capturedAt: string;
|
|
631
|
-
}
|
|
632
|
-
type AttributionInput = Omit<AttributionCapture, "capturedAt">;
|
|
633
|
-
/**
|
|
634
|
-
* Attribution module — first-write-wins persistence of UTM / click-ID data.
|
|
635
|
-
*
|
|
636
|
-
* Once a capture is stored, subsequent `capture()` calls are silently ignored.
|
|
637
|
-
* Use `clear()` to reset (e.g. on logout or in tests).
|
|
638
|
-
*
|
|
639
|
-
* @example
|
|
640
|
-
* await attributionTracker.capture({ utmSource: "google", gclid: "Cj0KCQ..." });
|
|
641
|
-
* const attr = attributionTracker.get(); // { utmSource: "google", capturedAt: "..." }
|
|
642
|
-
*/
|
|
643
|
-
declare class AttributionTracker {
|
|
644
|
-
private cache;
|
|
645
|
-
private captureInProgress;
|
|
646
|
-
private readonly storage;
|
|
647
|
-
constructor(debug?: boolean);
|
|
648
|
-
/**
|
|
649
|
-
* Load persisted attribution from storage into in-memory cache.
|
|
650
|
-
* Called once on SDK init. Subsequent `get()` reads are synchronous.
|
|
651
|
-
*/
|
|
652
|
-
loadFromStorage(): Promise<void>;
|
|
653
|
-
/**
|
|
654
|
-
* Persist attribution data. First-write wins — ignores if already captured
|
|
655
|
-
* or if all fields are absent (empty capture).
|
|
656
|
-
*
|
|
657
|
-
* @param data - Attribution fields without `capturedAt` (generated internally).
|
|
658
|
-
*/
|
|
659
|
-
capture(data: AttributionInput): Promise<void>;
|
|
660
|
-
/**
|
|
661
|
-
* Returns the persisted attribution capture, or `null` if none exists.
|
|
662
|
-
* Synchronous — reads from in-memory cache (populated via `loadFromStorage()`).
|
|
663
|
-
*/
|
|
664
|
-
get(): AttributionCapture | null;
|
|
665
|
-
/**
|
|
666
|
-
* Clears the persisted attribution from storage and in-memory cache.
|
|
667
|
-
* After `clear()`, `get()` returns `null` and the next `capture()` writes normally.
|
|
668
|
-
*/
|
|
669
|
-
clear(): Promise<void>;
|
|
670
|
-
}
|
|
671
|
-
declare const attributionTracker: AttributionTracker;
|
|
672
|
-
|
|
673
|
-
declare class IdentityError extends PaywalloError {
|
|
674
|
-
constructor(code: string, message: string);
|
|
675
|
-
}
|
|
676
|
-
declare const IDENTITY_ERROR_CODES: {
|
|
677
|
-
readonly NOT_INITIALIZED: "IDENTITY_NOT_INITIALIZED";
|
|
678
|
-
readonly DEVICE_ID_UNAVAILABLE: "IDENTITY_DEVICE_ID_UNAVAILABLE";
|
|
679
|
-
readonly STORAGE_READ_FAILED: "IDENTITY_STORAGE_READ_FAILED";
|
|
680
|
-
readonly STORAGE_WRITE_FAILED: "IDENTITY_STORAGE_WRITE_FAILED";
|
|
681
|
-
readonly IDENTIFY_FAILED: "IDENTITY_IDENTIFY_FAILED";
|
|
682
|
-
};
|
|
683
|
-
|
|
684
553
|
interface IdentityState {
|
|
685
554
|
deviceId: string;
|
|
686
555
|
email: string | null;
|
|
@@ -711,6 +580,8 @@ declare class IdentityManager {
|
|
|
711
580
|
private _doInitialize;
|
|
712
581
|
identify(options?: IdentifyOptions | UserProperties): Promise<void>;
|
|
713
582
|
getDistinctId(): string;
|
|
583
|
+
/** Public stable identifier — returns the same value as `getDistinctId()`. */
|
|
584
|
+
getId(): string;
|
|
714
585
|
getDeviceId(): string | null;
|
|
715
586
|
getEmail(): string | null;
|
|
716
587
|
getProperties(): UserProperties;
|
|
@@ -723,20 +594,6 @@ declare class IdentityManager {
|
|
|
723
594
|
}
|
|
724
595
|
declare const identityManager: IdentityManager;
|
|
725
596
|
|
|
726
|
-
declare class MetaBridge {
|
|
727
|
-
private cachedAnonId;
|
|
728
|
-
private debug;
|
|
729
|
-
setDebug(debug: boolean): void;
|
|
730
|
-
/** Sync read of the cached anonymous ID. Returns null until `getAnonymousID()` resolves once. */
|
|
731
|
-
getCachedAnonymousID(): string | null;
|
|
732
|
-
getAnonymousID(): Promise<string | null>;
|
|
733
|
-
logEvent(name: string, params?: Record<string, unknown>): Promise<void>;
|
|
734
|
-
logPurchase(amount: number, currency: string, params?: Record<string, unknown>): Promise<void>;
|
|
735
|
-
setUserID(userId: string): void;
|
|
736
|
-
flush(): void;
|
|
737
|
-
}
|
|
738
|
-
declare const metaBridge: MetaBridge;
|
|
739
|
-
|
|
740
597
|
interface FcmRemoteMessage {
|
|
741
598
|
messageId?: string;
|
|
742
599
|
data?: Record<string, string>;
|
|
@@ -1033,6 +890,106 @@ declare class PlanService {
|
|
|
1033
890
|
}
|
|
1034
891
|
declare const planService: PlanService;
|
|
1035
892
|
|
|
893
|
+
/**
|
|
894
|
+
* Guard usado pelo SessionManager.startSession() — aguarda distinctId ficar
|
|
895
|
+
* disponível antes de criar a sessão. Raiz dos 55% users com total_sessions=0
|
|
896
|
+
* era session.startSession rodando em paralelo com identity.initialize() e
|
|
897
|
+
* batendo em distinctId vazio. Agora sessão só inicia depois da identity
|
|
898
|
+
* estar pronta; este guard é uma defesa extra caso alguém chame startSession
|
|
899
|
+
* manualmente antes do init terminar.
|
|
900
|
+
*/
|
|
901
|
+
type DistinctIdProvider = () => string;
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* Attribution data captured at first touch (UTM params, click IDs, referrer).
|
|
905
|
+
* `capturedAt` is ISO 8601 UTC — generated automatically by `capture()`.
|
|
906
|
+
*/
|
|
907
|
+
interface AttributionCapture {
|
|
908
|
+
readonly utmSource?: string;
|
|
909
|
+
readonly utmMedium?: string;
|
|
910
|
+
readonly utmCampaign?: string;
|
|
911
|
+
readonly utmContent?: string;
|
|
912
|
+
readonly utmTerm?: string;
|
|
913
|
+
readonly fbclid?: string;
|
|
914
|
+
readonly gclid?: string;
|
|
915
|
+
readonly ttclid?: string;
|
|
916
|
+
readonly tiktokCampaignId?: string;
|
|
917
|
+
readonly tiktokAdgroupId?: string;
|
|
918
|
+
readonly tiktokAdId?: string;
|
|
919
|
+
readonly installReferrerRaw?: string;
|
|
920
|
+
readonly installReferrerSource?: string;
|
|
921
|
+
readonly referrer?: string;
|
|
922
|
+
readonly capturedAt: string;
|
|
923
|
+
}
|
|
924
|
+
type AttributionInput = Omit<AttributionCapture, "capturedAt">;
|
|
925
|
+
/**
|
|
926
|
+
* Attribution module — first-write-wins persistence of UTM / click-ID data.
|
|
927
|
+
*
|
|
928
|
+
* Once a capture is stored, subsequent `capture()` calls are silently ignored.
|
|
929
|
+
* Use `clear()` to reset (e.g. on logout or in tests).
|
|
930
|
+
*
|
|
931
|
+
* @example
|
|
932
|
+
* await attributionTracker.capture({ utmSource: "google", gclid: "Cj0KCQ..." });
|
|
933
|
+
* const attr = attributionTracker.get(); // { utmSource: "google", capturedAt: "..." }
|
|
934
|
+
*/
|
|
935
|
+
declare class AttributionTracker {
|
|
936
|
+
private cache;
|
|
937
|
+
private captureInProgress;
|
|
938
|
+
private readonly storage;
|
|
939
|
+
constructor(debug?: boolean);
|
|
940
|
+
/**
|
|
941
|
+
* Load persisted attribution from storage into in-memory cache.
|
|
942
|
+
* Called once on SDK init. Subsequent `get()` reads are synchronous.
|
|
943
|
+
*/
|
|
944
|
+
loadFromStorage(): Promise<void>;
|
|
945
|
+
/**
|
|
946
|
+
* Persist attribution data. First-write wins — ignores if already captured
|
|
947
|
+
* or if all fields are absent (empty capture).
|
|
948
|
+
*
|
|
949
|
+
* @param data - Attribution fields without `capturedAt` (generated internally).
|
|
950
|
+
*/
|
|
951
|
+
capture(data: AttributionInput): Promise<void>;
|
|
952
|
+
/**
|
|
953
|
+
* Returns the persisted attribution capture, or `null` if none exists.
|
|
954
|
+
* Synchronous — reads from in-memory cache (populated via `loadFromStorage()`).
|
|
955
|
+
*/
|
|
956
|
+
get(): AttributionCapture | null;
|
|
957
|
+
/**
|
|
958
|
+
* Clears the persisted attribution from storage and in-memory cache.
|
|
959
|
+
* After `clear()`, `get()` returns `null` and the next `capture()` writes normally.
|
|
960
|
+
*/
|
|
961
|
+
clear(): Promise<void>;
|
|
962
|
+
}
|
|
963
|
+
declare const attributionTracker: AttributionTracker;
|
|
964
|
+
|
|
965
|
+
declare class IdentityError extends PaywalloError {
|
|
966
|
+
constructor(code: string, message: string);
|
|
967
|
+
}
|
|
968
|
+
declare const IDENTITY_ERROR_CODES: {
|
|
969
|
+
readonly NOT_INITIALIZED: "IDENTITY_NOT_INITIALIZED";
|
|
970
|
+
readonly DEVICE_ID_UNAVAILABLE: "IDENTITY_DEVICE_ID_UNAVAILABLE";
|
|
971
|
+
readonly STORAGE_READ_FAILED: "IDENTITY_STORAGE_READ_FAILED";
|
|
972
|
+
readonly STORAGE_WRITE_FAILED: "IDENTITY_STORAGE_WRITE_FAILED";
|
|
973
|
+
readonly IDENTIFY_FAILED: "IDENTITY_IDENTIFY_FAILED";
|
|
974
|
+
};
|
|
975
|
+
|
|
976
|
+
declare class MetaBridge {
|
|
977
|
+
private cachedAnonId;
|
|
978
|
+
private cachedDeferredLink;
|
|
979
|
+
private deferredLinkFetched;
|
|
980
|
+
private debug;
|
|
981
|
+
setDebug(debug: boolean): void;
|
|
982
|
+
/** Sync read of the cached anonymous ID. Returns null until `getAnonymousID()` resolves once. */
|
|
983
|
+
getCachedAnonymousID(): string | null;
|
|
984
|
+
getAnonymousID(): Promise<string | null>;
|
|
985
|
+
fetchDeferredAppLink(): Promise<string | null>;
|
|
986
|
+
logEvent(name: string, params?: Record<string, unknown>): Promise<void>;
|
|
987
|
+
logPurchase(amount: number, currency: string, params?: Record<string, unknown>): Promise<void>;
|
|
988
|
+
setUserID(userId: string): void;
|
|
989
|
+
flush(): void;
|
|
990
|
+
}
|
|
991
|
+
declare const metaBridge: MetaBridge;
|
|
992
|
+
|
|
1036
993
|
declare class SessionError extends PaywalloError {
|
|
1037
994
|
constructor(code: string, message: string);
|
|
1038
995
|
}
|
|
@@ -1043,18 +1000,6 @@ declare const SESSION_ERROR_CODES: {
|
|
|
1043
1000
|
readonly RESTORE_FAILED: "SESSION_RESTORE_FAILED";
|
|
1044
1001
|
};
|
|
1045
1002
|
|
|
1046
|
-
interface SessionState {
|
|
1047
|
-
sessionId: string | null;
|
|
1048
|
-
startedAt: Date | null;
|
|
1049
|
-
isActive: boolean;
|
|
1050
|
-
duration: number;
|
|
1051
|
-
}
|
|
1052
|
-
interface SessionConfig {
|
|
1053
|
-
sessionTimeoutMs?: number;
|
|
1054
|
-
trackAppState?: boolean;
|
|
1055
|
-
}
|
|
1056
|
-
type EmergencyPaywallHandler = (paywallId: string) => Promise<void>;
|
|
1057
|
-
|
|
1058
1003
|
declare class SessionManager {
|
|
1059
1004
|
private sessionId;
|
|
1060
1005
|
private sessionStartedAt;
|
|
@@ -1124,7 +1069,6 @@ interface PaywalloInitConfig extends PaywalloConfig {
|
|
|
1124
1069
|
notifications?: boolean;
|
|
1125
1070
|
}
|
|
1126
1071
|
interface IPaywalloClient {
|
|
1127
|
-
init(config: PaywalloInitConfig): Promise<void>;
|
|
1128
1072
|
isReady(): boolean;
|
|
1129
1073
|
waitUntilReady(): Promise<void>;
|
|
1130
1074
|
identify(options?: IdentifyOptions | UserProperties): Promise<void>;
|
|
@@ -1155,6 +1099,8 @@ interface IPaywalloClient {
|
|
|
1155
1099
|
provisional?: boolean;
|
|
1156
1100
|
}): Promise<PushPermissionStatus>;
|
|
1157
1101
|
getConfig(): PaywalloConfig | null;
|
|
1102
|
+
/** Public stable identifier — wraps `getDistinctId()`. Established automatically on boot. */
|
|
1103
|
+
getId(): string;
|
|
1158
1104
|
getDistinctId(): string;
|
|
1159
1105
|
getDeviceId(): string | null;
|
|
1160
1106
|
getEmail(): string | null;
|
|
@@ -1191,7 +1137,151 @@ interface IPaywalloClient {
|
|
|
1191
1137
|
getCurrentPlan(): Promise<Plan | null>;
|
|
1192
1138
|
}
|
|
1193
1139
|
|
|
1194
|
-
|
|
1140
|
+
type PaywallPresenter = (placement: string) => Promise<PaywallResult>;
|
|
1141
|
+
type CampaignPresenter = (campaign: CampaignResponse) => Promise<CampaignResult>;
|
|
1142
|
+
type SubscriptionGetter = () => Promise<Subscription | null>;
|
|
1143
|
+
type ActiveChecker = () => Promise<boolean>;
|
|
1144
|
+
type RestoreHandler = () => Promise<RestoreResult$1>;
|
|
1145
|
+
|
|
1146
|
+
declare class PaywalloClientClass {
|
|
1147
|
+
private readonly state;
|
|
1148
|
+
init(config: PaywalloInitConfig): Promise<void>;
|
|
1149
|
+
isReady(): boolean;
|
|
1150
|
+
waitUntilReady(): Promise<void>;
|
|
1151
|
+
identify(options?: IdentifyOptions | UserProperties): Promise<void>;
|
|
1152
|
+
track(eventName: string, options?: TrackEventOptions): Promise<void>;
|
|
1153
|
+
onboardingStep(order: number, name: string): Promise<void>;
|
|
1154
|
+
coreAction(actionName: string): Promise<void>;
|
|
1155
|
+
getVariantCached(flagKey: string, defaultValue?: string): Promise<FlagVariant>;
|
|
1156
|
+
getVariant(flagKey: string): Promise<FlagVariant>;
|
|
1157
|
+
evaluateFlags(keys: string[]): Promise<Record<string, string | null>>;
|
|
1158
|
+
getConditionalFlag(flagKey: string, context?: Partial<ConditionalFlagContext>): Promise<boolean>;
|
|
1159
|
+
getPaywall(placement: string): Promise<PaywallConfig | null>;
|
|
1160
|
+
presentPaywall(placement: string): Promise<PaywallResult>;
|
|
1161
|
+
getCampaign(placement: string, context?: Record<string, unknown>): Promise<CampaignResponse | null>;
|
|
1162
|
+
presentCampaign(placement: string, context?: Record<string, unknown>): Promise<CampaignResult>;
|
|
1163
|
+
hasActiveSubscription(): Promise<boolean>;
|
|
1164
|
+
getSubscription(): Promise<Subscription | null>;
|
|
1165
|
+
restorePurchases(): Promise<RestoreResult$1>;
|
|
1166
|
+
reset(): Promise<void>;
|
|
1167
|
+
fullReset(): Promise<void>;
|
|
1168
|
+
/**
|
|
1169
|
+
* Request OS push permission (iOS/Android 13+) and, on grant, register
|
|
1170
|
+
* the FCM/APNS token with the Paywallo backend. Returns the final
|
|
1171
|
+
* permission status — no-op safe to call before init (returns
|
|
1172
|
+
* `notDetermined`). Token renewal via `onTokenRefresh` re-registers
|
|
1173
|
+
* automatically.
|
|
1174
|
+
*/
|
|
1175
|
+
requestPushPermission(options?: {
|
|
1176
|
+
provisional?: boolean;
|
|
1177
|
+
}): Promise<PushPermissionStatus>;
|
|
1178
|
+
getSessionFlag(key: string): string | null;
|
|
1179
|
+
getConfig(): PaywalloConfig | null;
|
|
1180
|
+
getId(): string;
|
|
1181
|
+
getDistinctId(): string;
|
|
1182
|
+
getDeviceId(): string | null;
|
|
1183
|
+
getEmail(): string | null;
|
|
1184
|
+
getEnvironment(): Environment;
|
|
1185
|
+
setEnvironment(environment: Environment): void;
|
|
1186
|
+
getApiClient(): ApiClient | null;
|
|
1187
|
+
getWebUrl(): string | null;
|
|
1188
|
+
getIdentityState(): IdentityState;
|
|
1189
|
+
getSessionState(): SessionState;
|
|
1190
|
+
getSessionId(): string | null;
|
|
1191
|
+
startSession(): Promise<string>;
|
|
1192
|
+
endSession(): Promise<void>;
|
|
1193
|
+
registerPaywallPresenter(p: PaywallPresenter | null): void;
|
|
1194
|
+
registerCampaignPresenter(p: CampaignPresenter | null): void;
|
|
1195
|
+
registerSubscriptionGetter(g: SubscriptionGetter | null): void;
|
|
1196
|
+
registerActiveChecker(c: ActiveChecker | null): void;
|
|
1197
|
+
registerRestoreHandler(h: RestoreHandler | null): void;
|
|
1198
|
+
registerEmergencyPaywallHandler(h: EmergencyPaywallHandler | null): void;
|
|
1199
|
+
getEmergencyPaywall(): Promise<EmergencyPaywallResponse>;
|
|
1200
|
+
requireSubscription(paywallPlacement?: string): Promise<boolean>;
|
|
1201
|
+
requireSubscriptionWithCampaign(placement: string, context?: Record<string, unknown>): Promise<boolean>;
|
|
1202
|
+
gateContent<T>(content: () => T | Promise<T>, paywallPlacement?: string): Promise<T | null>;
|
|
1203
|
+
gateContentWithCampaign<T>(content: () => T | Promise<T>, placement: string, context?: Record<string, unknown>): Promise<T | null>;
|
|
1204
|
+
preloadCampaign(placement: string, context?: Record<string, unknown>): Promise<PreloadCampaignResult>;
|
|
1205
|
+
getPreloadedCampaign(placement: string): CampaignResponse | null;
|
|
1206
|
+
isPreloaded(placement: string): boolean;
|
|
1207
|
+
preloadPaywall(placement: string): Promise<PreloadPaywallResult>;
|
|
1208
|
+
preloadPaywalls(placements: string[]): Promise<void>;
|
|
1209
|
+
isPaywallPreloaded(placement: string): boolean;
|
|
1210
|
+
getAutoPreloadedPlacement(): string | null;
|
|
1211
|
+
waitForAutoPreloadedPlacement(): Promise<string | null>;
|
|
1212
|
+
isOnline(): boolean;
|
|
1213
|
+
getOfflineQueueSize(): number;
|
|
1214
|
+
clearOfflineQueue(): Promise<void>;
|
|
1215
|
+
processOfflineQueue(): Promise<{
|
|
1216
|
+
processed: number;
|
|
1217
|
+
failed: number;
|
|
1218
|
+
}>;
|
|
1219
|
+
getPlans(): Promise<AllPlansResponse>;
|
|
1220
|
+
getCurrentPlan(): Promise<Plan | null>;
|
|
1221
|
+
private getApiClientOrThrow;
|
|
1222
|
+
private ensureInitialized;
|
|
1223
|
+
}
|
|
1224
|
+
declare const PaywalloClient: PaywalloClientClass;
|
|
1225
|
+
|
|
1226
|
+
interface PreloadResult {
|
|
1227
|
+
success: boolean;
|
|
1228
|
+
error?: Error;
|
|
1229
|
+
}
|
|
1230
|
+
interface PaywalloContextValue {
|
|
1231
|
+
config: PaywalloConfig | null;
|
|
1232
|
+
isInitialized: boolean;
|
|
1233
|
+
isReady: boolean;
|
|
1234
|
+
initError: Error | null;
|
|
1235
|
+
distinctId: string | null;
|
|
1236
|
+
subscription: Subscription | null;
|
|
1237
|
+
products: Map<string, Product>;
|
|
1238
|
+
isLoadingProducts: boolean;
|
|
1239
|
+
presentPaywall: (placement: string) => Promise<PaywallResult>;
|
|
1240
|
+
presentCampaign: (placement: string, context?: Record<string, unknown>) => Promise<CampaignResult>;
|
|
1241
|
+
preloadCampaign: (placement: string, context?: Record<string, unknown>) => Promise<PreloadResult>;
|
|
1242
|
+
hasActiveSubscription: () => Promise<boolean>;
|
|
1243
|
+
getSubscription: () => Promise<Subscription | null>;
|
|
1244
|
+
restorePurchases: () => Promise<{
|
|
1245
|
+
success: boolean;
|
|
1246
|
+
error?: Error;
|
|
1247
|
+
}>;
|
|
1248
|
+
getPaywallConfig: (placement: string) => Promise<PaywallConfig | null>;
|
|
1249
|
+
refreshProducts: (productIds: string[]) => Promise<void>;
|
|
1250
|
+
}
|
|
1251
|
+
declare const PaywalloContext: React.Context<PaywalloContextValue | null>;
|
|
1252
|
+
|
|
1253
|
+
type NetworkState = "online" | "offline" | "unknown";
|
|
1254
|
+
type NetworkListener = (state: NetworkState) => void;
|
|
1255
|
+
interface NetworkMonitorConfig {
|
|
1256
|
+
debug: boolean;
|
|
1257
|
+
checkInterval: number;
|
|
1258
|
+
checkUrl: string;
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
declare class NetworkMonitorClass {
|
|
1262
|
+
private config;
|
|
1263
|
+
private listeners;
|
|
1264
|
+
private currentState;
|
|
1265
|
+
private appStateSubscription;
|
|
1266
|
+
private initialized;
|
|
1267
|
+
private checkIntervalId;
|
|
1268
|
+
initialize(config?: Partial<NetworkMonitorConfig>): Promise<void>;
|
|
1269
|
+
private setupFallbackDetection;
|
|
1270
|
+
private setupAppStateListener;
|
|
1271
|
+
private checkConnectivity;
|
|
1272
|
+
private updateState;
|
|
1273
|
+
private notifyListeners;
|
|
1274
|
+
isOnline(): boolean;
|
|
1275
|
+
getState(): NetworkState;
|
|
1276
|
+
isInitialized(): boolean;
|
|
1277
|
+
addListener(listener: NetworkListener): () => void;
|
|
1278
|
+
removeListener(listener: NetworkListener): void;
|
|
1279
|
+
forceCheck(): Promise<NetworkState>;
|
|
1280
|
+
dispose(): void;
|
|
1281
|
+
private log;
|
|
1282
|
+
setDebug(debug: boolean): void;
|
|
1283
|
+
}
|
|
1284
|
+
declare const networkMonitor: NetworkMonitorClass;
|
|
1195
1285
|
|
|
1196
1286
|
type QueuePriority = "critical" | "normal";
|
|
1197
1287
|
interface QueueItem {
|
|
@@ -1431,7 +1521,7 @@ declare class IAPService {
|
|
|
1431
1521
|
private finishTransaction;
|
|
1432
1522
|
startTransactionListener(): void;
|
|
1433
1523
|
stopTransactionListener(): void;
|
|
1434
|
-
emitTransactionUpdate(
|
|
1524
|
+
emitTransactionUpdate(_update: NativeTransactionUpdate): Promise<void>;
|
|
1435
1525
|
purchase(productId: string, options?: ValidateOptions): Promise<PurchaseResult>;
|
|
1436
1526
|
restore(): Promise<Purchase[]>;
|
|
1437
1527
|
reset(): void;
|
|
@@ -1560,8 +1650,9 @@ declare class OnboardingManager {
|
|
|
1560
1650
|
* Saves the step name internally for implicit drop detection on the backend.
|
|
1561
1651
|
*
|
|
1562
1652
|
* @param stepName - Unique name for this onboarding step.
|
|
1653
|
+
* @param order - Optional explicit display order (accepts decimals, e.g. 2.1 for A/B variants).
|
|
1563
1654
|
*/
|
|
1564
|
-
step(stepName: string): Promise<void>;
|
|
1655
|
+
step(stepName: string, order?: number): Promise<void>;
|
|
1565
1656
|
/**
|
|
1566
1657
|
* Tracks successful completion of the onboarding flow.
|
|
1567
1658
|
* Marks the flow as finished.
|
|
@@ -1587,6 +1678,8 @@ declare const onboardingManager: OnboardingManager;
|
|
|
1587
1678
|
/** Payload sent with onboarding.step events. */
|
|
1588
1679
|
interface OnboardingStepPayload {
|
|
1589
1680
|
step_name: string;
|
|
1681
|
+
/** Optional explicit order (accepts decimals, e.g. 2.1 for A/B variants). */
|
|
1682
|
+
order?: number;
|
|
1590
1683
|
}
|
|
1591
1684
|
/** Payload sent with onboarding.drop events. */
|
|
1592
1685
|
interface OnboardingDropPayload {
|
|
@@ -1759,7 +1852,7 @@ interface UseOfferingsResult {
|
|
|
1759
1852
|
declare function useOfferings(ids?: string[]): UseOfferingsResult;
|
|
1760
1853
|
|
|
1761
1854
|
interface UseOnboardingResult {
|
|
1762
|
-
step: (stepName: string) => Promise<void>;
|
|
1855
|
+
step: (stepName: string, order?: number) => Promise<void>;
|
|
1763
1856
|
complete: () => Promise<void>;
|
|
1764
1857
|
drop: (stepName: string) => Promise<void>;
|
|
1765
1858
|
}
|
|
@@ -1841,6 +1934,35 @@ interface UseSubscriptionResult {
|
|
|
1841
1934
|
}
|
|
1842
1935
|
declare function useSubscription(): UseSubscriptionResult;
|
|
1843
1936
|
|
|
1937
|
+
/**
|
|
1938
|
+
* Extracts the name of the currently active leaf route from a react-navigation
|
|
1939
|
+
* NavigationState. Descends into nested navigators recursively.
|
|
1940
|
+
*
|
|
1941
|
+
* Does NOT import react-navigation — accepts `state: unknown` and uses
|
|
1942
|
+
* structural duck-typing, so it works with v6, v7, and future versions alike.
|
|
1943
|
+
*
|
|
1944
|
+
* @returns the active route name string, or null if the shape is unexpected.
|
|
1945
|
+
*/
|
|
1946
|
+
declare function getActiveRouteName(state: unknown): string | null;
|
|
1947
|
+
/**
|
|
1948
|
+
* Returns a stable `onStateChange` callback ready to be passed directly to
|
|
1949
|
+
* `<NavigationContainer onStateChange={onStateChange}>`.
|
|
1950
|
+
*
|
|
1951
|
+
* Emits a `screen_view` event via the PaywalloClient pipeline each time the
|
|
1952
|
+
* active route changes. Consecutive calls with the same screen are no-ops
|
|
1953
|
+
* (deduplication by name). If the SDK is not yet initialized, calls are
|
|
1954
|
+
* silently ignored.
|
|
1955
|
+
*
|
|
1956
|
+
* @example
|
|
1957
|
+
* ```tsx
|
|
1958
|
+
* const onStateChange = usePaywalloScreenTracking();
|
|
1959
|
+
* <NavigationContainer onStateChange={onStateChange}>
|
|
1960
|
+
* {children}
|
|
1961
|
+
* </NavigationContainer>
|
|
1962
|
+
* ```
|
|
1963
|
+
*/
|
|
1964
|
+
declare function usePaywalloScreenTracking(): (state: unknown) => void;
|
|
1965
|
+
|
|
1844
1966
|
interface PaywalloProviderProps {
|
|
1845
1967
|
children: React__default.ReactNode;
|
|
1846
1968
|
config: PaywalloConfig;
|
|
@@ -1884,4 +2006,4 @@ declare function hasVariables(text: string): boolean;
|
|
|
1884
2006
|
|
|
1885
2007
|
declare const Paywallo: IPaywalloClient;
|
|
1886
2008
|
|
|
1887
|
-
export { type AllPlansResponse, ApiClient, type ApiClientConfig, type AttributionCapture, AttributionTracker, type BlockType, type BoxSpacing, CAMPAIGN_ERROR_CODES, type CachedOfferings, type CachedPlans, type CachedSubscription, CampaignError, type CampaignPresentOptions, type CampaignResponse, type CampaignResult, type ConditionalFlagContext, type ConditionalFlagResult, type DeviceTokenRegistration, PURCHASE_ERROR_CODES as ERROR_CODES, type EmergencyPaywallResponse, type Environment, type FlagVariant, HttpClient, type HttpClientConfig, type HttpResponse, type IAPProduct, type IAPPurchase, IAPService, IDENTITY_ERROR_CODES, type IPaywalloClient, type IPushBridge, type IdentifyOptions, IdentityError, IdentityManager, type IdentityState, type LocalizedText, MetaBridge, NOTIFICATIONS_ERROR_CODES, NativePushBridge, type NetworkListener, type NetworkMonitorConfig, type NetworkState, type NotificationEventType, type NotificationListener, type NotificationPayload, NotificationsError, NotificationsManager, ONBOARDING_ERROR_CODES, type Offering, type OfferingProduct, OfferingService, type OfferingServiceConfig, type OfflineQueueConfig, type OnboardingDropPayload, OnboardingError, OnboardingManager, type OnboardingStepPayload, PAYWALL_ERROR_CODES, PURCHASE_ERROR_CODES, type PaywallBlockConfig, type PaywallConfig, PaywallContext, PaywallError, type PaywallErrorStrings$1 as PaywallErrorStrings, PaywallModal, type PaywallNode, type PaywallPresentOptions, type PaywallResult, type PaywallState, Paywallo, PaywalloClient, type PaywalloConfig, PaywalloContext, PaywalloError, type PaywalloInitConfig, PaywalloProvider, type PaywalloProviderProps, type Plan, PlanCache, type PlanProduct, PlanService, type PlanServiceConfig, type PlansResponse, type PrePromptHandle, type PrePromptOptions, type PreloadCampaignResult, type PreloadResult, type Product, type ProductPriceInfo, type Purchase, type PurchaseControllerConfig, PurchaseError, type PurchaseResult, type PurchaseState, type PushPermissionStatus, type PushPlatform, type QueueEvent, type QueueItem, type QueueListener, type QueueProcessorConfig, type RequestOptions, type RestoreResult$1 as RestoreResult, type RetryConfig, SESSION_ERROR_CODES, type SessionConfig, SessionError, SessionManager, type SessionState, type Subscription, SubscriptionCache, type SubscriptionInfo, type SubscriptionManagerConfig, type SubscriptionPlatform, type SubscriptionStatus$1 as SubscriptionStatus, type SubscriptionStatusResponse$1 as SubscriptionStatusResponse, type TapBehavior, type TrackEventOptions, type UserProperties, type ValidatePurchaseResponse, type VariableContext, attributionTracker, createPurchaseError, Paywallo as default, detectDeviceLanguage, getCurrentLanguage, getDefaultLanguage, getIAPService, getLocalizedString, hasVariables, identityManager, initLocalization, metaBridge, nativeStoreKit, networkMonitor, notificationsManager, offeringService, offlineQueue, onboardingManager, parseVariables, planCache, planService, queueProcessor, resolveText, sessionManager, setCurrentLanguage, setDefaultLanguage, subscriptionManager, useOfferingPurchase, useOfferings, useOnboarding, usePaywallContext, usePaywallo, usePlanPurchase, usePlans, useProducts, usePurchase, useSubscription };
|
|
2009
|
+
export { type AllPlansResponse, ApiClient, type ApiClientConfig, type AttributionCapture, AttributionTracker, type BlockType, type BoxSpacing, CAMPAIGN_ERROR_CODES, type CachedOfferings, type CachedPlans, type CachedSubscription, CampaignError, type CampaignPresentOptions, type CampaignResponse, type CampaignResult, type ConditionalFlagContext, type ConditionalFlagResult, type DeviceTokenRegistration, PURCHASE_ERROR_CODES as ERROR_CODES, type EmergencyPaywallResponse, type Environment, type FlagVariant, HttpClient, type HttpClientConfig, type HttpResponse, type IAPProduct, type IAPPurchase, IAPService, IDENTITY_ERROR_CODES, type IPaywalloClient, type IPushBridge, type IdentifyOptions, IdentityError, IdentityManager, type IdentityState, type LocalizedText, MetaBridge, NOTIFICATIONS_ERROR_CODES, NativePushBridge, type NetworkListener, type NetworkMonitorConfig, type NetworkState, type NotificationEventType, type NotificationListener, type NotificationPayload, NotificationsError, NotificationsManager, ONBOARDING_ERROR_CODES, type Offering, type OfferingProduct, OfferingService, type OfferingServiceConfig, type OfflineQueueConfig, type OnboardingDropPayload, OnboardingError, OnboardingManager, type OnboardingStepPayload, PAYWALL_ERROR_CODES, PURCHASE_ERROR_CODES, type PaywallBlockConfig, type PaywallConfig, PaywallContext, PaywallError, type PaywallErrorStrings$1 as PaywallErrorStrings, PaywallModal, type PaywallNode, type PaywallPresentOptions, type PaywallResult, type PaywallState, Paywallo, PaywalloClient, type PaywalloConfig, PaywalloContext, PaywalloError, type PaywalloInitConfig, PaywalloProvider, type PaywalloProviderProps, type Plan, PlanCache, type PlanProduct, PlanService, type PlanServiceConfig, type PlansResponse, type PrePromptHandle, type PrePromptOptions, type PreloadCampaignResult, type PreloadResult, type Product, type ProductPriceInfo, type Purchase, type PurchaseControllerConfig, PurchaseError, type PurchaseResult, type PurchaseState, type PushPermissionStatus, type PushPlatform, type QueueEvent, type QueueItem, type QueueListener, type QueueProcessorConfig, type RequestOptions, type RestoreResult$1 as RestoreResult, type RetryConfig, SESSION_ERROR_CODES, type SessionConfig, SessionError, SessionManager, type SessionState, type Subscription, SubscriptionCache, type SubscriptionInfo, type SubscriptionManagerConfig, type SubscriptionPlatform, type SubscriptionStatus$1 as SubscriptionStatus, type SubscriptionStatusResponse$1 as SubscriptionStatusResponse, type TapBehavior, type TrackEventOptions, type UserProperties, type ValidatePurchaseResponse, type VariableContext, attributionTracker, createPurchaseError, Paywallo as default, detectDeviceLanguage, getActiveRouteName, getCurrentLanguage, getDefaultLanguage, getIAPService, getLocalizedString, hasVariables, identityManager, initLocalization, metaBridge, nativeStoreKit, networkMonitor, notificationsManager, offeringService, offlineQueue, onboardingManager, parseVariables, planCache, planService, queueProcessor, resolveText, sessionManager, setCurrentLanguage, setDefaultLanguage, subscriptionManager, useOfferingPurchase, useOfferings, useOnboarding, usePaywallContext, usePaywallo, usePaywalloScreenTracking, usePlanPurchase, usePlans, useProducts, usePurchase, useSubscription };
|