Skip to content

Commit 31f7fe2

Browse files
Merge pull request #153 from mixpanel/jared-deprecate-decide
make trackAutomaticEvents required and bump versions to deprecate Decide
2 parents 267f6b2 + 4e4d48f commit 31f7fe2

File tree

10 files changed

+151
-146
lines changed

10 files changed

+151
-146
lines changed

MixpanelReactNative.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ Pod::Spec.new do |s|
1919
s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
2020

2121
s.dependency "React"
22-
s.dependency "Mixpanel-swift", '3.3.0'
22+
s.dependency "Mixpanel-swift", '4.0.1'
2323
end

Samples/ContextAPIMixpanel/Analytics.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ export const MixpanelProvider = ({children}) => {
99
const [mixpanel, setMixpanel] = React.useState(null);
1010

1111
React.useEffect(() => {
12-
const mixpanelInstance = new Mixpanel(`Your Project Token`);
12+
const trackAutomaticEvents = true;
13+
const mixpanelInstance = new Mixpanel(`Your Project Token`, trackAutomaticEvents);
1314
mixpanelInstance.init();
1415
setMixpanel(mixpanelInstance);
1516
}, []);

Samples/MixpanelDemo/Analytics.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import {Mixpanel} from 'mixpanel-react-native';
2-
import {token as MixpanelToken} from './app.json';
2+
import {token as MixpanelToken, trackAutomaticEvents} from './app.json';
33

44

55
export class MixpanelManager {
66
static sharedInstance = MixpanelManager.sharedInstance || new MixpanelManager();
77

88
constructor() {
9-
this.mixpanel = new Mixpanel(MixpanelToken);
9+
this.mixpanel = new Mixpanel(MixpanelToken, trackAutomaticEvents);
1010
this.mixpanel.init();
1111
this.mixpanel.setLoggingEnabled(true);
1212
}

Samples/MixpanelDemo/app.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "MixpanelDemo",
33
"displayName": "MixpanelDemo",
4-
"token": "YOUR_PROJECT_TOKEN"
4+
"token": "YOUR_PROJECT_TOKEN",
5+
"trackAutomaticEvents": true
56
}

Samples/SimpleMixpanel/App.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import React, { Component } from 'react';
22
import { Button, SafeAreaView } from "react-native";
33
import { Mixpanel } from 'mixpanel-react-native';
44

5-
const mixpanel = new Mixpanel("Your Project Token");
5+
const trackAutomaticEvents = true;
6+
const mixpanel = new Mixpanel("Your Project Token", trackAutomaticEvents);
67
mixpanel.init();
78

89
// *************************************

__tests__/index.test.js

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -8,103 +8,103 @@ import { NativeModules } from 'react-native';
88

99

1010
test(`it calls MixpanelReactNative initialize`, async () => {
11-
const mixpanel = await Mixpanel.init("token");
12-
expect(NativeModules.MixpanelReactNative.initialize).toBeCalledWith("token", false, {"$lib_version": "1.5.0", "mp_lib": "react-native"});
11+
const mixpanel = await Mixpanel.init("token", true);
12+
expect(NativeModules.MixpanelReactNative.initialize).toBeCalledWith("token", true, false, {"$lib_version": "1.5.0", "mp_lib": "react-native"});
1313
});
1414

1515
test(`it calls MixpanelReactNative initialize with optOut and superProperties`, async () => {
16-
const mixpanel = new Mixpanel("token");
16+
const mixpanel = new Mixpanel("token", true);
1717
mixpanel.init(true, {"super": "property"})
18-
expect(NativeModules.MixpanelReactNative.initialize).toBeCalledWith("token", true, {"$lib_version": "1.5.0", "mp_lib": "react-native", "super": "property"});
18+
expect(NativeModules.MixpanelReactNative.initialize).toBeCalledWith("token", true, true, {"$lib_version": "1.5.0", "mp_lib": "react-native", "super": "property"});
1919
});
2020

2121
test(`it calls MixpanelReactNative setServerURL`, async () => {
22-
const mixpanel = await Mixpanel.init("token");
22+
const mixpanel = await Mixpanel.init("token", true);
2323
mixpanel.setServerURL("https://api-eu.mixpanel.com");
2424
expect(NativeModules.MixpanelReactNative.setServerURL).toBeCalledWith("token", "https://api-eu.mixpanel.com");
2525
});
2626

2727
test(`it calls MixpanelReactNative setLoggingEnabled`, async () => {
28-
const mixpanel = await Mixpanel.init("token");
28+
const mixpanel = await Mixpanel.init("token", true);
2929
mixpanel.setLoggingEnabled(true);
3030
expect(NativeModules.MixpanelReactNative.setLoggingEnabled).toBeCalledWith("token", true);
3131
});
3232

3333
test(`it calls MixpanelReactNative setUseIpAddressForGeolocation`, async () => {
34-
const mixpanel = await Mixpanel.init("token");
34+
const mixpanel = await Mixpanel.init("token", true);
3535
mixpanel.setUseIpAddressForGeolocation(true);
3636
expect(NativeModules.MixpanelReactNative.setUseIpAddressForGeolocation).toBeCalledWith("token", true);
3737
});
3838

3939
test(`it calls MixpanelReactNative hasOptedOutTracking`, async () => {
40-
const mixpanel = await Mixpanel.init("token");
40+
const mixpanel = await Mixpanel.init("token", true);
4141
mixpanel.hasOptedOutTracking();
4242
expect(NativeModules.MixpanelReactNative.hasOptedOutTracking).toBeCalledWith("token");
4343
});
4444

4545

4646
test(`it calls MixpanelReactNative optInTracking`, async () => {
47-
const mixpanel = await Mixpanel.init("token");
47+
const mixpanel = await Mixpanel.init("token", true);
4848
mixpanel.optInTracking();
4949
expect(NativeModules.MixpanelReactNative.optInTracking).toBeCalledWith("token");
5050
});
5151

5252
test(`it calls MixpanelReactNative optOutTracking`, async () => {
53-
const mixpanel = await Mixpanel.init("token");
53+
const mixpanel = await Mixpanel.init("token", true);
5454
mixpanel.optOutTracking();
5555
expect(NativeModules.MixpanelReactNative.optOutTracking).toBeCalledWith("token");
5656
});
5757

5858
test(`it calls MixpanelReactNative identify`, async () => {
59-
const mixpanel = await Mixpanel.init("token");
59+
const mixpanel = await Mixpanel.init("token", true);
6060
mixpanel.identify("distinct_id");
6161
expect(NativeModules.MixpanelReactNative.identify).toBeCalledWith("token", "distinct_id");
6262
});
6363

6464
test(`it calls MixpanelReactNative alias`, async () => {
65-
const mixpanel = await Mixpanel.init("token");
65+
const mixpanel = await Mixpanel.init("token", true);
6666
mixpanel.alias("alias", "distinct_id");
6767
expect(NativeModules.MixpanelReactNative.alias).toBeCalledWith("token", "alias", "distinct_id");
6868
});
6969

7070
test(`it calls MixpanelReactNative track`, async () => {
71-
const mixpanel = await Mixpanel.init("token");
71+
const mixpanel = await Mixpanel.init("token", true);
7272
mixpanel.track("event name", {"Cool Property": "Property Value"});
7373
expect(NativeModules.MixpanelReactNative.track).toBeCalledWith("token", "event name", {"Cool Property": "Property Value"});
7474
});
7575

7676
test(`it calls MixpanelReactNative trackWithGroups`, async () => {
77-
const mixpanel = await Mixpanel.init("token");
77+
const mixpanel = await Mixpanel.init("token", true);
7878
mixpanel.trackWithGroups("tracked with groups", {"a": 1, "b": 2.3}, {"company_id": "Mixpanel"});
7979
expect(NativeModules.MixpanelReactNative.trackWithGroups).toBeCalledWith("token", "tracked with groups", {"a": 1, "b": 2.3}, {"company_id": "Mixpanel"});
8080
});
8181

8282
test(`it calls MixpanelReactNative setGroup`, async () => {
83-
const mixpanel = await Mixpanel.init("token");
83+
const mixpanel = await Mixpanel.init("token", true);
8484
mixpanel.setGroup("company_id", 12345);
8585
expect(NativeModules.MixpanelReactNative.setGroup).toBeCalledWith("token", "company_id", 12345);
8686
});
8787

8888
test(`it calls MixpanelReactNative addGroup`, async () => {
89-
const mixpanel = await Mixpanel.init("token");
89+
const mixpanel = await Mixpanel.init("token", true);
9090
mixpanel.addGroup("company_id", 12345);
9191
expect(NativeModules.MixpanelReactNative.addGroup).toBeCalledWith("token", "company_id", 12345);
9292
});
9393

9494
test(`it calls MixpanelReactNative removeGroup`, async () => {
95-
const mixpanel = await Mixpanel.init("token");
95+
const mixpanel = await Mixpanel.init("token", true);
9696
mixpanel.removeGroup("company_id", 12345);
9797
expect(NativeModules.MixpanelReactNative.removeGroup).toBeCalledWith("token", "company_id", 12345);
9898
});
9999

100100
test(`it calls MixpanelReactNative deleteGroup`, async () => {
101-
const mixpanel = await Mixpanel.init("token");
101+
const mixpanel = await Mixpanel.init("token", true);
102102
mixpanel.deleteGroup("company_id", 12345);
103103
expect(NativeModules.MixpanelReactNative.deleteGroup).toBeCalledWith("token", "company_id", 12345);
104104
});
105105

106106
test(`it calls MixpanelReactNative registerSuperProperties`, async () => {
107-
const mixpanel = await Mixpanel.init("token");
107+
const mixpanel = await Mixpanel.init("token", true);
108108
mixpanel.registerSuperProperties({
109109
"super property": "super property value",
110110
"super property1": "super property value1",
@@ -116,7 +116,7 @@ test(`it calls MixpanelReactNative registerSuperProperties`, async () => {
116116
});
117117

118118
test(`it calls MixpanelReactNative registerSuperPropertiesOnce`, async () => {
119-
const mixpanel = await Mixpanel.init("token");
119+
const mixpanel = await Mixpanel.init("token", true);
120120
mixpanel.registerSuperPropertiesOnce({
121121
"super property": "super property value",
122122
"super property1": "super property value1",
@@ -128,49 +128,49 @@ test(`it calls MixpanelReactNative registerSuperPropertiesOnce`, async () => {
128128
});
129129

130130
test(`it calls MixpanelReactNative unregisterSuperProperty`, async () => {
131-
const mixpanel = await Mixpanel.init("token");
131+
const mixpanel = await Mixpanel.init("token", true);
132132
mixpanel.unregisterSuperProperty("super property");
133133
expect(NativeModules.MixpanelReactNative.unregisterSuperProperty).toBeCalledWith("token", "super property");
134134
});
135135

136136
test(`it calls MixpanelReactNative getSuperProperties`, async () => {
137-
const mixpanel = await Mixpanel.init("token");
137+
const mixpanel = await Mixpanel.init("token", true);
138138
mixpanel.getSuperProperties();
139139
expect(NativeModules.MixpanelReactNative.getSuperProperties).toBeCalledWith("token");
140140
});
141141

142142
test(`it calls MixpanelReactNative clearSuperProperties`, async () => {
143-
const mixpanel = await Mixpanel.init("token");
143+
const mixpanel = await Mixpanel.init("token", true);
144144
mixpanel.clearSuperProperties();
145145
expect(NativeModules.MixpanelReactNative.clearSuperProperties).toBeCalledWith("token");
146146
});
147147

148148
test(`it calls MixpanelReactNative timeEvent`, async () => {
149-
const mixpanel = await Mixpanel.init("token");
149+
const mixpanel = await Mixpanel.init("token", true);
150150
mixpanel.timeEvent("Timed Event");
151151
expect(NativeModules.MixpanelReactNative.timeEvent).toBeCalledWith("token", "Timed Event");
152152
});
153153

154154
test(`it calls MixpanelReactNative eventElapsedTime`, async () => {
155-
const mixpanel = await Mixpanel.init("token");
155+
const mixpanel = await Mixpanel.init("token", true);
156156
mixpanel.eventElapsedTime("Timed Event");
157157
expect(NativeModules.MixpanelReactNative.eventElapsedTime).toBeCalledWith("token", "Timed Event");
158158
});
159159

160160
test(`it calls MixpanelReactNative reset`, async () => {
161-
const mixpanel = await Mixpanel.init("token");
161+
const mixpanel = await Mixpanel.init("token", true);
162162
mixpanel.reset();
163163
expect(NativeModules.MixpanelReactNative.reset).toBeCalledWith("token");
164164
});
165165

166166
test(`it calls MixpanelReactNative getDistinctId`, async () => {
167-
const mixpanel = await Mixpanel.init("token");
167+
const mixpanel = await Mixpanel.init("token", true);
168168
mixpanel.getDistinctId();
169169
expect(NativeModules.MixpanelReactNative.getDistinctId).toBeCalledWith("token");
170170
});
171171

172172
test(`it calls MixpanelReactNative profile set`, async () => {
173-
const mixpanel = await Mixpanel.init("token");
173+
const mixpanel = await Mixpanel.init("token", true);
174174
mixpanel.getPeople().set({
175175
"a": 1,
176176
"b": 2.3,
@@ -187,7 +187,7 @@ test(`it calls MixpanelReactNative profile set`, async () => {
187187
});
188188

189189
test(`it calls MixpanelReactNative profile setOnce`, async () => {
190-
const mixpanel = await Mixpanel.init("token");
190+
const mixpanel = await Mixpanel.init("token", true);
191191
mixpanel.getPeople().setOnce({
192192
"a": 1,
193193
"b": 2.3,
@@ -204,7 +204,7 @@ test(`it calls MixpanelReactNative profile setOnce`, async () => {
204204
});
205205

206206
test(`it calls MixpanelReactNative profile increment`, async () => {
207-
const mixpanel = await Mixpanel.init("token");
207+
const mixpanel = await Mixpanel.init("token", true);
208208
mixpanel.getPeople().increment({
209209
"a": 1,
210210
"b": 2.3,
@@ -219,73 +219,73 @@ test(`it calls MixpanelReactNative profile increment`, async () => {
219219
});
220220

221221
test(`it calls MixpanelReactNative profile append`, async () => {
222-
const mixpanel = await Mixpanel.init("token");
222+
const mixpanel = await Mixpanel.init("token", true);
223223
mixpanel.getPeople().append("a", "1");
224224
expect(NativeModules.MixpanelReactNative.append).toBeCalledWith("token", {"a": "1"});
225225
});
226226

227227
test(`it calls MixpanelReactNative profile union`, async () => {
228-
const mixpanel = await Mixpanel.init("token");
228+
const mixpanel = await Mixpanel.init("token", true);
229229
mixpanel.getPeople().union("a1", "1");
230230
expect(NativeModules.MixpanelReactNative.union).toBeCalledWith("token", {"a1": ["1"]});
231231
});
232232

233233
test(`it calls MixpanelReactNative profile remove`, async () => {
234-
const mixpanel = await Mixpanel.init("token");
234+
const mixpanel = await Mixpanel.init("token", true);
235235
mixpanel.getPeople().remove("a", "1");
236236
expect(NativeModules.MixpanelReactNative.remove).toBeCalledWith("token", {"a": "1"});
237237
});
238238

239239
test(`it calls MixpanelReactNative profile unset`, async () => {
240-
const mixpanel = await Mixpanel.init("token");
240+
const mixpanel = await Mixpanel.init("token", true);
241241
mixpanel.getPeople().unset("a");
242242
expect(NativeModules.MixpanelReactNative.unset).toBeCalledWith("token", "a");
243243
});
244244

245245
test(`it calls MixpanelReactNative profile trackCharge`, async () => {
246-
const mixpanel = await Mixpanel.init("token");
246+
const mixpanel = await Mixpanel.init("token", true);
247247
mixpanel.getPeople().trackCharge(22.8);
248248
expect(NativeModules.MixpanelReactNative.trackCharge).toBeCalledWith("token", 22.8, {});
249249
});
250250

251251
test(`it calls MixpanelReactNative profile clearCharges`, async () => {
252-
const mixpanel = await Mixpanel.init("token");
252+
const mixpanel = await Mixpanel.init("token", true);
253253
mixpanel.getPeople().clearCharges();
254254
expect(NativeModules.MixpanelReactNative.clearCharges).toBeCalledWith("token");
255255
});
256256

257257
test(`it calls MixpanelReactNative profile deleteUser`, async () => {
258-
const mixpanel = await Mixpanel.init("token");
258+
const mixpanel = await Mixpanel.init("token", true);
259259
mixpanel.getPeople().deleteUser();
260260
expect(NativeModules.MixpanelReactNative.deleteUser).toBeCalledWith("token");
261261
});
262262

263263
test(`it calls MixpanelReactNative group set properties`, async () => {
264-
const mixpanel = await Mixpanel.init("token");
264+
const mixpanel = await Mixpanel.init("token", true);
265265
mixpanel.getGroup("company_id", 12345).set("prop_key", "prop_value");
266266
expect(NativeModules.MixpanelReactNative.groupSetProperties).toBeCalledWith("token", "company_id", 12345, {"prop_key": "prop_value"});
267267
});
268268

269269
test(`it calls MixpanelReactNative group set property once`, async () => {
270-
const mixpanel = await Mixpanel.init("token");
270+
const mixpanel = await Mixpanel.init("token", true);
271271
mixpanel.getGroup("company_id", 12345).setOnce("prop_key", "prop_value");
272272
expect(NativeModules.MixpanelReactNative.groupSetPropertyOnce).toBeCalledWith("token", "company_id", 12345, {"prop_key": "prop_value"});
273273
});
274274

275275
test(`it calls MixpanelReactNative group unset property`, async () => {
276-
const mixpanel = await Mixpanel.init("token");
276+
const mixpanel = await Mixpanel.init("token", true);
277277
mixpanel.getGroup("company_id", 12345).unset("prop_key");
278278
expect(NativeModules.MixpanelReactNative.groupUnsetProperty).toBeCalledWith("token", "company_id", 12345, "prop_key");
279279
});
280280

281281
test(`it calls MixpanelReactNative group remove property`, async () => {
282-
const mixpanel = await Mixpanel.init("token");
282+
const mixpanel = await Mixpanel.init("token", true);
283283
mixpanel.getGroup("company_id", 12345).remove("prop_key", "334");
284284
expect(NativeModules.MixpanelReactNative.groupRemovePropertyValue).toBeCalledWith("token", "company_id", 12345, "prop_key", "334");
285285
});
286286

287287
test(`it calls MixpanelReactNative group union property`, async () => {
288-
const mixpanel = await Mixpanel.init("token");
288+
const mixpanel = await Mixpanel.init("token", true);
289289
mixpanel.getGroup("company_id", 12345).union("prop_key", "334");
290290
expect(NativeModules.MixpanelReactNative.groupRemovePropertyValue).toBeCalledWith("token", "company_id", 12345, "prop_key", "334");
291291
});

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ repositories {
3434

3535
dependencies {
3636
implementation 'com.facebook.react:react-native:+'
37-
implementation 'com.mixpanel.android:mixpanel-android:6.3.0'
37+
implementation 'com.mixpanel.android:mixpanel-android:7.0.1'
3838
}

0 commit comments

Comments
 (0)