mixpanel-react-native 2.3.1 → 2.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.
Files changed (65) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/MixpanelReactNative.podspec +1 -1
  3. package/Samples/ContextAPIMixpanel/Analytics.js +0 -6
  4. package/__tests__/index.test.js +186 -60
  5. package/__tests__/jest_setup.js +1 -0
  6. package/android/bin/.gradle/5.5/executionHistory/executionHistory.lock +0 -0
  7. package/android/bin/.gradle/5.5/fileChanges/last-build.bin +0 -0
  8. package/android/bin/.gradle/5.5/fileHashes/fileHashes.bin +0 -0
  9. package/android/bin/.gradle/5.5/fileHashes/fileHashes.lock +0 -0
  10. package/android/bin/.gradle/5.5/gc.properties +0 -0
  11. package/android/bin/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  12. package/android/bin/.gradle/buildOutputCleanup/cache.properties +2 -0
  13. package/android/bin/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
  14. package/android/bin/.gradle/vcs-1/gc.properties +0 -0
  15. package/android/bin/.idea/caches/build_file_checksums.ser +0 -0
  16. package/android/bin/.idea/compiler.xml +6 -0
  17. package/android/bin/.idea/gradle.xml +21 -0
  18. package/android/bin/.idea/jarRepositories.xml +30 -0
  19. package/android/bin/.idea/libraries/Gradle__com_android_support_appcompat_v7_23_0_1_aar.xml +16 -0
  20. package/android/bin/.idea/libraries/Gradle__com_android_support_recyclerview_v7_23_0_1_aar.xml +13 -0
  21. package/android/bin/.idea/libraries/Gradle__com_android_support_support_annotations_23_0_1.xml +11 -0
  22. package/android/bin/.idea/libraries/Gradle__com_android_support_support_v4_23_0_1_aar.xml +17 -0
  23. package/android/bin/.idea/libraries/Gradle__com_facebook_fresco_drawee_0_8_1_aar.xml +13 -0
  24. package/android/bin/.idea/libraries/Gradle__com_facebook_fresco_fbcore_0_8_1_aar.xml +13 -0
  25. package/android/bin/.idea/libraries/Gradle__com_facebook_fresco_fresco_0_8_1_aar.xml +13 -0
  26. package/android/bin/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_0_8_1_aar.xml +13 -0
  27. package/android/bin/.idea/libraries/Gradle__com_facebook_fresco_imagepipeline_okhttp_0_8_1_aar.xml +13 -0
  28. package/android/bin/.idea/libraries/Gradle__com_facebook_react_react_native_0_20_1_aar.xml +17 -0
  29. package/android/bin/.idea/libraries/Gradle__com_facebook_stetho_stetho_1_2_0.xml +11 -0
  30. package/android/bin/.idea/libraries/Gradle__com_facebook_stetho_stetho_okhttp_1_2_0.xml +11 -0
  31. package/android/bin/.idea/libraries/Gradle__com_fasterxml_jackson_core_jackson_core_2_2_3.xml +11 -0
  32. package/android/bin/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_3_0_0.xml +11 -0
  33. package/android/bin/.idea/libraries/Gradle__com_mixpanel_android_mixpanel_android_6_0_0_beta1_aar.xml +16 -0
  34. package/android/bin/.idea/libraries/Gradle__com_nineoldandroids_library_2_4_0.xml +11 -0
  35. package/android/bin/.idea/libraries/Gradle__com_parse_bolts_bolts_android_1_1_4.xml +11 -0
  36. package/android/bin/.idea/libraries/Gradle__com_squareup_okhttp_okhttp_2_5_0.xml +11 -0
  37. package/android/bin/.idea/libraries/Gradle__com_squareup_okhttp_okhttp_ws_2_5_0.xml +11 -0
  38. package/android/bin/.idea/libraries/Gradle__com_squareup_okio_okio_1_6_0.xml +11 -0
  39. package/android/bin/.idea/libraries/Gradle__commons_cli_commons_cli_1_2.xml +11 -0
  40. package/android/bin/.idea/libraries/Gradle__org_webkit_android_jsc_r174650_aar.xml +11 -0
  41. package/android/bin/.idea/misc.xml +9 -0
  42. package/android/bin/.idea/modules.xml +8 -0
  43. package/android/bin/.idea/vcs.xml +6 -0
  44. package/android/bin/.idea/workspace.xml +57 -0
  45. package/android/bin/.project +34 -0
  46. package/android/bin/.settings/org.eclipse.buildship.core.prefs +13 -0
  47. package/android/bin/build.gradle +45 -0
  48. package/android/bin/gradle/wrapper/gradle-wrapper.jar +0 -0
  49. package/android/bin/gradle/wrapper/gradle-wrapper.properties +6 -0
  50. package/android/bin/gradlew +172 -0
  51. package/android/bin/gradlew.bat +84 -0
  52. package/android/bin/local.properties +8 -0
  53. package/android/bin/src/main/AndroidManifest.xml +2 -0
  54. package/android/build.gradle +8 -1
  55. package/android/src/main/java/com/mixpanel/reactnative/MixpanelReactNativeModule.java +15 -1
  56. package/docs/Mixpanel.html +164 -25
  57. package/docs/MixpanelGroup.html +7 -7
  58. package/docs/People.html +12 -12
  59. package/docs/index.html +1 -1
  60. package/docs/index.js.html +14 -1
  61. package/index.d.ts +1 -1
  62. package/index.js +896 -820
  63. package/ios/MixpanelReactNative.m +2 -0
  64. package/ios/MixpanelReactNative.swift +10 -0
  65. package/package.json +56 -56
package/index.js CHANGED
@@ -1,39 +1,39 @@
1
1
  "use strict";
2
2
 
3
- import { Platform, NativeModules } from "react-native";
3
+ import {Platform, NativeModules} from "react-native";
4
4
  import packageJson from "./package.json";
5
- const { MixpanelReactNative } = NativeModules;
5
+ const {MixpanelReactNative} = NativeModules;
6
6
 
7
7
  if (!MixpanelReactNative) {
8
- throw new Error(`mixpanel-react-native: MixpanelReactNative is null.
8
+ throw new Error(`mixpanel-react-native: MixpanelReactNative is null.
9
9
  Please follow the guide on the Github repository: https://github.com/mixpanel/mixpanel-react-native.`);
10
10
  }
11
11
 
12
12
  const DevicePlatform = {
13
- Unknown: "Unknown",
14
- Android: "android",
15
- iOS: "ios"
16
- }
13
+ Unknown: "Unknown",
14
+ Android: "android",
15
+ iOS: "ios",
16
+ };
17
17
 
18
18
  const ERROR_MESSAGE = {
19
- INVALID_OBJECT: " is not a valid json object",
20
- INVALID_STRING: " is not a valid string",
21
- REQUIRED_DOUBLE: " is not a valid number"
22
- }
19
+ INVALID_OBJECT: " is not a valid json object",
20
+ INVALID_STRING: " is not a valid string",
21
+ REQUIRED_DOUBLE: " is not a valid number",
22
+ };
23
23
 
24
24
  const PARAMS = {
25
- TOKEN: "token",
26
- DISTINCT_ID: "distinctId",
27
- ALIAS: "alias",
28
- EVENT_NAME: "eventName",
29
- GROUP_KEY: "groupKey",
30
- PROPERTIES: "properties",
31
- PROPERTY_NAME: "propertyName",
32
- PROP: "prop",
33
- NAME: "name",
34
- CHARGE: "charge",
35
- PROPERTY_VALUE: "property value"
36
- }
25
+ TOKEN: "token",
26
+ DISTINCT_ID: "distinctId",
27
+ ALIAS: "alias",
28
+ EVENT_NAME: "eventName",
29
+ GROUP_KEY: "groupKey",
30
+ PROPERTIES: "properties",
31
+ PROPERTY_NAME: "propertyName",
32
+ PROP: "prop",
33
+ NAME: "name",
34
+ CHARGE: "charge",
35
+ PROPERTY_VALUE: "property value",
36
+ };
37
37
 
38
38
  const DEFAULT_OPT_OUT = false;
39
39
 
@@ -41,480 +41,528 @@ const DEFAULT_OPT_OUT = false;
41
41
  * The primary class for integrating Mixpanel with your app.
42
42
  */
