mixpanel-react-native 1.3.9 → 1.4.1

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.
@@ -134,6 +134,21 @@ export class Mixpanel {
134
134
  MixpanelReactNative.setLoggingEnabled(this.token, loggingEnabled);
135
135
  }
136
136
 
137
+ /**
138
+ * This allows enabling or disabling whether or not Mixpanel flushes events
139
+ * when the app enters the background on iOS. This is set to true by default.
140
+ *
141
+ * @param {boolean} flushOnBackground whether to enable logging
142
+ *
143
+ */
144
+ setFlushOnBackground(flushOnBackground) {
145
+ if (Platform.OS === 'ios') {
146
+ MixpanelReactNative.setFlushOnBackground(this.token, flushOnBackground);
147
+ } else {
148
+ console.warn('Mixpanel setFlushOnBackground was called and ignored because this method only works on iOS.')
149
+ }
150
+ }
151
+
137
152
  /**
138
153
  * This controls whether to automatically send the client IP Address as part of event tracking.
139
154
  * With an IP address, geo-location is possible down to neighborhoods within a city,
@@ -480,6 +495,24 @@ export class Mixpanel {
480
495
  return MixpanelReactNative.getDistinctId(this.token);
481
496
  }
482
497
 
498
+ /**
499
+ * Returns the current device id of the device.
500
+ * This id automatically generated by the library and regenerated when logout or reset is called.
501
+ *
502
+ * example of usage:
503
+ * <pre>
504
+ * <code>
505
+ * const deviceId = await mixpanel.getDeviceId();
506
+ * </code>
507
+ * </pre>
508
+ *
509
+ * @return {Promise<string>} A Promise to the device id
510
+ *
511
+ */
512
+ getDeviceId() {
513
+ return MixpanelReactNative.getDeviceId(this.token);
514
+ }
515
+
483
516
  /**
484
517
  * Push all queued Mixpanel events and People Analytics changes to Mixpanel servers.
485
518
  *
@@ -889,7 +922,7 @@ class ObjectHelper {
889
922
  <br class="clear">
890
923
 
891
924
  <footer>
892
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Fri Feb 25 2022 13:58:49 GMT-0800 (Pacific Standard Time)
925
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Fri May 06 2022 10:59:40 GMT-0700 (Pacific Daylight Time)
893
926
  </footer>
894
927
 
895
928
  <script> prettyPrint(); </script>
package/index.d.ts CHANGED
@@ -7,6 +7,8 @@ export class Mixpanel {
7
7
  init(optOutTrackingDefault?: boolean, superProperties?: MixpanelProperties): Promise<void>;
8
8
  setServerURL(serverURL: string): void;
9
9
  setLoggingEnabled(loggingEnabled: boolean): void;
10
+ setFlushOnBackground(flushOnBackground: boolean): void;
11
+
10
12
  setUseIpAddressForGeolocation(useIpAddressForGeolocation: boolean): void;
11
13
  hasOptedOutTracking(): Promise<boolean>;
12
14
  optInTracking(): void;
@@ -30,6 +32,7 @@ export class Mixpanel {
30
32
  eventElapsedTime(eventName: string): Promise<number>;
31
33
  reset(): void;
32
34
  getDistinctId(): Promise<string>;
35
+ getDeviceId(): Promise<string>;
33
36
  flush(): void;
34
37
  }
35
38
 
package/index.js CHANGED
@@ -106,6 +106,21 @@ export class Mixpanel {
106
106
  MixpanelReactNative.setLoggingEnabled(this.token, loggingEnabled);
107
107
  }
108
108
 
109
+ /**
110
+ * This allows enabling or disabling whether or not Mixpanel flushes events
111
+ * when the app enters the background on iOS. This is set to true by default.
112
+ *
113
+ * @param {boolean} flushOnBackground whether to enable logging
114
+ *
115
+ */
116
+ setFlushOnBackground(flushOnBackground) {
117
+ if (Platform.OS === 'ios') {
118
+ MixpanelReactNative.setFlushOnBackground(this.token, flushOnBackground);
119
+ } else {
120
+ console.warn('Mixpanel setFlushOnBackground was called and ignored because this method only works on iOS.')
121
+ }
122
+ }
123
+
109
124
  /**
110
125
  * This controls whether to automatically send the client IP Address as part of event tracking.
111
126
  * With an IP address, geo-location is possible down to neighborhoods within a city,
@@ -452,6 +467,24 @@ export class Mixpanel {
452
467
  return MixpanelReactNative.getDistinctId(this.token);
453
468
  }
454
469
 
470
+ /**
471
+ * Returns the current device id of the device.
472
+ * This id automatically generated by the library and regenerated when logout or reset is called.
473
+ *
474
+ * example of usage:
475
+ * <pre>
476
+ * <code>
477
+ * const deviceId = await mixpanel.getDeviceId();
478
+ * </code>
479
+ * </pre>
480
+ *
481
+ * @return {Promise<string>} A Promise to the device id
482
+ *
483
+ */
484
+ getDeviceId() {
485
+ return MixpanelReactNative.getDeviceId(this.token);
486
+ }
487
+
455
488
  /**
456
489
  * Push all queued Mixpanel events and People Analytics changes to Mixpanel servers.
457
490
  *
@@ -12,6 +12,8 @@ RCT_EXTERN_METHOD(setServerURL:(NSString *)token serverURL:(NSString *)serverURL
12
12
 
13
13
  RCT_EXTERN_METHOD(setLoggingEnabled:(NSString *)token loggingEnabled:(BOOL)loggingEnabled resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
14
14
 
15
+ RCT_EXTERN_METHOD(setFlushOnBackground:(NSString *)token flushOnBackground:(BOOL)flushOnBackground resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
16
+
15
17
  RCT_EXTERN_METHOD(setUseIpAddressForGeolocation:(NSString *)token useIpAddressForGeolocation:(BOOL)useIpAddressForGeolocation resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
16
18
 
17
19
  // MARK: - Opting Users Out of Tracking
@@ -44,6 +46,8 @@ RCT_EXTERN_METHOD(reset:(NSString *)token resolver:(RCTPromiseResolveBlock)resol
44
46
 
45
47
  RCT_EXTERN_METHOD(getDistinctId:(NSString *)token resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
46
48
 
49
+ RCT_EXTERN_METHOD(getDeviceId:(NSString *)token resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
50
+
47
51
  // MARK: - Super Properties
48
52
 
49
53
  RCT_EXTERN_METHOD(registerSuperProperties:(NSString *)token properties:(NSDictionary *)properties resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject)
@@ -44,6 +44,16 @@ open class MixpanelReactNative: NSObject {
44
44
  resolve(nil)
45
45
  }
46
46
 
47
+ @objc
48
+ func setFlushOnBackground(_ token: String,
49
+ flushOnBackground: Bool,
50
+ resolver resolve: RCTPromiseResolveBlock,
51
+ rejecter reject: RCTPromiseRejectBlock) -> Void {
52
+ let instance = MixpanelReactNative.getMixpanelInstance(token)
53
+ instance?.flushOnBackground = flushOnBackground
54
+ resolve(nil)
55
+ }
56
+
47
57
  @objc
48
58
  func setUseIpAddressForGeolocation(_ token: String,
49
59
  useIpAddressForGeolocation: Bool,
@@ -155,6 +165,13 @@ open class MixpanelReactNative: NSObject {
155
165
  let instance = MixpanelReactNative.getMixpanelInstance(token)
156
166
  resolve(instance?.distinctId)
157
167
  }
168
+
169
+ @objc
170
+ func getDeviceId(_ token: String, resolver resolve: RCTPromiseResolveBlock,
171
+ rejecter reject: RCTPromiseRejectBlock) -> Void {
172
+ let instance = MixpanelReactNative.getMixpanelInstance(token)
173
+ resolve(instance?.anonymousId)
174
+ }
158
175
 
159
176
  // MARK: - Super Properties
160
177
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mixpanel-react-native",
3
- "version": "1.3.9",
3
+ "version": "1.4.1",
4
4
  "description": "Official React Native Tracking Library for Mixpanel Analytics",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/release.py CHANGED
@@ -11,14 +11,12 @@ args = parser.parse_args()
11
11
  def bump_version():
12
12
  replace_version('package.json', "\"version\": \"" + args.old + "\"", "\"version\": \"" + args.new + "\"")
13
13
  replace_version('__tests__/index.test.js', "\"$lib_version\": \"" + args.old + "\"", "\"$lib_version\": \"" + args.new + "\"")
14
- #subprocess.call('cd Samples/MixpanelDemo;yarn upgrade mixpanel-react-native --latest', shell=True)
15
- #subprocess.call('cd Samples/SimpleMixpanel;yarn upgrade mixpanel-react-native --latest', shell=True)
16
- #subprocess.call('cd Samples/ContextAPIMixpanel;yarn upgrade mixpanel-react-native --latest', shell=True)
14
+ subprocess.call('cd Samples/MixpanelDemo;rm -fr node_modules;rm -fr android/app/build', shell=True)
15
+ subprocess.call('cd Samples/SimpleMixpanel;rm -fr node_modules;rm -fr android/app/build', shell=True)
16
+ subprocess.call('cd Samples/ContextAPIMixpanel;rm -fr node_modules;rm -fr android/app/build', shell=True)
17
17
  subprocess.call('git add package.json', shell=True)
18
18
  subprocess.call('git add __tests__/index.test.js', shell=True)
19
- #subprocess.call('git add Samples/MixpanelDemo/yarn.lock', shell=True)
20
- #subprocess.call('git add Samples/SimpleMixpanel/yarn.lock', shell=True)
21
- #subprocess.call('git add Samples/ContextAPIMixpanel/yarn.lock', shell=True)
19
+
22
20
  subprocess.call('git commit -m "Version {}"'.format(args.new), shell=True)
23
21
  subprocess.call('git push', shell=True)
24
22