mixpanel-react-native 2.4.1 → 3.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.vscode/settings.json +4 -0
- package/CHANGELOG.md +84 -51
- package/README.md +9 -3
- package/Samples/MixpanelExpo/App.js +340 -0
- package/Samples/MixpanelExpo/app.json +30 -0
- package/Samples/MixpanelExpo/assets/adaptive-icon.png +0 -0
- package/Samples/MixpanelExpo/assets/favicon.png +0 -0
- package/Samples/MixpanelExpo/assets/icon.png +0 -0
- package/Samples/MixpanelExpo/assets/splash.png +0 -0
- package/Samples/MixpanelExpo/babel.config.js +6 -0
- package/Samples/MixpanelExpo/package-lock.json +22551 -0
- package/Samples/MixpanelExpo/package.json +25 -0
- package/__mocks__/@react-native-async-storage/async-storage.js +1 -0
- package/__tests__/core.test.js +135 -0
- package/__tests__/index.test.js +74 -42
- package/__tests__/jest_setup.js +23 -4
- package/__tests__/main.test.js +788 -0
- package/__tests__/network.test.js +72 -0
- package/__tests__/queue.test.js +65 -0
- package/docs/Mixpanel.html +42 -44
- package/docs/MixpanelGroup.html +7 -7
- package/docs/People.html +12 -12
- package/docs/index.html +5 -4
- package/docs/index.js.html +888 -793
- package/index.d.ts +75 -53
- package/index.js +89 -57
- package/javascript/mixpanel-config.js +102 -0
- package/javascript/mixpanel-constants.js +22 -0
- package/javascript/mixpanel-core.js +163 -0
- package/javascript/mixpanel-logger.js +35 -0
- package/javascript/mixpanel-main.js +550 -0
- package/javascript/mixpanel-network.js +86 -0
- package/javascript/mixpanel-persistent.js +312 -0
- package/javascript/mixpanel-queue.js +65 -0
- package/javascript/mixpanel-storage.js +36 -0
- package/javascript/mixpanel-utils.js +38 -0
- package/logs/.b11bf985d66a037ca5688a574653f3bf76a28dfa-audit.json +19 -0
- package/logs/.c366df74eeb671df60a57a2075ae40a3dae2af25-audit.json +19 -0
- package/package.json +11 -6
- package/release.py +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,68 @@
|
|
|
1
1
|
#
|
|
2
2
|
|
|
3
|
+
## [v3.0.0-beta.2](https://github.com/mixpanel/mixpanel-react-native/tree/v3.0.0-beta.2) (2024-03-06)
|
|
4
|
+
|
|
5
|
+
### Enhancements
|
|
6
|
+
- Add support to use custom storage instead of @react-native-async-storage/async-storage.(https://github.com/mixpanel/mixpanel-react-native/pull/225)
|
|
7
|
+
When JavaScript mode is enabled, Mixpanel utilizes [AsyncStorage](https://reactnative.dev/docs/asyncstorage) to persist data. If you prefer not to use it, or if AsyncStorage is unavailable in your target environment, you can import or define a different storage class. However, it must follow the same interface as [AsyncStorage](https://reactnative.dev/docs/asyncstorage) The following example demonstrates how to use a custom storage solution:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
const MyAsyncStorage = require("@my-org/<library-path>/AsyncStorage"); // or your own storage class
|
|
11
|
+
const trackAutomaticEvents = false;
|
|
12
|
+
const useNative = false;
|
|
13
|
+
const mixpanel = new Mixpanel('YOUR_TOKEN', trackAutomaticEvents, useNative, MyAsyncStorage);
|
|
14
|
+
mixpanel.init();
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Fixes
|
|
18
|
+
- Make `optOutTracking` and `optInTracking` consistent with the native SDK.(https://github.com/mixpanel/mixpanel-react-native/pull/225)
|
|
19
|
+
|
|
20
|
+
#
|
|
21
|
+
|
|
22
|
+
## [v3.0.0-beta.1](https://github.com/mixpanel/mixpanel-react-native/tree/v3.0.0-beta.1) (2024-02-29)
|
|
23
|
+
|
|
24
|
+
### Expo and React Native Web support
|
|
25
|
+
|
|
26
|
+
This version(PR [\#223](https://github.com/mixpanel/mixpanel-react-native/pull/223)) introduces support for Expo, React Native Web, and any platform using React Native that does not support iOS and Android. To activate this, initialize Mixpanel with an additional parameter `useNative` set to false, which will enable JavaScript mode. Currently in beta, we plan to iterate on this to address any issues and add more features. We welcome your feedback.
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
const trackAutomaticEvents = false;
|
|
30
|
+
const useNative = false;
|
|
31
|
+
const mixpanel = new Mixpanel(
|
|
32
|
+
"YOUR_MIXPANEL_TOKEN",
|
|
33
|
+
trackAutomaticEvents,
|
|
34
|
+
useNative
|
|
35
|
+
);
|
|
36
|
+
mixpanel.init();
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
To try the Expo sample app, navigate to `Samples/MixpanelExpo`, run `npm install`, and then execute `npm run ios` or `npm run android`
|
|
40
|
+
|
|
41
|
+
Known limitations and differences compared to the native mode (iOS/Android):
|
|
42
|
+
|
|
43
|
+
- Automatic Events are currently not supported in this mode. Setting 'trackAutomaticEvents' to 'true' will have no effect.
|
|
44
|
+
- Certain Mixpanel Properties are unavailable in Javascript mode, including detailed information about the device and screen.
|
|
45
|
+
- The default flush interval is set to 10 seconds. The data will not flush automatically when the app moves to the background. We recommend flushing more frequently for key events.
|
|
46
|
+
|
|
47
|
+
#
|
|
48
|
+
|
|
49
|
+
## [v2.4.1](https://github.com/mixpanel/mixpanel-react-native/tree/v2.4.1) (2024-03-01)
|
|
50
|
+
|
|
51
|
+
### Fixes
|
|
52
|
+
|
|
53
|
+
- Fix mp_lib(Mixpanel Library) not being set as `react-native`
|
|
54
|
+
|
|
55
|
+
#
|
|
56
|
+
|
|
57
|
+
## [v2.4.0](https://github.com/mixpanel/mixpanel-react-native/tree/v2.4.0) (2023-12-02)
|
|
58
|
+
|
|
59
|
+
### Enhancements
|
|
60
|
+
|
|
61
|
+
- add api: setFlushBatchSize [\#219](https://github.com/mixpanel/mixpanel-react-native/pull/219)
|
|
62
|
+
- RN 73 support for Android with AGP 8 required [\#215](https://github.com/mixpanel/mixpanel-react-native/pull/215)
|
|
63
|
+
|
|
64
|
+
#
|
|
65
|
+
|
|
3
66
|
## [v2.3.1](https://github.com/mixpanel/mixpanel-react-native/tree/v2.3.1) (2023-06-20)
|
|
4
67
|
|
|
5
68
|
### Fixes
|
|
@@ -62,8 +125,8 @@
|
|
|
62
125
|
## [v2.2.0](https://github.com/mixpanel/mixpanel-react-native/tree/v2.2.0) (2023-03-06)
|
|
63
126
|
|
|
64
127
|
### NOTE:
|
|
65
|
-
- From this version we will prefix randomly generated device-specific distinct_ids with "$device:". The prefix is applied the next time a new random ID is generated, any IDs generated by previous SDK versions and persisted on the device will continue to be used as-is until reset is called to generate a new ID. This does not change the value sent for the $device_id property, which will continue to be the randomly-generated ID without a prefix. Mixpanel's $identify endpoint has been updated to accept UUIDs with this prefix to coordinate with this change.
|
|
66
128
|
|
|
129
|
+
- From this version we will prefix randomly generated device-specific distinct_ids with "$device:". The prefix is applied the next time a new random ID is generated, any IDs generated by previous SDK versions and persisted on the device will continue to be used as-is until reset is called to generate a new ID. This does not change the value sent for the $device_id property, which will continue to be the randomly-generated ID without a prefix. Mixpanel's $identify endpoint has been updated to accept UUIDs with this prefix to coordinate with this change.
|
|
67
130
|
|
|
68
131
|
### Enhancements
|
|
69
132
|
|
|
@@ -89,7 +152,8 @@
|
|
|
89
152
|
|
|
90
153
|
## [v2.0.0](https://github.com/mixpanel/mixpanel-react-native/tree/v2.0.0) (2022-09-09)
|
|
91
154
|
|
|
92
|
-
### BREAKING CHANGE:
|
|
155
|
+
### BREAKING CHANGE:
|
|
156
|
+
|
|
93
157
|
This major release removes all remaining calls to Mixpanel's `/decide` API endpoint. The main effect of this is that the SDK no longer fetches the remote status of your [project's "Automatically collect common mobile events" setting](https://help.mixpanel.com/hc/en-us/articles/115004596186#enable-or-disable-common-mobile-events). From this version forward, automatic event tracking can only be controlled by the, now required, parameter `trackAutomaticEvents`. Upon upgrading, existing implementations will need to add this parameter to their Mixpanel initializer calls.
|
|
94
158
|
|
|
95
159
|
### Enhancements
|
|
@@ -102,7 +166,7 @@ This major release removes all remaining calls to Mixpanel's `/decide` API endpo
|
|
|
102
166
|
|
|
103
167
|
### Enhancements
|
|
104
168
|
|
|
105
|
-
-
|
|
169
|
+
- bump versions to get millisecond precision for event time property [\#146](https://github.com/mixpanel/mixpanel-react-native/pull/146)
|
|
106
170
|
|
|
107
171
|
#
|
|
108
172
|
|
|
@@ -128,7 +192,7 @@ This major release removes all remaining calls to Mixpanel's `/decide` API endpo
|
|
|
128
192
|
|
|
129
193
|
- Bump to latest ios and android sdk versions and remove android people identify\(deprecated\) [\#137](https://github.com/mixpanel/mixpanel-react-native/pull/137)
|
|
130
194
|
- Allow disable flush on background [\#135](https://github.com/mixpanel/mixpanel-react-native/pull/135)
|
|
131
|
-
- Adds
|
|
195
|
+
- Adds a new API `getDeviceId` for React Native [\#134](https://github.com/mixpanel/mixpanel-react-native/pull/134)
|
|
132
196
|
|
|
133
197
|
#
|
|
134
198
|
|
|
@@ -165,11 +229,12 @@ This major release removes all remaining calls to Mixpanel's `/decide` API endpo
|
|
|
165
229
|
#
|
|
166
230
|
|
|
167
231
|
## [v1.3.6](https://github.com/mixpanel/mixpanel-react-native/tree/v1.3.6) (2022-01-13)
|
|
232
|
+
|
|
168
233
|
### Caution: Please DO NOT use this build! In this version, we have a bug in iOS that event names with `&` or `%` will be rejected by the server. We recommend you update to 1.3.7 or above.
|
|
169
234
|
|
|
170
235
|
### Fixes
|
|
171
236
|
|
|
172
|
-
- Fix common mobile events not showing
|
|
237
|
+
- Fix common mobile events not showing 'react-native' as property value for 'Mixpanel Library' [\#122](https://github.com/mixpanel/mixpanel-react-native/pull/122)
|
|
173
238
|
|
|
174
239
|
#
|
|
175
240
|
|
|
@@ -254,85 +319,53 @@ This major release removes all remaining calls to Mixpanel's `/decide` API endpo
|
|
|
254
319
|
## [v1.2.3](https://github.com/mixpanel/mixpanel-react-native/tree/v1.2.3) (2021-05-20)
|
|
255
320
|
|
|
256
321
|
- Bump Mixpanel Andriod dependency to 5.9.1 (Migrate to Airship 12.x for the integration)
|
|
257
|
-
https://github.com/mixpanel/mixpanel-react-native/pull/59
|
|
322
|
+
https://github.com/mixpanel/mixpanel-react-native/pull/59
|
|
258
323
|
|
|
259
324
|
#
|
|
260
325
|
|
|
261
326
|
## [v1.2.2](https://github.com/mixpanel/mixpanel-react-native/tree/v1.2.2) (2021-05-08)
|
|
262
327
|
|
|
263
328
|
- Fix Mixpanel type conversion for ios
|
|
264
|
-
https://github.com/mixpanel/mixpanel-react-native/pull/48
|
|
329
|
+
https://github.com/mixpanel/mixpanel-react-native/pull/48
|
|
265
330
|
- Fix iOS compile error
|
|
266
|
-
https://github.com/mixpanel/mixpanel-react-native/pull/53
|
|
331
|
+
https://github.com/mixpanel/mixpanel-react-native/pull/53
|
|
267
332
|
|
|
268
333
|
#
|
|
269
334
|
|
|
270
335
|
## [v1.2.0](https://github.com/mixpanel/mixpanel-react-native/tree/v1.2.0) (2021-05-03)
|
|
271
336
|
|
|
272
337
|
- Add new settings APIs: setUseIpAddressForGeolocation, setLoggingEnabled(add android), setServerURL(add android)
|
|
273
|
-
https://github.com/mixpanel/mixpanel-react-native/pull/44
|
|
338
|
+
https://github.com/mixpanel/mixpanel-react-native/pull/44
|
|
274
339
|
|
|
275
340
|
#
|
|
276
341
|
|
|
277
342
|
## [v1.1.1](https://github.com/mixpanel/mixpanel-react-native/tree/v1.1.1) (2021-03-17)
|
|
343
|
+
|
|
278
344
|
- Fix the issue of passing boolean value as int in iOS
|
|
279
|
-
https://github.com/mixpanel/mixpanel-react-native/pull/34
|
|
345
|
+
https://github.com/mixpanel/mixpanel-react-native/pull/34
|
|
280
346
|
|
|
281
347
|
#
|
|
282
348
|
|
|
283
349
|
## [v1.1.0](https://github.com/mixpanel/mixpanel-react-native/tree/v1.1.0) (2021-03-03)
|
|
350
|
+
|
|
284
351
|
- Add Typescript support
|
|
285
352
|
- https://github.com/mixpanel/mixpanel-react-native/pull/31. thanks @sroy3 !
|
|
286
353
|
|
|
287
354
|
#
|
|
288
355
|
|
|
289
356
|
## [v1.0.2](https://github.com/mixpanel/mixpanel-react-native/tree/v1.0.2) (2021-01-27)
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
357
|
+
|
|
358
|
+
- Fix dynamic type not being able to convert properly in android that causes some group apis to fail
|
|
359
|
+
PR: https://github.com/mixpanel/mixpanel-react-native/pull/23
|
|
360
|
+
This is to address issue: https://github.com/mixpanel/mixpanel-react-native/issues/21
|
|
293
361
|
|
|
294
362
|
#
|
|
295
363
|
|
|
296
364
|
## [v1.0.0](https://github.com/mixpanel/mixpanel-react-native/tree/v1.0.0) (2020-12-08)
|
|
297
|
-
|
|
298
|
-
|
|
365
|
+
|
|
366
|
+
- This is our first release! :tada::tada::tada:
|
|
367
|
+
Report issues or give us any feedback is appreciated!
|
|
299
368
|
- integration guide: https://developer.mixpanel.com/docs/react-native
|
|
300
369
|
- full API reference: https://mixpanel.github.io/mixpanel-react-native
|
|
301
370
|
|
|
302
371
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ To start tracking with the library you must first initialize with your project t
|
|
|
55
55
|
```js
|
|
56
56
|
import { Mixpanel } from 'mixpanel-react-native';
|
|
57
57
|
|
|
58
|
-
const trackAutomaticEvents =
|
|
58
|
+
const trackAutomaticEvents = false;
|
|
59
59
|
const mixpanel = new Mixpanel("Your Project Token", trackAutomaticEvents);
|
|
60
60
|
mixpanel.init();
|
|
61
61
|
|
|
@@ -82,7 +82,7 @@ import React from 'react';
|
|
|
82
82
|
import { Button, SafeAreaView } from "react-native";
|
|
83
83
|
import { Mixpanel } from 'mixpanel-react-native';
|
|
84
84
|
|
|
85
|
-
const trackAutomaticEvents =
|
|
85
|
+
const trackAutomaticEvents = false;
|
|
86
86
|
const mixpanel = new Mixpanel("Your Project Token", trackAutomaticEvents);
|
|
87
87
|
mixpanel.init();
|
|
88
88
|
|
|
@@ -100,7 +100,13 @@ const SampleApp = () => {
|
|
|
100
100
|
export default SampleApp;
|
|
101
101
|
|
|
102
102
|
```
|
|
103
|
-
###
|
|
103
|
+
### Expo and React Native for Web support
|
|
104
|
+
Starting from version 3.0.0, we have introduced support for Expo, React Native for Web, and other platforms utilizing React Native that do not support iOS and Android directly. To enable this feature, initialize Mixpanel with an additional parameter, `useNative`, set to false(```const mixpanel = new Mixpanel(
|
|
105
|
+
"YOUR_MIXPANEL_TOKEN",
|
|
106
|
+
trackAutomaticEvents,
|
|
107
|
+
useNative
|
|
108
|
+
);```). This will activate JavaScript mode. Please note that this functionality is currently in beta testing. For further details and installation guidelines, refer to the release notes available at Mixpanel React Native [v3.0.0-beta.1](https://github.com/mixpanel/mixpanel-react-native/releases/tag/v3.0.0-beta.1).
|
|
109
|
+
|
|
104
110
|
👋 👋 Tell us about the Mixpanel developer experience! [https://www.mixpanel.com/devnps](https://www.mixpanel.com/devnps) 👍 👎
|
|
105
111
|
|
|
106
112
|
|
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {
|
|
3
|
+
SectionList,
|
|
4
|
+
Text,
|
|
5
|
+
View,
|
|
6
|
+
Button,
|
|
7
|
+
StyleSheet,
|
|
8
|
+
SafeAreaView,
|
|
9
|
+
} from "react-native";
|
|
10
|
+
|
|
11
|
+
import {Mixpanel} from "mixpanel-react-native";
|
|
12
|
+
|
|
13
|
+
const App = () => {
|
|
14
|
+
const trackAutomaticEvents = false;
|
|
15
|
+
const useNative = false;
|
|
16
|
+
const mixpanel = new Mixpanel(
|
|
17
|
+
"YOUR_MIXPANEL_TOKEN",
|
|
18
|
+
trackAutomaticEvents,
|
|
19
|
+
useNative
|
|
20
|
+
);
|
|
21
|
+
mixpanel.init();
|
|
22
|
+
mixpanel.setLoggingEnabled(true);
|
|
23
|
+
|
|
24
|
+
const group = mixpanel.getGroup("company_id", 111);
|
|
25
|
+
const track = async () => {
|
|
26
|
+
await mixpanel.track("Track Event!");
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const identify = async () => {
|
|
30
|
+
await mixpanel.identify("testDistinctId");
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const timeEvent = () => {
|
|
34
|
+
const eventName = "Timed Event";
|
|
35
|
+
mixpanel.timeEvent(eventName);
|
|
36
|
+
setTimeout(async () => {
|
|
37
|
+
await mixpanel.track(eventName);
|
|
38
|
+
}, 2000);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const createAlias = async () => {
|
|
42
|
+
const distinctId = await mixpanel.getDistinctId();
|
|
43
|
+
alert(distinctId);
|
|
44
|
+
await mixpanel.alias("New Alias", distinctId);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const trackWProperties = async () => {
|
|
48
|
+
const properties = {"Cool Property": "Property Value"};
|
|
49
|
+
await mixpanel.track("Track event with property", properties);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
registerSuperProperties will store a new superProperty and possibly overwriting any existing superProperty with the same name.
|
|
54
|
+
*/
|
|
55
|
+
const registerSuperProperties = () => {
|
|
56
|
+
mixpanel.registerSuperProperties({
|
|
57
|
+
"super property": "super property value",
|
|
58
|
+
"super property1": "super property value1",
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
Erase all currently registered superProperties.
|
|
63
|
+
*/
|
|
64
|
+
const clearSuperProperties = () => {
|
|
65
|
+
mixpanel.clearSuperProperties();
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const unregisterSuperProperty = () => {
|
|
69
|
+
mixpanel.unregisterSuperProperty("super property");
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
Returns a json object of the user's current super properties.
|
|
73
|
+
*/
|
|
74
|
+
const getSuperProperties = () => {
|
|
75
|
+
mixpanel.getSuperProperties().then((t) => {
|
|
76
|
+
alert(JSON.stringify(t));
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const registerSuperPropertiesOnce = () => {
|
|
81
|
+
mixpanel.registerSuperPropertiesOnce({
|
|
82
|
+
"super property": "super property value1",
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const flush = () => {
|
|
87
|
+
mixpanel.flush();
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
const optIn = () => {
|
|
91
|
+
mixpanel.optInTracking(mixpanel.getDistinctId());
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const optOut = () => {
|
|
95
|
+
mixpanel.optOutTracking();
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const reset = () => {
|
|
99
|
+
mixpanel.reset();
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const setProperty = () => {
|
|
103
|
+
mixpanel.getPeople().set({
|
|
104
|
+
a: 1,
|
|
105
|
+
b: 2.3,
|
|
106
|
+
c: ["4", 5],
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const setOneProperty = () => {
|
|
111
|
+
mixpanel.getPeople().set("d", "yo");
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const setOnePropertyOnce = () => {
|
|
115
|
+
mixpanel.getPeople().setOnce("c", "just once");
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
const unsetProperties = () => {
|
|
119
|
+
mixpanel.getPeople().unset("a");
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const incrementProperty = () => {
|
|
123
|
+
mixpanel.getPeople().increment("a", 2.2);
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const removePropertyValue = () => {
|
|
127
|
+
mixpanel.getPeople().remove("c", 5);
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const appendProperties = () => {
|
|
131
|
+
mixpanel.getPeople().append("a", "Hello");
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
const unionProperties = () => {
|
|
135
|
+
mixpanel.getPeople().union("a", ["goodbye", "hi"]);
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
const trackChargeWithoutProperties = () => {
|
|
139
|
+
mixpanel.getPeople().trackCharge(22.8);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
const trackCharge = () => {
|
|
143
|
+
mixpanel.getPeople().trackCharge(12.8, {sandwich: 1});
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const clearCharges = () => {
|
|
147
|
+
mixpanel.getPeople().clearCharges();
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const deleteUser = () => {
|
|
151
|
+
mixpanel.getPeople().deleteUser();
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// ----------------- Group API -----------------
|
|
155
|
+
const addGroup = () => {
|
|
156
|
+
mixpanel.addGroup("company_id", 111);
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const deleteGroup = () => {
|
|
160
|
+
mixpanel.deleteGroup("company_id", 111);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const setGroup = () => {
|
|
164
|
+
mixpanel.setGroup("company_id", 3233);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const removeGroup = () => {
|
|
168
|
+
mixpanel.removeGroup("company_id", 3233);
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
const setGroupProperty = () => {
|
|
172
|
+
group.set("prop_key", "prop_value1");
|
|
173
|
+
group.set("prop_key1", ["prop_value11", "prop_value12"]);
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const setGroupPropertyOnce = () => {
|
|
177
|
+
group.setOnce("prop_key", "prop_value222");
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const unsetGroupProperty = () => {
|
|
181
|
+
group.unset("aaa");
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const removeGroupProperty = () => {
|
|
185
|
+
group.remove("prop_key1", "prop_value11");
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const unionGroupProperty = () => {
|
|
189
|
+
group.union("prop_key", ["prop_value_a", "prop_value_b"]);
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const trackWithGroups = () => {
|
|
193
|
+
mixpanel.trackWithGroups(
|
|
194
|
+
"tracked with groups",
|
|
195
|
+
{a: 1, b: 2.3},
|
|
196
|
+
{company_id: 111}
|
|
197
|
+
);
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
const DATA = [
|
|
201
|
+
{
|
|
202
|
+
title: "Events and Properties",
|
|
203
|
+
data: [
|
|
204
|
+
{id: "1", label: "Track Event", onPress: track},
|
|
205
|
+
{id: "2", label: "Identify", onPress: identify},
|
|
206
|
+
{id: "3", label: "Time Event for 2 secs", onPress: timeEvent},
|
|
207
|
+
{
|
|
208
|
+
id: "4",
|
|
209
|
+
label: "Track Event with Properties",
|
|
210
|
+
onPress: trackWProperties,
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
id: "5",
|
|
214
|
+
label: "Register Super Properties",
|
|
215
|
+
onPress: registerSuperProperties,
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
id: "6",
|
|
219
|
+
label: "Clear Super Properties",
|
|
220
|
+
onPress: clearSuperProperties,
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
id: "7",
|
|
224
|
+
label: "Unregister Super Property",
|
|
225
|
+
onPress: unregisterSuperProperty,
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
id: "8",
|
|
229
|
+
label: "Get Super Properties",
|
|
230
|
+
onPress: getSuperProperties,
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
id: "9",
|
|
234
|
+
label: "Register Super Properties Once",
|
|
235
|
+
onPress: registerSuperPropertiesOnce,
|
|
236
|
+
},
|
|
237
|
+
{id: "10", label: "Create Alias", onPress: createAlias},
|
|
238
|
+
{id: "11", label: "Flush", onPress: flush},
|
|
239
|
+
],
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
title: "GDPR",
|
|
243
|
+
data: [
|
|
244
|
+
{id: "1", label: "Opt In", onPress: optIn},
|
|
245
|
+
{id: "2", label: "Opt Out", onPress: optOut},
|
|
246
|
+
],
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
title: "Profile",
|
|
250
|
+
data: [
|
|
251
|
+
{id: "2", label: "Set Property", onPress: setProperty},
|
|
252
|
+
{id: "3", label: "Set One Property", onPress: setOneProperty},
|
|
253
|
+
{
|
|
254
|
+
id: "4",
|
|
255
|
+
label: "Set One Property Once",
|
|
256
|
+
onPress: setOnePropertyOnce,
|
|
257
|
+
},
|
|
258
|
+
{id: "5", label: "Unset Properties", onPress: unsetProperties},
|
|
259
|
+
{id: "6", label: "Increment Property", onPress: incrementProperty},
|
|
260
|
+
{
|
|
261
|
+
id: "7",
|
|
262
|
+
label: "Remove Property Value",
|
|
263
|
+
onPress: removePropertyValue,
|
|
264
|
+
},
|
|
265
|
+
{id: "8", label: "Append Properties", onPress: appendProperties},
|
|
266
|
+
{id: "9", label: "Union Properties", onPress: unionProperties},
|
|
267
|
+
{
|
|
268
|
+
id: "10",
|
|
269
|
+
label: "Track Charge",
|
|
270
|
+
onPress: trackChargeWithoutProperties,
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
id: "11",
|
|
274
|
+
label: "Track Charge with Properties",
|
|
275
|
+
onPress: trackCharge,
|
|
276
|
+
},
|
|
277
|
+
{id: "12", label: "Clear Charges", onPress: clearCharges},
|
|
278
|
+
{id: "1", label: "Reset", onPress: reset},
|
|
279
|
+
{id: "13", label: "Delete User", onPress: deleteUser},
|
|
280
|
+
{id: "14", label: "Flush", onPress: flush},
|
|
281
|
+
],
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
title: "Group",
|
|
285
|
+
data: [
|
|
286
|
+
{id: "1", label: "Add Group", onPress: addGroup},
|
|
287
|
+
{id: "2", label: "Set Group", onPress: setGroup},
|
|
288
|
+
{id: "3", label: "Remove Group", onPress: removeGroup},
|
|
289
|
+
{id: "4", label: "Delete Group", onPress: deleteGroup},
|
|
290
|
+
{id: "5", label: "Track With Groups", onPress: trackWithGroups},
|
|
291
|
+
{id: "6", label: "Set Group Property", onPress: setGroupProperty},
|
|
292
|
+
{id: "7", label: "Set Property Once", onPress: setGroupPropertyOnce},
|
|
293
|
+
{id: "8", label: "Unset Property", onPress: unsetGroupProperty},
|
|
294
|
+
{id: "9", label: "Remove Property", onPress: removeGroupProperty},
|
|
295
|
+
{id: "10", label: "Union Property", onPress: unionGroupProperty},
|
|
296
|
+
{id: "11", label: "Flush", onPress: flush},
|
|
297
|
+
],
|
|
298
|
+
},
|
|
299
|
+
];
|
|
300
|
+
|
|
301
|
+
const renderItem = ({item}) => (
|
|
302
|
+
<View style={styles.item}>
|
|
303
|
+
<Button title={item.label} onPress={item.onPress} color="#8A2BE2" />
|
|
304
|
+
</View>
|
|
305
|
+
);
|
|
306
|
+
|
|
307
|
+
const renderSectionHeader = ({section: {title}}) => (
|
|
308
|
+
<Text style={styles.header}>{title}</Text>
|
|
309
|
+
);
|
|
310
|
+
|
|
311
|
+
return (
|
|
312
|
+
<SafeAreaView style={styles.container}>
|
|
313
|
+
<SectionList
|
|
314
|
+
sections={DATA}
|
|
315
|
+
keyExtractor={(item, index) => item.id}
|
|
316
|
+
renderItem={renderItem}
|
|
317
|
+
renderSectionHeader={renderSectionHeader}
|
|
318
|
+
/>
|
|
319
|
+
</SafeAreaView>
|
|
320
|
+
);
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
const styles = StyleSheet.create({
|
|
324
|
+
container: {
|
|
325
|
+
flex: 1,
|
|
326
|
+
},
|
|
327
|
+
header: {
|
|
328
|
+
fontSize: 20,
|
|
329
|
+
backgroundColor: "#f4f4f4",
|
|
330
|
+
padding: 10,
|
|
331
|
+
},
|
|
332
|
+
item: {
|
|
333
|
+
backgroundColor: "#ffffff",
|
|
334
|
+
padding: 10,
|
|
335
|
+
borderBottomWidth: 1,
|
|
336
|
+
borderBottomColor: "#eeeeee",
|
|
337
|
+
},
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
export default App;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"expo": {
|
|
3
|
+
"name": "MixpanelExpo",
|
|
4
|
+
"slug": "MixpanelExpo",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"orientation": "portrait",
|
|
7
|
+
"icon": "./assets/icon.png",
|
|
8
|
+
"userInterfaceStyle": "light",
|
|
9
|
+
"splash": {
|
|
10
|
+
"image": "./assets/splash.png",
|
|
11
|
+
"resizeMode": "contain",
|
|
12
|
+
"backgroundColor": "#ffffff"
|
|
13
|
+
},
|
|
14
|
+
"assetBundlePatterns": [
|
|
15
|
+
"**/*"
|
|
16
|
+
],
|
|
17
|
+
"ios": {
|
|
18
|
+
"supportsTablet": true
|
|
19
|
+
},
|
|
20
|
+
"android": {
|
|
21
|
+
"adaptiveIcon": {
|
|
22
|
+
"foregroundImage": "./assets/adaptive-icon.png",
|
|
23
|
+
"backgroundColor": "#ffffff"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"web": {
|
|
27
|
+
"favicon": "./assets/favicon.png"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|