apps-sdk 1.1.64 → 1.1.66
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/config.js +1 -0
- package/index.js +4 -1
- package/package.json +1 -1
- package/src/components/AdaptyOnboarding.js +208 -0
- package/src/libraries/Adapty.js +7 -0
- package/src/libraries/Legal.js +43 -0
- package/src/libraries/index.js +1 -0
- package/types/index.d.ts +32 -7
package/config.js
CHANGED
|
@@ -13,6 +13,7 @@ export var ENDPOINTS = {
|
|
|
13
13
|
AUDIENCES: "https://backend.ailandsapp.com",
|
|
14
14
|
CONTENTS: "https://backend.ailandsapp.com",
|
|
15
15
|
EVENTS: "https://ap0404.gways.org",
|
|
16
|
+
GET_LEGAL_TEXT: "https://backend.ailandsapp.com/content/andromeda/get-legal-text",
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
export var EVENTS = {}
|
package/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {NotificationsPush, Networking, Storage, Session, Utils, PayWallLogic, Rating, AdJust, TrackingTransparency, Voice, MixPanel, Adapty, HomeActions, Facebook} from "./src/libraries";
|
|
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,9 +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,
|
|
66
|
+
legal: Legal,
|
|
64
67
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,208 @@
|
|
|
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 { placementID, lang } = this.props;
|
|
22
|
+
this.loadOnboarding(placementID, lang);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async componentDidUpdate(prevProps) {
|
|
26
|
+
if (this.props.visible && !prevProps.visible) {
|
|
27
|
+
const { placementID, lang } = this.props;
|
|
28
|
+
await this.loadOnboarding(placementID, lang);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
loadOnboarding = async (placementID, lang) => {
|
|
33
|
+
try {
|
|
34
|
+
this.setState({ isLoading: true });
|
|
35
|
+
const onboarding = await Adapty.getOnboardingForPlacement(placementID, lang);
|
|
36
|
+
|
|
37
|
+
if (onboarding) {
|
|
38
|
+
this.remoteConfig = onboarding.remoteConfig || {};
|
|
39
|
+
|
|
40
|
+
if (this.props.onRemoteConfigLoaded && this.remoteConfig) {
|
|
41
|
+
config.DEBUG_MODE && console.log('Remote config loaded:', this.remoteConfig);
|
|
42
|
+
this.props.onRemoteConfigLoaded(this.remoteConfig);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
this.setState({ onboarding, isLoading: false });
|
|
46
|
+
} else {
|
|
47
|
+
console.log('Onboarding not found for placement:', placementID, 'and language:', lang);
|
|
48
|
+
this.setState({ isLoading: false });
|
|
49
|
+
if (this.props.onError) {
|
|
50
|
+
this.props.onError(new Error('Onboarding not found'), this.remoteConfig);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.log('Error loading onboarding:', error);
|
|
55
|
+
this.setState({ isLoading: false });
|
|
56
|
+
if (this.props.onError) {
|
|
57
|
+
this.props.onError(error, this.remoteConfig);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// --------------------------------------- Event Handlers ---------------------------------------
|
|
63
|
+
handleCustom = (actionId, meta) => {
|
|
64
|
+
config.DEBUG_MODE && console.log('Onboarding custom AdaptyOnboarding:', actionId, meta);
|
|
65
|
+
|
|
66
|
+
if (this.props.onCustom) {
|
|
67
|
+
this.props.onCustom(actionId, meta, this.remoteConfig);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
handleClose = (actionId, meta) => {
|
|
72
|
+
const isLastStep = this.totalSteps > 0 && this.currentStep === this.totalSteps - 1;
|
|
73
|
+
|
|
74
|
+
config.DEBUG_MODE && console.log('Onboarding close attempt AdaptyOnboarding:', {actionId, meta, currentStep: this.currentStep, totalSteps: this.totalSteps, isLastStep });
|
|
75
|
+
|
|
76
|
+
if (this.props.onClose) {
|
|
77
|
+
this.props.onClose(actionId, meta, this.remoteConfig);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
handleModalDismiss = () => {
|
|
84
|
+
config.DEBUG_MODE && console.log('AdaptyOnboarding Modal fully dismissed');
|
|
85
|
+
|
|
86
|
+
// Reset state after modal is fully dismissed
|
|
87
|
+
this.currentStep = 0;
|
|
88
|
+
this.totalSteps = 0;
|
|
89
|
+
|
|
90
|
+
// Notify parent that modal is fully closed
|
|
91
|
+
if (this.props.onModalDismissed) {
|
|
92
|
+
this.props.onModalDismissed();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
handleStateUpdated = (action, meta) => {
|
|
97
|
+
if (meta && typeof meta === 'object') {
|
|
98
|
+
this.currentStep = meta.screen_index ?? this.currentStep;
|
|
99
|
+
this.totalSteps = meta.total_screens ?? this.totalSteps;
|
|
100
|
+
|
|
101
|
+
config.DEBUG_MODE && console.log('State updated AdaptyOnboarding:', {action, meta, currentStep: this.currentStep, totalSteps: this.totalSteps});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (this.props.onStateUpdated) {
|
|
105
|
+
this.props.onStateUpdated(action, meta, this.remoteConfig);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
handleError = (error) => {
|
|
110
|
+
console.log('Onboarding error:', error);
|
|
111
|
+
|
|
112
|
+
// Check if it's a WebResource ORB error (common on Android)
|
|
113
|
+
const isORBError = error?.message?.includes('ERR_BLOCKED_BY_ORB');
|
|
114
|
+
|
|
115
|
+
if (isORBError) {
|
|
116
|
+
config.DEBUG_MODE && console.log('WebResource ORB error detected - non-critical, continuing');
|
|
117
|
+
// Don't propagate ORB errors as they don't break functionality
|
|
118
|
+
return false; // Continue
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (this.props.onError) {
|
|
122
|
+
this.props.onError(error, this.remoteConfig);
|
|
123
|
+
}
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
handleAnalytics = (event, data) => {
|
|
128
|
+
config.DEBUG_MODE && console.log('Onboarding analytics AdaptyOnboarding:', event, data);
|
|
129
|
+
|
|
130
|
+
if (this.props.onAnalytics) {
|
|
131
|
+
this.props.onAnalytics(event, data, this.remoteConfig);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
handlePaywall = (actionId, meta) => {
|
|
136
|
+
config.DEBUG_MODE && console.log('Onboarding paywall AdaptyOnboarding:', actionId, meta);
|
|
137
|
+
|
|
138
|
+
if (this.props.onPaywall) {
|
|
139
|
+
this.props.onPaywall(actionId, meta, this.remoteConfig);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
handleFinishedLoading = (meta) => {
|
|
144
|
+
config.DEBUG_MODE && console.log('Onboarding finished loading AdaptyOnboarding:', meta);
|
|
145
|
+
|
|
146
|
+
if (this.props.onFinishedLoading) {
|
|
147
|
+
this.props.onFinishedLoading(meta, this.remoteConfig);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
// --------------------------------------- Event Handlers ---------------------------------------
|
|
151
|
+
|
|
152
|
+
render() {
|
|
153
|
+
const { visible } = this.props;
|
|
154
|
+
const { onboarding, isLoading } = this.state;
|
|
155
|
+
|
|
156
|
+
if (!visible) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const content = (
|
|
161
|
+
<View style={styles.container}>
|
|
162
|
+
{!isLoading && onboarding ? (
|
|
163
|
+
<AdaptyOnboardingView
|
|
164
|
+
onboarding={onboarding}
|
|
165
|
+
style={styles.onboardingView}
|
|
166
|
+
eventHandlers={{
|
|
167
|
+
onAnalytics: this.handleAnalytics,
|
|
168
|
+
onClose: this.handleClose,
|
|
169
|
+
onCustom: this.handleCustom,
|
|
170
|
+
onPaywall: this.handlePaywall,
|
|
171
|
+
onStateUpdated: this.handleStateUpdated,
|
|
172
|
+
onFinishedLoading: this.handleFinishedLoading,
|
|
173
|
+
onError: this.handleError,
|
|
174
|
+
}}
|
|
175
|
+
/>
|
|
176
|
+
) : null}
|
|
177
|
+
</View>
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
return (
|
|
181
|
+
<Modal
|
|
182
|
+
visible={visible}
|
|
183
|
+
animationType="slide"
|
|
184
|
+
presentationStyle="fullScreen"
|
|
185
|
+
onRequestClose={() => {
|
|
186
|
+
config.DEBUG_MODE && console.log('Modal onRequestClose prevented');
|
|
187
|
+
return false;
|
|
188
|
+
}}
|
|
189
|
+
onDismiss={this.handleModalDismiss}
|
|
190
|
+
>
|
|
191
|
+
{content}
|
|
192
|
+
</Modal>
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const styles = {
|
|
198
|
+
container: {
|
|
199
|
+
backgroundColor: '#000',
|
|
200
|
+
width: '100%',
|
|
201
|
+
height: '100%',
|
|
202
|
+
},
|
|
203
|
+
onboardingView: {
|
|
204
|
+
flex: 1,
|
|
205
|
+
},
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
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; }),
|
|
@@ -104,9 +109,11 @@ class Adapty {
|
|
|
104
109
|
}
|
|
105
110
|
} else {
|
|
106
111
|
console.warn('Error preloading paywall: paywall not found for placement', placementID, 'and language', lang);
|
|
112
|
+
return null;
|
|
107
113
|
}
|
|
108
114
|
} catch (error) {
|
|
109
115
|
console.error('Error preloading paywall:', error);
|
|
116
|
+
return null;
|
|
110
117
|
}
|
|
111
118
|
}
|
|
112
119
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as config from '../../config';
|
|
2
|
+
import Networking from './Networking';
|
|
3
|
+
|
|
4
|
+
class Legal {
|
|
5
|
+
constructor() {}
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Obtiene textos legales desde el backend
|
|
9
|
+
* @param {string} webId - ID del proyecto web
|
|
10
|
+
* @param {'tc' | 'privacy' | 'cookies'} type - Tipo de texto legal
|
|
11
|
+
* @param {string} language - Código de idioma (por defecto 'es')
|
|
12
|
+
* @returns {Promise<any>} Respuesta con el texto legal
|
|
13
|
+
*/
|
|
14
|
+
async getLegalText(webId, type, language = 'es') {
|
|
15
|
+
config.DEBUG_MODE && console.debug("getLegalText", { webId, type, language });
|
|
16
|
+
|
|
17
|
+
if (!webId) {
|
|
18
|
+
console.error('getLegalText: webId es requerido');
|
|
19
|
+
throw new Error('webId es requerido');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (!['tc', 'privacy', 'cookies'].includes(type)) {
|
|
23
|
+
console.error('getLegalText: tipo inválido. Debe ser tc, privacy o cookies');
|
|
24
|
+
throw new Error('Tipo inválido. Debe ser tc, privacy o cookies');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
const response = await Networking.request(config.ENDPOINTS.GET_LEGAL_TEXT, {
|
|
29
|
+
webId,
|
|
30
|
+
type,
|
|
31
|
+
language
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
config.DEBUG_MODE && console.debug("getLegalText response", response);
|
|
35
|
+
return response;
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error(`Failed to fetch legal text (${type}) for webId ${webId}:`, error);
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default new Legal();
|
package/src/libraries/index.js
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -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>;
|
|
@@ -268,6 +287,10 @@ declare module 'apps-sdk' {
|
|
|
268
287
|
getApplicationId(): string | null;
|
|
269
288
|
}
|
|
270
289
|
|
|
290
|
+
export class Legal {
|
|
291
|
+
getLegalText(webId: string, type: 'tc' | 'privacy' | 'cookies', language?: string): Promise<any>;
|
|
292
|
+
}
|
|
293
|
+
|
|
271
294
|
export class AppsSDK {
|
|
272
295
|
initializePushNotifications(): Promise<string>;
|
|
273
296
|
}
|
|
@@ -280,6 +303,7 @@ declare module 'apps-sdk' {
|
|
|
280
303
|
session : Session;
|
|
281
304
|
utils : Utils;
|
|
282
305
|
paywall : PayWall;
|
|
306
|
+
adaptyOnboarding : typeof AdaptyOnboarding;
|
|
283
307
|
rating : Rating;
|
|
284
308
|
adjust : AdJust;
|
|
285
309
|
mixpanel : MixPanel;
|
|
@@ -290,6 +314,7 @@ declare module 'apps-sdk' {
|
|
|
290
314
|
adapty : Adapty;
|
|
291
315
|
homeActions : HomeActions;
|
|
292
316
|
facebook : Facebook;
|
|
317
|
+
legal : Legal;
|
|
293
318
|
}
|
|
294
319
|
|
|
295
320
|
const Core: AppsSDK;
|