43
43
  export class Mixpanel {
44
-
45
- constructor(token, trackAutomaticEvents) {
46
- if (!StringHelper.isValid(token)) {
47
- StringHelper.raiseError(PARAMS.TOKEN);
48
- }
49
- if (trackAutomaticEvents == null) {
50
- throw new Error(`trackAutomaticEvents is undefined`);
51
- }
52
- this.token = token;
53
- this.trackAutomaticEvents = trackAutomaticEvents;
54
- this.people = new People(this.token);
55
- }
56
-
57
- /**
58
- * Initializes Mixpanel
59
- *
60
- * @param {boolean} optOutTrackingDefault Optional Whether or not Mixpanel can start tracking by default. See optOutTracking()
61
- * @param {object} superProperties Optional A Map containing the key value pairs of the super properties to register
62
- * @param {string} serverURL Optional Set the base URL used for Mixpanel API requests. See setServerURL()
63
- *
64
- */
65
- async init(optOutTrackingDefault = DEFAULT_OPT_OUT, superProperties = {}, serverURL = "https://api.mixpanel.com") {
66
- let metadata = Helper.getMetaData();
67
- await MixpanelReactNative.initialize(this.token, this.trackAutomaticEvents, optOutTrackingDefault, {...metadata, ...superProperties}, serverURL);
68
- }
69
-
70
- /**
71
- * @deprecated since version 1.3.0. To initialize Mixpanel, please use the instance method `init` instead. See the example below:
72
- *
73
- * <pre><code>
74
- * const trackAutomaticEvents = true;
75
- * const mixpanel = new Mixpanel('your project token', trackAutomaticEvents);
76
- * mixpanel.init();
77
- * </code></pre>
78
- *
79
- * Initializes Mixpanel and return an instance of Mixpanel the given project token.
80
- *
81
- * @param {string} token your project token.
82
- * @param {boolean} trackAutomaticEvents Whether or not to automatically track common mobile events
83
- * @param {boolean} Optional Whether or not Mixpanel can start tracking by default. See optOutTracking()
84
- *
85
- */
86
- static async init(token, trackAutomaticEvents, optOutTrackingDefault = DEFAULT_OPT_OUT) {
87
- let metadata = Helper.getMetaData();
88
- await MixpanelReactNative.initialize(token, trackAutomaticEvents, optOutTrackingDefault, metadata, "https://api.mixpanel.com");
89
- return new Mixpanel(token, trackAutomaticEvents);
90
- }
91
-
92
- /**
93
- * Set the base URL used for Mixpanel API requests.
94
- * Useful if you need to proxy Mixpanel requests. Defaults to https://api.mixpanel.com.
95
- * To route data to Mixpanel's EU servers, set to https://api-eu.mixpanel.com
96
- *
97
- * @param {string} serverURL the base URL used for Mixpanel API requests
98
- *
99
- */
100
- setServerURL(serverURL) {
101
- MixpanelReactNative.setServerURL(this.token, serverURL);
102
- }
103
-
104
- /**
105
- * This allows enabling or disabling of all Mixpanel logs at run time.
106
- * All logging is disabled by default. Usually, this is only required if
107
- * you are running into issues with the SDK that you want to debug
108
- *
109
- * @param {boolean} loggingEnabled whether to enable logging
110
- *
111
- */
112
- setLoggingEnabled(loggingEnabled) {
113
- MixpanelReactNative.setLoggingEnabled(this.token, loggingEnabled);
114
- }
115
-
116
- /**
117
- * This allows enabling or disabling whether or not Mixpanel flushes events
118
- * when the app enters the background on iOS. This is set to true by default.
119
- *
120
- * @param {boolean} flushOnBackground whether to enable logging
121
- *
122
- */
123
- setFlushOnBackground(flushOnBackground) {
124
- if (Platform.OS === 'ios') {
125
- MixpanelReactNative.setFlushOnBackground(this.token, flushOnBackground);
126
- } else {
127
- console.warn('Mixpanel setFlushOnBackground was called and ignored because this method only works on iOS.')
128
- }
129
- }
130
-
131
- /**
132
- * This controls whether to automatically send the client IP Address as part of event tracking.
133
- * With an IP address, geo-location is possible down to neighborhoods within a city,
134
- * although the Mixpanel Dashboard will just show you city level location specificity.
135
- *
136
- * @param {boolean} useIpAddressForGeolocation whether to automatically send the client IP Address.
137
- * Defaults to true.
138
- *
139
- */
140
- setUseIpAddressForGeolocation(useIpAddressForGeolocation) {
141
- MixpanelReactNative.setUseIpAddressForGeolocation(this.token, useIpAddressForGeolocation);
142
- }
143
-
144
- /**
145
- * Will return true if the user has opted out from tracking.
146
- *
147
- * @return {Promise<boolean>} true if user has opted out from tracking. Defaults to false.
148
- */
149
- hasOptedOutTracking() {
150
- return MixpanelReactNative.hasOptedOutTracking(this.token);
151
- }
152
-
153
- /**
154
- * Use this method to opt-in an already opted-out user from tracking. People updates and track
155
- * calls will be sent to Mixpanel after using this method.
156
- * This method will internally track an opt-in event to your project.
157
- *
158
- */
159
- optInTracking() {
160
- MixpanelReactNative.optInTracking(this.token);
161
- }
162
-
163
- /**
164
- * Use this method to opt-out a user from tracking. Events and people updates that haven't been
165
- * flushed yet will be deleted. Use flush() before calling this method if you want
166
- * to send all the queues to Mixpanel before.
167
- *
168
- * This method will also remove any user-related information from the device.
169
- */
170
- optOutTracking() {
171
- MixpanelReactNative.optOutTracking(this.token);
172
- }
173
-
174
- /**
175
- * Associate all future calls to track() with the user identified by
176
- * the given distinct id.
177
- *
178
- * <p>Calls to track() made before corresponding calls to identify
179
- * will use an anonymous locally generated distinct id, which means it is best to call identify
180
- * early to ensure that your Mixpanel funnels and retention analytics can continue to track the
181
- * user throughout their lifetime. We recommend calling identify when the user authenticates.
182
- *
183
- * <p>Once identify is called, the local distinct id persists across restarts of
184
- * your application.
185
- *
186
- * @param {string} distinctId a string uniquely identifying this user. Events sent to
187
- * Mixpanel using the same disinct_id will be considered associated with the
188
- * same visitor/customer for retention and funnel reporting, so be sure that the given
189
- * value is globally unique for each individual user you intend to track.
190
- * @returns {Promise} A promise that resolves when the identify is successful.
191
- * It does not return any value.
192
- *
193
- */
194
- identify(distinctId) {
195
- return new Promise((resolve, 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
- });
44
+ constructor(token, trackAutomaticEvents) {
45
+ if (!StringHelper.isValid(token)) {
46
+ StringHelper.raiseError(PARAMS.TOKEN);
47
+ }
48
+ if (trackAutomaticEvents == null) {
49
+ throw new Error(`trackAutomaticEvents is undefined`);
50
+ }
51
+ this.token = token;
52
+ this.trackAutomaticEvents = trackAutomaticEvents;
53
+ this.people = new People(this.token);
54
+ }
55
+
56
+ /**
57
+ * Initializes Mixpanel
58
+ *
59
+ * @param {boolean} optOutTrackingDefault Optional Whether or not Mixpanel can start tracking by default. See optOutTracking()
60
+ * @param {object} superProperties Optional A Map containing the key value pairs of the super properties to register
61
+ * @param {string} serverURL Optional Set the base URL used for Mixpanel API requests. See setServerURL()
62
+ *
63
+ */
64
+ async init(
65
+ optOutTrackingDefault = DEFAULT_OPT_OUT,
66
+ superProperties = {},
67
+ serverURL = "https://api.mixpanel.com"
68
+ ) {
69
+ await MixpanelReactNative.initialize(
70
+ this.token,
71
+ this.trackAutomaticEvents,
72
+ optOutTrackingDefault,
73
+ {...Helper.getMetaData(), ...superProperties},
74
+ serverURL
75
+ );
76
+ }
77
+
78
+ /**
79
+ * @deprecated since version 1.3.0. To initialize Mixpanel, please use the instance method `init` instead. See the example below:
80
+ *
81
+ * <pre><code>
82
+ * const trackAutomaticEvents = true;
83
+ * const mixpanel = new Mixpanel('your project token', trackAutomaticEvents);
84
+ * mixpanel.init();
85
+ * </code></pre>
86
+ *
87
+ * Initializes Mixpanel and return an instance of Mixpanel the given project token.
88
+ *
89
+ * @param {string} token your project token.
90
+ * @param {boolean} trackAutomaticEvents Whether or not to automatically track common mobile events
91
+ * @param {boolean} Optional Whether or not Mixpanel can start tracking by default. See optOutTracking()
92
+ *
93
+ */
94
+ static async init(
95
+ token,
96
+ trackAutomaticEvents,
97
+ optOutTrackingDefault = DEFAULT_OPT_OUT
98
+ ) {
99
+ await MixpanelReactNative.initialize(
100
+ token,
101
+ trackAutomaticEvents,
102
+ optOutTrackingDefault,
103
+ Helper.getMetaData(),
104
+ "https://api.mixpanel.com"
105
+ );
106
+ return new Mixpanel(token, trackAutomaticEvents);
107
+ }
108
+
109
+ /**
110
+ * Set the base URL used for Mixpanel API requests.
111
+ * Useful if you need to proxy Mixpanel requests. Defaults to https://api.mixpanel.com.
112
+ * To route data to Mixpanel's EU servers, set to https://api-eu.mixpanel.com
113
+ *
114
+ * @param {string} serverURL the base URL used for Mixpanel API requests
115
+ *
116
+ */
117
+ setServerURL(serverURL) {
118
+ MixpanelReactNative.setServerURL(this.token, serverURL);
119
+ }
120
+
121
+ /**
122
+ * This allows enabling or disabling of all Mixpanel logs at run time.
123
+ * All logging is disabled by default. Usually, this is only required if
124
+ * you are running into issues with the SDK that you want to debug
125
+ *
126
+ * @param {boolean} loggingEnabled whether to enable logging
127
+ *
128
+ */
129
+ setLoggingEnabled(loggingEnabled) {
130
+ MixpanelReactNative.setLoggingEnabled(this.token, loggingEnabled);
131
+ }
132
+
133
+ /**
134
+ * This allows enabling or disabling whether or not Mixpanel flushes events
135
+ * when the app enters the background on iOS. This is set to true by default.
136
+ *
137
+ * @param {boolean} flushOnBackground whether to enable logging
138
+ *
139
+ */
140
+ setFlushOnBackground(flushOnBackground) {
141
+ if (Platform.OS === "ios") {
142
+ MixpanelReactNative.setFlushOnBackground(this.token, flushOnBackground);
143
+ } else {
144
+ console.warn(
145
+ "Mixpanel setFlushOnBackground was called and ignored because this method only works on iOS."
146
+ );
147
+ }
148
+ }
149
+
150
+ /**
151
+ * This controls whether to automatically send the client IP Address as part of event tracking.
152
+ * With an IP address, geo-location is possible down to neighborhoods within a city,
153
+ * although the Mixpanel Dashboard will just show you city level location specificity.
154
+ *
155
+ * @param {boolean} useIpAddressForGeolocation whether to automatically send the client IP Address.
156
+ * Defaults to true.
157
+ *
158
+ */
159
+ setUseIpAddressForGeolocation(useIpAddressForGeolocation) {
160
+ MixpanelReactNative.setUseIpAddressForGeolocation(
161
+ this.token,
162
+ useIpAddressForGeolocation
163
+ );
164
+ }
165
+
166
+ /**
167
+ * Set the number of events sent in a single network request to the Mixpanel server.
168
+ * By configuring this value, you can optimize network usage and manage the frequency of communication between the client and the server. The maximum size is 50; any value over 50 will default to 50.
169
+ *
170
+ * @param {integer} flushBatchSize whether to automatically send the client IP Address.
171
+ * Defaults to true.
172
+ *
173
+ */
174
+ setFlushBatchSize(flushBatchSize) {
175
+ MixpanelReactNative.setFlushBatchSize(this.token, flushBatchSize);
176
+ }
177
+
178
+ /**
179
+ * Will return true if the user has opted out from tracking.
180
+ *
181
+ * @return {Promise<boolean>} true if user has opted out from tracking. Defaults to false.
182
+ */
183
+ hasOptedOutTracking() {
184
+ return MixpanelReactNative.hasOptedOutTracking(this.token);
185
+ }
186
+
187
+ /**
188
+ * Use this method to opt-in an already opted-out user from tracking. People updates and track
189
+ * calls will be sent to Mixpanel after using this method.
190
+ * This method will internally track an opt-in event to your project.
191
+ *
192
+ */
193
+ optInTracking() {
194
+ MixpanelReactNative.optInTracking(this.token);
195
+ }
196
+
197
+ /**
198
+ * Use this method to opt-out a user from tracking. Events and people updates that haven't been
199
+ * flushed yet will be deleted. Use flush() before calling this method if you want
200
+ * to send all the queues to Mixpanel before.
201
+ *
202
+ * This method will also remove any user-related information from the device.
203
+ */
204
+ optOutTracking() {
205
+ MixpanelReactNative.optOutTracking(this.token);
206
+ }
207
+
208
+ /**
209
+ * Associate all future calls to track() with the user identified by
210
+ * the given distinct id.
211
+ *
212
+ * <p>Calls to track() made before corresponding calls to identify
213
+ * will use an anonymous locally generated distinct id, which means it is best to call identify
214
+ * early to ensure that your Mixpanel funnels and retention analytics can continue to track the
215
+ * user throughout their lifetime. We recommend calling identify when the user authenticates.
216
+ *
217
+ * <p>Once identify is called, the local distinct id persists across restarts of
218
+ * your application.
219
+ *
220
+ * @param {string} distinctId a string uniquely identifying this user. Events sent to
221
+ * Mixpanel using the same disinct_id will be considered associated with the
222
+ * same visitor/customer for retention and funnel reporting, so be sure that the given
223
+ * value is globally unique for each individual user you intend to track.
224
+ * @returns {Promise} A promise that resolves when the identify is successful.
225
+ * It does not return any value.
226
+ *
227
+ */
228
+ identify(distinctId) {
229
+ return new Promise((resolve, reject) => {
230
+ if (!StringHelper.isValid(distinctId)) {
231
+ StringHelper.raiseError(PARAMS.DISTINCT_ID);
232
+ reject(new Error("Invalid distinctId"));
233
+ }
234
+ MixpanelReactNative.identify(this.token, distinctId)
235
+ .then(() => {
236
+ resolve();
237
+ })
238
+ .catch((err) => {
239
+ reject(err);
207
240
  });
208
- }
209
-
210
- /**
211
- * The alias method creates an alias which Mixpanel will use to remap one id to another.
212
- * Multiple aliases can point to the same identifier.
213
- *
214
- * `mixpane.alias("New ID", mixpane.distinctId)`
215
- * `mixpane.alias("Newer ID", mixpane.distinctId)`
216
- *
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.
219
- *
220
- * @param {string} alias A unique identifier that you want to use as an identifier for this user.
221
- * @param {string} distinctId the current distinct_id that alias will be mapped to.
222
- */
223
- alias(alias, distinctId) {
224
- if (!StringHelper.isValid(alias)) {
225
- StringHelper.raiseError(PARAMS.ALIAS);
226
- }
227
- if (!StringHelper.isValid(distinctId)) {
228
- StringHelper.raiseError(PARAMS.DISTINCT_ID);
229
- }
230
- MixpanelReactNative.alias(this.token, alias, distinctId);
231
- }
232
-
233
- /**
234
- * Track an event.
235
- *
236
- * <p>Every call to track eventually results in a data point sent to Mixpanel. These data points
237
- * are what are measured, counted, and broken down to create your Mixpanel reports. Events
238
- * have a string name, and an optional set of name/value pairs that describe the properties of
239
- * that event.
240
- *
241
- * @param {string} eventName The name of the event to send
242
- * @param {object} properties A Map containing the key value pairs of the properties to include in this event.
243
- * Pass null if no extra properties exist.
244
- */
245
- track(eventName, properties) {
246
- if (!StringHelper.isValid(eventName)) {
247
- StringHelper.raiseError(PARAMS.EVENT_NAME);
248
- }
249
- if (!ObjectHelper.isValidOrUndefined(properties)) {
250
- ObjectHelper.raiseError(PARAMS.PROPERTIES);
251
- }
252
- MixpanelReactNative.track(this.token, eventName, properties || {});
253
- }
254
-
255
- /**
256
- * Returns a Mixpanel People object that can be used to set and increment
257
- * People Analytics properties.
258
- *
259
- * @return {People} an instance of People that you can use to update
260
- * records in Mixpanel People Analytics
261
- */
262
- getPeople() {
263
- return this.people;
264
- }
265
-
266
- /**
267
- * Track an event with specific groups.
268
- *
269
- * <p>Every call to track eventually results in a data point sent to Mixpanel. These data points
270
- * are what are measured, counted, and broken down to create your Mixpanel reports. Events
271
- * have a string name, and an optional set of name/value pairs that describe the properties of
272
- * that event. Group key/value pairs are upserted into the property map before tracking.
273
- *
274
- * @param {string} eventName The name of the event to send
275
- * @param {object} properties A Map containing the key value pairs of the properties to include in this event.
276
- * Pass null if no extra properties exist.
277
- * @param {object} groups A Map containing the group key value pairs for this event.
278
- *
279
- */
280
- trackWithGroups(eventName, properties, groups) {
281
- if (!StringHelper.isValid(eventName)) {
282
- StringHelper.raiseError(PARAMS.EVENT_NAME);
283
- }
284
- if (!ObjectHelper.isValidOrUndefined(properties)) {
285
- ObjectHelper.raiseError(PARAMS.PROPERTIES);
286
- }
287
- MixpanelReactNative.trackWithGroups(this.token, eventName, properties || {}, groups);
288
- }
289
-
290
- /**
291
- * Set the group this user belongs to.
292
- *
293
- * @param {string} groupKey The property name associated with this group type (must already have been set up).
294
- * @param {object} groupID The group the user belongs to.
295
- */
296
- setGroup(groupKey, groupID) {
297
- if (!StringHelper.isValid(groupKey)) {
298
- StringHelper.raiseError(PARAMS.GROUP_KEY);
299
- }
300
- MixpanelReactNative.setGroup(this.token, groupKey, groupID);
301
- }
302
-
303
- /**
304
- * Returns a MixpanelGroup object that can be used to set and increment
305
- * Group Analytics properties.
306
- *
307
- * @param {string} groupKey String identifying the type of group (must be already in use as a group key)
308
- * @param {object} groupID Object identifying the specific group
309
- * @return an instance of MixpanelGroup that you can use to update
310
- * records in Mixpanel Group Analytics
311
- */
312
- getGroup(groupKey, groupID) {
313
- return new MixpanelGroup(this.token, groupKey, groupID);
314
- }
315
-
316
- /**
317
- * Add a group to this user's membership for a particular group key
318
- *
319
- * @param {string} groupKey The property name associated with this group type (must already have been set up).
320
- * @param {object} groupID The new group the user belongs to.
321
- */
322
- addGroup(groupKey, groupID) {
323
- if (!StringHelper.isValid(groupKey)) {
324
- StringHelper.raiseError(PARAMS.GROUP_KEY);
325
- }
326
- MixpanelReactNative.addGroup(this.token, groupKey, groupID);
327
- }
328
-
329
- /**
330
- * Remove a group from this user's membership for a particular group key
331
- *
332
- * @param {string} groupKey The property name associated with this group type (must already have been set up).
333
- * @param {object} groupID The group value to remove.
334
- */
335
- removeGroup(groupKey, groupID) {
336
- if (!StringHelper.isValid(groupKey)) {
337
- StringHelper.raiseError(PARAMS.GROUP_KEY);
338
- }
339
- MixpanelReactNative.removeGroup(this.token, groupKey, groupID);
340
- }
341
-
342
- /**
343
- * Permanently deletes this group's record from Group Analytics.
344
- *
345
- * @param {string} groupKey String identifying the type of group (must be already in use as a group key)
346
- * @param {object} groupID Object identifying the specific group
347
- * <p>Calling deleteGroup deletes an entire record completely. Any future calls
348
- * to Group Analytics using the same group value will create and store new values.
349
- */
350
- deleteGroup(groupKey, groupID) {
351
- if (!StringHelper.isValid(groupKey)) {
352
- StringHelper.raiseError(PARAMS.GROUP_KEY);
353
- }
354
- MixpanelReactNative.deleteGroup(this.token, groupKey, groupID);
355
- }
356
-
357
- /**
358
- * Register properties that will be sent with every subsequent call to track().
359
- *
360
- * <p>SuperProperties are a collection of properties that will be sent with every event to Mixpanel,
361
- * and persist beyond the lifetime of your application.
362
- *
363
- * <p>Setting a superProperty with registerSuperProperties will store a new superProperty,
364
- * possibly overwriting any existing superProperty with the same name (to set a
365
- * superProperty only if it is currently unset, use registerSuperPropertiesOnce())
366
- *
367
- * <p>SuperProperties will persist even if your application is taken completely out of memory.
368
- * to remove a superProperty, call unregisterSuperProperty() or clearSuperProperties()
369
- *
370
- * @param {object} properties A Map containing super properties to register
371
- */
372
- registerSuperProperties(properties) {
373
- if (!ObjectHelper.isValidOrUndefined(properties)) {
374
- ObjectHelper.raiseError(PARAMS.PROPERTIES);
375
- }
376
- MixpanelReactNative.registerSuperProperties(this.token, properties || {});
377
- }
378
-
379
- /**
380
- * Register super properties for events, only if no other super property with the
381
- * same names has already been registered.
382
- *
383
- * <p>Calling registerSuperPropertiesOnce will never overwrite existing properties.
384
- *
385
- * @param {object} properties A Map containing the super properties to register.
386
- */
387
- registerSuperPropertiesOnce(properties) {
388
- if (!ObjectHelper.isValidOrUndefined(properties)) {
389
- ObjectHelper.raiseError(PARAMS.PROPERTIES);
390
- }
391
- MixpanelReactNative.registerSuperPropertiesOnce(this.token, properties || {});
392
- }
393
-
394
- /**
395
- * Remove a single superProperty, so that it will not be sent with future calls to track().
396
- *
397
- * <p>If there is a superProperty registered with the given name, it will be permanently
398
- * removed from the existing superProperties.
399
- * To clear all superProperties, use clearSuperProperties()
400
- *
401
- * @param {string} propertyName name of the property to unregister
402
- */
403
- unregisterSuperProperty(propertyName) {
404
- if (!StringHelper.isValid(propertyName)) {
405
- StringHelper.raiseError(PARAMS.PROPERTY_NAME);
406
- }
407
- MixpanelReactNative.unregisterSuperProperty(this.token, propertyName);
408
- }
409
-
410
- /**
411
- * Returns a json object of the user's current super properties
412
- *
413
- *<p>SuperProperties are a collection of properties that will be sent with every event to Mixpanel,
414
- * and persist beyond the lifetime of your application.
415
- *
416
- * @return {Promise<object>} Super properties for this Mixpanel instance.
417
- */
418
- getSuperProperties() {
419
- return MixpanelReactNative.getSuperProperties(this.token);
420
- }
421
-
422
- /**
423
- * Erase all currently registered superProperties.
424
- *
425
- * <p>Future tracking calls to Mixpanel will not contain the specific
426
- * superProperties registered before the clearSuperProperties method was called.
427
- *
428
- * <p>To remove a single superProperty, use unregisterSuperProperty()
429
- */
430
- clearSuperProperties() {
431
- MixpanelReactNative.clearSuperProperties(this.token);
432
- }
433
-
434
- /**
435
- * Begin timing of an event. Calling timeEvent("Thing") will not send an event, but
436
- * when you eventually call track("Thing"), your tracked event will be sent with a "$duration"
437
- * property, representing the number of seconds between your calls.
438
- *
439
- * @param {string} eventName the name of the event to track with timing.
440
- */
441
- timeEvent(eventName) {
442
- if (!StringHelper.isValid(eventName)) {
443
- StringHelper.raiseError(PARAMS.EVENT_NAME);
444
- }
445
- MixpanelReactNative.timeEvent(this.token, eventName);
446
- }
447
-
448
- /**
449
- * Retrieves the time elapsed for the named event since timeEvent() was called.
450
- *
451
- * @param {string} eventName the name of the event to be tracked that was previously called with timeEvent()
452
- *
453
- * @return {Promise<number>} Time elapsed since timeEvent(String) was called for the given eventName.
454
- */
455
- eventElapsedTime(eventName) {
456
- if (!StringHelper.isValid(eventName)) {
457
- StringHelper.raiseError(PARAMS.EVENT_NAME);
458
- }
459
- return MixpanelReactNative.eventElapsedTime(this.token, eventName);
460
- }
461
-
462
- /**
241
+ });
242
+ }
243
+
244
+ /**
245
+ * The alias method creates an alias which Mixpanel will use to remap one id to another.
246
+ * Multiple aliases can point to the same identifier.
247
+ *
248
+ * `mixpane.alias("New ID", mixpane.distinctId)`
249
+ * `mixpane.alias("Newer ID", mixpane.distinctId)`
250
+ *
251
+ * <p>This call does not identify the user after. You must still call identify()
252
+ * if you wish the new alias to be used for Events and People.
253
+ *
254
+ * @param {string} alias A unique identifier that you want to use as an identifier for this user.
255
+ * @param {string} distinctId the current distinct_id that alias will be mapped to.
256
+ */
257
+ alias(alias, distinctId) {
258
+ if (!StringHelper.isValid(alias)) {
259
+ StringHelper.raiseError(PARAMS.ALIAS);
260
+ }
261
+ if (!StringHelper.isValid(distinctId)) {
262
+ StringHelper.raiseError(PARAMS.DISTINCT_ID);
263
+ }
264
+ MixpanelReactNative.alias(this.token, alias, distinctId);
265
+ }
266
+
267
+ /**
268
+ * Track an event.
269
+ *
270
+ * <p>Every call to track eventually results in a data point sent to Mixpanel. These data points
271
+ * are what are measured, counted, and broken down to create your Mixpanel reports. Events
272
+ * have a string name, and an optional set of name/value pairs that describe the properties of
273
+ * that event.
274
+ *
275
+ * @param {string} eventName The name of the event to send
276
+ * @param {object} properties A Map containing the key value pairs of the properties to include in this event.
277
+ * Pass null if no extra properties exist.
278
+ */
279
+ track(eventName, properties) {
280
+ if (!StringHelper.isValid(eventName)) {
281
+ StringHelper.raiseError(PARAMS.EVENT_NAME);
282
+ }
283
+ if (!ObjectHelper.isValidOrUndefined(properties)) {
284
+ ObjectHelper.raiseError(PARAMS.PROPERTIES);
285
+ }
286
+ MixpanelReactNative.track(this.token, eventName, {
287
+ ...Helper.getMetaData(),
288
+ ...properties,
289
+ });
290
+ }
291
+
292
+ /**
293
+ * Returns a Mixpanel People object that can be used to set and increment
294
+ * People Analytics properties.
295
+ *
296
+ * @return {People} an instance of People that you can use to update
297
+ * records in Mixpanel People Analytics
298
+ */
299
+ getPeople() {
300
+ return this.people;
301
+ }
302
+
303
+ /**
304
+ * Track an event with specific groups.
305
+ *
306
+ * <p>Every call to track eventually results in a data point sent to Mixpanel. These data points
307
+ * are what are measured, counted, and broken down to create your Mixpanel reports. Events
308
+ * have a string name, and an optional set of name/value pairs that describe the properties of
309
+ * that event. Group key/value pairs are upserted into the property map before tracking.
310
+ *
311
+ * @param {string} eventName The name of the event to send
312
+ * @param {object} properties A Map containing the key value pairs of the properties to include in this event.
313
+ * Pass null if no extra properties exist.
314
+ * @param {object} groups A Map containing the group key value pairs for this event.
315
+ *
316
+ */
317
+ trackWithGroups(eventName, properties, groups) {
318
+ if (!StringHelper.isValid(eventName)) {
319
+ StringHelper.raiseError(PARAMS.EVENT_NAME);
320
+ }
321
+ if (!ObjectHelper.isValidOrUndefined(properties)) {
322
+ ObjectHelper.raiseError(PARAMS.PROPERTIES);
323
+ }
324
+ MixpanelReactNative.trackWithGroups(
325
+ this.token,
326
+ eventName,
327
+ {
328
+ ...Helper.getMetaData(),
329
+ ...properties,
330
+ },
331
+ groups
332
+ );
333
+ }
334
+
335
+ /**
336
+ * Set the group this user belongs to.
337
+ *
338
+ * @param {string} groupKey The property name associated with this group type (must already have been set up).
339
+ * @param {object} groupID The group the user belongs to.
340
+ */
341
+ setGroup(groupKey, groupID) {
342
+ if (!StringHelper.isValid(groupKey)) {
343
+ StringHelper.raiseError(PARAMS.GROUP_KEY);
344
+ }
345
+ MixpanelReactNative.setGroup(this.token, groupKey, groupID);
346
+ }
347
+
348
+ /**
349
+ * Returns a MixpanelGroup object that can be used to set and increment
350
+ * Group Analytics properties.
351
+ *
352
+ * @param {string} groupKey String identifying the type of group (must be already in use as a group key)
353
+ * @param {object} groupID Object identifying the specific group
354
+ * @return an instance of MixpanelGroup that you can use to update
355
+ * records in Mixpanel Group Analytics
356
+ */
357
+ getGroup(groupKey, groupID) {
358
+ return new MixpanelGroup(this.token, groupKey, groupID);
359
+ }
360
+
361
+ /**
362
+ * Add a group to this user's membership for a particular group key
363
+ *
364
+ * @param {string} groupKey The property name associated with this group type (must already have been set up).
365
+ * @param {object} groupID The new group the user belongs to.
366
+ */
367
+ addGroup(groupKey, groupID) {
368
+ if (!StringHelper.isValid(groupKey)) {
369
+ StringHelper.raiseError(PARAMS.GROUP_KEY);
370
+ }
371
+ MixpanelReactNative.addGroup(this.token, groupKey, groupID);
372
+ }
373
+
374
+ /**
375
+ * Remove a group from this user's membership for a particular group key
376
+ *
377
+ * @param {string} groupKey The property name associated with this group type (must already have been set up).
378
+ * @param {object} groupID The group value to remove.
379
+ */
380
+ removeGroup(groupKey, groupID) {
381
+ if (!StringHelper.isValid(groupKey)) {
382
+ StringHelper.raiseError(PARAMS.GROUP_KEY);
383
+ }
384
+ MixpanelReactNative.removeGroup(this.token, groupKey, groupID);
385
+ }
386
+
387
+ /**
388
+ * Permanently deletes this group's record from Group Analytics.
389
+ *
390
+ * @param {string} groupKey String identifying the type of group (must be already in use as a group key)
391
+ * @param {object} groupID Object identifying the specific group
392
+ * <p>Calling deleteGroup deletes an entire record completely. Any future calls
393
+ * to Group Analytics using the same group value will create and store new values.
394
+ */
395
+ deleteGroup(groupKey, groupID) {
396
+ if (!StringHelper.isValid(groupKey)) {
397
+ StringHelper.raiseError(PARAMS.GROUP_KEY);
398
+ }
399
+ MixpanelReactNative.deleteGroup(this.token, groupKey, groupID);
400
+ }
401
+
402
+ /**
403
+ * Register properties that will be sent with every subsequent call to track().
404
+ *
405
+ * <p>SuperProperties are a collection of properties that will be sent with every event to Mixpanel,
406
+ * and persist beyond the lifetime of your application.
407
+ *
408
+ * <p>Setting a superProperty with registerSuperProperties will store a new superProperty,
409
+ * possibly overwriting any existing superProperty with the same name (to set a
410
+ * superProperty only if it is currently unset, use registerSuperPropertiesOnce())
411
+ *
412
+ * <p>SuperProperties will persist even if your application is taken completely out of memory.
413
+ * to remove a superProperty, call unregisterSuperProperty() or clearSuperProperties()
414
+ *
415
+ * @param {object} properties A Map containing super properties to register
416
+ */
417
+ registerSuperProperties(properties) {
418
+ if (!ObjectHelper.isValidOrUndefined(properties)) {
419
+ ObjectHelper.raiseError(PARAMS.PROPERTIES);
420
+ }
421
+ MixpanelReactNative.registerSuperProperties(this.token, properties || {});
422
+ }
423
+
424
+ /**
425
+ * Register super properties for events, only if no other super property with the
426
+ * same names has already been registered.
427
+ *
428
+ * <p>Calling registerSuperPropertiesOnce will never overwrite existing properties.
429
+ *
430
+ * @param {object} properties A Map containing the super properties to register.
431
+ */
432
+ registerSuperPropertiesOnce(properties) {
433
+ if (!ObjectHelper.isValidOrUndefined(properties)) {
434
+ ObjectHelper.raiseError(PARAMS.PROPERTIES);
435
+ }
436
+ MixpanelReactNative.registerSuperPropertiesOnce(
437
+ this.token,
438
+ properties || {}
439
+ );
440
+ }
441
+
442
+ /**
443
+ * Remove a single superProperty, so that it will not be sent with future calls to track().
444
+ *
445
+ * <p>If there is a superProperty registered with the given name, it will be permanently
446
+ * removed from the existing superProperties.
447
+ * To clear all superProperties, use clearSuperProperties()
448
+ *
449
+ * @param {string} propertyName name of the property to unregister
450
+ */
451
+ unregisterSuperProperty(propertyName) {
452
+ if (!StringHelper.isValid(propertyName)) {
453
+ StringHelper.raiseError(PARAMS.PROPERTY_NAME);
454
+ }
455
+ MixpanelReactNative.unregisterSuperProperty(this.token, propertyName);
456
+ }
457
+
458
+ /**
459
+ * Returns a json object of the user's current super properties
460
+ *
461
+ *<p>SuperProperties are a collection of properties that will be sent with every event to Mixpanel,
462
+ * and persist beyond the lifetime of your application.
463
+ *
464
+ * @return {Promise<object>} Super properties for this Mixpanel instance.
465
+ */
466
+ getSuperProperties() {
467
+ return MixpanelReactNative.getSuperProperties(this.token);
468
+ }
469
+
470
+ /**
471
+ * Erase all currently registered superProperties.
472
+ *
473
+ * <p>Future tracking calls to Mixpanel will not contain the specific
474
+ * superProperties registered before the clearSuperProperties method was called.
475
+ *
476
+ * <p>To remove a single superProperty, use unregisterSuperProperty()
477
+ */
478
+ clearSuperProperties() {
479
+ MixpanelReactNative.clearSuperProperties(this.token);
480
+ }
481
+
482
+ /**
483
+ * Begin timing of an event. Calling timeEvent("Thing") will not send an event, but
484
+ * when you eventually call track("Thing"), your tracked event will be sent with a "$duration"
485
+ * property, representing the number of seconds between your calls.
486
+ *
487
+ * @param {string} eventName the name of the event to track with timing.
488
+ */
489
+ timeEvent(eventName) {
490
+ if (!StringHelper.isValid(eventName)) {
491
+ StringHelper.raiseError(PARAMS.EVENT_NAME);
492
+ }
493
+ MixpanelReactNative.timeEvent(this.token, eventName);
494
+ }
495
+
496
+ /**
497
+ * Retrieves the time elapsed for the named event since timeEvent() was called.
498
+ *
499
+ * @param {string} eventName the name of the event to be tracked that was previously called with timeEvent()
500
+ *
501
+ * @return {Promise<number>} Time elapsed since timeEvent(String) was called for the given eventName.
502
+ */
503
+ eventElapsedTime(eventName) {
504
+ if (!StringHelper.isValid(eventName)) {
505
+ StringHelper.raiseError(PARAMS.EVENT_NAME);
506
+ }
507
+ return MixpanelReactNative.eventElapsedTime(this.token, eventName);
508
+ }
509
+
510
+ /**
463
511
  Clear super properties and generates a new random distinctId for this instance.
464
512
  Useful for clearing data when a user logs out.
465
513
  */
466
- reset() {
467
- MixpanelReactNative.reset(this.token);
468
- }
469
-
470
- /**
471
- * Returns the current distinct id of the user.
472
- * This is either the id automatically generated by the library or the id that has been passed by a call to identify().
473
- *
474
- * example of usage:
475
- * <pre>
476
- * <code>
477
- * const distinctId = await mixpanel.getDistinctId();
478
- * </code>
479
- * </pre>
480
- *
481
- * @return {Promise<string>} A Promise to the distinct id associated with Mixpanel event and People Analytics
482
- *
483
- */
484
- getDistinctId() {
485
- return MixpanelReactNative.getDistinctId(this.token);
486
- }
487
-
488
- /**
489
- * Returns the current device id of the device.
490
- * This id automatically generated by the library and regenerated when logout or reset is called.
491
- *
492
- * example of usage:
493
- * <pre>
494
- * <code>
495
- * const deviceId = await mixpanel.getDeviceId();
496
- * </code>
497
- * </pre>
498
- *
499
- * @return {Promise<string>} A Promise to the device id
500
- *
501
- */
502
- getDeviceId() {
503
- return MixpanelReactNative.getDeviceId(this.token);
504
- }
505
-
506
- /**
507
- * Push all queued Mixpanel events and People Analytics changes to Mixpanel servers.
508
- *
509
- * <p>Events and People messages are pushed gradually throughout
510
- * the lifetime of your application. This means that to ensure that all messages
511
- * are sent to Mixpanel when your application is shut down, you will
512
- * need to call flush() to let the Mixpanel library know it should
513
- * send all remaining messages to the server.
514
- */
515
- flush() {
516
- MixpanelReactNative.flush(this.token);
517
- }
514
+ reset() {
515
+ MixpanelReactNative.reset(this.token);
516
+ }
517
+
518
+ /**
519
+ * Returns the current distinct id of the user.
520
+ * This is either the id automatically generated by the library or the id that has been passed by a call to identify().
521
+ *
522
+ * example of usage:
523
+ * <pre>
524
+ * <code>
525
+ * const distinctId = await mixpanel.getDistinctId();
526
+ * </code>
527
+ * </pre>
528
+ *
529
+ * @return {Promise<string>} A Promise to the distinct id associated with Mixpanel event and People Analytics
530
+ *
531
+ */
532
+ getDistinctId() {
533
+ return MixpanelReactNative.getDistinctId(this.token);
534
+ }
535
+
536
+ /**
537
+ * Returns the current device id of the device.
538
+ * This id automatically generated by the library and regenerated when logout or reset is called.
539
+ *
540
+ * example of usage:
541
+ * <pre>
542
+ * <code>
543
+ * const deviceId = await mixpanel.getDeviceId();
544
+ * </code>
545
+ * </pre>
546
+ *
547
+ * @return {Promise<string>} A Promise to the device id
548
+ *
549
+ */
550
+ getDeviceId() {
551
+ return MixpanelReactNative.getDeviceId(this.token);
552
+ }
553
+
554
+ /**
555
+ * Push all queued Mixpanel events and People Analytics changes to Mixpanel servers.
556
+ *
557
+ * <p>Events and People messages are pushed gradually throughout
558
+ * the lifetime of your application. This means that to ensure that all messages
559
+ * are sent to Mixpanel when your application is shut down, you will
560
+ * need to call flush() to let the Mixpanel library know it should
561
+ * send all remaining messages to the server.
562
+ */
563
+ flush() {
564
+ MixpanelReactNative.flush(this.token);
565
+ }
518
566
  }
519
567
 
520
568
  /**
@@ -529,199 +577,202 @@ export class Mixpanel {
529
577
  *
530
578
  */
531
579
  export class People {
532
-
533
- constructor(token) {
534
- if (!StringHelper.isValid(token)) {
535
- StringHelper.raiseError(PARAMS.TOKEN);
536
- }
537
- this.token = token;
538
- }
539
-
540
- /**
541
- * Sets a single property with the given name and value for this user.
542
- * The given name and value will be assigned to the user in Mixpanel People Analytics,
543
- * possibly overwriting an existing property with the same name.
544
- *
545
- * @param {string} prop The name of the Mixpanel property. This must be a String, for example "Zip Code"
546
- * @param {object} to The value of the Mixpanel property. For "Zip Code", this value might be the String "90210"
547
- */
548
- set(prop, to) {
549
- let properties = {};
550
- if (ObjectHelper.isValid(prop)) {
551
- properties = JSON.parse(JSON.stringify(prop || {}));
552
- } else {
553
- if (!StringHelper.isValid(prop)) {
554
- StringHelper.raiseError(PARAMS.PROP);
555
- }
556
- properties[prop] = to;
557
- }
558
- MixpanelReactNative.set(this.token, properties);
559
- }
560
-
561
- /**
562
- * Works just like set(), except it will not overwrite existing property values. This is useful for properties like "First login date".
563
- *
564
- * @param {string} prop The name of the Mixpanel property. This must be a String, for example "Zip Code"
565
- * @param {object} to The value of the Mixpanel property. For "Zip Code", this value might be the String "90210"
566
- */
567
- setOnce(prop, to) {
568
- let properties = {};
569
- if (ObjectHelper.isValid(prop)) {
570
- prop = prop || {};
571
- properties = JSON.parse(JSON.stringify(prop));
572
- } else {
573
- if (!StringHelper.isValid(prop)) {
574
- StringHelper.raiseError(PARAMS.PROP);
575
- }
576
- properties[prop] = to;
577
- }
578
- MixpanelReactNative.setOnce(this.token, properties);
579
- }
580
-
581
- /**
582
- * Add the given amount to an existing property on the identified user. If the user does not already
583
- * have the associated property, the amount will be added to zero. To reduce a property,
584
- * provide a negative number for the value.
585
- *
586
- * @param {string} prop the People Analytics property that should have its value changed
587
- * @param {number} by the amount to be added to the current value of the named property
588
- *
589
- */
590
- increment(prop, by) {
591
- var add = {};
592
- if (ObjectHelper.isValid(prop)) {
593
- Object.keys(prop).forEach(function (key) {
594
- var val = prop[key];
595
- if (isNaN(parseFloat(val))) {
596
- throw new Error(`${PARAMS.PROPERTY_VALUE}${ERROR_MESSAGE.REQUIRED_DOUBLE}`);
597
- }
598
- add[key] = val;
599
- });
600
- } else {
601
- by = by || 1;
602
- if (isNaN(parseFloat(by))) {
603
- throw new Error(`${PARAMS.PROPERTY_VALUE}${ERROR_MESSAGE.REQUIRED_DOUBLE}`);
604
- }
605
-
606
- if (!StringHelper.isValid(prop)) {
607
- StringHelper.raiseError(PARAMS.NAME);
608
- }
609
-
610
- add[prop] = by;
611
- }
612
- MixpanelReactNative.increment(this.token, add);
613
- }
614
-
615
- /**
616
- * Appends a value to a list-valued property. If the property does not currently exist,
617
- * it will be created as a list of one element. If the property does exist and doesn't
618
- * currently have a list value, the append will be ignored.
619
- * @param {string} name the People Analytics property that should have it's value appended to
620
- * @param {object} value the new value that will appear at the end of the property's list
621
- */
622
- append(name, value) {
623
- let appendProp = {};
624
- if (!StringHelper.isValid(name)) {
625
- StringHelper.raiseError(PARAMS.NAME);
626
- } else {
627
- appendProp[name] = value;
628
- }
629
-
630
- if (DevicePlatform.iOS === Helper.getDevicePlatform()) {
631
- MixpanelReactNative.append(this.token, appendProp);
632
- } else {
633
- MixpanelReactNative.append(this.token, name, value);
634
- }
635
- }
636
-
637
- /**
638
- * Adds values to a list-valued property only if they are not already present in the list.
639
- * If the property does not currently exist, it will be created with the given list as it's value.
640
- * If the property exists and is not list-valued, the union will be ignored.
641
- *
642
- * @param {string} name name of the list-valued property to set or modify
643
- * @param {array} value an array of values to add to the property value if not already present
644
- */
645
- union(name, value) {
646
- if (!StringHelper.isValid(name)) {
647
- StringHelper.raiseError(PARAMS.NAME);
648
- }
649
-
650
- value = Array.isArray(value) ? value : [value];
651
-
652
- if (DevicePlatform.iOS === Helper.getDevicePlatform()) {
653
- MixpanelReactNative.union(this.token, {[name]: value});
654
- } else {
655
- MixpanelReactNative.union(this.token, name, value);
656
- }
657
- }
658
-
659
- /**
660
- * Remove value from a list-valued property only if they are already present in the list.
661
- * If the property does not currently exist, the remove will be ignored.
662
- * If the property exists and is not list-valued, the remove will be ignored.
663
- * @param {string} name the People Analytics property that should have it's value removed from
664
- * @param {object} value the value that will be removed from the property's list
665
- */
666
- remove(name, value) {
667
- let removeProp = {};
668
- if (!StringHelper.isValid(name)) {
669
- StringHelper.raiseError(PARAMS.NAME);
670
- } else {
671
- removeProp[name] = value;
672
- }
673
-
674
- if (DevicePlatform.iOS === Helper.getDevicePlatform()) {
675
- MixpanelReactNative.remove(this.token, removeProp);
676
- } else {
677
- MixpanelReactNative.remove(this.token, name, value);
678
- }
679
- }
680
-
681
- /**
682
- * permanently removes the property with the given name from the user's profile
683
- * @param {string} name name of a property to unset
684
- */
685
- unset(name) {
686
- if (!StringHelper.isValid(name)) {
687
- StringHelper.raiseError(PARAMS.PROPERTY_NAME);
688
- }
689
- MixpanelReactNative.unset(this.token, name);
690
- }
691
-
692
- /**
693
- * Track a revenue transaction for the identified people profile.
694
- *
695
- * @param {number} charge the amount of money exchanged. Positive amounts represent purchases or income from the customer, negative amounts represent refunds or payments to the customer.
696
- * @param {object} properties an optional collection of properties to associate with this transaction.
697
- */
698
- trackCharge(charge, properties) {
699
- if (isNaN(parseFloat(charge))) {
700
- throw new Error(`${PARAMS.CHARGE}${ERROR_MESSAGE.REQUIRED_DOUBLE}`)
701
- }
702
-
703
- if (!ObjectHelper.isValidOrUndefined(properties)) {
704
- ObjectHelper.raiseError(PARAMS.PROPERTIES);
705
- }
706
- MixpanelReactNative.trackCharge(this.token, charge, properties || {});
707
- }
708
-
709
- /**
710
- * Permanently clear the whole transaction history for the identified people profile.
711
- */
712
- clearCharges() {
713
- MixpanelReactNative.clearCharges(this.token);
714
- }
715
-
716
- /**
717
- * Permanently deletes the identified user's record from People Analytics.
718
- *
719
- * <p>Calling deleteUser deletes an entire record completely. Any future calls
720
- * to People Analytics using the same distinct id will create and store new values.
721
- */
722
- deleteUser() {
723
- MixpanelReactNative.deleteUser(this.token);
724
- }
580
+ constructor(token) {
581
+ if (!StringHelper.isValid(token)) {
582
+ StringHelper.raiseError(PARAMS.TOKEN);
583
+ }
584
+ this.token = token;
585
+ }
586
+
587
+ /**
588
+ * Sets a single property with the given name and value for this user.
589
+ * The given name and value will be assigned to the user in Mixpanel People Analytics,
590
+ * possibly overwriting an existing property with the same name.
591
+ *
592
+ * @param {string} prop The name of the Mixpanel property. This must be a String, for example "Zip Code"
593
+ * @param {object} to The value of the Mixpanel property. For "Zip Code", this value might be the String "90210"
594
+ */
595
+ set(prop, to) {
596
+ let properties = {};
597
+ if (ObjectHelper.isValid(prop)) {
598
+ properties = JSON.parse(JSON.stringify(prop || {}));
599
+ } else {
600
+ if (!StringHelper.isValid(prop)) {
601
+ StringHelper.raiseError(PARAMS.PROP);
602
+ }
603
+ properties[prop] = to;
604
+ }
605
+ MixpanelReactNative.set(this.token, properties);
606
+ }
607
+
608
+ /**
609
+ * Works just like set(), except it will not overwrite existing property values. This is useful for properties like "First login date".
610
+ *
611
+ * @param {string} prop The name of the Mixpanel property. This must be a String, for example "Zip Code"
612
+ * @param {object} to The value of the Mixpanel property. For "Zip Code", this value might be the String "90210"
613
+ */
614
+ setOnce(prop, to) {
615
+ let properties = {};
616
+ if (ObjectHelper.isValid(prop)) {
617
+ prop = prop || {};
618
+ properties = JSON.parse(JSON.stringify(prop));
619
+ } else {
620
+ if (!StringHelper.isValid(prop)) {
621
+ StringHelper.raiseError(PARAMS.PROP);
622
+ }
623
+ properties[prop] = to;
624
+ }
625
+ MixpanelReactNative.setOnce(this.token, properties);
626
+ }
627
+
628
+ /**
629
+ * Add the given amount to an existing property on the identified user. If the user does not already
630
+ * have the associated property, the amount will be added to zero. To reduce a property,
631
+ * provide a negative number for the value.
632
+ *
633
+ * @param {string} prop the People Analytics property that should have its value changed
634
+ * @param {number} by the amount to be added to the current value of the named property
635
+ *
636
+ */
637
+ increment(prop, by) {
638
+ var add = {};
639
+ if (ObjectHelper.isValid(prop)) {
640
+ Object.keys(prop).forEach(function (key) {
641
+ var val = prop[key];
642
+ if (isNaN(parseFloat(val))) {
643
+ throw new Error(
644
+ `${PARAMS.PROPERTY_VALUE}${ERROR_MESSAGE.REQUIRED_DOUBLE}`
645
+ );
646
+ }
647
+ add[key] = val;
648
+ });
649
+ } else {
650
+ by = by || 1;
651
+ if (isNaN(parseFloat(by))) {
652
+ throw new Error(
653
+ `${PARAMS.PROPERTY_VALUE}${ERROR_MESSAGE.REQUIRED_DOUBLE}`
654
+ );
655
+ }
656
+
657
+ if (!StringHelper.isValid(prop)) {
658
+ StringHelper.raiseError(PARAMS.NAME);
659
+ }
660
+
661
+ add[prop] = by;
662
+ }
663
+ MixpanelReactNative.increment(this.token, add);
664
+ }
665
+
666
+ /**
667
+ * Appends a value to a list-valued property. If the property does not currently exist,
668
+ * it will be created as a list of one element. If the property does exist and doesn't
669
+ * currently have a list value, the append will be ignored.
670
+ * @param {string} name the People Analytics property that should have it's value appended to
671
+ * @param {object} value the new value that will appear at the end of the property's list
672
+ */
673
+ append(name, value) {
674
+ let appendProp = {};
675
+ if (!StringHelper.isValid(name)) {
676
+ StringHelper.raiseError(PARAMS.NAME);
677
+ } else {
678
+ appendProp[name] = value;
679
+ }
680
+
681
+ if (DevicePlatform.iOS === Helper.getDevicePlatform()) {
682
+ MixpanelReactNative.append(this.token, appendProp);
683
+ } else {
684
+ MixpanelReactNative.append(this.token, name, value);
685
+ }
686
+ }
687
+
688
+ /**
689
+ * Adds values to a list-valued property only if they are not already present in the list.
690
+ * If the property does not currently exist, it will be created with the given list as it's value.
691
+ * If the property exists and is not list-valued, the union will be ignored.
692
+ *
693
+ * @param {string} name name of the list-valued property to set or modify
694
+ * @param {array} value an array of values to add to the property value if not already present
695
+ */
696
+ union(name, value) {
697
+ if (!StringHelper.isValid(name)) {
698
+ StringHelper.raiseError(PARAMS.NAME);
699
+ }
700
+
701
+ value = Array.isArray(value) ? value : [value];
702
+
703
+ if (DevicePlatform.iOS === Helper.getDevicePlatform()) {
704
+ MixpanelReactNative.union(this.token, {[name]: value});
705
+ } else {
706
+ MixpanelReactNative.union(this.token, name, value);
707
+ }
708
+ }
709
+
710
+ /**
711
+ * Remove value from a list-valued property only if they are already present in the list.
712
+ * If the property does not currently exist, the remove will be ignored.
713
+ * If the property exists and is not list-valued, the remove will be ignored.
714
+ * @param {string} name the People Analytics property that should have it's value removed from
715
+ * @param {object} value the value that will be removed from the property's list
716
+ */
717
+ remove(name, value) {
718
+ let removeProp = {};
719
+ if (!StringHelper.isValid(name)) {
720
+ StringHelper.raiseError(PARAMS.NAME);
721
+ } else {
722
+ removeProp[name] = value;
723
+ }
724
+
725
+ if (DevicePlatform.iOS === Helper.getDevicePlatform()) {
726
+ MixpanelReactNative.remove(this.token, removeProp);
727
+ } else {
728
+ MixpanelReactNative.remove(this.token, name, value);
729
+ }
730
+ }
731
+
732
+ /**
733
+ * permanently removes the property with the given name from the user's profile
734
+ * @param {string} name name of a property to unset
735
+ */
736
+ unset(name) {
737
+ if (!StringHelper.isValid(name)) {
738
+ StringHelper.raiseError(PARAMS.PROPERTY_NAME);
739
+ }
740
+ MixpanelReactNative.unset(this.token, name);
741
+ }
742
+
743
+ /**
744
+ * Track a revenue transaction for the identified people profile.
745
+ *
746
+ * @param {number} charge the amount of money exchanged. Positive amounts represent purchases or income from the customer, negative amounts represent refunds or payments to the customer.
747
+ * @param {object} properties an optional collection of properties to associate with this transaction.
748
+ */
749
+ trackCharge(charge, properties) {
750
+ if (isNaN(parseFloat(charge))) {
751
+ throw new Error(`${PARAMS.CHARGE}${ERROR_MESSAGE.REQUIRED_DOUBLE}`);
752
+ }
753
+
754
+ if (!ObjectHelper.isValidOrUndefined(properties)) {
755
+ ObjectHelper.raiseError(PARAMS.PROPERTIES);
756
+ }
757
+ MixpanelReactNative.trackCharge(this.token, charge, properties || {});
758
+ }
759
+
760
+ /**
761
+ * Permanently clear the whole transaction history for the identified people profile.
762
+ */
763
+ clearCharges() {
764
+ MixpanelReactNative.clearCharges(this.token);
765
+ }
766
+
767
+ /**
768
+ * Permanently deletes the identified user's record from People Analytics.
769
+ *
770
+ * <p>Calling deleteUser deletes an entire record completely. Any future calls
771
+ * to People Analytics using the same distinct id will create and store new values.
772
+ */
773
+ deleteUser() {
774
+ MixpanelReactNative.deleteUser(this.token);
775
+ }
725
776
  }
726
777
 
727
778
  /**
@@ -730,169 +781,194 @@ export class People {
730
781
  * <p>The MixpanelGroup object is used to update properties in a group's Group Analytics record.
731
782
  */
732
783
  export class MixpanelGroup {
733
-
734
- constructor(token, groupKey, groupID) {
735
- if (!StringHelper.isValid(token)) {
736
- StringHelper.raiseError(PARAMS.TOKEN);
737
- }
738
- this.token = token;
739
- this.groupKey = groupKey;
740
- this.groupID = groupID;
741
- }
742
-
743
- /**
744
- * Sets a single property with the given name and value for this group.
745
- * The given name and value will be assigned to the user in Mixpanel Group Analytics,
746
- * possibly overwriting an existing property with the same name.
747
- *
748
- * @param {string} prop The name of the Mixpanel property. This must be a String, for example "Zip Code"
749
- * @param {string} to The value to set on the given property name. For "Zip Code", this value might be the String "90210"
750
- */
751
- set(prop, to) {
752
- let properties = {};
753
- if (ObjectHelper.isValid(prop)) {
754
- properties = JSON.parse(JSON.stringify(prop || {}));
755
- } else {
756
- if (!StringHelper.isValid(prop)) {
757
- StringHelper.raiseError(PARAMS.PROP);
758
- }
759
- properties[prop] = to;
760
- }
761
- MixpanelReactNative.groupSetProperties(this.token, this.groupKey, this.groupID, properties);
762
- }
763
-
764
- /**
765
- * Works just like groupSet() except it will not overwrite existing property values. This is useful for properties like "First login date".
766
- *
767
- * @param {string} prop The name of the Mixpanel property. This must be a String, for example "Zip Code"
768
- * @param {string} to The value to set on the given property name. For "Zip Code", this value might be the String "90210"
769
- */
770
- setOnce(prop, to) {
771
- let properties = {};
772
- if (ObjectHelper.isValid(prop)) {
773
- properties = JSON.parse(JSON.stringify(prop || {}));
774
- } else {
775
- if (!StringHelper.isValid(prop)) {
776
- StringHelper.raiseError(PARAMS.PROP);
777
- }
778
- properties[prop] = to;
779
- }
780
- MixpanelReactNative.groupSetPropertyOnce(this.token, this.groupKey, this.groupID, properties);
781
- }
782
-
783
- /**
784
- * Permanently removes the property with the given name from the group's profile
785
- *
786
- * @param {string} prop name of a property to unset
787
- */
788
- unset(prop) {
789
- if (!StringHelper.isValid(prop)) {
790
- StringHelper.raiseError(PARAMS.PROPERTY_NAME);
791
- }
792
- MixpanelReactNative.groupUnsetProperty(this.token, this.groupKey, this.groupID, prop);
793
- }
794
-
795
- /**
796
- * Remove value from a list-valued property only if it is already present in the list.
797
- * If the property does not currently exist, the remove will be ignored.
798
- * If the property exists and is not list-valued, the remove will be ignored.
799
- *
800
- * @param {string} name the Group Analytics list-valued property that should have a value removed
801
- * @param {any} value the value that will be removed from the list
802
- */
803
- remove(name, value) {
804
- if (!StringHelper.isValid(name)) {
805
- StringHelper.raiseError(PARAMS.PROPERTY_NAME);
806
- }
807
-
808
- MixpanelReactNative.groupRemovePropertyValue(this.token, this.groupKey, this.groupID, name, value);
809
- }
810
-
811
- /**
812
- * Adds values to a list-valued property only if they are not already present in the list.
813
- * If the property does not currently exist, it will be created with the given list as its value.
814
- * If the property exists and is not list-valued, the union will be ignored.
815
- *
816
- * @param {string} name name of the list-valued property to set or modify
817
- * @param {array} value an array of values to add to the property value if not already present
818
- */
819
- union(name, value) {
820
- if (!StringHelper.isValid(name)) {
821
- StringHelper.raiseError(PARAMS.PROPERTY_NAME);
822
- }
823
- value = Array.isArray(value) ? value : [value];
824
- MixpanelReactNative.groupUnionProperty(this.token, this.groupKey, this.groupID, name, value);
825
- }
826
-
784
+ constructor(token, groupKey, groupID) {
785
+ if (!StringHelper.isValid(token)) {
786
+ StringHelper.raiseError(PARAMS.TOKEN);
787
+ }
788
+ this.token = token;
789
+ this.groupKey = groupKey;
790
+ this.groupID = groupID;
791
+ }
792
+
793
+ /**
794
+ * Sets a single property with the given name and value for this group.
795
+ * The given name and value will be assigned to the user in Mixpanel Group Analytics,
796
+ * possibly overwriting an existing property with the same name.
797
+ *
798
+ * @param {string} prop The name of the Mixpanel property. This must be a String, for example "Zip Code"
799
+ * @param {string} to The value to set on the given property name. For "Zip Code", this value might be the String "90210"
800
+ */
801
+ set(prop, to) {
802
+ let properties = {};
803
+ if (ObjectHelper.isValid(prop)) {
804
+ properties = JSON.parse(JSON.stringify(prop || {}));
805
+ } else {
806
+ if (!StringHelper.isValid(prop)) {
807
+ StringHelper.raiseError(PARAMS.PROP);
808
+ }
809
+ properties[prop] = to;
810
+ }
811
+ MixpanelReactNative.groupSetProperties(
812
+ this.token,
813
+ this.groupKey,
814
+ this.groupID,
815
+ properties
816
+ );
817
+ }
818
+
819
+ /**
820
+ * Works just like groupSet() except it will not overwrite existing property values. This is useful for properties like "First login date".
821
+ *
822
+ * @param {string} prop The name of the Mixpanel property. This must be a String, for example "Zip Code"
823
+ * @param {string} to The value to set on the given property name. For "Zip Code", this value might be the String "90210"
824
+ */
825
+ setOnce(prop, to) {
826
+ let properties = {};
827
+ if (ObjectHelper.isValid(prop)) {
828
+ properties = JSON.parse(JSON.stringify(prop || {}));
829
+ } else {
830
+ if (!StringHelper.isValid(prop)) {
831
+ StringHelper.raiseError(PARAMS.PROP);
832
+ }
833
+ properties[prop] = to;
834
+ }
835
+ MixpanelReactNative.groupSetPropertyOnce(
836
+ this.token,
837
+ this.groupKey,
838
+ this.groupID,
839
+ properties
840
+ );
841
+ }
842
+
843
+ /**
844
+ * Permanently removes the property with the given name from the group's profile
845
+ *
846
+ * @param {string} prop name of a property to unset
847
+ */
848
+ unset(prop) {
849
+ if (!StringHelper.isValid(prop)) {
850
+ StringHelper.raiseError(PARAMS.PROPERTY_NAME);
851
+ }
852
+ MixpanelReactNative.groupUnsetProperty(
853
+ this.token,
854
+ this.groupKey,
855
+ this.groupID,
856
+ prop
857
+ );
858
+ }
859
+
860
+ /**
861
+ * Remove value from a list-valued property only if it is already present in the list.
862
+ * If the property does not currently exist, the remove will be ignored.
863
+ * If the property exists and is not list-valued, the remove will be ignored.
864
+ *
865
+ * @param {string} name the Group Analytics list-valued property that should have a value removed
866
+ * @param {any} value the value that will be removed from the list
867
+ */
868
+ remove(name, value) {
869
+ if (!StringHelper.isValid(name)) {
870
+ StringHelper.raiseError(PARAMS.PROPERTY_NAME);
871
+ }
872
+
873
+ MixpanelReactNative.groupRemovePropertyValue(
874
+ this.token,
875
+ this.groupKey,
876
+ this.groupID,
877
+ name,
878
+ value
879
+ );
880
+ }
881
+
882
+ /**
883
+ * Adds values to a list-valued property only if they are not already present in the list.
884
+ * If the property does not currently exist, it will be created with the given list as its value.
885
+ * If the property exists and is not list-valued, the union will be ignored.
886
+ *
887
+ * @param {string} name name of the list-valued property to set or modify
888
+ * @param {array} value an array of values to add to the property value if not already present
889
+ */
890
+ union(name, value) {
891
+ if (!StringHelper.isValid(name)) {
892
+ StringHelper.raiseError(PARAMS.PROPERTY_NAME);
893
+ }
894
+ value = Array.isArray(value) ? value : [value];
895
+ MixpanelReactNative.groupUnionProperty(
896
+ this.token,
897
+ this.groupKey,
898
+ this.groupID,
899
+ name,
900
+ value
901
+ );
902
+ }
827
903
  }
828
904
 
829
905
  class Helper {
830
- /**
906
+ /**
831
907
  Get the library data from package.json file.
832
908
  */
833
- static getMetaData() {
834
- let metadata = JSON.parse(JSON.stringify(packageJson.metadata));
835
- metadata["$lib_version"] = packageJson.version;
836
- return metadata;
837
- }
909
+ static getMetaData() {
910
+ let metadata = JSON.parse(JSON.stringify(packageJson.metadata));
911
+ metadata["$lib_version"] = packageJson.version;
912
+ return metadata;
913
+ }
838
914
 
839
- /**
915
+ /**
840
916
  Get current device platform.
841
917
  */
842
- static getDevicePlatform() {
843
- switch (Platform.OS) {
844
- case "android":
845
- return DevicePlatform.Android;
846
- case "ios":
847
- return DevicePlatform.iOS;
848
- default:
849
- return DevicePlatform.Unknown;
850
- }
918
+ static getDevicePlatform() {
919
+ switch (Platform.OS) {
920
+ case "android":
921
+ return DevicePlatform.Android;
922
+ case "ios":
923
+ return DevicePlatform.iOS;
924
+ default:
925
+ return DevicePlatform.Unknown;
851
926
  }
927
+ }
852
928
  }
853
929
 
854
930
  class StringHelper {
855
- /**
931
+ /**
856
932
  Check whether the parameter is not a blank string.
857
933
  */
858
- static isValid(str) {
859
- return typeof str === "string" && !(/^\s*$/).test(str);
860
- }
934
+ static isValid(str) {
935
+ return typeof str === "string" && !/^\s*$/.test(str);
936
+ }
861
937
 
862
- /**
938
+ /**
863
939
  Check whether the parameter is undefined or not a blank string.
864
940
  */
865
- static isValidOrUndefined(str) {
866
- return str === undefined || StringHelper.isValid(str);
867
- }
941
+ static isValidOrUndefined(str) {
942
+ return str === undefined || StringHelper.isValid(str);
943
+ }
868
944
 
869
- /**
945
+ /**
870
946
  Raise a string validation error.
871
947
  */
872
- static raiseError(paramName) {
873
- throw new Error(`${paramName}${ERROR_MESSAGE.INVALID_STRING}`);
874
- }
948
+ static raiseError(paramName) {
949
+ throw new Error(`${paramName}${ERROR_MESSAGE.INVALID_STRING}`);
950
+ }
875
951
  }
876
952
 
877
953
  class ObjectHelper {
878
- /**
954
+ /**
879
955
  Check whether the parameter is an object.
880
956
  */
881
- static isValid(obj) {
882
- return typeof obj === "object";
883
- }
957
+ static isValid(obj) {
958
+ return typeof obj === "object";
959
+ }
884
960
 
885
- /**
961
+ /**
886
962
  Check whether the parameter is undefined or an object.
887
963
  */
888
- static isValidOrUndefined(obj) {
889
- return obj === undefined || ObjectHelper.isValid(obj);
890
- }
964
+ static isValidOrUndefined(obj) {
965
+ return obj === undefined || ObjectHelper.isValid(obj);
966
+ }
891
967
 
892
- /**
968
+ /**
893
969
  Raise an object validation error.
894
970
  */
895
- static raiseError(paramName) {
896
- throw new Error(`${paramName}${ERROR_MESSAGE.INVALID_OBJECT}`);
897
- }
971
+ static raiseError(paramName) {
972
+ throw new Error(`${paramName}${ERROR_MESSAGE.INVALID_OBJECT}`);
973
+ }
898
974
  }