@tryheliumai/paywall-sdk-react-native 3.0.7 → 3.0.15
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/PaywallSdkReactNative.podspec +1 -1
- package/ios/HeliumSwiftInterface.swift +88 -40
- package/ios/RCTHeliumBridge.m +33 -4
- package/lib/commonjs/HeliumExperimentInfo.types.js +2 -0
- package/lib/commonjs/HeliumExperimentInfo.types.js.map +1 -0
- package/lib/commonjs/index.js +42 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/native-interface.js +112 -23
- package/lib/commonjs/native-interface.js.map +1 -1
- package/lib/commonjs/types.js.map +1 -1
- package/lib/module/HeliumExperimentInfo.types.js +2 -0
- package/lib/module/HeliumExperimentInfo.types.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/native-interface.js +103 -21
- package/lib/module/native-interface.js.map +1 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/commonjs/src/HeliumExperimentInfo.types.d.ts +92 -0
- package/lib/typescript/commonjs/src/HeliumExperimentInfo.types.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +3 -2
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/native-interface.d.ts +39 -2
- package/lib/typescript/commonjs/src/native-interface.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types.d.ts +29 -2
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
- package/lib/typescript/module/src/HeliumExperimentInfo.types.d.ts +92 -0
- package/lib/typescript/module/src/HeliumExperimentInfo.types.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +3 -2
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/native-interface.d.ts +39 -2
- package/lib/typescript/module/src/native-interface.d.ts.map +1 -1
- package/lib/typescript/module/src/types.d.ts +29 -2
- package/lib/typescript/module/src/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/HeliumExperimentInfo.types.ts +109 -0
- package/src/index.ts +16 -0
- package/src/native-interface.tsx +127 -29
- package/src/types.ts +33 -2
|
@@ -1,13 +1,24 @@
|
|
|
1
|
-
import type { HeliumConfig, HeliumUpsellViewProps, HeliumDownloadStatus, PaywallInfo, PresentUpsellParams } from './types';
|
|
1
|
+
import type { HeliumConfig, HeliumUpsellViewProps, HeliumDownloadStatus, HeliumLightDarkMode, PaywallInfo, PresentUpsellParams } from './types';
|
|
2
|
+
import type { ExperimentInfo } from './HeliumExperimentInfo.types';
|
|
2
3
|
export declare const NativeHeliumUpsellView: import("react-native").HostComponent<HeliumUpsellViewProps>;
|
|
3
4
|
export declare const getDownloadStatus: () => HeliumDownloadStatus;
|
|
4
5
|
export declare const initialize: (config: HeliumConfig) => Promise<void>;
|
|
5
|
-
export declare const presentUpsell: ({ triggerName, onFallback, eventHandlers, customPaywallTraits, }: PresentUpsellParams) => void;
|
|
6
|
+
export declare const presentUpsell: ({ triggerName, onFallback, eventHandlers, customPaywallTraits, dontShowIfAlreadyEntitled, }: PresentUpsellParams) => void;
|
|
6
7
|
export declare const hideUpsell: () => void;
|
|
7
8
|
export declare const hideAllUpsells: () => void;
|
|
8
9
|
export declare const getPaywallInfo: (trigger: string) => Promise<PaywallInfo | undefined>;
|
|
9
10
|
export declare const handleDeepLink: (url: string | null) => Promise<boolean>;
|
|
10
11
|
export declare const setRevenueCatAppUserId: (rcAppUserId: string) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Set a custom user ID for the current user
|
|
14
|
+
*/
|
|
15
|
+
export declare const setCustomUserId: (newUserId: string) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Checks if the user has an active entitlement for any product attached to the paywall that will show for provided trigger.
|
|
18
|
+
* @param trigger The trigger name to check entitlement for
|
|
19
|
+
* @returns Promise resolving to true if entitled, false if not, or undefined if not known (i.e. the paywall is not downloaded yet)
|
|
20
|
+
*/
|
|
21
|
+
export declare const hasEntitlementForPaywall: (trigger: string) => Promise<boolean | undefined>;
|
|
11
22
|
/**
|
|
12
23
|
* Checks if the user has any active subscription (including non-renewable)
|
|
13
24
|
*/
|
|
@@ -16,6 +27,32 @@ export declare const hasAnyActiveSubscription: () => Promise<boolean>;
|
|
|
16
27
|
* Checks if the user has any entitlement
|
|
17
28
|
*/
|
|
18
29
|
export declare const hasAnyEntitlement: () => Promise<boolean>;
|
|
30
|
+
/**
|
|
31
|
+
* Get experiment allocation info for a specific trigger
|
|
32
|
+
*
|
|
33
|
+
* @param trigger The trigger name to get experiment info for
|
|
34
|
+
* @returns ExperimentInfo if the trigger has experiment data, undefined otherwise
|
|
35
|
+
*/
|
|
36
|
+
export declare const getExperimentInfoForTrigger: (trigger: string) => Promise<ExperimentInfo | undefined>;
|
|
37
|
+
/**
|
|
38
|
+
* Reset Helium entirely so you can call initialize again. Only for advanced use cases.
|
|
39
|
+
*/
|
|
40
|
+
export declare const resetHelium: () => void;
|
|
41
|
+
/**
|
|
42
|
+
* Set custom strings to show in the dialog that Helium will display if a "Restore Purchases" action is not successful.
|
|
43
|
+
* Note that these strings will not be localized by Helium for you.
|
|
44
|
+
*/
|
|
45
|
+
export declare const setCustomRestoreFailedStrings: (customTitle?: string, customMessage?: string, customCloseButtonText?: string) => void;
|
|
46
|
+
/**
|
|
47
|
+
* Disable the default dialog that Helium will display if a "Restore Purchases" action is not successful.
|
|
48
|
+
* You can handle this yourself if desired by listening for the PurchaseRestoreFailedEvent.
|
|
49
|
+
*/
|
|
50
|
+
export declare const disableRestoreFailedDialog: () => void;
|
|
51
|
+
/**
|
|
52
|
+
* Override the light/dark mode for Helium paywalls
|
|
53
|
+
* @param mode The mode to set: 'light', 'dark', or 'system' (follows device setting)
|
|
54
|
+
*/
|
|
55
|
+
export declare const setLightDarkModeOverride: (mode: HeliumLightDarkMode) => void;
|
|
19
56
|
export declare const HELIUM_CTA_NAMES: {
|
|
20
57
|
SCHEDULE_CALL: string;
|
|
21
58
|
SUBSCRIBE_BUTTON: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"native-interface.d.ts","sourceRoot":"","sources":["../../../../src/native-interface.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,EACpB,WAAW,EACX,mBAAmB,EAGpB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"native-interface.d.ts","sourceRoot":"","sources":["../../../../src/native-interface.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EACV,YAAY,EACZ,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,EACnB,WAAW,EACX,mBAAmB,EAGpB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAMnE,eAAO,MAAM,sBAAsB,6DACgC,CAAC;AAMpE,eAAO,MAAM,iBAAiB,4BAA6B,CAAC;AAM5D,eAAO,MAAM,UAAU,WAAkB,YAAY,kBA0HpD,CAAC;AAIF,eAAO,MAAM,aAAa,gGAMvB,mBAAmB,SAgBrB,CAAC;AA2FF,eAAO,MAAM,UAAU,YAEtB,CAAC;AAEF,eAAO,MAAM,cAAc,YAE1B,CAAC;AAEF,eAAO,MAAM,cAAc,YAChB,MAAM,KACd,OAAO,CAAC,WAAW,GAAG,SAAS,CAiBjC,CAAC;AAEF,eAAO,MAAM,cAAc,QAAe,MAAM,GAAG,IAAI,KAAG,OAAO,CAAC,OAAO,CAWxE,CAAC;AAEF,eAAO,MAAM,sBAAsB,gBAAiB,MAAM,SAEzD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,cAAe,MAAM,SAEhD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,YAC1B,MAAM,KACd,OAAO,CAAC,OAAO,GAAG,SAAS,CAE7B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB,QAAa,OAAO,CAAC,OAAO,CAEhE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAAa,OAAO,CAAC,OAAO,CAEzD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,YAC7B,MAAM,KACd,OAAO,CAAC,cAAc,GAAG,SAAS,CAapC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,YAEvB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,6BAA6B,iBAC1B,MAAM,kBACJ,MAAM,0BACE,MAAM,SAO/B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,0BAA0B,YAEtC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,SAAU,mBAAmB,SAEjE,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;CAG5B,CAAC"}
|
|
@@ -4,6 +4,7 @@ export type HeliumPurchaseResult = {
|
|
|
4
4
|
error?: string;
|
|
5
5
|
};
|
|
6
6
|
export type HeliumDownloadStatus = 'success' | 'failed' | 'inProgress' | 'notStarted';
|
|
7
|
+
export type HeliumLightDarkMode = 'light' | 'dark' | 'system';
|
|
7
8
|
/** Interface for providing custom purchase handling logic. */
|
|
8
9
|
export interface HeliumPurchaseConfig {
|
|
9
10
|
makePurchase: (productId: string) => Promise<HeliumPurchaseResult>;
|
|
@@ -45,6 +46,8 @@ export interface PaywallEventHandlers {
|
|
|
45
46
|
onClose?: (event: PaywallCloseEvent) => void;
|
|
46
47
|
onDismissed?: (event: PaywallDismissedEvent) => void;
|
|
47
48
|
onPurchaseSucceeded?: (event: PurchaseSucceededEvent) => void;
|
|
49
|
+
onOpenFailed?: (event: PaywallOpenFailedEvent) => void;
|
|
50
|
+
onCustomPaywallAction?: (event: CustomPaywallActionEvent) => void;
|
|
48
51
|
}
|
|
49
52
|
export interface PaywallOpenEvent {
|
|
50
53
|
type: 'paywallOpen';
|
|
@@ -72,8 +75,24 @@ export interface PurchaseSucceededEvent {
|
|
|
72
75
|
paywallName: string;
|
|
73
76
|
isSecondTry: boolean;
|
|
74
77
|
}
|
|
78
|
+
export interface PaywallOpenFailedEvent {
|
|
79
|
+
type: 'paywallOpenFailed';
|
|
80
|
+
triggerName: string;
|
|
81
|
+
paywallName: string;
|
|
82
|
+
error: string;
|
|
83
|
+
paywallUnavailableReason?: string;
|
|
84
|
+
isSecondTry: boolean;
|
|
85
|
+
}
|
|
86
|
+
export interface CustomPaywallActionEvent {
|
|
87
|
+
type: 'customPaywallAction';
|
|
88
|
+
triggerName: string;
|
|
89
|
+
paywallName: string;
|
|
90
|
+
actionName: string;
|
|
91
|
+
params: Record<string, any>;
|
|
92
|
+
isSecondTry: boolean;
|
|
93
|
+
}
|
|
75
94
|
export type HeliumPaywallEvent = {
|
|
76
|
-
type: 'paywallOpen' | 'paywallClose' | 'paywallDismissed' | 'paywallOpenFailed' | 'paywallSkipped' | 'paywallButtonPressed' | 'productSelected' | 'purchasePressed' | 'purchaseSucceeded' | 'purchaseCancelled' | 'purchaseFailed' | 'purchaseRestored' | 'purchaseRestoreFailed' | 'purchasePending' | 'initializeStart' | 'paywallsDownloadSuccess' | 'paywallsDownloadError' | 'paywallWebViewRendered';
|
|
95
|
+
type: 'paywallOpen' | 'paywallClose' | 'paywallDismissed' | 'paywallOpenFailed' | 'paywallSkipped' | 'paywallButtonPressed' | 'productSelected' | 'purchasePressed' | 'purchaseSucceeded' | 'purchaseCancelled' | 'purchaseFailed' | 'purchaseRestored' | 'purchaseRestoreFailed' | 'purchasePending' | 'initializeStart' | 'paywallsDownloadSuccess' | 'paywallsDownloadError' | 'paywallWebViewRendered' | 'customPaywallAction' | 'userAllocated';
|
|
77
96
|
triggerName?: string;
|
|
78
97
|
paywallName?: string;
|
|
79
98
|
/**
|
|
@@ -107,6 +126,9 @@ export type HeliumPaywallEvent = {
|
|
|
107
126
|
* Unix timestamp in seconds
|
|
108
127
|
*/
|
|
109
128
|
timestamp?: number;
|
|
129
|
+
paywallUnavailableReason?: string;
|
|
130
|
+
customPaywallActionName?: string;
|
|
131
|
+
customPaywallActionParams?: Record<string, any>;
|
|
110
132
|
};
|
|
111
133
|
export type PresentUpsellParams = {
|
|
112
134
|
triggerName: string;
|
|
@@ -114,11 +136,16 @@ export type PresentUpsellParams = {
|
|
|
114
136
|
onFallback?: () => void;
|
|
115
137
|
eventHandlers?: PaywallEventHandlers;
|
|
116
138
|
customPaywallTraits?: Record<string, any>;
|
|
139
|
+
/** Optional. If true, the paywall will not be shown if the user already has an entitlement for a product in the paywall. */
|
|
140
|
+
dontShowIfAlreadyEntitled?: boolean;
|
|
117
141
|
};
|
|
118
142
|
export interface HeliumConfig {
|
|
119
143
|
/** Your Helium API Key */
|
|
120
144
|
apiKey: string;
|
|
121
|
-
/**
|
|
145
|
+
/**
|
|
146
|
+
* Configuration for handling purchases. Can be custom functions or a pre-built handler config.
|
|
147
|
+
* If not provided, Helium will handle purchases for you.
|
|
148
|
+
*/
|
|
122
149
|
purchaseConfig?: HeliumPurchaseConfig;
|
|
123
150
|
/** Callback for receiving all Helium paywall events. */
|
|
124
151
|
onHeliumPaywallEvent: (event: HeliumPaywallEvent) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAC/B,WAAW,GACX,QAAQ,GACR,WAAW,GACX,SAAS,GACT,UAAU,CAAC;AACf,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,EAAE,uBAAuB,CAAC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AACF,MAAM,MAAM,oBAAoB,GAC5B,SAAS,GACT,QAAQ,GACR,YAAY,GACZ,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,uBAAuB,GAC/B,WAAW,GACX,QAAQ,GACR,WAAW,GACX,SAAS,GACT,UAAU,CAAC;AACf,MAAM,MAAM,oBAA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|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Details about user hash bucketing for allocation
|
|
7
|
+
*/
|
|
8
|
+
export interface HashDetails {
|
|
9
|
+
/**
|
|
10
|
+
* User hash bucket (1-100) - used for consistent allocation
|
|
11
|
+
*/
|
|
12
|
+
hashedUserIdBucket1To100?: number;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* User ID that was hashed for allocation
|
|
16
|
+
*/
|
|
17
|
+
hashedUserId?: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Hash method used (e.g., "HASH_USER_ID", "HASH_HELIUM_PERSISTENT_ID")
|
|
21
|
+
*/
|
|
22
|
+
hashMethod?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Details about the chosen variant in an experiment
|
|
27
|
+
*/
|
|
28
|
+
export interface VariantDetails {
|
|
29
|
+
/**
|
|
30
|
+
* Name or identifier of the allocation/variant (e.g., paywall template name)
|
|
31
|
+
*/
|
|
32
|
+
allocationName?: string;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Unique identifier for this allocation (paywall UUID)
|
|
36
|
+
*/
|
|
37
|
+
allocationId?: string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Index of chosen variant (1 to len(variants))
|
|
41
|
+
*/
|
|
42
|
+
allocationIndex?: number;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Additional allocation metadata as a dictionary
|
|
46
|
+
*/
|
|
47
|
+
allocationMetadata?: Record<string, any>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Complete experiment allocation information for a user
|
|
52
|
+
*/
|
|
53
|
+
export interface ExperimentInfo {
|
|
54
|
+
/**
|
|
55
|
+
* Trigger name at which user was enrolled
|
|
56
|
+
*/
|
|
57
|
+
trigger: string;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Experiment name
|
|
61
|
+
*/
|
|
62
|
+
experimentName?: string;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Experiment ID
|
|
66
|
+
*/
|
|
67
|
+
experimentId?: string;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Experiment type (e.g., "A/B/n test")
|
|
71
|
+
*/
|
|
72
|
+
experimentType?: string;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Additional experiment metadata as a dictionary
|
|
76
|
+
*/
|
|
77
|
+
experimentMetadata?: Record<string, any>;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* When the experiment started (ISO8601 string)
|
|
81
|
+
*/
|
|
82
|
+
startDate?: string;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* When the experiment ends (ISO8601 string)
|
|
86
|
+
*/
|
|
87
|
+
endDate?: string;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Audience ID that user matched
|
|
91
|
+
*/
|
|
92
|
+
audienceId?: string;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Audience data as structured object
|
|
96
|
+
* Note: This may be returned as a string from native bridge, but will be parsed
|
|
97
|
+
*/
|
|
98
|
+
audienceData?: Record<string, any> | string;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Details about the chosen variant
|
|
102
|
+
*/
|
|
103
|
+
chosenVariantDetails?: VariantDetails;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Hash bucketing details
|
|
107
|
+
*/
|
|
108
|
+
hashDetails?: HashDetails;
|
|
109
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -8,8 +8,15 @@ export {
|
|
|
8
8
|
getPaywallInfo,
|
|
9
9
|
handleDeepLink,
|
|
10
10
|
setRevenueCatAppUserId,
|
|
11
|
+
setCustomUserId,
|
|
12
|
+
hasEntitlementForPaywall,
|
|
11
13
|
hasAnyActiveSubscription,
|
|
12
14
|
hasAnyEntitlement,
|
|
15
|
+
getExperimentInfoForTrigger,
|
|
16
|
+
resetHelium,
|
|
17
|
+
setCustomRestoreFailedStrings,
|
|
18
|
+
disableRestoreFailedDialog,
|
|
19
|
+
setLightDarkModeOverride,
|
|
13
20
|
HELIUM_CTA_NAMES,
|
|
14
21
|
NativeHeliumUpsellView,
|
|
15
22
|
} from './native-interface';
|
|
@@ -19,12 +26,21 @@ export type {
|
|
|
19
26
|
HeliumConfig,
|
|
20
27
|
HeliumUpsellViewProps,
|
|
21
28
|
HeliumPaywallLoadingConfig,
|
|
29
|
+
HeliumLightDarkMode,
|
|
22
30
|
TriggerLoadingConfig,
|
|
23
31
|
PaywallEventHandlers,
|
|
24
32
|
PaywallOpenEvent,
|
|
25
33
|
PaywallCloseEvent,
|
|
26
34
|
PaywallDismissedEvent,
|
|
27
35
|
PurchaseSucceededEvent,
|
|
36
|
+
PaywallOpenFailedEvent,
|
|
37
|
+
CustomPaywallActionEvent,
|
|
28
38
|
HeliumPaywallEvent,
|
|
29
39
|
PresentUpsellParams,
|
|
30
40
|
} from './types';
|
|
41
|
+
|
|
42
|
+
export type {
|
|
43
|
+
ExperimentInfo,
|
|
44
|
+
HashDetails,
|
|
45
|
+
VariantDetails,
|
|
46
|
+
} from './HeliumExperimentInfo.types';
|
package/src/native-interface.tsx
CHANGED
|
@@ -7,11 +7,13 @@ import type {
|
|
|
7
7
|
HeliumConfig,
|
|
8
8
|
HeliumUpsellViewProps,
|
|
9
9
|
HeliumDownloadStatus,
|
|
10
|
+
HeliumLightDarkMode,
|
|
10
11
|
PaywallInfo,
|
|
11
12
|
PresentUpsellParams,
|
|
12
13
|
PaywallEventHandlers,
|
|
13
14
|
HeliumPaywallEvent,
|
|
14
15
|
} from './types';
|
|
16
|
+
import type { ExperimentInfo } from './HeliumExperimentInfo.types';
|
|
15
17
|
|
|
16
18
|
const { HeliumBridge } = NativeModules;
|
|
17
19
|
const heliumEventEmitter = new NativeEventEmitter(HeliumBridge);
|
|
@@ -161,35 +163,23 @@ export const presentUpsell = ({
|
|
|
161
163
|
onFallback,
|
|
162
164
|
eventHandlers,
|
|
163
165
|
customPaywallTraits,
|
|
166
|
+
dontShowIfAlreadyEntitled,
|
|
164
167
|
}: PresentUpsellParams) => {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
HeliumBridge.presentUpsell(
|
|
181
|
-
triggerName,
|
|
182
|
-
convertBooleansToMarkers(customPaywallTraits) || null
|
|
183
|
-
);
|
|
184
|
-
} catch (error) {
|
|
185
|
-
console.log('[Helium] Present error', error);
|
|
186
|
-
paywallEventHandlers = undefined;
|
|
187
|
-
presentOnFallback = undefined;
|
|
188
|
-
onFallback?.();
|
|
189
|
-
HeliumBridge.fallbackOpenOrCloseEvent(triggerName, true, 'presented');
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
);
|
|
168
|
+
try {
|
|
169
|
+
paywallEventHandlers = eventHandlers;
|
|
170
|
+
presentOnFallback = onFallback;
|
|
171
|
+
HeliumBridge.presentUpsell(
|
|
172
|
+
triggerName,
|
|
173
|
+
convertBooleansToMarkers(customPaywallTraits) || null,
|
|
174
|
+
dontShowIfAlreadyEntitled ?? false
|
|
175
|
+
);
|
|
176
|
+
} catch (error) {
|
|
177
|
+
console.log('[Helium] presentUpsell error', error);
|
|
178
|
+
paywallEventHandlers = undefined;
|
|
179
|
+
presentOnFallback = undefined;
|
|
180
|
+
onFallback?.();
|
|
181
|
+
HeliumBridge.fallbackOpenOrCloseEvent(triggerName, true, 'presented');
|
|
182
|
+
}
|
|
193
183
|
};
|
|
194
184
|
|
|
195
185
|
function callPaywallEventHandlers(event: HeliumPaywallEvent) {
|
|
@@ -229,6 +219,26 @@ function callPaywallEventHandlers(event: HeliumPaywallEvent) {
|
|
|
229
219
|
isSecondTry: event.isSecondTry ?? false,
|
|
230
220
|
});
|
|
231
221
|
break;
|
|
222
|
+
case 'paywallOpenFailed':
|
|
223
|
+
paywallEventHandlers?.onOpenFailed?.({
|
|
224
|
+
type: 'paywallOpenFailed',
|
|
225
|
+
triggerName: event.triggerName ?? 'unknown',
|
|
226
|
+
paywallName: event.paywallName ?? 'unknown',
|
|
227
|
+
error: event.error ?? 'Unknown error',
|
|
228
|
+
paywallUnavailableReason: event.paywallUnavailableReason,
|
|
229
|
+
isSecondTry: event.isSecondTry ?? false,
|
|
230
|
+
});
|
|
231
|
+
break;
|
|
232
|
+
case 'customPaywallAction':
|
|
233
|
+
paywallEventHandlers?.onCustomPaywallAction?.({
|
|
234
|
+
type: 'customPaywallAction',
|
|
235
|
+
triggerName: event.triggerName ?? 'unknown',
|
|
236
|
+
paywallName: event.paywallName ?? 'unknown',
|
|
237
|
+
actionName: event.customPaywallActionName ?? 'unknown',
|
|
238
|
+
params: event.customPaywallActionParams ?? {},
|
|
239
|
+
isSecondTry: event.isSecondTry ?? false,
|
|
240
|
+
});
|
|
241
|
+
break;
|
|
232
242
|
}
|
|
233
243
|
}
|
|
234
244
|
}
|
|
@@ -247,7 +257,15 @@ function handlePaywallEvent(event: HeliumPaywallEvent) {
|
|
|
247
257
|
break;
|
|
248
258
|
case 'paywallOpenFailed':
|
|
249
259
|
paywallEventHandlers = undefined;
|
|
250
|
-
|
|
260
|
+
const unavailableReason = event.paywallUnavailableReason;
|
|
261
|
+
if (
|
|
262
|
+
event.triggerName &&
|
|
263
|
+
unavailableReason !== 'alreadyPresented' &&
|
|
264
|
+
unavailableReason !== 'secondTryNoMatch'
|
|
265
|
+
) {
|
|
266
|
+
console.log('[Helium] paywall open failed', unavailableReason);
|
|
267
|
+
presentOnFallback?.();
|
|
268
|
+
}
|
|
251
269
|
presentOnFallback = undefined;
|
|
252
270
|
break;
|
|
253
271
|
}
|
|
@@ -299,6 +317,24 @@ export const setRevenueCatAppUserId = (rcAppUserId: string) => {
|
|
|
299
317
|
HeliumBridge.setRevenueCatAppUserId(rcAppUserId);
|
|
300
318
|
};
|
|
301
319
|
|
|
320
|
+
/**
|
|
321
|
+
* Set a custom user ID for the current user
|
|
322
|
+
*/
|
|
323
|
+
export const setCustomUserId = (newUserId: string) => {
|
|
324
|
+
HeliumBridge.setCustomUserId(newUserId);
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Checks if the user has an active entitlement for any product attached to the paywall that will show for provided trigger.
|
|
329
|
+
* @param trigger The trigger name to check entitlement for
|
|
330
|
+
* @returns Promise resolving to true if entitled, false if not, or undefined if not known (i.e. the paywall is not downloaded yet)
|
|
331
|
+
*/
|
|
332
|
+
export const hasEntitlementForPaywall = async (
|
|
333
|
+
trigger: string
|
|
334
|
+
): Promise<boolean | undefined> => {
|
|
335
|
+
return HeliumBridge.hasEntitlementForPaywall(trigger);
|
|
336
|
+
};
|
|
337
|
+
|
|
302
338
|
/**
|
|
303
339
|
* Checks if the user has any active subscription (including non-renewable)
|
|
304
340
|
*/
|
|
@@ -313,6 +349,68 @@ export const hasAnyEntitlement = async (): Promise<boolean> => {
|
|
|
313
349
|
return HeliumBridge.hasAnyEntitlement();
|
|
314
350
|
};
|
|
315
351
|
|
|
352
|
+
/**
|
|
353
|
+
* Get experiment allocation info for a specific trigger
|
|
354
|
+
*
|
|
355
|
+
* @param trigger The trigger name to get experiment info for
|
|
356
|
+
* @returns ExperimentInfo if the trigger has experiment data, undefined otherwise
|
|
357
|
+
*/
|
|
358
|
+
export const getExperimentInfoForTrigger = async (
|
|
359
|
+
trigger: string
|
|
360
|
+
): Promise<ExperimentInfo | undefined> => {
|
|
361
|
+
return new Promise((resolve) => {
|
|
362
|
+
HeliumBridge.getExperimentInfoForTrigger(
|
|
363
|
+
trigger,
|
|
364
|
+
(success: boolean, data: any) => {
|
|
365
|
+
if (!success) {
|
|
366
|
+
resolve(undefined);
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
resolve(data as ExperimentInfo);
|
|
370
|
+
}
|
|
371
|
+
);
|
|
372
|
+
});
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* Reset Helium entirely so you can call initialize again. Only for advanced use cases.
|
|
377
|
+
*/
|
|
378
|
+
export const resetHelium = () => {
|
|
379
|
+
HeliumBridge.resetHelium();
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Set custom strings to show in the dialog that Helium will display if a "Restore Purchases" action is not successful.
|
|
384
|
+
* Note that these strings will not be localized by Helium for you.
|
|
385
|
+
*/
|
|
386
|
+
export const setCustomRestoreFailedStrings = (
|
|
387
|
+
customTitle?: string,
|
|
388
|
+
customMessage?: string,
|
|
389
|
+
customCloseButtonText?: string
|
|
390
|
+
) => {
|
|
391
|
+
HeliumBridge.setCustomRestoreFailedStrings(
|
|
392
|
+
customTitle,
|
|
393
|
+
customMessage,
|
|
394
|
+
customCloseButtonText
|
|
395
|
+
);
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
/**
|
|
399
|
+
* Disable the default dialog that Helium will display if a "Restore Purchases" action is not successful.
|
|
400
|
+
* You can handle this yourself if desired by listening for the PurchaseRestoreFailedEvent.
|
|
401
|
+
*/
|
|
402
|
+
export const disableRestoreFailedDialog = () => {
|
|
403
|
+
HeliumBridge.disableRestoreFailedDialog();
|
|
404
|
+
};
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* Override the light/dark mode for Helium paywalls
|
|
408
|
+
* @param mode The mode to set: 'light', 'dark', or 'system' (follows device setting)
|
|
409
|
+
*/
|
|
410
|
+
export const setLightDarkModeOverride = (mode: HeliumLightDarkMode) => {
|
|
411
|
+
HeliumBridge.setLightDarkModeOverride(mode);
|
|
412
|
+
};
|
|
413
|
+
|
|
316
414
|
export const HELIUM_CTA_NAMES = {
|
|
317
415
|
SCHEDULE_CALL: 'schedule_call',
|
|
318
416
|
SUBSCRIBE_BUTTON: 'subscribe_button',
|
package/src/types.ts
CHANGED
|
@@ -13,6 +13,7 @@ export type HeliumDownloadStatus =
|
|
|
13
13
|
| 'failed'
|
|
14
14
|
| 'inProgress'
|
|
15
15
|
| 'notStarted';
|
|
16
|
+
export type HeliumLightDarkMode = 'light' | 'dark' | 'system';
|
|
16
17
|
|
|
17
18
|
// --- Purchase Configuration Types ---
|
|
18
19
|
|
|
@@ -69,6 +70,8 @@ export interface PaywallEventHandlers {
|
|
|
69
70
|
onClose?: (event: PaywallCloseEvent) => void;
|
|
70
71
|
onDismissed?: (event: PaywallDismissedEvent) => void;
|
|
71
72
|
onPurchaseSucceeded?: (event: PurchaseSucceededEvent) => void;
|
|
73
|
+
onOpenFailed?: (event: PaywallOpenFailedEvent) => void;
|
|
74
|
+
onCustomPaywallAction?: (event: CustomPaywallActionEvent) => void;
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
// Typed event interfaces
|
|
@@ -102,6 +105,24 @@ export interface PurchaseSucceededEvent {
|
|
|
102
105
|
isSecondTry: boolean;
|
|
103
106
|
}
|
|
104
107
|
|
|
108
|
+
export interface PaywallOpenFailedEvent {
|
|
109
|
+
type: 'paywallOpenFailed';
|
|
110
|
+
triggerName: string;
|
|
111
|
+
paywallName: string;
|
|
112
|
+
error: string;
|
|
113
|
+
paywallUnavailableReason?: string;
|
|
114
|
+
isSecondTry: boolean;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface CustomPaywallActionEvent {
|
|
118
|
+
type: 'customPaywallAction';
|
|
119
|
+
triggerName: string;
|
|
120
|
+
paywallName: string;
|
|
121
|
+
actionName: string;
|
|
122
|
+
params: Record<string, any>;
|
|
123
|
+
isSecondTry: boolean;
|
|
124
|
+
}
|
|
125
|
+
|
|
105
126
|
export type HeliumPaywallEvent = {
|
|
106
127
|
type:
|
|
107
128
|
| 'paywallOpen'
|
|
@@ -121,7 +142,9 @@ export type HeliumPaywallEvent = {
|
|
|
121
142
|
| 'initializeStart'
|
|
122
143
|
| 'paywallsDownloadSuccess'
|
|
123
144
|
| 'paywallsDownloadError'
|
|
124
|
-
| 'paywallWebViewRendered'
|
|
145
|
+
| 'paywallWebViewRendered'
|
|
146
|
+
| 'customPaywallAction'
|
|
147
|
+
| 'userAllocated';
|
|
125
148
|
triggerName?: string;
|
|
126
149
|
paywallName?: string;
|
|
127
150
|
/**
|
|
@@ -155,6 +178,9 @@ export type HeliumPaywallEvent = {
|
|
|
155
178
|
* Unix timestamp in seconds
|
|
156
179
|
*/
|
|
157
180
|
timestamp?: number;
|
|
181
|
+
paywallUnavailableReason?: string;
|
|
182
|
+
customPaywallActionName?: string;
|
|
183
|
+
customPaywallActionParams?: Record<string, any>;
|
|
158
184
|
};
|
|
159
185
|
|
|
160
186
|
export type PresentUpsellParams = {
|
|
@@ -163,13 +189,18 @@ export type PresentUpsellParams = {
|
|
|
163
189
|
onFallback?: () => void;
|
|
164
190
|
eventHandlers?: PaywallEventHandlers;
|
|
165
191
|
customPaywallTraits?: Record<string, any>;
|
|
192
|
+
/** Optional. If true, the paywall will not be shown if the user already has an entitlement for a product in the paywall. */
|
|
193
|
+
dontShowIfAlreadyEntitled?: boolean;
|
|
166
194
|
};
|
|
167
195
|
|
|
168
196
|
// --- Main Helium Configuration ---
|
|
169
197
|
export interface HeliumConfig {
|
|
170
198
|
/** Your Helium API Key */
|
|
171
199
|
apiKey: string;
|
|
172
|
-
/**
|
|
200
|
+
/**
|
|
201
|
+
* Configuration for handling purchases. Can be custom functions or a pre-built handler config.
|
|
202
|
+
* If not provided, Helium will handle purchases for you.
|
|
203
|
+
*/
|
|
173
204
|
purchaseConfig?: HeliumPurchaseConfig;
|
|
174
205
|
/** Callback for receiving all Helium paywall events. */
|
|
175
206
|
onHeliumPaywallEvent: (event: HeliumPaywallEvent) => void;
|