mixpanel-react-native 2.2.5 → 2.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  #
2
2
 
3
+ ## [v2.3.0](https://github.com/mixpanel/mixpanel-react-native/tree/v2.3.0) (2023-06-16)
4
+
5
+ ### Enhancements
6
+
7
+ - Returning Promise for the identify\(\) to avoid race condition [\#200](https://github.com/mixpanel/mixpanel-react-native/pull/200)
8
+
9
+ ### Fixes
10
+
11
+ - Fix null reference used for synchronization \(monitor-enter\) [\#199](https://github.com/mixpanel/mixpanel-react-native/pull/199)
12
+ - fix initialize was called with 4 arguments but expects 5 arguments [\#198](https://github.com/mixpanel/mixpanel-react-native/pull/198)
13
+ - safer handling of super properties [\#197](https://github.com/mixpanel/mixpanel-react-native/pull/197)
14
+ - Android resource linking failure fix [\#187](https://github.com/mixpanel/mixpanel-react-native/pull/187)
15
+
16
+ **Closed issues:**
17
+
18
+ - Support new React Native new architecture \(TurboModules/Fabric\) [\#145](https://github.com/mixpanel/mixpanel-react-native/issues/145)
19
+ - Feature Request: Built in getInstance\(\) or similar instead of custom tooling [\#139](https://github.com/mixpanel/mixpanel-react-native/issues/139)
20
+ - \[Feature Request\] Add support for Expo Config Plugins [\#69](https://github.com/mixpanel/mixpanel-react-native/issues/69)
21
+
22
+ #
23
+
3
24
  ## [v2.2.5](https://github.com/mixpanel/mixpanel-react-native/tree/v2.2.5) (2023-04-29)
4
25
 
5
26
  ### Fixes
@@ -300,6 +321,8 @@ Report issues or give us any feedback is appreciated!
300
321
 
301
322
 
302
323
 
324
+
325
+
303
326
 
304
327
 
305
328
 
@@ -19,5 +19,5 @@ Pod::Spec.new do |s|
19
19
  s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
20
20
 
21
21
  s.dependency "React-Core"
22
- s.dependency "Mixpanel-swift", '4.1.1'
22
+ s.dependency "Mixpanel-swift", '4.1.3'
23
23
  end
package/README.md CHANGED
@@ -100,7 +100,7 @@ const SampleApp = () => {
100
100
  export default SampleApp;
101
101
 
102
102
  ```
103
-
103
+ ### For Expo support, please refer to this [issue](https://github.com/mixpanel/mixpanel-react-native/issues/82)
104
104
  👋 👋 Tell us about the Mixpanel developer experience! [https://www.mixpanel.com/devnps](https://www.mixpanel.com/devnps) 👍 👎
105
105
 
106
106
 
@@ -112,7 +112,7 @@ Yes, in Lexicon, you can intercept and drop incoming events or properties. Mixpa
112
112
  Mixpanel’s client-side tracking library contains the [optOutTracking()](https://mixpanel.github.io/mixpanel-react-native/Mixpanel.html#optOutTracking) method, which will set the user’s local opt-out state to “true” and will prevent data from being sent from a user’s device. More detailed instructions can be found in the section, [Opting users out of tracking](https://developer.mixpanel.com/docs/react-native#opting-users-out-of-tracking).
113
113
 
114
114
  **Why aren't my events showing up?**
115
- To preserve battery life and customer bandwidth, the Mixpanel library doesn't send the events you record immediately. Instead, it sends batches to the Mixpanel servers every 60 seconds while your application is running, as well as when the application transitions to the background. You can call [flush()](https://mixpanel.github.io/mixpanel-react-native/Mixpanel.html#flush) manually if you want to force a flush at a particular moment.
115
+ First, make sure your test device has internet access. To preserve battery life and customer bandwidth, the Mixpanel library doesn't send the events you record immediately. Instead, it sends batches to the Mixpanel servers every 60 seconds while your application is running, as well as when the application transitions to the background. You can call [flush()](https://mixpanel.github.io/mixpanel-react-native/Mixpanel.html#flush) manually if you want to force a flush at a particular moment.
116
116
 
117
117
  ```
118
118
  mixpanel.flush();
@@ -0,0 +1,28 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>android_</name>
4
+ <comment>Project android_ created by Buildship.</comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ </buildSpec>
14
+ <natures>
15
+ <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16
+ </natures>
17
+ <filteredResources>
18
+ <filter>
19
+ <id>1686200212448</id>
20
+ <name></name>
21
+ <type>30</type>
22
+ <matcher>
23
+ <id>org.eclipse.core.resources.regexFilterMatcher</id>
24
+ <arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
25
+ </matcher>
26
+ </filter>
27
+ </filteredResources>
28
+ </projectDescription>
@@ -0,0 +1,28 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>android__</name>
4
+ <comment>Project android__ created by Buildship.</comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ </buildSpec>
14
+ <natures>
15
+ <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16
+ </natures>
17
+ <filteredResources>
18
+ <filter>
19
+ <id>1686200212452</id>
20
+ <name></name>
21
+ <type>30</type>
22
+ <matcher>
23
+ <id>org.eclipse.core.resources.regexFilterMatcher</id>
24
+ <arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
25
+ </matcher>
26
+ </filter>
27
+ </filteredResources>
28
+ </projectDescription>
@@ -0,0 +1,28 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>SimpleMixpanel</name>
4
+ <comment>Project android created by Buildship.</comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ </buildSpec>
14
+ <natures>
15
+ <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16
+ </natures>
17
+ <filteredResources>
18
+ <filter>
19
+ <id>1686200212442</id>
20
+ <name></name>
21
+ <type>30</type>
22
+ <matcher>
23
+ <id>org.eclipse.core.resources.regexFilterMatcher</id>
24
+ <arguments>node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
25
+ </matcher>
26
+ </filter>
27
+ </filteredResources>
28
+ </projectDescription>
@@ -9,13 +9,13 @@ import { NativeModules } from 'react-native';
9
9
 
10
10
  test(`it calls MixpanelReactNative initialize`, async () => {
11
11
  const mixpanel = await Mixpanel.init("token", true);
12
- expect(NativeModules.MixpanelReactNative.initialize).toBeCalledWith("token", true, false, {"$lib_version": "2.2.5", "mp_lib": "react-native"});
12
+ expect(NativeModules.MixpanelReactNative.initialize).toBeCalledWith("token", true, false, {"$lib_version": "2.3.0", "mp_lib": "react-native"}, "https://api.mixpanel.com");
13
13
  });
14
14
 
15
15
  test(`it calls MixpanelReactNative initialize with optOut and superProperties`, async () => {
16
16
  const mixpanel = new Mixpanel("token", true);
17
17
  mixpanel.init(true, {"super": "property"})
18
- expect(NativeModules.MixpanelReactNative.initialize).toBeCalledWith("token", true, true, {"$lib_version": "2.2.5", "mp_lib": "react-native", "super": "property"}, "https://api.mixpanel.com");
18
+ expect(NativeModules.MixpanelReactNative.initialize).toBeCalledWith("token", true, true, {"$lib_version": "2.3.0", "mp_lib": "react-native", "super": "property"}, "https://api.mixpanel.com");
19
19
  });
20
20
 
21
21
  test(`it calls MixpanelReactNative setServerURL`, async () => {
@@ -4,18 +4,18 @@ buildscript {
4
4
  google()
5
5
  }
6
6
  dependencies {
7
- classpath 'com.android.tools.build:gradle:3.4.1'
7
+ classpath 'com.android.tools.build:gradle:7.3.1'
8
8
  }
9
9
  }
10
10
 
11
11
  apply plugin: 'com.android.library'
12
12
 
13
13
  android {
14
- compileSdkVersion 30
14
+ compileSdkVersion 33
15
15
  buildToolsVersion "30.0.3"
16
16
  defaultConfig {
17
17
  minSdkVersion 21
18
- targetSdkVersion 30
18
+ targetSdkVersion 33
19
19
  versionCode 1
20
20
  versionName "1.0"
21
21
  }
@@ -44,6 +44,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
44
44
  @ReactMethod
45
45
  public void setServerURL(final String token, final String serverURL, Promise promise) throws JSONException {
46
46
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
47
+ if (instance == null) {
48
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
49
+ return;
50
+ }
47
51
  synchronized (instance) {
48
52
  instance.setServerURL(serverURL);
49
53
  promise.resolve(null);
@@ -53,6 +57,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
53
57
  @ReactMethod
54
58
  public void setUseIpAddressForGeolocation(final String token, boolean useIpAddressForGeolocation, Promise promise) throws JSONException {
55
59
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
60
+ if (instance == null) {
61
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
62
+ return;
63
+ }
56
64
  synchronized (instance) {
57
65
  instance.setUseIpAddressForGeolocation(useIpAddressForGeolocation);
58
66
  promise.resolve(null);
@@ -62,6 +70,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
62
70
  @ReactMethod
63
71
  public void setLoggingEnabled(final String token, boolean enableLogging, Promise promise) throws JSONException {
64
72
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
73
+ if (instance == null) {
74
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
75
+ return;
76
+ }
65
77
  synchronized (instance) {
66
78
  instance.setEnableLogging(enableLogging);
67
79
  promise.resolve(null);
@@ -71,6 +83,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
71
83
  @ReactMethod
72
84
  public void hasOptedOutTracking(final String token, Promise promise) {
73
85
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
86
+ if (instance == null) {
87
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
88
+ return;
89
+ }
74
90
  synchronized (instance) {
75
91
  promise.resolve(instance.hasOptedOutTracking());
76
92
  }
@@ -79,6 +95,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
79
95
  @ReactMethod
80
96
  public void optInTracking(final String token, Promise promise) throws JSONException {
81
97
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
98
+ if (instance == null) {
99
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
100
+ return;
101
+ }
82
102
  synchronized (instance) {
83
103
  instance.optInTracking();
84
104
  promise.resolve(null);
@@ -88,6 +108,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
88
108
  @ReactMethod
89
109
  public void optOutTracking(final String token, Promise promise) {
90
110
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
111
+ if (instance == null) {
112
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
113
+ return;
114
+ }
91
115
  synchronized (instance) {
92
116
  instance.optOutTracking();
93
117
  promise.resolve(null);
@@ -97,6 +121,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
97
121
  @ReactMethod
98
122
  public void identify(final String token, final String distinctId, Promise promise) {
99
123
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
124
+ if (instance == null) {
125
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
126
+ return;
127
+ }
100
128
  synchronized (instance) {
101
129
  instance.identify(distinctId);
102
130
  promise.resolve(null);
@@ -106,6 +134,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
106
134
  @ReactMethod
107
135
  public void getDistinctId(final String token, Promise promise) {
108
136
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
137
+ if (instance == null) {
138
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
139
+ return;
140
+ }
109
141
  synchronized (instance) {
110
142
  promise.resolve(instance.getDistinctId());
111
143
  }
@@ -114,6 +146,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
114
146
  @ReactMethod
115
147
  public void getDeviceId(final String token, Promise promise) {
116
148
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
149
+ if (instance == null) {
150
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
151
+ return;
152
+ }
117
153
  synchronized (instance) {
118
154
  promise.resolve(instance.getAnonymousId());
119
155
  }
@@ -122,6 +158,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
122
158
  @ReactMethod
123
159
  public void track(final String token, final String eventName, ReadableMap properties, Promise promise) throws JSONException {
124
160
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
161
+ if (instance == null) {
162
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
163
+ return;
164
+ }
125
165
  synchronized (instance) {
126
166
  JSONObject eventProperties = ReactNativeHelper.reactToJSON(properties);
127
167
  AutomaticProperties.appendLibraryProperties(eventProperties);
@@ -133,6 +173,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
133
173
  @ReactMethod
134
174
  public void registerSuperProperties(final String token, ReadableMap properties, Promise promise) throws JSONException {
135
175
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
176
+ if (instance == null) {
177
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
178
+ return;
179
+ }
136
180
  synchronized (instance) {
137
181
  JSONObject superProperties = ReactNativeHelper.reactToJSON(properties);
138
182
  instance.registerSuperProperties(superProperties);
@@ -143,6 +187,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
143
187
  @ReactMethod
144
188
  public void registerSuperPropertiesOnce(final String token, ReadableMap properties, Promise promise) throws JSONException {
145
189
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
190
+ if (instance == null) {
191
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
192
+ return;
193
+ }
146
194
  synchronized (instance) {
147
195
  JSONObject superProperties = ReactNativeHelper.reactToJSON(properties);
148
196
  instance.registerSuperPropertiesOnce(superProperties);
@@ -153,6 +201,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
153
201
  @ReactMethod
154
202
  public void unregisterSuperProperty(final String token, String superPropertyName, Promise promise) {
155
203
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
204
+ if (instance == null) {
205
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
206
+ return;
207
+ }
156
208
  synchronized (instance) {
157
209
  instance.unregisterSuperProperty(superPropertyName);
158
210
  promise.resolve(null);
@@ -162,6 +214,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
162
214
  @ReactMethod
163
215
  public void union(final String token, String name, ReadableArray value, Promise promise) throws JSONException {
164
216
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
217
+ if (instance == null) {
218
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
219
+ return;
220
+ }
165
221
  synchronized (instance) {
166
222
  JSONArray propertyValue = ReactNativeHelper.reactToJSON(value);
167
223
  instance.getPeople().union(name, propertyValue);
@@ -172,6 +228,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
172
228
  @ReactMethod
173
229
  public void getSuperProperties(final String token, Promise promise) throws JSONException {
174
230
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
231
+ if (instance == null) {
232
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
233
+ return;
234
+ }
175
235
  synchronized (instance) {
176
236
  promise.resolve(ReactNativeHelper.convertJsonToMap(instance.getSuperProperties()));
177
237
  }
@@ -180,6 +240,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
180
240
  @ReactMethod
181
241
  public void clearSuperProperties(final String token, Promise promise) {
182
242
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
243
+ if (instance == null) {
244
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
245
+ return;
246
+ }
183
247
  synchronized (instance) {
184
248
  instance.clearSuperProperties();
185
249
  promise.resolve(null);
@@ -189,6 +253,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
189
253
  @ReactMethod
190
254
  public void alias(final String token, String alias, String original, Promise promise) {
191
255
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
256
+ if (instance == null) {
257
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
258
+ return;
259
+ }
192
260
  synchronized (instance) {
193
261
  instance.alias(alias, original);
194
262
  promise.resolve(null);
@@ -198,6 +266,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
198
266
  @ReactMethod
199
267
  public void reset(final String token, Promise promise) {
200
268
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
269
+ if (instance == null) {
270
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
271
+ return;
272
+ }
201
273
  synchronized (instance) {
202
274
  instance.reset();
203
275
  promise.resolve(null);
@@ -207,6 +279,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
207
279
  @ReactMethod
208
280
  public void flush(final String token, Promise promise) {
209
281
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
282
+ if (instance == null) {
283
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
284
+ return;
285
+ }
210
286
  synchronized (instance) {
211
287
  instance.flush();
212
288
  promise.resolve(null);
@@ -216,6 +292,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
216
292
  @ReactMethod
217
293
  public void timeEvent(final String token, final String eventName, Promise promise) {
218
294
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
295
+ if (instance == null) {
296
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
297
+ return;
298
+ }
219
299
  synchronized (instance) {
220
300
  instance.timeEvent(eventName);
221
301
  promise.resolve(null);
@@ -225,6 +305,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
225
305
  @ReactMethod
226
306
  public void eventElapsedTime(final String token, final String eventName, Promise promise) {
227
307
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
308
+ if (instance == null) {
309
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
310
+ return;
311
+ }
228
312
  synchronized (instance) {
229
313
  promise.resolve(instance.eventElapsedTime(eventName));
230
314
  }
@@ -233,6 +317,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
233
317
  @ReactMethod
234
318
  public void set(final String token, ReadableMap properties, Promise promise) throws JSONException {
235
319
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
320
+ if (instance == null) {
321
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
322
+ return;
323
+ }
236
324
  synchronized (instance) {
237
325
  JSONObject sendProperties = ReactNativeHelper.reactToJSON(properties);
238
326
  AutomaticProperties.appendLibraryProperties(sendProperties);
@@ -244,6 +332,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
244
332
  @ReactMethod
245
333
  public void unset(final String token, String propertyName, Promise promise) {
246
334
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
335
+ if (instance == null) {
336
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
337
+ return;
338
+ }
247
339
  synchronized (instance) {
248
340
  instance.getPeople().unset(propertyName);
249
341
  promise.resolve(null);
@@ -253,6 +345,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
253
345
  @ReactMethod
254
346
  public void setOnce(final String token, ReadableMap properties, Promise promise) throws JSONException {
255
347
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
348
+ if (instance == null) {
349
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
350
+ return;
351
+ }
256
352
  synchronized (instance) {
257
353
  JSONObject sendProperties = ReactNativeHelper.reactToJSON(properties);
258
354
  AutomaticProperties.appendLibraryProperties(sendProperties);
@@ -264,6 +360,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
264
360
  @ReactMethod
265
361
  public void trackCharge(final String token, double charge, ReadableMap properties, Promise promise) throws JSONException {
266
362
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
363
+ if (instance == null) {
364
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
365
+ return;
366
+ }
267
367
  synchronized (instance) {
268
368
  JSONObject transactionValue = ReactNativeHelper.reactToJSON(properties);
269
369
  instance.getPeople().trackCharge(charge, transactionValue);
@@ -274,6 +374,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
274
374
  @ReactMethod
275
375
  public void clearCharges(final String token, Promise promise) {
276
376
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
377
+ if (instance == null) {
378
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
379
+ return;
380
+ }
277
381
  synchronized (instance) {
278
382
  instance.getPeople().clearCharges();
279
383
  promise.resolve(null);
@@ -284,6 +388,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
284
388
  public void increment(final String token, ReadableMap properties, Promise promise) {
285
389
  Map incrementProperties = ReactNativeHelper.toMap(properties);
286
390
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
391
+ if (instance == null) {
392
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
393
+ return;
394
+ }
287
395
  synchronized (instance) {
288
396
  instance.getPeople().increment(incrementProperties);
289
397
  promise.resolve(null);
@@ -293,6 +401,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
293
401
  @ReactMethod
294
402
  public void append(final String token, String name, Dynamic value, Promise promise) throws JSONException {
295
403
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
404
+ if (instance == null) {
405
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
406
+ return;
407
+ }
296
408
  synchronized (instance) {
297
409
  instance.getPeople().append(name, ReactNativeHelper.dynamicToObject(value));
298
410
  promise.resolve(null);
@@ -302,6 +414,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
302
414
  @ReactMethod
303
415
  public void deleteUser(final String token, Promise promise) {
304
416
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
417
+ if (instance == null) {
418
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
419
+ return;
420
+ }
305
421
  synchronized (instance) {
306
422
  instance.getPeople().deleteUser();
307
423
  promise.resolve(null);
@@ -311,6 +427,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
311
427
  @ReactMethod
312
428
  public void remove(final String token, String name, Dynamic value, Promise promise) throws JSONException {
313
429
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
430
+ if (instance == null) {
431
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
432
+ return;
433
+ }
314
434
  synchronized (instance) {
315
435
  instance.getPeople().remove(name, ReactNativeHelper.dynamicToObject(value));
316
436
  promise.resolve(null);
@@ -320,6 +440,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
320
440
  @ReactMethod
321
441
  public void trackWithGroups(final String token, String eventName, ReadableMap properties, ReadableMap groups, Promise promise) {
322
442
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
443
+ if (instance == null) {
444
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
445
+ return;
446
+ }
323
447
  synchronized (instance) {
324
448
  Map eventProperties = ReactNativeHelper.toMap(properties);
325
449
  Map eventGroups = ReactNativeHelper.toMap(groups);
@@ -332,6 +456,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
332
456
  @ReactMethod
333
457
  public void setGroup(final String token, String groupKey, Dynamic groupID, Promise promise) {
334
458
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
459
+ if (instance == null) {
460
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
461
+ return;
462
+ }
335
463
  synchronized (instance) {
336
464
  instance.setGroup(groupKey, ReactNativeHelper.dynamicToObject(groupID));
337
465
  promise.resolve(null);
@@ -341,6 +469,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
341
469
  @ReactMethod
342
470
  public void setGroups(final String token, String groupKey, ReadableArray groupIDs, Promise promise) throws JSONException {
343
471
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
472
+ if (instance == null) {
473
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
474
+ return;
475
+ }
344
476
  synchronized (instance) {
345
477
  instance.setGroup(groupKey, Arrays.asList(ReactNativeHelper.toArray(groupIDs)));
346
478
  promise.resolve(null);
@@ -350,6 +482,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
350
482
  @ReactMethod
351
483
  public void addGroup(final String token, String groupKey, Dynamic groupID, Promise promise) {
352
484
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
485
+ if (instance == null) {
486
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
487
+ return;
488
+ }
353
489
  synchronized (instance) {
354
490
  instance.addGroup(groupKey, ReactNativeHelper.dynamicToObject(groupID));
355
491
  promise.resolve(null);
@@ -359,6 +495,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
359
495
  @ReactMethod
360
496
  public void removeGroup(final String token, String groupKey, Dynamic groupID, Promise promise) {
361
497
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
498
+ if (instance == null) {
499
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
500
+ return;
501
+ }
362
502
  synchronized (instance) {
363
503
  instance.removeGroup(groupKey, ReactNativeHelper.dynamicToObject(groupID));
364
504
  promise.resolve(null);
@@ -368,6 +508,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
368
508
  @ReactMethod
369
509
  public void deleteGroup(final String token, String groupKey, Dynamic groupID, Promise promise) {
370
510
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
511
+ if (instance == null) {
512
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
513
+ return;
514
+ }
371
515
  synchronized (instance) {
372
516
  instance.getGroup(groupKey, ReactNativeHelper.dynamicToObject(groupID)).deleteGroup();
373
517
  promise.resolve(null);
@@ -377,6 +521,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
377
521
  @ReactMethod
378
522
  public void groupSetProperties(final String token, String groupKey, Dynamic groupID, ReadableMap properties, Promise promise) throws JSONException {
379
523
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
524
+ if (instance == null) {
525
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
526
+ return;
527
+ }
380
528
  synchronized (instance) {
381
529
  JSONObject sendProperties = ReactNativeHelper.reactToJSON(properties);
382
530
  instance.getGroup(groupKey, ReactNativeHelper.dynamicToObject(groupID)).set(sendProperties);
@@ -387,6 +535,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
387
535
  @ReactMethod
388
536
  public void groupSetPropertyOnce(final String token, String groupKey, Dynamic groupID, ReadableMap properties, Promise promise) throws JSONException {
389
537
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
538
+ if (instance == null) {
539
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
540
+ return;
541
+ }
390
542
  synchronized (instance) {
391
543
  JSONObject sendProperties = ReactNativeHelper.reactToJSON(properties);
392
544
  instance.getGroup(groupKey, ReactNativeHelper.dynamicToObject(groupID)).setOnce(sendProperties);
@@ -397,6 +549,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
397
549
  @ReactMethod
398
550
  public void groupUnsetProperty(final String token, String groupKey, Dynamic groupID, String propertyName, Promise promise) throws JSONException {
399
551
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
552
+ if (instance == null) {
553
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
554
+ return;
555
+ }
400
556
  synchronized (instance) {
401
557
  instance.getGroup(groupKey, ReactNativeHelper.dynamicToObject(groupID)).unset(propertyName);
402
558
  promise.resolve(null);
@@ -406,6 +562,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
406
562
  @ReactMethod
407
563
  public void groupRemovePropertyValue(final String token, String groupKey, Dynamic groupID, String name, Dynamic value, Promise promise) throws JSONException {
408
564
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
565
+ if (instance == null) {
566
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
567
+ return;
568
+ }
409
569
  synchronized (instance) {
410
570
  instance.getGroup(groupKey, ReactNativeHelper.dynamicToObject(groupID)).remove(name, ReactNativeHelper.dynamicToObject(value));
411
571
  promise.resolve(null);
@@ -415,6 +575,10 @@ public class MixpanelReactNativeModule extends ReactContextBaseJavaModule {
415
575
  @ReactMethod
416
576
  public void groupUnionProperty(final String token, String groupKey, Dynamic groupID, String name, ReadableArray values, Promise promise) throws JSONException {
417
577
  MixpanelAPI instance = MixpanelAPI.getInstance(this.mReactContext, token, true);
578
+ if (instance == null) {
579
+ promise.reject("Instance Error", "Failed to get Mixpanel instance");
580
+ return;
581
+ }
418
582
  synchronized (instance) {
419
583
  JSONArray arrayValues = ReactNativeHelper.reactToJSON(values);
420
584
  instance.getGroup(groupKey, ReactNativeHelper.dynamicToObject(groupID)).union(name, arrayValues);
@@ -469,7 +469,7 @@ Initializes Mixpanel and return an instance of Mixpanel the given project token.
469
469
 
470
470
  <dt class="tag-source">Source:</dt>
471
471
  <dd class="tag-source"><ul class="dummy"><li>
472
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line311">line 311</a>
472
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line322">line 322</a>
473
473
  </li></ul></dd>
474
474
 
475
475
 
@@ -519,8 +519,8 @@ Multiple aliases can point to the same identifier.
519
519
  `mixpane.alias("New ID", mixpane.distinctId)`
520
520
  `mixpane.alias("Newer ID", mixpane.distinctId)`
521
521
 
522
- <p>This call does not identify the user after. You must still call both identify() and
523
- People.identify() if you wish the new alias to be used for Events and People.
522
+ <p>This call does not identify the user after. You must still call identify()
523
+ if you wish the new alias to be used for Events and People.
524
524
  </div>
525
525
 
526
526
 
@@ -636,7 +636,7 @@ People.identify() if you wish the new alias to be used for Events and People.
636
636
 
637
637
  <dt class="tag-source">Source:</dt>
638
638
  <dd class="tag-source"><ul class="dummy"><li>
639
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line212">line 212</a>
639
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line223">line 223</a>
640
640
  </li></ul></dd>
641
641
 
642
642
 
@@ -729,7 +729,7 @@ superProperties registered before the clearSuperProperties method was called.
729
729
 
730
730
  <dt class="tag-source">Source:</dt>
731
731
  <dd class="tag-source"><ul class="dummy"><li>
732
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line419">line 419</a>
732
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line430">line 430</a>
733
733
  </li></ul></dd>
734
734
 
735
735
 
@@ -891,7 +891,7 @@ to Group Analytics using the same group value will create and store new values.<
891
891
 
892
892
  <dt class="tag-source">Source:</dt>
893
893
  <dd class="tag-source"><ul class="dummy"><li>
894
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line339">line 339</a>
894
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line350">line 350</a>
895
895
  </li></ul></dd>
896
896
 
897
897
 
@@ -1028,7 +1028,7 @@ to Group Analytics using the same group value will create and store new values.<
1028
1028
 
1029
1029
  <dt class="tag-source">Source:</dt>
1030
1030
  <dd class="tag-source"><ul class="dummy"><li>
1031
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line444">line 444</a>
1031
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line455">line 455</a>
1032
1032
  </li></ul></dd>
1033
1033
 
1034
1034
 
@@ -1144,7 +1144,7 @@ send all remaining messages to the server.
1144
1144
 
1145
1145
  <dt class="tag-source">Source:</dt>
1146
1146
  <dd class="tag-source"><ul class="dummy"><li>
1147
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line504">line 504</a>
1147
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line515">line 515</a>
1148
1148
  </li></ul></dd>
1149
1149
 
1150
1150
 
@@ -1240,7 +1240,7 @@ const deviceId = await mixpanel.getDeviceId();
1240
1240
 
1241
1241
  <dt class="tag-source">Source:</dt>
1242
1242
  <dd class="tag-source"><ul class="dummy"><li>
1243
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line491">line 491</a>
1243
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line502">line 502</a>
1244
1244
  </li></ul></dd>
1245
1245
 
1246
1246
 
@@ -1358,7 +1358,7 @@ const distinctId = await mixpanel.getDistinctId();
1358
1358
 
1359
1359
  <dt class="tag-source">Source:</dt>
1360
1360
  <dd class="tag-source"><ul class="dummy"><li>
1361
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line473">line 473</a>
1361
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line484">line 484</a>
1362
1362
  </li></ul></dd>
1363
1363
 
1364
1364
 
@@ -1541,7 +1541,7 @@ Group Analytics properties.
1541
1541
 
1542
1542
  <dt class="tag-source">Source:</dt>
1543
1543
  <dd class="tag-source"><ul class="dummy"><li>
1544
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line301">line 301</a>
1544
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line312">line 312</a>
1545
1545
  </li></ul></dd>
1546
1546
 
1547
1547
 
@@ -1641,7 +1641,7 @@ People Analytics properties.
1641
1641
 
1642
1642
  <dt class="tag-source">Source:</dt>
1643
1643
  <dd class="tag-source"><ul class="dummy"><li>
1644
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line251">line 251</a>
1644
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line262">line 262</a>
1645
1645
  </li></ul></dd>
1646
1646
 
1647
1647
 
@@ -1755,7 +1755,7 @@ and persist beyond the lifetime of your application.
1755
1755
 
1756
1756
  <dt class="tag-source">Source:</dt>
1757
1757
  <dd class="tag-source"><ul class="dummy"><li>
1758
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line407">line 407</a>
1758
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line418">line 418</a>
1759
1759
  </li></ul></dd>
1760
1760
 
1761
1761
 
@@ -1923,7 +1923,7 @@ and persist beyond the lifetime of your application.
1923
1923
 
1924
1924
 
1925
1925
 
1926
- <h4 class="name" id="identify"><span class="type-signature"></span>identify<span class="signature">(distinctId)</span><span class="type-signature"></span></h4>
1926
+ <h4 class="name" id="identify"><span class="type-signature"></span>identify<span class="signature">(distinctId)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
1927
1927
 
1928
1928
 
1929
1929
 
@@ -2036,7 +2036,7 @@ your application.
2036
2036
 
2037
2037
  <dt class="tag-source">Source:</dt>
2038
2038
  <dd class="tag-source"><ul class="dummy"><li>
2039
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line192">line 192</a>
2039
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line194">line 194</a>
2040
2040
  </li></ul></dd>
2041
2041
 
2042
2042
 
@@ -2061,6 +2061,29 @@ your application.
2061
2061
 
2062
2062
 
2063
2063
 
2064
+ <h5>Returns:</h5>
2065
+
2066
+
2067
+ <div class="param-desc">
2068
+ A promise that resolves when the identify is successful.
2069
+ It does not return any value.
2070
+ </div>
2071
+
2072
+
2073
+
2074
+ <dl>
2075
+ <dt>
2076
+ Type
2077
+ </dt>
2078
+ <dd>
2079
+
2080
+ <span class="param-type">Promise</span>
2081
+
2082
+
2083
+ </dd>
2084
+ </dl>
2085
+
2086
+
2064
2087
 
2065
2088
 
2066
2089
 
@@ -2564,7 +2587,7 @@ to remove a superProperty, call unregisterSuperProperty() or clearSuperPropertie
2564
2587
 
2565
2588
  <dt class="tag-source">Source:</dt>
2566
2589
  <dd class="tag-source"><ul class="dummy"><li>
2567
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line361">line 361</a>
2590
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line372">line 372</a>
2568
2591
  </li></ul></dd>
2569
2592
 
2570
2593
 
@@ -2704,7 +2727,7 @@ same names has already been registered.
2704
2727
 
2705
2728
  <dt class="tag-source">Source:</dt>
2706
2729
  <dd class="tag-source"><ul class="dummy"><li>
2707
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line376">line 376</a>
2730
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line387">line 387</a>
2708
2731
  </li></ul></dd>
2709
2732
 
2710
2733
 
@@ -2864,7 +2887,7 @@ same names has already been registered.
2864
2887
 
2865
2888
  <dt class="tag-source">Source:</dt>
2866
2889
  <dd class="tag-source"><ul class="dummy"><li>
2867
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line324">line 324</a>
2890
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line335">line 335</a>
2868
2891
  </li></ul></dd>
2869
2892
 
2870
2893
 
@@ -2953,7 +2976,7 @@ same names has already been registered.
2953
2976
 
2954
2977
  <dt class="tag-source">Source:</dt>
2955
2978
  <dd class="tag-source"><ul class="dummy"><li>
2956
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line455">line 455</a>
2979
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line466">line 466</a>
2957
2980
  </li></ul></dd>
2958
2981
 
2959
2982
 
@@ -3251,7 +3274,7 @@ when the app enters the background on iOS. This is set to true by default.
3251
3274
 
3252
3275
  <dt class="tag-source">Source:</dt>
3253
3276
  <dd class="tag-source"><ul class="dummy"><li>
3254
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line285">line 285</a>
3277
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line296">line 296</a>
3255
3278
  </li></ul></dd>
3256
3279
 
3257
3280
 
@@ -3808,7 +3831,7 @@ property, representing the number of seconds between your calls.
3808
3831
 
3809
3832
  <dt class="tag-source">Source:</dt>
3810
3833
  <dd class="tag-source"><ul class="dummy"><li>
3811
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line430">line 430</a>
3834
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line441">line 441</a>
3812
3835
  </li></ul></dd>
3813
3836
 
3814
3837
 
@@ -3974,7 +3997,7 @@ that event.
3974
3997
 
3975
3998
  <dt class="tag-source">Source:</dt>
3976
3999
  <dd class="tag-source"><ul class="dummy"><li>
3977
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line234">line 234</a>
4000
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line245">line 245</a>
3978
4001
  </li></ul></dd>
3979
4002
 
3980
4003
 
@@ -4163,7 +4186,7 @@ that event. Group key/value pairs are upserted into the property map before trac
4163
4186
 
4164
4187
  <dt class="tag-source">Source:</dt>
4165
4188
  <dd class="tag-source"><ul class="dummy"><li>
4166
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line269">line 269</a>
4189
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line280">line 280</a>
4167
4190
  </li></ul></dd>
4168
4191
 
4169
4192
 
@@ -4304,7 +4327,7 @@ To clear all superProperties, use clearSuperProperties()
4304
4327
 
4305
4328
  <dt class="tag-source">Source:</dt>
4306
4329
  <dd class="tag-source"><ul class="dummy"><li>
4307
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line392">line 392</a>
4330
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line403">line 403</a>
4308
4331
  </li></ul></dd>
4309
4332
 
4310
4333
 
@@ -4356,7 +4379,7 @@ To clear all superProperties, use clearSuperProperties()
4356
4379
  <br class="clear">
4357
4380
 
4358
4381
  <footer>
4359
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Mar 22 2023 21:33:52 GMT-0700 (Pacific Daylight Time)
4382
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Fri Jun 16 2023 16:47:53 GMT-0700 (Pacific Daylight Time)
4360
4383
  </footer>
4361
4384
 
4362
4385
  <script> prettyPrint(); </script>
@@ -95,7 +95,7 @@
95
95
 
96
96
  <dt class="tag-source">Source:</dt>
97
97
  <dd class="tag-source"><ul class="dummy"><li>
98
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line721">line 721</a>
98
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line732">line 732</a>
99
99
  </li></ul></dd>
100
100
 
101
101
 
@@ -284,7 +284,7 @@ If the property exists and is not list-valued, the remove will be ignored.
284
284
 
285
285
  <dt class="tag-source">Source:</dt>
286
286
  <dd class="tag-source"><ul class="dummy"><li>
287
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line792">line 792</a>
287
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line803">line 803</a>
288
288
  </li></ul></dd>
289
289
 
290
290
 
@@ -446,7 +446,7 @@ possibly overwriting an existing property with the same name.
446
446
 
447
447
  <dt class="tag-source">Source:</dt>
448
448
  <dd class="tag-source"><ul class="dummy"><li>
449
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line740">line 740</a>
449
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line751">line 751</a>
450
450
  </li></ul></dd>
451
451
 
452
452
 
@@ -606,7 +606,7 @@ possibly overwriting an existing property with the same name.
606
606
 
607
607
  <dt class="tag-source">Source:</dt>
608
608
  <dd class="tag-source"><ul class="dummy"><li>
609
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line759">line 759</a>
609
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line770">line 770</a>
610
610
  </li></ul></dd>
611
611
 
612
612
 
@@ -768,7 +768,7 @@ If the property exists and is not list-valued, the union will be ignored.
768
768
 
769
769
  <dt class="tag-source">Source:</dt>
770
770
  <dd class="tag-source"><ul class="dummy"><li>
771
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line808">line 808</a>
771
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line819">line 819</a>
772
772
  </li></ul></dd>
773
773
 
774
774
 
@@ -905,7 +905,7 @@ If the property exists and is not list-valued, the union will be ignored.
905
905
 
906
906
  <dt class="tag-source">Source:</dt>
907
907
  <dd class="tag-source"><ul class="dummy"><li>
908
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line777">line 777</a>
908
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line788">line 788</a>
909
909
  </li></ul></dd>
910
910
 
911
911
 
@@ -957,7 +957,7 @@ If the property exists and is not list-valued, the union will be ignored.
957
957
  <br class="clear">
958
958
 
959
959
  <footer>
960
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Mar 22 2023 21:33:52 GMT-0700 (Pacific Daylight Time)
960
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Fri Jun 16 2023 16:47:53 GMT-0700 (Pacific Daylight Time)
961
961
  </footer>
962
962
 
963
963
  <script> prettyPrint(); </script>
package/docs/People.html CHANGED
@@ -100,7 +100,7 @@ call to identify using a different id.</div>
100
100
 
101
101
  <dt class="tag-source">Source:</dt>
102
102
  <dd class="tag-source"><ul class="dummy"><li>
103
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line520">line 520</a>
103
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line531">line 531</a>
104
104
  </li></ul></dd>
105
105
 
106
106
 
@@ -289,7 +289,7 @@ currently have a list value, the append will be ignored.
289
289
 
290
290
  <dt class="tag-source">Source:</dt>
291
291
  <dd class="tag-source"><ul class="dummy"><li>
292
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line611">line 611</a>
292
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line622">line 622</a>
293
293
  </li></ul></dd>
294
294
 
295
295
 
@@ -377,7 +377,7 @@ currently have a list value, the append will be ignored.
377
377
 
378
378
  <dt class="tag-source">Source:</dt>
379
379
  <dd class="tag-source"><ul class="dummy"><li>
380
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line701">line 701</a>
380
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line712">line 712</a>
381
381
  </li></ul></dd>
382
382
 
383
383
 
@@ -468,7 +468,7 @@ to People Analytics using the same distinct id will create and store new values.
468
468
 
469
469
  <dt class="tag-source">Source:</dt>
470
470
  <dd class="tag-source"><ul class="dummy"><li>
471
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line711">line 711</a>
471
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line722">line 722</a>
472
472
  </li></ul></dd>
473
473
 
474
474
 
@@ -630,7 +630,7 @@ provide a negative number for the value.
630
630
 
631
631
  <dt class="tag-source">Source:</dt>
632
632
  <dd class="tag-source"><ul class="dummy"><li>
633
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line579">line 579</a>
633
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line590">line 590</a>
634
634
  </li></ul></dd>
635
635
 
636
636
 
@@ -792,7 +792,7 @@ If the property exists and is not list-valued, the remove will be ignored.
792
792
 
793
793
  <dt class="tag-source">Source:</dt>
794
794
  <dd class="tag-source"><ul class="dummy"><li>
795
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line655">line 655</a>
795
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line666">line 666</a>
796
796
  </li></ul></dd>
797
797
 
798
798
 
@@ -954,7 +954,7 @@ possibly overwriting an existing property with the same name.
954
954
 
955
955
  <dt class="tag-source">Source:</dt>
956
956
  <dd class="tag-source"><ul class="dummy"><li>
957
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line537">line 537</a>
957
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line548">line 548</a>
958
958
  </li></ul></dd>
959
959
 
960
960
 
@@ -1114,7 +1114,7 @@ possibly overwriting an existing property with the same name.
1114
1114
 
1115
1115
  <dt class="tag-source">Source:</dt>
1116
1116
  <dd class="tag-source"><ul class="dummy"><li>
1117
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line556">line 556</a>
1117
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line567">line 567</a>
1118
1118
  </li></ul></dd>
1119
1119
 
1120
1120
 
@@ -1274,7 +1274,7 @@ possibly overwriting an existing property with the same name.
1274
1274
 
1275
1275
  <dt class="tag-source">Source:</dt>
1276
1276
  <dd class="tag-source"><ul class="dummy"><li>
1277
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line687">line 687</a>
1277
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line698">line 698</a>
1278
1278
  </li></ul></dd>
1279
1279
 
1280
1280
 
@@ -1436,7 +1436,7 @@ If the property exists and is not list-valued, the union will be ignored.
1436
1436
 
1437
1437
  <dt class="tag-source">Source:</dt>
1438
1438
  <dd class="tag-source"><ul class="dummy"><li>
1439
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line634">line 634</a>
1439
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line645">line 645</a>
1440
1440
  </li></ul></dd>
1441
1441
 
1442
1442
 
@@ -1573,7 +1573,7 @@ If the property exists and is not list-valued, the union will be ignored.
1573
1573
 
1574
1574
  <dt class="tag-source">Source:</dt>
1575
1575
  <dd class="tag-source"><ul class="dummy"><li>
1576
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line674">line 674</a>
1576
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line685">line 685</a>
1577
1577
  </li></ul></dd>
1578
1578
 
1579
1579
 
@@ -1625,7 +1625,7 @@ If the property exists and is not list-valued, the union will be ignored.
1625
1625
  <br class="clear">
1626
1626
 
1627
1627
  <footer>
1628
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Mar 22 2023 21:33:52 GMT-0700 (Pacific Daylight Time)
1628
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Fri Jun 16 2023 16:47:53 GMT-0700 (Pacific Daylight Time)
1629
1629
  </footer>
1630
1630
 
1631
1631
  <script> prettyPrint(); </script>
package/docs/index.html CHANGED
@@ -44,7 +44,7 @@
44
44
 
45
45
  <section>
46
46
  <article><div align="center" style="text-align: center">
47
- <img src="https://github.com/mixpanel/mixpanel-android/blob/assets/mixpanel.png?raw=true" alt="Mixpanel React Native Library" height="150"/>
47
+ <img src="https://user-images.githubusercontent.com/71290498/231855346-12c8fc52-5f24-485c-b9e6-24468599fb87.png" alt="Mixpanel React Native Library" height="150"/>
48
48
  </div>
49
49
  <h5></h5>
50
50
  <h2>Table of Contents</h2>
@@ -138,6 +138,7 @@ const SampleApp = () => {
138
138
  export default SampleApp;
139
139
 
140
140
  </code></pre>
141
+ <h3>For Expo support, please refer to this <a href="https://github.com/mixpanel/mixpanel-react-native/issues/82">issue</a></h3>
141
142
  <p>👋 👋 Tell us about the Mixpanel developer experience! <a href="https://www.mixpanel.com/devnps">https://www.mixpanel.com/devnps</a> 👍 👎</p>
142
143
  <h2>FAQ</h2>
143
144
  <p><strong>I want to stop tracking an event/event property in Mixpanel. Is that possible?</strong><br>
@@ -145,7 +146,7 @@ Yes, in Lexicon, you can intercept and drop incoming events or properties. Mixpa
145
146
  <p><strong>I have a test user I would like to opt out of tracking. How do I do that?</strong><br>
146
147
  Mixpanel’s client-side tracking library contains the <a href="https://mixpanel.github.io/mixpanel-react-native/Mixpanel.html#optOutTracking">optOutTracking()</a> method, which will set the user’s local opt-out state to “true” and will prevent data from being sent from a user’s device. More detailed instructions can be found in the section, <a href="https://developer.mixpanel.com/docs/react-native#opting-users-out-of-tracking">Opting users out of tracking</a>.</p>
147
148
  <p><strong>Why aren't my events showing up?</strong><br>
148
- To preserve battery life and customer bandwidth, the Mixpanel library doesn't send the events you record immediately. Instead, it sends batches to the Mixpanel servers every 60 seconds while your application is running, as well as when the application transitions to the background. You can call <a href="https://mixpanel.github.io/mixpanel-react-native/Mixpanel.html#flush">flush()</a> manually if you want to force a flush at a particular moment.</p>
149
+ First, make sure your test device has internet access. To preserve battery life and customer bandwidth, the Mixpanel library doesn't send the events you record immediately. Instead, it sends batches to the Mixpanel servers every 60 seconds while your application is running, as well as when the application transitions to the background. You can call <a href="https://mixpanel.github.io/mixpanel-react-native/Mixpanel.html#flush">flush()</a> manually if you want to force a flush at a particular moment.</p>
149
150
  <pre class="prettyprint source"><code>mixpanel.flush();
150
151
  </code></pre>
151
152
  <p>If your events are still not showing up after 60 seconds, check if you have opted out of tracking. You can also enable Mixpanel debugging and logging, it allows you to see the debug output from the Mixpanel library. To enable it, call <a href="https://mixpanel.github.io/mixpanel-react-native/Mixpanel.html#setLoggingEnabled">setLoggingEnabled</a> with true, then run your iOS project with Xcode or android project with Android Studio. The logs should be available in the console.</p>
@@ -178,7 +179,7 @@ Please refer to our <a href="https://mixpanel.com/legal/app-store-privacy-detai
178
179
  <br class="clear">
179
180
 
180
181
  <footer>
181
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Mar 22 2023 21:33:52 GMT-0700 (Pacific Daylight Time)
182
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Fri Jun 16 2023 16:47:53 GMT-0700 (Pacific Daylight Time)
182
183
  </footer>
183
184
 
184
185
  <script> prettyPrint(); </script>
@@ -113,7 +113,7 @@ export class Mixpanel {
113
113
  */
114
114
  static async init(token, trackAutomaticEvents, optOutTrackingDefault = DEFAULT_OPT_OUT) {
115
115
  let metadata = Helper.getMetaData();
116
- await MixpanelReactNative.initialize(token, trackAutomaticEvents, optOutTrackingDefault, metadata);
116
+ await MixpanelReactNative.initialize(token, trackAutomaticEvents, optOutTrackingDefault, metadata, "https://api.mixpanel.com");
117
117
  return new Mixpanel(token, trackAutomaticEvents);
118
118
  }
119
119
 
@@ -215,13 +215,24 @@ export class Mixpanel {
215
215
  * Mixpanel using the same disinct_id will be considered associated with the
216
216
  * same visitor/customer for retention and funnel reporting, so be sure that the given
217
217
  * value is globally unique for each individual user you intend to track.
218
- *
218
+ * @returns {Promise} A promise that resolves when the identify is successful.
219
+ * It does not return any value.
220
+ *
219
221
  */
220
222
  identify(distinctId) {
221
- if (!StringHelper.isValid(distinctId)) {
222
- StringHelper.raiseError(PARAMS.DISTINCT_ID);
223
- }
224
- MixpanelReactNative.identify(this.token, distinctId);
223
+ return new Promise((resolvem, reject) => {
224
+ if (!StringHelper.isValid(distinctId)) {
225
+ StringHelper.raiseError(PARAMS.DISTINCT_ID);
226
+ reject(new Error('Invalid distinctId'));
227
+ }
228
+ MixpanelReactNative.identify(this.token, distinctId)
229
+ .then(() => {
230
+ resolve();
231
+ })
232
+ .catch(err => {
233
+ reject(err);
234
+ });
235
+ });
225
236
  }
226
237
 
227
238
  /**
@@ -231,8 +242,8 @@ export class Mixpanel {
231
242
  * `mixpane.alias("New ID", mixpane.distinctId)`
232
243
  * `mixpane.alias("Newer ID", mixpane.distinctId)`
233
244
  *
234
- * &lt;p>This call does not identify the user after. You must still call both identify() and
235
- * People.identify() if you wish the new alias to be used for Events and People.
245
+ * &lt;p>This call does not identify the user after. You must still call identify()
246
+ * if you wish the new alias to be used for Events and People.
236
247
  *
237
248
  * @param {string} alias A unique identifier that you want to use as an identifier for this user.
238
249
  * @param {string} distinctId the current distinct_id that alias will be mapped to.
@@ -929,7 +940,7 @@ class ObjectHelper {
929
940
  <br class="clear">
930
941
 
931
942
  <footer>
932
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Wed Mar 22 2023 21:33:52 GMT-0700 (Pacific Daylight Time)
943
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Fri Jun 16 2023 16:47:53 GMT-0700 (Pacific Daylight Time)
933
944
  </footer>
934
945
 
935
946
  <script> prettyPrint(); </script>
package/index.d.ts CHANGED
@@ -13,7 +13,7 @@ export class Mixpanel {
13
13
  hasOptedOutTracking(): Promise<boolean>;
14
14
  optInTracking(): void;
15
15
  optOutTracking(): void;
16
- identify(distinctId: string): void;
16
+ identify(distinctId: string): Promise<void>;
17
17
  alias(alias: string, distinctId: string): void
18
18
  track(eventName: string, properties?: MixpanelProperties): void
19
19
  getPeople(): People;
package/index.js CHANGED
@@ -85,7 +85,7 @@ export class Mixpanel {
85
85
  */
86
86
  static async init(token, trackAutomaticEvents, optOutTrackingDefault = DEFAULT_OPT_OUT) {
87
87
  let metadata = Helper.getMetaData();
88
- await MixpanelReactNative.initialize(token, trackAutomaticEvents, optOutTrackingDefault, metadata);
88
+ await MixpanelReactNative.initialize(token, trackAutomaticEvents, optOutTrackingDefault, metadata, "https://api.mixpanel.com");
89
89
  return new Mixpanel(token, trackAutomaticEvents);
90
90
  }
91
91
 
@@ -187,13 +187,24 @@ export class Mixpanel {
187
187
  * Mixpanel using the same disinct_id will be considered associated with the
188
188
  * same visitor/customer for retention and funnel reporting, so be sure that the given
189
189
  * value is globally unique for each individual user you intend to track.
190
- *
190
+ * @returns {Promise} A promise that resolves when the identify is successful.
191
+ * It does not return any value.
192
+ *
191
193
  */
192
194
  identify(distinctId) {
193
- if (!StringHelper.isValid(distinctId)) {
194
- StringHelper.raiseError(PARAMS.DISTINCT_ID);
195
- }
196
- MixpanelReactNative.identify(this.token, distinctId);
195
+ return new Promise((resolvem, reject) => {
196
+ if (!StringHelper.isValid(distinctId)) {
197
+ StringHelper.raiseError(PARAMS.DISTINCT_ID);
198
+ reject(new Error('Invalid distinctId'));
199
+ }
200
+ MixpanelReactNative.identify(this.token, distinctId)
201
+ .then(() => {
202
+ resolve();
203
+ })
204
+ .catch(err => {
205
+ reject(err);
206
+ });
207
+ });
197
208
  }
198
209
 
199
210
  /**
@@ -203,8 +214,8 @@ export class Mixpanel {
203
214
  * `mixpane.alias("New ID", mixpane.distinctId)`
204
215
  * `mixpane.alias("Newer ID", mixpane.distinctId)`
205
216
  *
206
- * <p>This call does not identify the user after. You must still call both identify() and
207
- * People.identify() if you wish the new alias to be used for Events and People.
217
+ * <p>This call does not identify the user after. You must still call identify()
218
+ * if you wish the new alias to be used for Events and People.
208
219
  *
209
220
  * @param {string} alias A unique identifier that you want to use as an identifier for this user.
210
221
  * @param {string} distinctId the current distinct_id that alias will be mapped to.
@@ -21,7 +21,7 @@ open class MixpanelReactNative: NSObject {
21
21
  rejecter reject: RCTPromiseRejectBlock) -> Void {
22
22
  let autoProps = properties // copy
23
23
  AutomaticProperties.setAutomaticProperties(autoProps)
24
- let propsProcessed = MixpanelTypeHandler.processProperties(properties: properties)
24
+ let propsProcessed = MixpanelTypeHandler.processProperties(properties: autoProps)
25
25
  Mixpanel.initialize(token: token, trackAutomaticEvents: trackAutomaticEvents, flushInterval: Constants.DEFAULT_FLUSH_INTERVAL,
26
26
  instanceName: token, optOutTrackingByDefault: optOutTrackingByDefault,
27
27
  superProperties: propsProcessed,
@@ -131,11 +131,12 @@ open class MixpanelReactNative: NSObject {
131
131
 
132
132
  @objc
133
133
  func identify(_ token: String, distinctId: String,
134
- resolver resolve: RCTPromiseResolveBlock,
135
- rejecter reject: RCTPromiseRejectBlock) -> Void {
134
+ resolver resolve: @escaping RCTPromiseResolveBlock,
135
+ rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
136
136
  let instance = MixpanelReactNative.getMixpanelInstance(token)
137
- instance?.identify(distinctId: distinctId)
138
- resolve(nil)
137
+ instance?.identify(distinctId: distinctId) {
138
+ resolve(nil)
139
+ }
139
140
  }
140
141
 
141
142
  @objc
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mixpanel-react-native",
3
- "version": "2.2.5",
3
+ "version": "2.3.0",
4
4
  "description": "Official React Native Tracking Library for Mixpanel Analytics",
5
5
  "main": "index.js",
6
6
  "scripts": {