mixpanel-react-native 3.0.4 → 3.0.6

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.
@@ -27,7 +27,7 @@ jobs:
27
27
  - run: npm test
28
28
 
29
29
  test_android:
30
- runs-on: macos-11
30
+ runs-on: macos-13
31
31
  strategy:
32
32
  matrix:
33
33
  node-version: [18.x]
@@ -51,18 +51,18 @@ jobs:
51
51
  working-directory: ./Samples/SimpleMixpanel
52
52
  run: yarn install
53
53
  - name: Setup Android
54
- uses: reactivecircus/android-emulator-runner@v2.20.0
54
+ uses: reactivecircus/android-emulator-runner@v2.32.0
55
55
  with:
56
- api-level: 30
57
- profile: Nexus 6
56
+ api-level: 34
57
+ profile: Nexus 5X
58
58
  arch: x86_64
59
59
  working-directory: ./Samples/SimpleMixpanel/android
60
60
  script: ./gradlew
61
61
  - name: Test Android
62
- uses: reactivecircus/android-emulator-runner@v2.20.0
62
+ uses: reactivecircus/android-emulator-runner@v2.32.0
63
63
  with:
64
- api-level: 30
65
- profile: Nexus 6
64
+ api-level: 34
65
+ profile: Nexus 5X
66
66
  arch: x86_64
67
67
  working-directory: ./Samples/SimpleMixpanel
68
68
  script: react-native run-android
@@ -0,0 +1,21 @@
1
+ name: Node.js CI
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ jobs:
7
+ test_main_code:
8
+ runs-on: macos-latest
9
+ strategy:
10
+ matrix:
11
+ node-version: [18.x]
12
+ # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
13
+ steps:
14
+ - name: Checkout
15
+ uses: actions/checkout@v2
16
+ - name: Use Node.js ${{ matrix.node-version }}
17
+ uses: actions/setup-node@v2
18
+ with:
19
+ node-version: ${{ matrix.node-version }}
20
+ - run: npm install
21
+ - run: npm test
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  #
2
2
 
