mobiqo-react-native 0.0.10 → 1.0.0

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/README.md CHANGED
@@ -54,8 +54,10 @@ await mobiqo.syncUser({
54
54
  revenue_cat_user_id: 'user-123',
55
55
  include_advanced_analysis: false,
56
56
  additional_data: {
57
- email: 'user@example.com',
58
- plan: 'premium'
57
+ user_id: 'user-123',
58
+ user_name: 'John Doe',
59
+ user_email: 'user@example.com',
60
+ referrer: 'google'
59
61
  }
60
62
  });
61
63
 
@@ -82,6 +84,21 @@ await mobiqo.trackEvent(
82
84
  await mobiqo.trackEvent('screen_opened', MobiqoEvent.SCREEN_VIEW);
83
85
  ```
84
86
 
87
+ ### Update user data
88
+
89
+ ```typescript
90
+ // Update user information without creating a new session
91
+ await mobiqo.updateUser({
92
+ revenue_cat_user_id: 'user-123',
93
+ additional_data: {
94
+ user_id: 'user-123',
95
+ user_name: 'John Doe Updated',
96
+ user_email: 'newemail@example.com',
97
+ referrer: 'facebook'
98
+ }
99
+ });
100
+ ```
101
+
85
102
  ### Get user information
86
103
 
87
104
  ```typescript
@@ -106,8 +123,13 @@ Initialize the Mobiqo service with your API key.
106
123
  #### `syncUser(options)`
107
124
  Sync user data with Mobiqo and start a session.
108
125
  - `options.revenue_cat_user_id` (string): RevenueCat user ID
109
- - `options.include_advanced_analysis` (boolean): whether or not to include advanced analysis in the response (to get the purchase probability and other data, but the request will take more time)
110
- - `options.additional_data` (Record<string, any>, optional): Additional user data
126
+ - `options.include_advanced_analysis` (boolean, optional): whether or not to include advanced analysis in the response (to get the purchase probability and other data, but the request will take more time)
127
+ - `options.additional_data` (AdditionalData, optional): Additional user data (user_id, user_name, user_email, referrer)
128
+
129
+ #### `updateUser(options)`
130
+ Update user information without creating a new session.
131
+ - `options.revenue_cat_user_id` (string): RevenueCat user ID
132
+ - `options.additional_data` (AdditionalData, optional): Additional user data to update (user_id, user_name, user_email, referrer)
111
133
 
112
134
  #### `getUserInfo(options)`
113
135
  Retrieve user information from Mobiqo.
@@ -187,6 +209,16 @@ interface Statistics {
187
209
  }
188
210
  ```
189
211
 
212
+ #### `AdditionalData`
213
+ ```typescript
214
+ interface AdditionalData {
215
+ user_id?: string;
216
+ user_name?: string;
217
+ user_email?: string;
218
+ referrer?: string;
219
+ }
220
+ ```
221
+
190
222
  ## Requirements
191
223
 
192
224
  - React Native
package/dist/index.d.ts CHANGED
@@ -31,6 +31,12 @@ export interface AppUser {
31
31
  /** Currently active entitlements/subscriptions */
32
32
  active_entitlements: string[];
33
33
  }
34
+ export interface AdditionalData {
35
+ user_id?: string;
36
+ user_name?: string;
37
+ user_email?: string;
38
+ referrer?: string;
39
+ }
34
40
  /**
35
41
  * User analytics and prediction statistics
36
42
  */
@@ -67,14 +73,14 @@ export interface GetUserInfoResponse {
67
73
  statistics: Statistics;
68
74
  }
69
75
  /**
70
- * Mobiqo Analytics Service for Capacitor apps
76
+ * Mobiqo Analytics Service for React Native apps
71
77
  *
72
78
  * This service provides analytics tracking, user management, and session handling
73
79
  * for mobile applications using the Mobiqo platform.
74
80
  *
75
81
  * @example
76
82
  * ```typescript
77
- * import Mobiqo, { MobiqoEvent, SyncUserResponse, AppUser } from 'mobiqo-capacitor';
83
+ * import Mobiqo, { MobiqoEvent, SyncUserResponse, AppUser } from 'mobiqo-react-native';
78
84
  *
79
85
  * const mobiqo = new Mobiqo();
80
86
  * await mobiqo.init({ mobiqoKey: 'your-api-key' });
@@ -82,7 +88,8 @@ export interface GetUserInfoResponse {
82
88
  * // Sync user with optional additional data
83
89
  * const result: SyncUserResponse = await mobiqo.syncUser({
84
90
  * revenue_cat_user_id: 'user-123',
85
- * additional_data: { plan: 'premium' }
91
+ * include_advanced_analysis: true,
92
+ * additional_data: { user_id: 'user-123', user_name: 'John Doe', user_email: 'john.doe@example.com', referrer: 'google' }
86
93
  * });
87
94
  * console.log('User OS:', result.appUser.os);
88
95
  * console.log('Purchase intent:', result.statistics.purchase_intent);
@@ -118,7 +125,7 @@ export default class Mobiqo {
118
125
  * Get device model information
119
126
  *
120
127
  * Returns actual device model when possible. For best results, install react-native-device-info:
121
- * npm install react-native-device-info
128
+ * npm install --save react-native-device-info
122
129
  *
123
130
  * @returns Device model string or 'unknown' if not available
124
131
  * @private
@@ -134,7 +141,7 @@ export default class Mobiqo {
134
141
  * @param options - User sync options
135
142
  * @param options.revenue_cat_user_id - The RevenueCat user identifier
136
143
  * @param options.include_advanced_analysis - Whether to include advanced analysis in the response (purchase probability and other data, but request takes more time)
137
- * @param options.additional_data - Optional extra user data to store (email, plan, etc.)
144
+ * @param options.additional_data - Optional extra user data to store (email, name, etc.)
138
145
  * @returns Promise that resolves with user sync response including user data and statistics
139
146
  *
140
147
  * @example
@@ -144,9 +151,10 @@ export default class Mobiqo {
144
151
  * revenue_cat_user_id: 'user-123',
145
152
  * include_advanced_analysis: true,
146
153
  * additional_data: {
147
- * email: 'user@example.com',
148
- * plan: 'premium',
149
- * signupDate: '2024-01-01'
154
+ * user_id: 'user-123',
155
+ * user_name: 'John Doe',
156
+ * user_email: 'user@example.com',
157
+ * referrer: 'google',
150
158
  * }
151
159
  * });
152
160
  *
@@ -159,8 +167,37 @@ export default class Mobiqo {
159
167
  syncUser({ revenue_cat_user_id, include_advanced_analysis, additional_data }: {
160
168
  revenue_cat_user_id: string;
161
169
  include_advanced_analysis?: boolean;
162
- additional_data?: Record<string, any>;
170
+ additional_data?: AdditionalData;
163
171
  }): Promise<SyncUserResponse | undefined>;
172
+ /**
173
+ * Update user data in Mobiqo
174
+ *
175
+ * This method allows you to update additional user data for an existing user.
176
+ * Use this when you want to update user information without creating a new session.
177
+ *
178
+ * @param options - User update options
179
+ * @param options.revenue_cat_user_id - The RevenueCat user identifier
180
+ * @param options.additional_data - Optional extra user data to update (email, name, etc.)
181
+ * @returns Promise that resolves when the update is complete
182
+ *
183
+ * @example
184
+ * ```typescript
185
+ * // Update user data
186
+ * await mobiqo.updateUser({
187
+ * revenue_cat_user_id: 'user-123',
188
+ * additional_data: {
189
+ * user_id: 'user-123',
190
+ * user_name: 'John Doe',
191
+ * user_email: 'john.doe@example.com',
192
+ * referrer: 'google',
193
+ * }
194
+ * });
195
+ * ```
196
+ */
197
+ updateUser({ revenue_cat_user_id, additional_data }: {
198
+ revenue_cat_user_id: string;
199
+ additional_data?: AdditionalData;
200
+ }): Promise<void>;
164
201
  /**
165
202
  * Retrieve user information from Mobiqo
166
203
  *
package/dist/index.js CHANGED
@@ -18,14 +18,14 @@ const react_native_1 = require("react-native");
18
18
  var MobiqoEvent_1 = require("./MobiqoEvent");
19
19
  Object.defineProperty(exports, "MobiqoEvent", { enumerable: true, get: function () { return MobiqoEvent_1.MobiqoEvent; } });
20
20
  /**
21
- * Mobiqo Analytics Service for Capacitor apps
21
+ * Mobiqo Analytics Service for React Native apps
22
22
  *
23
23
  * This service provides analytics tracking, user management, and session handling
24
24
  * for mobile applications using the Mobiqo platform.
25
25
  *
26
26
  * @example
27
27
  * ```typescript
28
- * import Mobiqo, { MobiqoEvent, SyncUserResponse, AppUser } from 'mobiqo-capacitor';
28
+ * import Mobiqo, { MobiqoEvent, SyncUserResponse, AppUser } from 'mobiqo-react-native';
29
29
  *
30
30
  * const mobiqo = new Mobiqo();
31
31
  * await mobiqo.init({ mobiqoKey: 'your-api-key' });
@@ -33,7 +33,8 @@ Object.defineProperty(exports, "MobiqoEvent", { enumerable: true, get: function
33
33
  * // Sync user with optional additional data
34
34
  * const result: SyncUserResponse = await mobiqo.syncUser({
35
35
  * revenue_cat_user_id: 'user-123',
36
- * additional_data: { plan: 'premium' }
36
+ * include_advanced_analysis: true,
37
+ * additional_data: { user_id: 'user-123', user_name: 'John Doe', user_email: 'john.doe@example.com', referrer: 'google' }
37
38
  * });
38
39
  * console.log('User OS:', result.appUser.os);
39
40
  * console.log('Purchase intent:', result.statistics.purchase_intent);
@@ -92,7 +93,7 @@ class Mobiqo {
92
93
  * Get device model information
93
94
  *
94
95
  * Returns actual device model when possible. For best results, install react-native-device-info:
95
- * npm install react-native-device-info
96
+ * npm install --save react-native-device-info
96
97
  *
97
98
  * @returns Device model string or 'unknown' if not available
98
99
  * @private
@@ -140,7 +141,7 @@ class Mobiqo {
140
141
  * @param options - User sync options
141
142
  * @param options.revenue_cat_user_id - The RevenueCat user identifier
142
143
  * @param options.include_advanced_analysis - Whether to include advanced analysis in the response (purchase probability and other data, but request takes more time)
143
- * @param options.additional_data - Optional extra user data to store (email, plan, etc.)
144
+ * @param options.additional_data - Optional extra user data to store (email, name, etc.)
144
145
  * @returns Promise that resolves with user sync response including user data and statistics
145
146
  *
146
147
  * @example
@@ -150,9 +151,10 @@ class Mobiqo {
150
151
  * revenue_cat_user_id: 'user-123',
151
152
  * include_advanced_analysis: true,
152
153
  * additional_data: {
153
- * email: 'user@example.com',
154
- * plan: 'premium',
155
- * signupDate: '2024-01-01'
154
+ * user_id: 'user-123',
155
+ * user_name: 'John Doe',
156
+ * user_email: 'user@example.com',
157
+ * referrer: 'google',
156
158
  * }
157
159
  * });
158
160
  *
@@ -171,12 +173,18 @@ class Mobiqo {
171
173
  return;
172
174
  }
173
175
  const device_model = this.getDeviceModel();
176
+ const additionalData = {
177
+ id: additional_data === null || additional_data === void 0 ? void 0 : additional_data.user_id,
178
+ name: additional_data === null || additional_data === void 0 ? void 0 : additional_data.user_name,
179
+ email: additional_data === null || additional_data === void 0 ? void 0 : additional_data.user_email,
180
+ referrer: additional_data === null || additional_data === void 0 ? void 0 : additional_data.referrer,
181
+ };
174
182
  const response = yield fetch(this.API_URL + "/linkUser", {
175
183
  method: "POST",
176
184
  headers: {
177
185
  "Content-Type": "application/json"
178
186
  },
179
- body: JSON.stringify({ revenue_cat_user_id, project_id, include_advanced_analysis, additional_data, device_model, local_timestamp: new Date().getTime() })
187
+ body: JSON.stringify({ revenue_cat_user_id, project_id, include_advanced_analysis, personal_data: additionalData || {}, device_model, local_timestamp: new Date().getTime() })
180
188
  });
181
189
  const responseData = yield response.json();
182
190
  yield async_storage_1.default.setItem('mobiqo_session_id', responseData.sessionId);
@@ -194,6 +202,59 @@ class Mobiqo {
194
202
  }
195
203
  });
196
204
  }
205
+ /**
206
+ * Update user data in Mobiqo
207
+ *
208
+ * This method allows you to update additional user data for an existing user.
209
+ * Use this when you want to update user information without creating a new session.
210
+ *
211
+ * @param options - User update options
212
+ * @param options.revenue_cat_user_id - The RevenueCat user identifier
213
+ * @param options.additional_data - Optional extra user data to update (email, name, etc.)
214
+ * @returns Promise that resolves when the update is complete
215
+ *
216
+ * @example
217
+ * ```typescript
218
+ * // Update user data
219
+ * await mobiqo.updateUser({
220
+ * revenue_cat_user_id: 'user-123',
221
+ * additional_data: {
222
+ * user_id: 'user-123',
223
+ * user_name: 'John Doe',
224
+ * user_email: 'john.doe@example.com',
225
+ * referrer: 'google',
226
+ * }
227
+ * });
228
+ * ```
229
+ */
230
+ updateUser(_a) {
231
+ return __awaiter(this, arguments, void 0, function* ({ revenue_cat_user_id, additional_data }) {
232
+ try {
233
+ const project_id = yield async_storage_1.default.getItem('mobiqo_project_id');
234
+ if (!project_id) {
235
+ console.error('Project ID not found');
236
+ return;
237
+ }
238
+ const additionalData = {
239
+ id: additional_data === null || additional_data === void 0 ? void 0 : additional_data.user_id,
240
+ name: additional_data === null || additional_data === void 0 ? void 0 : additional_data.user_name,
241
+ email: additional_data === null || additional_data === void 0 ? void 0 : additional_data.user_email,
242
+ referrer: additional_data === null || additional_data === void 0 ? void 0 : additional_data.referrer,
243
+ };
244
+ const response = yield fetch(this.API_URL + "/updateUser", {
245
+ method: "POST",
246
+ headers: {
247
+ "Content-Type": "application/json"
248
+ },
249
+ body: JSON.stringify({ revenue_cat_user_id, project_id, personal_data: additionalData || {} })
250
+ });
251
+ yield response.json();
252
+ }
253
+ catch (error) {
254
+ console.error('Error updating user', error);
255
+ }
256
+ });
257
+ }
197
258
  /**
198
259
  * Retrieve user information from Mobiqo
199
260
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobiqo-react-native",
3
- "version": "0.0.10",
3
+ "version": "1.0.0",
4
4
  "description": "Mobiqo SDK for Capacitor apps - Mobile analytics and user tracking",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",