apps-sdk 1.1.68 → 1.1.70
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/index.js +3 -1
- package/package.json +1 -1
- package/src/components/AdaptyOnboarding.js +214 -0
- package/src/libraries/Adapty.js +8 -4
- package/types/index.d.ts +29 -9
package/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {NotificationsPush, Networking, Storage, Session, Utils, PayWallLogic, Rating, AdJust, TrackingTransparency, Voice, MixPanel, Adapty, HomeActions, Facebook, Legal} from "./src/libraries";
|
|
2
2
|
import PayWall from "./src/components/PayWall";
|
|
3
|
+
import AdaptyOnboarding from "./src/components/AdaptyOnboarding";
|
|
3
4
|
|
|
4
5
|
class AppsSDK {
|
|
5
6
|
constructor() {
|
|
@@ -56,10 +57,11 @@ export default {
|
|
|
56
57
|
mixpanel: MixPanel,
|
|
57
58
|
tracking: TrackingTransparency,
|
|
58
59
|
paywall: PayWall,
|
|
60
|
+
adaptyOnboarding: AdaptyOnboarding,
|
|
59
61
|
notifications: NotificationsPush,
|
|
60
62
|
voice: Voice,
|
|
61
63
|
adapty: Adapty,
|
|
62
64
|
homeActions: HomeActions,
|
|
63
65
|
facebook: Facebook,
|
|
64
66
|
legal: Legal,
|
|
65
|
-
}
|
|
67
|
+
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Modal } from 'react-native';
|
|
3
|
+
import { AdaptyOnboardingView } from 'react-native-adapty/dist/ui';
|
|
4
|
+
import { View } from "react-native";
|
|
5
|
+
import Adapty from '../libraries/Adapty';
|
|
6
|
+
import * as config from '../../config';
|
|
7
|
+
|
|
8
|
+
class AdaptyOnboarding extends React.Component {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
this.state = {
|
|
12
|
+
onboarding: null,
|
|
13
|
+
isLoading: true,
|
|
14
|
+
};
|
|
15
|
+
this.remoteConfig = null;
|
|
16
|
+
this.currentStep = 0;
|
|
17
|
+
this.totalSteps = 0;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
componentDidMount() {
|
|
21
|
+
const { preloadedOnboarding, placementID, lang } = this.props;
|
|
22
|
+
|
|
23
|
+
// If preloaded onboarding is provided, use it immediately (no loading screen!)
|
|
24
|
+
if (preloadedOnboarding) {
|
|
25
|
+
console.log('[ONBOARDING] Using preloaded onboarding data - skipping load');
|
|
26
|
+
this.remoteConfig = preloadedOnboarding.remoteConfig || {};
|
|
27
|
+
|
|
28
|
+
if (this.props.onRemoteConfigLoaded && this.remoteConfig) {
|
|
29
|
+
config.DEBUG_MODE && console.log('Remote config loaded from preload:', this.remoteConfig);
|
|
30
|
+
this.props.onRemoteConfigLoaded(this.remoteConfig);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
this.setState({ onboarding: preloadedOnboarding, isLoading: false });
|
|
34
|
+
} else {
|
|
35
|
+
// Fallback to loading if not preloaded
|
|
36
|
+
console.log('[ONBOARDING] No preloaded data, loading normally');
|
|
37
|
+
this.loadOnboarding(placementID, lang);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async componentDidUpdate(prevProps) {
|
|
42
|
+
if (this.props.visible && !prevProps.visible) {
|
|
43
|
+
const { placementID, lang } = this.props;
|
|
44
|
+
await this.loadOnboarding(placementID, lang);
|
|
45
|
+
}
|
|
46
|
+
if (!this.props.visible && prevProps.visible) {
|
|
47
|
+
this.handleModalDismiss();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
loadOnboarding = async (placementID, lang) => {
|
|
52
|
+
try {
|
|
53
|
+
this.setState({ isLoading: true });
|
|
54
|
+
const onboarding = await Adapty.getOnboardingForPlacement(placementID, lang);
|
|
55
|
+
|
|
56
|
+
if (onboarding) {
|
|
57
|
+
this.remoteConfig = onboarding.remoteConfig || {};
|
|
58
|
+
|
|
59
|
+
if (this.props.onRemoteConfigLoaded && this.remoteConfig) {
|
|
60
|
+
config.DEBUG_MODE && console.log('Remote config loaded:', this.remoteConfig);
|
|
61
|
+
this.props.onRemoteConfigLoaded(this.remoteConfig);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
this.setState({ onboarding, isLoading: false });
|
|
65
|
+
} else {
|
|
66
|
+
console.log('Onboarding not found for placement:', placementID, 'and language:', lang);
|
|
67
|
+
this.setState({ isLoading: false });
|
|
68
|
+
if (this.props.onError) {
|
|
69
|
+
this.props.onError(new Error('Onboarding not found'), this.remoteConfig);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.log('Error loading onboarding:', error);
|
|
74
|
+
this.setState({ isLoading: false });
|
|
75
|
+
if (this.props.onError) {
|
|
76
|
+
this.props.onError(error, this.remoteConfig);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// --------------------------------------- Event Handlers ---------------------------------------
|
|
82
|
+
handleCustom = (actionId, meta) => {
|
|
83
|
+
config.DEBUG_MODE && console.log('Onboarding custom AdaptyOnboarding:', actionId, meta);
|
|
84
|
+
|
|
85
|
+
if (this.props.onCustom) {
|
|
86
|
+
this.props.onCustom(actionId, meta, this.remoteConfig);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
handleClose = (actionId, meta) => {
|
|
91
|
+
const isLastStep = this.totalSteps > 0 && this.currentStep === this.totalSteps - 1;
|
|
92
|
+
|
|
93
|
+
config.DEBUG_MODE && console.log('Onboarding close attempt AdaptyOnboarding:', {actionId, meta, currentStep: this.currentStep, totalSteps: this.totalSteps, isLastStep });
|
|
94
|
+
|
|
95
|
+
if (this.props.onClose) {
|
|
96
|
+
this.props.onClose(actionId, meta, this.remoteConfig);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
handleModalDismiss = () => {
|
|
103
|
+
config.DEBUG_MODE && console.log('AdaptyOnboarding Modal fully dismissed');
|
|
104
|
+
|
|
105
|
+
// Reset state after modal is fully dismissed
|
|
106
|
+
this.currentStep = 0;
|
|
107
|
+
this.totalSteps = 0;
|
|
108
|
+
|
|
109
|
+
// Notify parent that modal is fully closed
|
|
110
|
+
if (this.props.onModalDismissed) {
|
|
111
|
+
this.props.onModalDismissed();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
handleStateUpdated = (action, meta) => {
|
|
116
|
+
if (meta && typeof meta === 'object') {
|
|
117
|
+
this.currentStep = meta.screen_index ?? this.currentStep;
|
|
118
|
+
this.totalSteps = meta.total_screens ?? this.totalSteps;
|
|
119
|
+
|
|
120
|
+
config.DEBUG_MODE && console.log('State updated AdaptyOnboarding:', {action, meta, currentStep: this.currentStep, totalSteps: this.totalSteps});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if (this.props.onStateUpdated) {
|
|
124
|
+
this.props.onStateUpdated(action, meta, this.remoteConfig);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
handleError = (error) => {
|
|
129
|
+
console.log('Onboarding error:', error);
|
|
130
|
+
|
|
131
|
+
// Check if it's a WebResource ORB error (common on Android)
|
|
132
|
+
const isORBError = error?.message?.includes('ERR_BLOCKED_BY_ORB');
|
|
133
|
+
|
|
134
|
+
if (isORBError) {
|
|
135
|
+
config.DEBUG_MODE && console.log('WebResource ORB error detected - non-critical, continuing');
|
|
136
|
+
// Don't propagate ORB errors as they don't break functionality
|
|
137
|
+
return false; // Continue
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (this.props.onError) {
|
|
141
|
+
this.props.onError(error, this.remoteConfig);
|
|
142
|
+
}
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
handleAnalytics = (event, data) => {
|
|
147
|
+
config.DEBUG_MODE && console.log('Onboarding analytics AdaptyOnboarding:', event, data);
|
|
148
|
+
|
|
149
|
+
if (this.props.onAnalytics) {
|
|
150
|
+
this.props.onAnalytics(event, data, this.remoteConfig);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
handlePaywall = (actionId, meta) => {
|
|
155
|
+
config.DEBUG_MODE && console.log('Onboarding paywall AdaptyOnboarding:', actionId, meta);
|
|
156
|
+
|
|
157
|
+
if (this.props.onPaywall) {
|
|
158
|
+
this.props.onPaywall(actionId, meta, this.remoteConfig);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
handleFinishedLoading = (meta) => {
|
|
163
|
+
config.DEBUG_MODE && console.log('Onboarding finished loading AdaptyOnboarding:', meta);
|
|
164
|
+
|
|
165
|
+
if (this.props.onFinishedLoading) {
|
|
166
|
+
this.props.onFinishedLoading(meta, this.remoteConfig);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// --------------------------------------- Event Handlers ---------------------------------------
|
|
170
|
+
|
|
171
|
+
render() {
|
|
172
|
+
const { visible } = this.props;
|
|
173
|
+
const { onboarding, isLoading } = this.state;
|
|
174
|
+
|
|
175
|
+
if (!visible) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const content = (
|
|
180
|
+
<View style={styles.container}>
|
|
181
|
+
{!isLoading && onboarding ? (
|
|
182
|
+
<AdaptyOnboardingView
|
|
183
|
+
onboarding={onboarding}
|
|
184
|
+
style={styles.onboardingView}
|
|
185
|
+
eventHandlers={{
|
|
186
|
+
onAnalytics: this.handleAnalytics,
|
|
187
|
+
onClose: this.handleClose,
|
|
188
|
+
onCustom: this.handleCustom,
|
|
189
|
+
onPaywall: this.handlePaywall,
|
|
190
|
+
onStateUpdated: this.handleStateUpdated,
|
|
191
|
+
onFinishedLoading: this.handleFinishedLoading,
|
|
192
|
+
onError: this.handleError,
|
|
193
|
+
}}
|
|
194
|
+
/>
|
|
195
|
+
) : null}
|
|
196
|
+
</View>
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
return content;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const styles = {
|
|
204
|
+
container: {
|
|
205
|
+
backgroundColor: '#000',
|
|
206
|
+
width: '100%',
|
|
207
|
+
height: '100%',
|
|
208
|
+
},
|
|
209
|
+
onboardingView: {
|
|
210
|
+
flex: 1,
|
|
211
|
+
},
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
export default AdaptyOnboarding;
|
package/src/libraries/Adapty.js
CHANGED
|
@@ -59,6 +59,11 @@ class Adapty {
|
|
|
59
59
|
config.DEBUG_MODE && console.log('Getting paywall for placement:', placementID, 'and language:', lang, 'paywall:', paywall);
|
|
60
60
|
if (paywall) {
|
|
61
61
|
const paywallView = await this.createPaywallView(paywall);
|
|
62
|
+
|
|
63
|
+
if (!paywallView) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
62
67
|
paywallView.registerEventHandlers({
|
|
63
68
|
onCloseButtonPress: eventHandlers.onCloseButtonPress || (() => { return true; }),
|
|
64
69
|
onAndroidSystemBack: eventHandlers.onAndroidSystemBack || (() => { paywallView.dismiss(); return true; }),
|
|
@@ -75,14 +80,11 @@ class Adapty {
|
|
|
75
80
|
onCustomAction: eventHandlers.onCustomAction || (() => { }),
|
|
76
81
|
});
|
|
77
82
|
await paywallView.present();
|
|
78
|
-
return paywallView;
|
|
79
83
|
} else {
|
|
80
84
|
console.warn('Error showing paywall: paywall not found for placement', placementID, 'and language', lang);
|
|
81
|
-
return null;
|
|
82
85
|
}
|
|
83
86
|
} catch (error) {
|
|
84
87
|
console.error('Error showing paywall:', error);
|
|
85
|
-
return null;
|
|
86
88
|
}
|
|
87
89
|
}
|
|
88
90
|
|
|
@@ -104,9 +106,11 @@ class Adapty {
|
|
|
104
106
|
}
|
|
105
107
|
} else {
|
|
106
108
|
console.warn('Error preloading paywall: paywall not found for placement', placementID, 'and language', lang);
|
|
109
|
+
return null;
|
|
107
110
|
}
|
|
108
111
|
} catch (error) {
|
|
109
112
|
console.error('Error preloading paywall:', error);
|
|
113
|
+
return null;
|
|
110
114
|
}
|
|
111
115
|
}
|
|
112
116
|
|
|
@@ -295,4 +299,4 @@ class Adapty {
|
|
|
295
299
|
}
|
|
296
300
|
}
|
|
297
301
|
|
|
298
|
-
export default new Adapty();
|
|
302
|
+
export default new Adapty();
|
package/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare module 'apps-sdk' {
|
|
2
2
|
import { Component } from 'react';
|
|
3
|
-
import {SpeechResultsEvent} from "@react-native-voice/voice";
|
|
3
|
+
import { SpeechResultsEvent } from "@react-native-voice/voice";
|
|
4
4
|
|
|
5
5
|
export interface SessionData {
|
|
6
6
|
app: {
|
|
@@ -213,15 +213,34 @@ declare module 'apps-sdk' {
|
|
|
213
213
|
};
|
|
214
214
|
|
|
215
215
|
type OnboardingEventHandlers = {
|
|
216
|
-
onAnalytics?: (event: any, meta: any) => void;
|
|
217
|
-
onClose?: (actionId: string, meta: any) => Promise<boolean> | boolean;
|
|
218
|
-
onCustom?: (actionId: string, meta: any) => void;
|
|
219
|
-
onPaywall?: (actionId: string, meta: any) => void;
|
|
220
|
-
onStateUpdated?: (action: any, meta: any) => void;
|
|
221
|
-
onFinishedLoading?: (meta: any) => void;
|
|
222
|
-
onError?: (error: any) => void;
|
|
216
|
+
onAnalytics?: (event: any, meta: any, remoteConfig?: any) => void;
|
|
217
|
+
onClose?: (actionId: string, meta: any, remoteConfig?: any) => Promise<boolean> | boolean;
|
|
218
|
+
onCustom?: (actionId: string, meta: any, remoteConfig?: any) => void;
|
|
219
|
+
onPaywall?: (actionId: string, meta: any, remoteConfig?: any) => void;
|
|
220
|
+
onStateUpdated?: (action: any, meta: any, remoteConfig?: any) => void;
|
|
221
|
+
onFinishedLoading?: (meta: any, remoteConfig?: any) => void;
|
|
222
|
+
onError?: (error: any, remoteConfig?: any) => void;
|
|
223
|
+
onRemoteConfigLoaded?: (remoteConfig: any) => void;
|
|
224
|
+
onModalDismissed?: () => void;
|
|
223
225
|
};
|
|
224
226
|
|
|
227
|
+
export interface AdaptyOnboardingProps {
|
|
228
|
+
visible: boolean;
|
|
229
|
+
placementID: string;
|
|
230
|
+
lang: string;
|
|
231
|
+
onAnalytics?: (event: any, meta: any, remoteConfig?: any) => void;
|
|
232
|
+
onClose?: (actionId: string, meta: any, remoteConfig?: any) => Promise<boolean> | boolean;
|
|
233
|
+
onCustom?: (actionId: string, meta: any, remoteConfig?: any) => void;
|
|
234
|
+
onPaywall?: (actionId: string, meta: any, remoteConfig?: any) => void;
|
|
235
|
+
onStateUpdated?: (action: any, meta: any, remoteConfig?: any) => void;
|
|
236
|
+
onFinishedLoading?: (meta: any, remoteConfig?: any) => void;
|
|
237
|
+
onError?: (error: any, remoteConfig?: any) => boolean | void;
|
|
238
|
+
onRemoteConfigLoaded?: (remoteConfig: any) => void;
|
|
239
|
+
onModalDismissed?: () => void;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export class AdaptyOnboarding extends Component<AdaptyOnboardingProps, {}> { }
|
|
243
|
+
|
|
225
244
|
export class Adapty {
|
|
226
245
|
initialize(apiKey: string): Promise<void>;
|
|
227
246
|
getPaywallForPlacement(placementID: string, lang: string): Promise<any>;
|
|
@@ -284,6 +303,7 @@ declare module 'apps-sdk' {
|
|
|
284
303
|
session : Session;
|
|
285
304
|
utils : Utils;
|
|
286
305
|
paywall : PayWall;
|
|
306
|
+
adaptyOnboarding : typeof AdaptyOnboarding;
|
|
287
307
|
rating : Rating;
|
|
288
308
|
adjust : AdJust;
|
|
289
309
|
mixpanel : MixPanel;
|
|
@@ -299,4 +319,4 @@ declare module 'apps-sdk' {
|
|
|
299
319
|
|
|
300
320
|
const Core: AppsSDK;
|
|
301
321
|
export default Core;
|
|
302
|
-
}
|
|
322
|
+
}
|