mixpanel-react-native 1.3.5 → 1.3.8

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.
@@ -82,11 +82,12 @@ export class Mixpanel {
82
82
  * Initializes Mixpanel
83
83
  *
84
84
  * @param {boolean} Optional Whether or not Mixpanel can start tracking by default. See optOutTracking()
85
+ * @param {object} Optional A Map containing the key value pairs of the super properties to register
85
86
  *
86
87
  */
87
- async init(optOutTrackingDefault = DEFAULT_OPT_OUT) {
88
+ async init(optOutTrackingDefault = DEFAULT_OPT_OUT, superProperties = {}) {
88
89
  let metadata = Helper.getMetaData();
89
- await MixpanelReactNative.initialize(this.token, optOutTrackingDefault, metadata);
90
+ await MixpanelReactNative.initialize(this.token, optOutTrackingDefault, {...metadata, ...superProperties});
90
91
  }
91
92
 
92
93
  /**
@@ -96,12 +97,12 @@ export class Mixpanel {
96
97
  * const mixpanel = new Mixpanel('your project token');
97
98
  * mixpanel.init();
98
99
  * </code></pre>
99
- *
100
+ *
100
101
  * Initializes Mixpanel and return an instance of Mixpanel the given project token.
101
102
  *
102
103
  * @param {string} token your project token.
103
104
  * @param {boolean} Optional Whether or not Mixpanel can start tracking by default. See optOutTracking()
104
- *
105
+ *
105
106
  */
106
107
  static async init(token, optOutTrackingDefault = DEFAULT_OPT_OUT) {
107
108
  let metadata = Helper.getMetaData();
@@ -115,7 +116,7 @@ export class Mixpanel {
115
116
  * To route data to Mixpanel's EU servers, set to https://api-eu.mixpanel.com
116
117
  *
117
118
  * @param {string} serverURL the base URL used for Mixpanel API requests
118
- *
119
+ *
119
120
  */
120
121
  setServerURL(serverURL) {
121
122
  MixpanelReactNative.setServerURL(this.token, serverURL);
@@ -124,10 +125,10 @@ export class Mixpanel {
124
125
  /**
125
126
  * This allows enabling or disabling of all Mixpanel logs at run time.
126
127
  * All logging is disabled by default. Usually, this is only required if
127
- * you are running into issues with the SDK that you want to debug
128
- *
128
+ * you are running into issues with the SDK that you want to debug
129
+ *
129
130
  * @param {boolean} loggingEnabled whether to enable logging
130
- *
131
+ *
131
132
  */
132
133
  setLoggingEnabled(loggingEnabled) {
133
134
  MixpanelReactNative.setLoggingEnabled(this.token, loggingEnabled);
@@ -135,12 +136,12 @@ export class Mixpanel {
135
136
 
136
137
  /**
137
138
  * This controls whether to automatically send the client IP Address as part of event tracking.
138
- * With an IP address, geo-location is possible down to neighborhoods within a city,
139
+ * With an IP address, geo-location is possible down to neighborhoods within a city,
139
140
  * although the Mixpanel Dashboard will just show you city level location specificity.
140
- *
141
- * @param {boolean} useIpAddressForGeolocation whether to automatically send the client IP Address.
141
+ *
142
+ * @param {boolean} useIpAddressForGeolocation whether to automatically send the client IP Address.
142
143
  * Defaults to true.
143
- *
144
+ *
144
145
  */
145
146
  setUseIpAddressForGeolocation(useIpAddressForGeolocation) {
146
147
  MixpanelReactNative.setUseIpAddressForGeolocation(this.token, useIpAddressForGeolocation);
@@ -154,7 +155,7 @@ export class Mixpanel {
154
155
  hasOptedOutTracking() {
155
156
  return MixpanelReactNative.hasOptedOutTracking(this.token);
156
157
  }
157
-
158
+
158
159
  /**
159
160
  * Use this method to opt-in an already opted-out user from tracking. People updates and track
160
161
  * calls will be sent to Mixpanel after using this method.
@@ -204,10 +205,10 @@ export class Mixpanel {
204
205
  /**
205
206
  * The alias method creates an alias which Mixpanel will use to remap one id to another.
206
207
  * Multiple aliases can point to the same identifier.
207
- *
208
+ *
208
209
  * `mixpane.alias("New ID", mixpane.distinctId)`
209
210
  * `mixpane.alias("Newer ID", mixpane.distinctId)`
210
- *
211
+ *
211
212
  * <p>This call does not identify the user after. You must still call both identify() and
212
213
  * People.identify() if you wish the new alias to be used for Events and People.
213
214
  *
@@ -270,7 +271,7 @@ export class Mixpanel {
270
271
  * Pass null if no extra properties exist.
271
272
  * @param {object} groups A Map containing the group key value pairs for this event.
272
273
  *
273
- */
274
+ */
274
275
  trackWithGroups(eventName, properties, groups) {
275
276
  if (!StringHelper.isValid(eventName)) {
276
277
  StringHelper.raiseError(PARAMS.EVENT_NAME);
@@ -462,13 +463,13 @@ export class Mixpanel {
462
463
  }
463
464
 
464
465
  /**
465
- * Returns the current distinct id of the user.
466
+ * Returns the current distinct id of the user.
466
467
  * This is either the id automatically generated by the library or the id that has been passed by a call to identify().
467
- *
468
- * example of usage:
468
+ *
469
+ * example of usage:
469
470
  * <pre>
470
471
  * <code>
471
- * const distinctId = await mixpanel.getDistinctId();
472
+ * const distinctId = await mixpanel.getDistinctId();
472
473
  * </code>
473
474
  * </pre>
474
475
  *
@@ -758,7 +759,7 @@ export class MixpanelGroup {
758
759
 
759
760
  /**
760
761
  * Permanently removes the property with the given name from the group's profile
761
- *
762
+ *
762
763
  * @param {string} prop name of a property to unset
763
764
  */
764
765
  unset(prop) {
@@ -772,7 +773,7 @@ export class MixpanelGroup {
772
773
  * Remove value from a list-valued property only if it is already present in the list.
773
774
  * If the property does not currently exist, the remove will be ignored.
774
775
  * If the property exists and is not list-valued, the remove will be ignored.
775
- *
776
+ *
776
777
  * @param {string} name the Group Analytics list-valued property that should have a value removed
777
778
  * @param {any} value the value that will be removed from the list
778
779
  */
@@ -888,7 +889,7 @@ class ObjectHelper {
888
889
  <br class="clear">
889
890
 
890
891
  <footer>
891
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Mon Jan 03 2022 19:43:40 GMT-0800 (Pacific Standard Time)
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)
892
893
  </footer>
893
894
 
894
895
  <script> prettyPrint(); </script>
package/index.d.ts CHANGED
@@ -4,7 +4,7 @@ type MixpanelProperties = { [key: string]: MixpanelType };
4
4
  export class Mixpanel {
5
5
  constructor(token: string);
6
6
  static init(token: string, optOutTrackingDefault?: boolean): Promise<Mixpanel>;
7
- init(optOutTrackingDefault?: boolean): Promise<void>;
7
+ init(optOutTrackingDefault?: boolean, superProperties?: MixpanelProperties): Promise<void>;
8
8
  setServerURL(serverURL: string): void;
9
9
  setLoggingEnabled(loggingEnabled: boolean): void;
10
10
  setUseIpAddressForGeolocation(useIpAddressForGeolocation: boolean): void;
@@ -36,8 +36,11 @@ export class Mixpanel {
36
36
  export class People {
37
37
  constructor(token: string);
38
38
  set(prop: string, to: MixpanelType): void;
39
+ set(properties: MixpanelProperties): void;
39
40
  setOnce(prop: string, to: MixpanelType): void;
41
+ setOnce(properties: MixpanelProperties): void;
40
42
  increment(prop: string, by: number): void;
43
+ increment(properties: MixpanelProperties): void;
41
44
  append(name: string, value: MixpanelType): void;
42
45
  union(name: string, value: Array<MixpanelType>): void;
43
46
  remove(name: string, value: MixpanelType): void;
package/index.js CHANGED
@@ -54,11 +54,12 @@ export class Mixpanel {
54
54
  * Initializes Mixpanel
55
55
  *
56
56
  * @param {boolean} Optional Whether or not Mixpanel can start tracking by default. See optOutTracking()
57
+ * @param {object} Optional A Map containing the key value pairs of the super properties to register
57
58
  *
58
59
  */
59
- async init(optOutTrackingDefault = DEFAULT_OPT_OUT) {
60
+ async init(optOutTrackingDefault = DEFAULT_OPT_OUT, superProperties = {}) {
60
61
  let metadata = Helper.getMetaData();
61
- await MixpanelReactNative.initialize(this.token, optOutTrackingDefault, metadata);
62
+ await MixpanelReactNative.initialize(this.token, optOutTrackingDefault, {...metadata, ...superProperties});
62
63
  }
63
64
 
64
65
  /**
@@ -68,12 +69,12 @@ export class Mixpanel {
68
69
  * const mixpanel = new Mixpanel('your project token');
69
70
  * mixpanel.init();
70
71
  * </code></pre>
71
- *
72
+ *
72
73
  * Initializes Mixpanel and return an instance of Mixpanel the given project token.
73
74
  *
74
75
  * @param {string} token your project token.
75
76
  * @param {boolean} Optional Whether or not Mixpanel can start tracking by default. See optOutTracking()
76
- *
77
+ *
77
78
  */
78
79
  static async init(token, optOutTrackingDefault = DEFAULT_OPT_OUT) {
79
80
  let metadata = Helper.getMetaData();
@@ -87,7 +88,7 @@ export class Mixpanel {
87
88
  * To route data to Mixpanel's EU servers, set to https://api-eu.mixpanel.com
88
89
  *
89
90
  * @param {string} serverURL the base URL used for Mixpanel API requests
90
- *
91
+ *
91
92
  */
92
93
  setServerURL(serverURL) {
93
94
  MixpanelReactNative.setServerURL(this.token, serverURL);
@@ -96,10 +97,10 @@ export class Mixpanel {
96
97
  /**
97
98
  * This allows enabling or disabling of all Mixpanel logs at run time.
98
99
  * All logging is disabled by default. Usually, this is only required if
99
- * you are running into issues with the SDK that you want to debug
100
- *
100
+ * you are running into issues with the SDK that you want to debug
101
+ *
101
102
  * @param {boolean} loggingEnabled whether to enable logging
102
- *
103
+ *
103
104
  */
104
105
  setLoggingEnabled(loggingEnabled) {
105
106
  MixpanelReactNative.setLoggingEnabled(this.token, loggingEnabled);
@@ -107,12 +108,12 @@ export class Mixpanel {
107
108
 
108
109
  /**
109
110
  * This controls whether to automatically send the client IP Address as part of event tracking.
110
- * With an IP address, geo-location is possible down to neighborhoods within a city,
111
+ * With an IP address, geo-location is possible down to neighborhoods within a city,
111
112
  * although the Mixpanel Dashboard will just show you city level location specificity.
112
- *
113
- * @param {boolean} useIpAddressForGeolocation whether to automatically send the client IP Address.
113
+ *
114
+ * @param {boolean} useIpAddressForGeolocation whether to automatically send the client IP Address.
114
115
  * Defaults to true.
115
- *
116
+ *
116
117
  */
117
118
  setUseIpAddressForGeolocation(useIpAddressForGeolocation) {
118
119
  MixpanelReactNative.setUseIpAddressForGeolocation(this.token, useIpAddressForGeolocation);
@@ -126,7 +127,7 @@ export class Mixpanel {
126
127
  hasOptedOutTracking() {
127
128
  return MixpanelReactNative.hasOptedOutTracking(this.token);
128
129
  }
129
-
130
+
130
131
  /**
131
132
  * Use this method to opt-in an already opted-out user from tracking. People updates and track
132
133
  * calls will be sent to Mixpanel after using this method.
@@ -176,10 +177,10 @@ export class Mixpanel {
176
177
  /**
177
178
  * The alias method creates an alias which Mixpanel will use to remap one id to another.
178
179
  * Multiple aliases can point to the same identifier.
179
- *
180
+ *
180
181
  * `mixpane.alias("New ID", mixpane.distinctId)`
181
182
  * `mixpane.alias("Newer ID", mixpane.distinctId)`
182
- *
183
+ *
183
184
  * <p>This call does not identify the user after. You must still call both identify() and
184
185
  * People.identify() if you wish the new alias to be used for Events and People.
185
186
  *
@@ -242,7 +243,7 @@ export class Mixpanel {
242
243
  * Pass null if no extra properties exist.
243
244
  * @param {object} groups A Map containing the group key value pairs for this event.
244
245
  *
245
- */
246
+ */
246
247
  trackWithGroups(eventName, properties, groups) {
247
248
  if (!StringHelper.isValid(eventName)) {
248
249
  StringHelper.raiseError(PARAMS.EVENT_NAME);
@@ -434,13 +435,13 @@ export class Mixpanel {
434
435
  }
435
436
 
436
437
  /**
437
- * Returns the current distinct id of the user.
438
+ * Returns the current distinct id of the user.
438
439
  * This is either the id automatically generated by the library or the id that has been passed by a call to identify().
439
- *
440
- * example of usage:
440
+ *
441
+ * example of usage:
441
442
  * <pre>
442
443
  * <code>
443
- * const distinctId = await mixpanel.getDistinctId();
444
+ * const distinctId = await mixpanel.getDistinctId();
444
445
  * </code>
445
446
  * </pre>
446
447
  *
@@ -730,7 +731,7 @@ export class MixpanelGroup {
730
731
 
731
732
  /**
732
733
  * Permanently removes the property with the given name from the group's profile
733
- *
734
+ *
734
735
  * @param {string} prop name of a property to unset
735
736
  */
736
737
  unset(prop) {
@@ -744,7 +745,7 @@ export class MixpanelGroup {
744
745
  * Remove value from a list-valued property only if it is already present in the list.
745
746
  * If the property does not currently exist, the remove will be ignored.
746
747
  * If the property exists and is not list-valued, the remove will be ignored.
747
- *
748
+ *
748
749
  * @param {string} name the Group Analytics list-valued property that should have a value removed
749
750
  * @param {any} value the value that will be removed from the list
750
751
  */
@@ -18,9 +18,9 @@ open class MixpanelReactNative: NSObject {
18
18
  resolver resolve: RCTPromiseResolveBlock,
19
19
  rejecter reject: RCTPromiseRejectBlock) -> Void {
20
20
  AutomaticProperties.setAutomaticProperties(properties)
21
- Mixpanel.initialize(token: token, flushInterval: Constants.DEFAULT_FLUSH_INTERVAL, instanceName: token, optOutTrackingByDefault: optOutTrackingByDefault)
22
- let instance = MixpanelReactNative.getMixpanelInstance(token)
23
- instance?.flushInterval = Constants.DEFAULT_FLUSH_INTERVAL
21
+ Mixpanel.initialize(token: token, flushInterval: Constants.DEFAULT_FLUSH_INTERVAL,
22
+ instanceName: token, optOutTrackingByDefault: optOutTrackingByDefault,
23
+ superProperties: MixpanelTypeHandler.processProperties(properties: properties, includeLibInfo: true))
24
24
  resolve(true)
25
25
  }
26
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mixpanel-react-native",
3
- "version": "1.3.5",
3
+ "version": "1.3.8",
4
4
  "description": "Official React Native Tracking Library for Mixpanel Analytics",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -31,31 +31,30 @@
31
31
  "mp_lib": "react-native"
32
32
  },
33
33
  "devDependencies": {
34
- "@babel/core": "^7.12.3",
35
- "@babel/runtime": "^7.12.1",
36
- "@react-native-community/eslint-config": "^2.0.0",
37
- "babel-jest": "^26.6.0",
38
- "eslint": "^7.11.0",
39
- "jest": "^26.6.0",
40
- "metro-react-native-babel-preset": "^0.63.0",
41
- "react-native": "^0.63.3",
42
- "react-native-clean-project": "^3.6.7",
43
- "react-test-renderer": "16.13.1"
34
+ "@babel/core": "^7.12.3",
35
+ "@babel/runtime": "^7.12.1",
36
+ "@react-native-community/eslint-config": "^2.0.0",
37
+ "babel-jest": "^26.6.0",
38
+ "eslint": "^7.11.0",
39
+ "jest": "^26.6.0",
40
+ "metro-react-native-babel-preset": "^0.63.0",
41
+ "react-test-renderer": "16.13.1",
42
+ "react-native": "^0.63.3"
44
43
  },
45
44
  "jest": {
46
- "modulePathIgnorePatterns": [
47
- "<rootDir>/MixpanelDemo/"
48
- ],
49
- "testMatch": [
50
- "<rootDir>/__tests__/index.test.js"
51
- ],
52
- "setupFiles": [
53
- "<rootDir>/__tests__/jest_setup.js"
54
- ],
55
- "verbose": true,
56
- "preset": "react-native",
57
- "transform": {
58
- "^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js"
59
- }
45
+ "modulePathIgnorePatterns": [
46
+ "<rootDir>/MixpanelDemo/"
47
+ ],
48
+ "testMatch": [
49
+ "<rootDir>/__tests__/index.test.js"
50
+ ],
51
+ "setupFiles": [
52
+ "<rootDir>/__tests__/jest_setup.js"
53
+ ],
54
+ "verbose": true,
55
+ "preset": "react-native",
56
+ "transform": {
57
+ "^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js"
58
+ }
60
59
  }
61
60
  }
package/release.py CHANGED
@@ -11,9 +11,9 @@ 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;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)
17
17
  subprocess.call('git add package.json', shell=True)
18
18
  subprocess.call('git add __tests__/index.test.js', shell=True)
19
19
  subprocess.call('git add Samples/MixpanelDemo/yarn.lock', shell=True)