3
+ ## [v3.0.6](https://github.com/mixpanel/mixpanel-react-native/tree/v3.0.6) (2024-09-10)
4
+
5
+ ### Enhancements
6
+
7
+ - bump iOS to 4.3.0 and Android minSDK to 23 [\#264](https://github.com/mixpanel/mixpanel-react-native/pull/264)
8
+ - upgrade android sdk to 7.5.3 [\#263](https://github.com/mixpanel/mixpanel-react-native/pull/263)
9
+
10
+ ### Fixes
11
+
12
+ - fix: opt in tracking issue during initialize [\#257](https://github.com/mixpanel/mixpanel-react-native/pull/257)
13
+
14
+ #
15
+
16
+ ## [v3.0.5](https://github.com/mixpanel/mixpanel-react-native/tree/v3.0.5) (2024-05-14)
17
+
18
+ ### Fixes
19
+
20
+ - fix: resolve import issue for MixpanelMain [\#253](https://github.com/mixpanel/mixpanel-react-native/pull/253)
21
+
22
+ #
23
+
3
24
  ## [v3.0.4](https://github.com/mixpanel/mixpanel-react-native/tree/v3.0.4) (2024-05-13)
4
25
 
5
26
  ### Fixes
@@ -436,3 +457,7 @@ This major release removes all remaining calls to Mixpanel's `/decide` API endpo
436
457
 
437
458
 
438
459
 
460
+
461
+
462
+
463
+
@@ -19,5 +19,5 @@ Pod::Spec.new do |s|
19
19
  s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' }
20
20
 
21
21
  s.dependency "React-Core"
22
- s.dependency "Mixpanel-swift", '4.2.7'
22
+ s.dependency "Mixpanel-swift", '4.3.0'
23
23
  end
@@ -153,6 +153,54 @@ describe("MixpanelMain", () => {
153
153
  ).toHaveBeenCalledWith(token);
154
154
  });
155
155
 
156
+ it("should not track if initialize with optOutTrackingDefault being true", async () => {
157
+ const trackAutomaticEvents = false;
158
+ const optOutTrackingDefault = true;
159
+ const superProperties = {superProp1: "value1", superProp2: "value2"};
160
+ const serverURL = "https://api.mixpanel.com";
161
+
162
+
163
+ await mixpanelMain.initialize(
164
+ token,
165
+ trackAutomaticEvents,
166
+ optOutTrackingDefault,
167
+ superProperties,
168
+ serverURL
169
+ );
170
+
171
+ const eventName = "Test Event";
172
+ const eventProperties = {prop1: "value1", prop2: "value2"};
173
+
174
+ expect(
175
+ mixpanelMain.mixpanelPersistent.updateOptedOut
176
+ ).toHaveBeenCalledWith(token, true);
177
+
178
+ mixpanelMain.mixpanelPersistent.getOptedOut.mockReturnValue(true);
179
+ await mixpanelMain.track(token, eventName, eventProperties);
180
+ expect(mixpanelMain.core.addToMixpanelQueue).not.toHaveBeenCalled();
181
+ });
182
+
183
+ it("should track if initialize with optOutTrackingDefault being false", async () => {
184
+ const trackAutomaticEvents = false;
185
+ const optOutTrackingDefault = false;
186
+ const superProperties = {superProp1: "value1", superProp2: "value2"};
187
+ const serverURL = "https://api.mixpanel.com";
188
+ console.info("here111");
189
+ await mixpanelMain.initialize(
190
+ token,
191
+ trackAutomaticEvents,
192
+ optOutTrackingDefault,
193
+ superProperties,
194
+ serverURL
195
+ );
196
+ mixpanelMain.setLoggingEnabled(token, true);
197
+ const eventName = "Test Event";
198
+ const eventProperties = {prop1: "value1", prop2: "value2"};
199
+
200
+ await mixpanelMain.track(token, eventName, eventProperties);
201
+ expect(mixpanelMain.core.addToMixpanelQueue).toHaveBeenCalled();
202
+ });
203
+
156
204
  it("register super properties should update properties", async () => {
157
205
  mixpanelMain.registerSuperProperties(token, {superProp3: "value3"});
158
206
  expect(
@@ -4,15 +4,15 @@ buildscript {
4
4
  google()
5
5
  }
6
6
  dependencies {
7
- classpath 'com.android.tools.build:gradle:7.3.1'
7
+ classpath 'com.android.tools.build:gradle:8.1.0'
8
8
  }
9
9
  }
10
10
 
11
11
  apply plugin: 'com.android.library'
12
12
 
13
13
  android {
14
- compileSdkVersion 33
15
- buildToolsVersion "30.0.3"
14
+ compileSdkVersion 34
15
+ buildToolsVersion "34.0.0"
16
16
 
17
17
  def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
18
18
 
@@ -21,8 +21,8 @@ android {
21
21
  }
22
22
 
23
23
  defaultConfig {
24
- minSdkVersion 21
25
- targetSdkVersion 33
24
+ minSdkVersion 23
25
+ targetSdkVersion 34
26
26
  versionCode 1
27
27
  versionName "1.0"
28
28
  }
@@ -41,5 +41,5 @@ repositories {
41
41
 
42
42
  dependencies {
43
43
  implementation 'com.facebook.react:react-native:+'
44
- implementation 'com.mixpanel.android:mixpanel-android:7.5.2'
44
+ implementation 'com.mixpanel.android:mixpanel-android:7.5.3'
45
45
  }
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
3
3
  distributionPath=wrapper/dists
4
4
  zipStoreBase=GRADLE_USER_HOME
5
5
  zipStorePath=wrapper/dists
6
- distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip
6
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-all.zip
@@ -93,7 +93,7 @@
93
93
 
94
94
  <dt class="tag-source">Source:</dt>
95
95
  <dd class="tag-source"><ul class="dummy"><li>
96
- <a href="index.js.html">index.js</a>, <a href="index.js.html#line38">line 38</a>
96
+ <a href="index.js.html">index.js</a>, <a href="index.js.html#line39">line 39</a>
97
97
  </li></ul></dd>
98
98
 
99
99
 
@@ -4516,7 +4516,7 @@ To clear all superProperties, use clearSuperProperties()
4516
4516
  <br class="clear">
4517
4517
 
4518
4518
  <footer>
4519
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Mon May 13 2024 11:52:17 GMT-0700 (Pacific Daylight Time)
4519
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Tue May 14 2024 09:36:01 GMT-0700 (Pacific Daylight Time)
4520
4520
  </footer>
4521
4521
 
4522
4522
  <script> prettyPrint(); </script>
@@ -957,7 +957,7 @@ If the property exists and is not list-valued, the union will be ignored.
957
957
  <br class="clear">
958
958
 
959
959
  <footer>
960
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Mon May 13 2024 11:52:17 GMT-0700 (Pacific Daylight Time)
960
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Tue May 14 2024 09:36:01 GMT-0700 (Pacific Daylight Time)
961
961
  </footer>
962
962
 
963
963
  <script> prettyPrint(); </script>
package/docs/People.html CHANGED
@@ -1625,7 +1625,7 @@ If the property exists and is not list-valued, the union will be ignored.
1625
1625
  <br class="clear">
1626
1626
 
1627
1627
  <footer>
1628
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Mon May 13 2024 11:52:17 GMT-0700 (Pacific Daylight Time)
1628
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Tue May 14 2024 09:36:01 GMT-0700 (Pacific Daylight Time)
1629
1629
  </footer>
1630
1630
 
1631
1631
  <script> prettyPrint(); </script>
package/docs/index.html CHANGED
@@ -203,7 +203,7 @@ Please refer to our <a href="https://mixpanel.com/legal/app-store-privacy-detai
203
203
  <br class="clear">
204
204
 
205
205
  <footer>
206
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Mon May 13 2024 11:52:17 GMT-0700 (Pacific Daylight Time)
206
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Tue May 14 2024 09:36:01 GMT-0700 (Pacific Daylight Time)
207
207
  </footer>
208
208
 
209
209
  <script> prettyPrint(); </script>
@@ -31,6 +31,7 @@
31
31
  import {Platform, NativeModules} from "react-native";
32
32
  import packageJson from "./package.json";
33
33
  const {MixpanelReactNative} = NativeModules;
34
+ import MixpanelMain from "mixpanel-react-native/javascript/mixpanel-main"
34
35
 
35
36
  const DevicePlatform = {
36
37
  Unknown: "Unknown",
@@ -83,7 +84,6 @@ export class Mixpanel {
83
84
  );
84
85
  }
85
86
 
86
- const MixpanelMain = require("mixpanel-react-native/javascript/mixpanel-main");
87
87
  this.mixpanelImpl = new MixpanelMain(token, trackAutomaticEvents, storage);
88
88
  }
89
89
 
@@ -1038,7 +1038,7 @@ class ObjectHelper {
1038
1038
  <br class="clear">
1039
1039
 
1040
1040
  <footer>
1041
- Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Mon May 13 2024 11:52:17 GMT-0700 (Pacific Daylight Time)
1041
+ Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.6</a> on Tue May 14 2024 09:36:01 GMT-0700 (Pacific Daylight Time)
1042
1042
  </footer>
1043
1043
 
1044
1044
  <script> prettyPrint(); </script>
package/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  import {Platform, NativeModules} from "react-native";
4
4
  import packageJson from "./package.json";
5
5
  const {MixpanelReactNative} = NativeModules;
6
+ import MixpanelMain from "mixpanel-react-native/javascript/mixpanel-main"
6
7
 
7
8
  const DevicePlatform = {
8
9
  Unknown: "Unknown",
@@ -55,7 +56,6 @@ export class Mixpanel {
55
56
  );
56
57
  }
57
58
 
58
- const MixpanelMain = require("mixpanel-react-native/javascript/mixpanel-main");
59
59
  this.mixpanelImpl = new MixpanelMain(token, trackAutomaticEvents, storage);
60
60
  }
61
61
 
@@ -30,7 +30,7 @@ export default class MixpanelMain {
30
30
  await this.optOutTracking(token);
31
31
  return;
32
32
  } else {
33
- await this.optInTracking(token);
33
+ await this._setOptedOutTrackingFlag(token, false);
34
34
  }
35
35
 
36
36
  this.setServerURL(token, serverURL);
@@ -71,6 +71,14 @@ export default class MixpanelMain {
71
71
  }
72
72
 
73
73
  async track(token, eventName, properties) {
74
+ if (this.mixpanelPersistent.getOptedOut(token)) {
75
+ MixpanelLogger.log(
76
+ token,
77
+ `User has opted out of tracking, skipping tracking.`
78
+ );
79
+ return;
80
+ }
81
+
74
82
  MixpanelLogger.log(
75
83
  token,
76
84
  `Track '${eventName}' with properties`,
@@ -133,19 +141,22 @@ export default class MixpanelMain {
133
141
  }
134
142
 
135
143
  async optOutTracking(token) {
136
- this.mixpanelPersistent.updateOptedOut(token, true);
137
- await this.mixpanelPersistent.persistOptedOut(token);
144
+ await this._setOptedOutTrackingFlag(token, true);
138
145
  MixpanelLogger.log(token, "User has opted out of tracking");
139
146
  await this.mixpanelPersistent.reset(token);
140
147
  }
141
148
 
142
149
  async optInTracking(token) {
143
- this.mixpanelPersistent.updateOptedOut(token, false);
144
- await this.mixpanelPersistent.persistOptedOut(token);
150
+ await this._setOptedOutTrackingFlag(token, false);
145
151
  MixpanelLogger.log(token, "User has opted in to tracking");
146
152
  await this.track(token, "$opt_in");
147
153
  }
148
154
 
155
+ async _setOptedOutTrackingFlag(token, optedOut) {
156
+ this.mixpanelPersistent.updateOptedOut(token, optedOut);
157
+ await this.mixpanelPersistent.persistOptedOut(token);
158
+ }
159
+
149
160
  hasOptedOutTracking(token) {
150
161
  return this.mixpanelPersistent.getOptOut(token);
151
162
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mixpanel-react-native",
3
- "version": "3.0.4",
3
+ "version": "3.0.6",
4
4
  "description": "Official React Native Tracking Library for Mixpanel Analytics",
5
5
  "main": "index.js",
6
6
  "scripts": {