mixpanel-react-native 2.2.4 → 2.2.5
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/CHANGELOG.md +10 -0
- package/MixpanelReactNative.podspec +1 -1
- package/__tests__/index.test.js +2 -2
- package/android/build.gradle +1 -1
- package/ios/AutomaticProperties.swift +0 -4
- package/ios/MixpanelReactNative.swift +6 -4
- package/ios/MixpanelTypeHandler.swift +1 -9
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
#
|
|
2
2
|
|
|
3
|
+
## [v2.2.5](https://github.com/mixpanel/mixpanel-react-native/tree/v2.2.5) (2023-04-29)
|
|
4
|
+
|
|
5
|
+
### Fixes
|
|
6
|
+
|
|
7
|
+
- Remove semaphores, copy properties, use .merging, don't includeLibInfo in init [\#191](https://github.com/mixpanel/mixpanel-react-native/pull/191)
|
|
8
|
+
|
|
9
|
+
#
|
|
10
|
+
|
|
3
11
|
## [v2.2.4](https://github.com/mixpanel/mixpanel-react-native/tree/v2.2.4) (2023-04-25)
|
|
4
12
|
|
|
5
13
|
### Fixes
|
|
@@ -290,6 +298,8 @@ Report issues or give us any feedback is appreciated!
|
|
|
290
298
|
|
|
291
299
|
|
|
292
300
|
|
|
301
|
+
|
|
302
|
+
|
|
293
303
|
|
|
294
304
|
|
|
295
305
|
|
package/__tests__/index.test.js
CHANGED
|
@@ -9,13 +9,13 @@ import { NativeModules } from 'react-native';
|
|
|
9
9
|
|
|
10
10
|
test(`it calls MixpanelReactNative initialize`, async () => {
|
|
11
11
|
const mixpanel = await Mixpanel.init("token", true);
|
|
12
|
-
expect(NativeModules.MixpanelReactNative.initialize).toBeCalledWith("token", true, false, {"$lib_version": "2.2.
|
|
12
|
+
expect(NativeModules.MixpanelReactNative.initialize).toBeCalledWith("token", true, false, {"$lib_version": "2.2.5", "mp_lib": "react-native"});
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
test(`it calls MixpanelReactNative initialize with optOut and superProperties`, async () => {
|
|
16
16
|
const mixpanel = new Mixpanel("token", true);
|
|
17
17
|
mixpanel.init(true, {"super": "property"})
|
|
18
|
-
expect(NativeModules.MixpanelReactNative.initialize).toBeCalledWith("token", true, true, {"$lib_version": "2.2.
|
|
18
|
+
expect(NativeModules.MixpanelReactNative.initialize).toBeCalledWith("token", true, true, {"$lib_version": "2.2.5", "mp_lib": "react-native", "super": "property"}, "https://api.mixpanel.com");
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
test(`it calls MixpanelReactNative setServerURL`, async () => {
|
package/android/build.gradle
CHANGED
|
@@ -3,14 +3,10 @@ import Mixpanel
|
|
|
3
3
|
|
|
4
4
|
class AutomaticProperties {
|
|
5
5
|
static var peopleProperties: Dictionary<String, MixpanelType> = [:];
|
|
6
|
-
private static let semaphore = DispatchSemaphore(value: 0)
|
|
7
|
-
|
|
8
6
|
|
|
9
7
|
static func setAutomaticProperties(_ properties: [String: Any]) {
|
|
10
|
-
semaphore.wait()
|
|
11
8
|
for (key,value) in properties {
|
|
12
9
|
peopleProperties[key] = MixpanelTypeHandler.mixpanelTypeValue(value)
|
|
13
10
|
}
|
|
14
|
-
semaphore.signal()
|
|
15
11
|
}
|
|
16
12
|
}
|
|
@@ -19,10 +19,12 @@ open class MixpanelReactNative: NSObject {
|
|
|
19
19
|
serverURL: String,
|
|
20
20
|
resolver resolve: RCTPromiseResolveBlock,
|
|
21
21
|
rejecter reject: RCTPromiseRejectBlock) -> Void {
|
|
22
|
-
|
|
22
|
+
let autoProps = properties // copy
|
|
23
|
+
AutomaticProperties.setAutomaticProperties(autoProps)
|
|
24
|
+
let propsProcessed = MixpanelTypeHandler.processProperties(properties: properties)
|
|
23
25
|
Mixpanel.initialize(token: token, trackAutomaticEvents: trackAutomaticEvents, flushInterval: Constants.DEFAULT_FLUSH_INTERVAL,
|
|
24
26
|
instanceName: token, optOutTrackingByDefault: optOutTrackingByDefault,
|
|
25
|
-
superProperties:
|
|
27
|
+
superProperties: propsProcessed,
|
|
26
28
|
serverURL: serverURL)
|
|
27
29
|
resolve(true)
|
|
28
30
|
}
|
|
@@ -101,7 +103,7 @@ open class MixpanelReactNative: NSObject {
|
|
|
101
103
|
resolver resolve: RCTPromiseResolveBlock,
|
|
102
104
|
rejecter reject: RCTPromiseRejectBlock) -> Void {
|
|
103
105
|
let instance = MixpanelReactNative.getMixpanelInstance(token)
|
|
104
|
-
let mpProperties = MixpanelTypeHandler.processProperties(properties: properties
|
|
106
|
+
let mpProperties = MixpanelTypeHandler.processProperties(properties: properties)
|
|
105
107
|
instance?.track(event: event, properties: mpProperties)
|
|
106
108
|
resolve(nil)
|
|
107
109
|
}
|
|
@@ -318,7 +320,7 @@ open class MixpanelReactNative: NSObject {
|
|
|
318
320
|
resolver resolve: RCTPromiseResolveBlock,
|
|
319
321
|
rejecter reject: RCTPromiseRejectBlock) -> Void {
|
|
320
322
|
let instance = MixpanelReactNative.getMixpanelInstance(token)
|
|
321
|
-
let mpProperties = MixpanelTypeHandler.processProperties(properties: properties
|
|
323
|
+
let mpProperties = MixpanelTypeHandler.processProperties(properties: properties)
|
|
322
324
|
var mpGroups = Dictionary<String, MixpanelType>()
|
|
323
325
|
for (key,value) in groups ?? [:] {
|
|
324
326
|
mpGroups[key] = MixpanelTypeHandler.mixpanelTypeValue(value)
|
|
@@ -78,16 +78,8 @@
|
|
|
78
78
|
mpProperties[key] = mixpanelTypeValue(value)
|
|
79
79
|
}
|
|
80
80
|
if (includeLibInfo) {
|
|
81
|
-
mpProperties.
|
|
81
|
+
return mpProperties.merging(AutomaticProperties.peopleProperties) { (_, new) in new }
|
|
82
82
|
}
|
|
83
83
|
return mpProperties
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
|
|
87
|
-
extension Dictionary {
|
|
88
|
-
mutating func merge(dict: [Key: Value]){
|
|
89
|
-
for (k, v) in dict {
|
|
90
|
-
updateValue(v, forKey: k)
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|