apps-sdk 1.1.56 → 1.1.57
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
|
@@ -8,6 +8,9 @@ class AdaptyOnboarding extends React.Component {
|
|
|
8
8
|
this.onboardingView = null;
|
|
9
9
|
this.isPresenting = false;
|
|
10
10
|
this.remoteConfig = null;
|
|
11
|
+
this.termsAccepted = false;
|
|
12
|
+
this.currentStep = 0;
|
|
13
|
+
this.totalSteps = 0;
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
async componentDidMount() {
|
|
@@ -58,19 +61,56 @@ class AdaptyOnboarding extends React.Component {
|
|
|
58
61
|
this.onboardingView.registerEventHandlers({
|
|
59
62
|
onCustom: (actionId, meta) => {
|
|
60
63
|
config.DEBUG_MODE && console.log('Onboarding custom action:', actionId, meta);
|
|
64
|
+
|
|
65
|
+
// Marcar términos aceptados solo cuando se dispara este action
|
|
66
|
+
if (actionId === 'accept_terms') {
|
|
67
|
+
this.termsAccepted = true;
|
|
68
|
+
config.DEBUG_MODE && console.log('Terms accepted - can close when reaching last step');
|
|
69
|
+
}
|
|
70
|
+
|
|
61
71
|
// Pasar remoteConfig en el handler
|
|
62
72
|
if (onCustom) {
|
|
63
73
|
onCustom(actionId, meta, this.remoteConfig);
|
|
64
74
|
}
|
|
65
75
|
},
|
|
66
76
|
onClose: async (actionId, meta) => {
|
|
67
|
-
|
|
77
|
+
const isLastStep = this.totalSteps > 0 && this.currentStep === this.totalSteps - 1;
|
|
78
|
+
const canClose = this.termsAccepted && isLastStep;
|
|
79
|
+
|
|
80
|
+
config.DEBUG_MODE && console.log('Onboarding close attempt:', {
|
|
81
|
+
actionId,
|
|
82
|
+
meta,
|
|
83
|
+
termsAccepted: this.termsAccepted,
|
|
84
|
+
currentStep: this.currentStep,
|
|
85
|
+
totalSteps: this.totalSteps,
|
|
86
|
+
isLastStep,
|
|
87
|
+
canClose
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// Solo permitir cerrar si:
|
|
91
|
+
// 1. El usuario aceptó los términos Y
|
|
92
|
+
// 2. Está en el último paso del onboarding
|
|
93
|
+
if (!canClose) {
|
|
94
|
+
config.DEBUG_MODE && console.log('Onboarding close prevented - must accept terms and reach last step');
|
|
95
|
+
return false; // Bloquear cierre
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// Permitir cerrar
|
|
99
|
+
config.DEBUG_MODE && console.log('Onboarding close allowed - terms accepted and last step reached');
|
|
68
100
|
this.isPresenting = false;
|
|
101
|
+
|
|
69
102
|
// Pasar remoteConfig en el handler
|
|
70
103
|
if (onClose) {
|
|
71
104
|
onClose(actionId, meta, this.remoteConfig);
|
|
72
105
|
}
|
|
106
|
+
|
|
73
107
|
await this.onboardingView.dismiss();
|
|
108
|
+
|
|
109
|
+
// Reset para próxima vez
|
|
110
|
+
this.termsAccepted = false;
|
|
111
|
+
this.currentStep = 0;
|
|
112
|
+
this.totalSteps = 0;
|
|
113
|
+
|
|
74
114
|
return true;
|
|
75
115
|
},
|
|
76
116
|
onError: (error) => {
|
|
@@ -94,16 +134,29 @@ class AdaptyOnboarding extends React.Component {
|
|
|
94
134
|
handlers.onPaywall(this.remoteConfig);
|
|
95
135
|
}
|
|
96
136
|
},
|
|
97
|
-
onStateUpdated: (
|
|
98
|
-
|
|
137
|
+
onStateUpdated: (action, meta) => {
|
|
138
|
+
// Extraer información del paso actual desde meta
|
|
139
|
+
if (meta && typeof meta === 'object') {
|
|
140
|
+
this.currentStep = meta.screen_index ?? this.currentStep;
|
|
141
|
+
this.totalSteps = meta.total_screens ?? this.totalSteps;
|
|
142
|
+
|
|
143
|
+
config.DEBUG_MODE && console.log('Onboarding state updated:', {
|
|
144
|
+
action,
|
|
145
|
+
meta,
|
|
146
|
+
currentStep: this.currentStep,
|
|
147
|
+
totalSteps: this.totalSteps,
|
|
148
|
+
termsAccepted: this.termsAccepted
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
|
|
99
152
|
if (handlers.onStateUpdated) {
|
|
100
|
-
handlers.onStateUpdated(
|
|
153
|
+
handlers.onStateUpdated(action, meta, this.remoteConfig);
|
|
101
154
|
}
|
|
102
155
|
},
|
|
103
|
-
onFinishedLoading: () => {
|
|
104
|
-
config.DEBUG_MODE && console.log('Onboarding finished loading');
|
|
156
|
+
onFinishedLoading: (meta) => {
|
|
157
|
+
config.DEBUG_MODE && console.log('Onboarding finished loading', meta);
|
|
105
158
|
if (handlers.onFinishedLoading) {
|
|
106
|
-
handlers.onFinishedLoading(this.remoteConfig);
|
|
159
|
+
handlers.onFinishedLoading(meta, this.remoteConfig);
|
|
107
160
|
}
|
|
108
161
|
},
|
|
109
162
|
});
|
package/types/index.d.ts
CHANGED
|
@@ -168,8 +168,8 @@ declare module 'apps-sdk' {
|
|
|
168
168
|
onRemoteConfigLoaded?: (remoteConfig: Record<string, any>) => void;
|
|
169
169
|
onAnalytics?: (event: string | any, data?: Record<string, any>, remoteConfig?: Record<string, any>) => void;
|
|
170
170
|
onPaywall?: (remoteConfig?: Record<string, any>) => void;
|
|
171
|
-
onStateUpdated?: (
|
|
172
|
-
onFinishedLoading?: (remoteConfig?: Record<string, any>) => void;
|
|
171
|
+
onStateUpdated?: (action: any, meta?: Record<string, any>, remoteConfig?: Record<string, any>) => void;
|
|
172
|
+
onFinishedLoading?: (meta?: Record<string, any>, remoteConfig?: Record<string, any>) => void;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
175
|
export class AdaptyOnboarding extends Component<AdaptyOnboardingProps, {}> {}
|