apps-sdk 1.1.91 → 1.1.93

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apps-sdk",
3
- "version": "1.1.91",
3
+ "version": "1.1.93",
4
4
  "description": "Apps SDK",
5
5
  "main": "index.js",
6
6
  "author": "ASD",
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { AdaptyOnboardingView } from 'react-native-adapty/dist/ui';
3
- import { View } from "react-native";
2
+ import { AdaptyOnboardingView } from 'react-native-adapty';
3
+ import { View, Platform } from "react-native";
4
4
  import Adapty from '../libraries/Adapty';
5
5
  import * as config from '../../config';
6
6
 
@@ -20,27 +20,22 @@ class AdaptyOnboarding extends React.Component {
20
20
  componentDidMount() {
21
21
  const { preloadedOnboarding, placementID, lang } = this.props;
22
22
 
23
- // If preloaded onboarding is provided, use it immediately (no loading screen!)
24
23
  if (preloadedOnboarding) {
25
- config.DEBUG_MODE && console.log('[ONBOARDING] Using preloaded onboarding data - skipping load');
24
+ config.DEBUG_MODE && console.log('[ONBOARDING] Using preloaded onboarding data');
26
25
  this.remoteConfig = preloadedOnboarding.remoteConfig || {};
27
26
 
28
27
  if (this.props.onRemoteConfigLoaded && this.remoteConfig) {
29
- config.DEBUG_MODE && console.log('Remote config loaded from preload:', this.remoteConfig);
30
28
  this.props.onRemoteConfigLoaded(this.remoteConfig);
31
29
  }
32
30
 
33
31
  this.setState({ onboarding: preloadedOnboarding, isLoading: false });
34
32
  } else {
35
- // Fallback to loading if not preloaded
36
- config.DEBUG_MODE && console.log('[ONBOARDING] No preloaded data, loading normally');
37
33
  this.loadOnboarding(placementID, lang);
38
34
  }
39
35
  }
40
36
 
41
37
  async componentDidUpdate(prevProps) {
42
38
  if (this.props.visible && !prevProps.visible) {
43
- // Only reload if we don't already have onboarding data
44
39
  if (!this.state.onboarding) {
45
40
  const { placementID, lang } = this.props;
46
41
  await this.loadOnboarding(placementID, lang);
@@ -61,20 +56,17 @@ class AdaptyOnboarding extends React.Component {
61
56
  this.remoteConfig = onboarding.remoteConfig || {};
62
57
 
63
58
  if (this.props.onRemoteConfigLoaded && this.remoteConfig) {
64
- config.DEBUG_MODE && console.log('Remote config loaded:', this.remoteConfig);
65
59
  this.props.onRemoteConfigLoaded(this.remoteConfig);
66
60
  }
67
61
 
68
62
  this.setState({ onboarding, isLoading: false });
69
63
  } else {
70
- console.log('Onboarding not found for placement:', placementID, 'and language:', lang);
71
64
  this.setState({ isLoading: false });
72
65
  if (this.props.onError) {
73
66
  this.props.onError(new Error('Onboarding not found'), this.remoteConfig);
74
67
  }
75
68
  }
76
69
  } catch (error) {
77
- console.log('Error loading onboarding:', error);
78
70
  this.setState({ isLoading: false });
79
71
  if (this.props.onError) {
80
72
  this.props.onError(error, this.remoteConfig);
@@ -84,33 +76,22 @@ class AdaptyOnboarding extends React.Component {
84
76
 
85
77
  // --------------------------------------- Event Handlers ---------------------------------------
86
78
  handleCustom = (actionId, meta) => {
87
- config.DEBUG_MODE && console.log('Onboarding custom AdaptyOnboarding:', actionId, meta);
88
-
89
79
  if (this.props.onCustom) {
90
80
  this.props.onCustom(actionId, meta, this.remoteConfig);
91
81
  }
92
82
  }
93
83
 
94
84
  handleClose = (actionId, meta) => {
95
- const isLastStep = this.totalSteps > 0 && this.currentStep === this.totalSteps - 1;
96
-
97
- config.DEBUG_MODE && console.log('Onboarding close attempt AdaptyOnboarding:', {actionId, meta, currentStep: this.currentStep, totalSteps: this.totalSteps, isLastStep });
98
-
99
85
  if (this.props.onClose) {
100
86
  this.props.onClose(actionId, meta, this.remoteConfig);
101
87
  }
102
-
103
88
  return true;
104
89
  }
105
90
 
106
91
  handleModalDismiss = () => {
107
- config.DEBUG_MODE && console.log('AdaptyOnboarding Modal fully dismissed');
108
-
109
- // Reset state after modal is fully dismissed
110
92
  this.currentStep = 0;
111
93
  this.totalSteps = 0;
112
94
 
113
- // Notify parent that modal is fully closed
114
95
  if (this.props.onModalDismissed) {
115
96
  this.props.onModalDismissed();
116
97
  }
@@ -120,8 +101,6 @@ class AdaptyOnboarding extends React.Component {
120
101
  if (meta && typeof meta === 'object') {
121
102
  this.currentStep = meta.screen_index ?? this.currentStep;
122
103
  this.totalSteps = meta.total_screens ?? this.totalSteps;
123
-
124
- config.DEBUG_MODE && console.log('State updated AdaptyOnboarding:', {action, meta, currentStep: this.currentStep, totalSteps: this.totalSteps});
125
104
  }
126
105
 
127
106
  if (this.props.onStateUpdated) {
@@ -130,15 +109,10 @@ class AdaptyOnboarding extends React.Component {
130
109
  }
131
110
 
132
111
  handleError = (error) => {
133
- console.log('Onboarding error:', error);
134
-
135
- // Check if it's a WebResource ORB error (common on Android)
136
112
  const isORBError = error?.message?.includes('ERR_BLOCKED_BY_ORB');
137
113
 
138
114
  if (isORBError) {
139
- config.DEBUG_MODE && console.log('WebResource ORB error detected - non-critical, continuing');
140
- // Don't propagate ORB errors as they don't break functionality
141
- return false; // Continue
115
+ return false;
142
116
  }
143
117
 
144
118
  if (this.props.onError) {
@@ -148,26 +122,32 @@ class AdaptyOnboarding extends React.Component {
148
122
  }
149
123
 
150
124
  handleAnalytics = (event, data) => {
151
- config.DEBUG_MODE && console.log('Onboarding analytics AdaptyOnboarding:', event, data);
152
-
125
+ // Available events from Adapty:
126
+ // - onboarding_started (screenIndex: 0, totalScreens: 4)
127
+ // - screen_presented (screenIndex: 0-3, totalScreens: 4) - fires for each screen
128
+ // - screen_completed (screenIndex: 0-2) - fires when leaving a screen
129
+ //
130
+ // To track these events: Access event.name and data.screenIndex in onAnalytics callback
131
+ // Example: if (event?.name === 'screen_presented') { track(data.screenIndex) }
132
+
153
133
  if (this.props.onAnalytics) {
154
134
  this.props.onAnalytics(event, data, this.remoteConfig);
155
135
  }
156
136
  }
157
137
 
158
138
  handlePaywall = (actionId, meta) => {
159
- config.DEBUG_MODE && console.log('Onboarding paywall AdaptyOnboarding:', actionId, meta);
160
-
161
139
  if (this.props.onPaywall) {
162
140
  this.props.onPaywall(actionId, meta, this.remoteConfig);
163
141
  }
164
142
  }
165
143
 
166
144
  handleFinishedLoading = (meta) => {
167
- config.DEBUG_MODE && console.log('Onboarding finished loading AdaptyOnboarding:', meta);
145
+ // Prop: loaderMaskDelay - Delay before showing onboarding content (default: 300ms)
146
+ const delay = this.props.loaderMaskDelay ?? 300;
168
147
 
169
- // Mark WebView as ready to show content
170
- this.setState({ webViewReady: true });
148
+ setTimeout(() => {
149
+ this.setState({ webViewReady: true });
150
+ }, delay);
171
151
 
172
152
  if (this.props.onFinishedLoading) {
173
153
  this.props.onFinishedLoading(meta, this.remoteConfig);
@@ -183,38 +163,51 @@ class AdaptyOnboarding extends React.Component {
183
163
  return null;
184
164
  }
185
165
 
186
- const content = (
166
+ // Prop: loaderMaskColor - Background color for the loader mask (default: '#121212')
167
+ const maskColor = this.props.loaderMaskColor || '#121212';
168
+
169
+ return (
187
170
  <View style={styles.container}>
171
+ {/* Loader mask: Hides WebView white loader without blocking touch events */}
172
+ {!webViewReady && onboarding && (
173
+ <View style={[styles.loaderMask, { backgroundColor: maskColor }]} />
174
+ )}
175
+
188
176
  {!isLoading && onboarding ? (
189
- <View style={[styles.onboardingWrapper, { opacity: webViewReady ? 1 : 0 }]}>
177
+ <View style={styles.onboardingWrapper}>
190
178
  <AdaptyOnboardingView
191
179
  onboarding={onboarding}
192
180
  style={styles.onboardingView}
193
- eventHandlers={{
194
- onAnalytics: this.handleAnalytics,
195
- onClose: this.handleClose,
196
- onCustom: this.handleCustom,
197
- onPaywall: this.handlePaywall,
198
- onStateUpdated: this.handleStateUpdated,
199
- onFinishedLoading: this.handleFinishedLoading,
200
- onError: this.handleError,
201
- }}
181
+ onAnalytics={this.handleAnalytics}
182
+ onClose={this.handleClose}
183
+ onCustom={this.handleCustom}
184
+ onPaywall={this.handlePaywall}
185
+ onStateUpdated={this.handleStateUpdated}
186
+ onFinishedLoading={this.handleFinishedLoading}
187
+ onError={this.handleError}
202
188
  />
203
189
  </View>
204
190
  ) : null}
205
191
  </View>
206
192
  );
207
-
208
- return content;
209
193
  }
210
194
  }
211
195
 
212
196
  const styles = {
213
197
  container: {
214
- backgroundColor: '#000',
198
+ backgroundColor: '#121212',
199
+ flex: 1,
215
200
  width: '100%',
216
201
  height: '100%',
217
202
  },
203
+ loaderMask: {
204
+ position: 'absolute',
205
+ top: 0,
206
+ left: 0,
207
+ right: 0,
208
+ bottom: 0,
209
+ zIndex: 10,
210
+ },
218
211
  onboardingWrapper: {
219
212
  flex: 1,
220
213
  width: '100%',
@@ -156,13 +156,18 @@ class Networking {
156
156
  console.log('checkSubscription', subStatus);
157
157
  if (subStatus && subStatus.success === 1) {
158
158
  const currentSubscriptionStatus = await storage.getData('isSubscribed');
159
- await Session.setIsSubscribed(subStatus.data.subscription_active);
160
- if (currentSubscriptionStatus === false && !subStatus.data.subscription_active === true) {
161
- await MixPanel.superProperties({
162
- "subscription_status": "free",
163
- "plan_type": "free",
164
- });
165
- }
159
+ const isActive = subStatus.data.subscription_active;
160
+
161
+ await Session.setIsSubscribed(isActive);
162
+ const productId = subStatus.data.product_id || 0;
163
+ const planType = (isActive && productId) ? String(productId) : "free";
164
+
165
+ await MixPanel.superProperties({
166
+ "subscription_status": isActive ? "premium" : "free",
167
+ "plan_type": planType,
168
+ "app_version": Session.getAppVersion()
169
+ });
170
+
166
171
  await Session.setSubscriptionData(subStatus.data);
167
172
  return true;
168
173
  }
package/types/index.d.ts CHANGED
@@ -229,6 +229,8 @@ declare module 'apps-sdk' {
229
229
  placementID: string;
230
230
  lang: string;
231
231
  preloadedOnboarding?: any;
232
+ loaderMaskColor?: string; // Color of the mask that hides WebView loader (default: '#121212')
233
+ loaderMaskDelay?: number; // Delay in ms before showing content (default: 300ms)
232
234
  onAnalytics?: (event: any, meta: any, remoteConfig?: any) => void;
233
235
  onClose?: (actionId: string, meta: any, remoteConfig?: any) => Promise<boolean> | boolean;
234
236
  onCustom?: (actionId: string, meta: any, remoteConfig?: any) => void;