@amplitude/analytics-react-native 1.4.0 → 1.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.
@@ -17,7 +17,8 @@ class ReactNative: NSObject {
17
17
  ) -> Void {
18
18
  let trackingOptions = options as! [String: Bool]
19
19
  let trackIdfv = trackingOptions["idfv"] ?? false
20
- let appleContextProvider = AppleContextProvider(trackIdfv: trackIdfv)
20
+ let trackCarrier = trackingOptions["carrier"] ?? false
21
+ let appleContextProvider = AppleContextProvider(trackIdfv: trackIdfv, trackCarrier: trackCarrier)
21
22
 
22
23
  var applicationContext: [String: String?] = [
23
24
  "version": appleContextProvider.version,
@@ -31,6 +32,9 @@ class ReactNative: NSObject {
31
32
  if (trackIdfv) {
32
33
  applicationContext["idfv"] = appleContextProvider.idfv
33
34
  }
35
+ if (trackCarrier) {
36
+ applicationContext["carrier"] = appleContextProvider.carrier
37
+ }
34
38
  resolve(applicationContext)
35
39
  }
36
40
 
@@ -1,3 +1,6 @@
1
+ #if os(iOS) && !targetEnvironment(simulator)
2
+ import CoreTelephony
3
+ #endif
1
4
  import Foundation
2
5
 
3
6
  @objc public class AppleContextProvider : NSObject {
@@ -10,12 +13,16 @@ import Foundation
10
13
  public let deviceManufacturer: String = AppleContextProvider.getDeviceManufacturer()
11
14
  public let deviceModel: String = AppleContextProvider.getDeviceModel()
12
15
  public var idfv: String? = nil
16
+ public var carrier: String? = nil
13
17
 
14
- init(trackIdfv: Bool) {
18
+ init(trackIdfv: Bool, trackCarrier: Bool) {
15
19
  super.init()
16
20
  if (trackIdfv) {
17
21
  fetchIdfv()
18
22
  }
23
+ if (trackCarrier) {
24
+ fetchCarrier()
25
+ }
19
26
  }
20
27
 
21
28
  private static func getVersion() -> String? {
@@ -53,6 +60,22 @@ import Foundation
53
60
  self.idfv = UIDevice.current.identifierForVendor?.uuidString
54
61
  }
55
62
 
63
+ private func fetchCarrier() {
64
+ self.carrier = "Unknown"
65
+ #if os(iOS) && !targetEnvironment(simulator)
66
+ if #available(iOS 12.0, *) {
67
+ let networkInfo = CTTelephonyNetworkInfo()
68
+ if let providers = networkInfo.serviceSubscriberCellularProviders {
69
+ for (_, provider) in providers where provider.mobileNetworkCode != nil {
70
+ self.carrier = provider.carrierName ?? carrier
71
+ // As long as we get one carrier information, we break.
72
+ break
73
+ }
74
+ }
75
+ }
76
+ #endif
77
+ }
78
+
56
79
  private static func getDeviceModel() -> String {
57
80
  let platform = getPlatformString()
58
81
  // == iPhone ==
@@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.VERSION = void 0;
7
- const VERSION = '1.4.0';
7
+ const VERSION = '1.4.1';
8
8
  exports.VERSION = VERSION;
9
9
  //# sourceMappingURL=version.js.map
@@ -1,2 +1,2 @@
1
- export const VERSION = '1.4.0';
1
+ export const VERSION = '1.4.1';
2
2
  //# sourceMappingURL=version.js.map
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.4.0";
1
+ export declare const VERSION = "1.4.1";
2
2
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amplitude/analytics-react-native",
3
- "version": "1.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Official React Native SDK",
5
5
  "keywords": [
6
6
  "analytics",
@@ -90,5 +90,5 @@
90
90
  ]
91
91
  ]
92
92
  },
93
- "gitHead": "cde2f7f24aa4b45c72dc8f243fe95178a2b032ba"
93
+ "gitHead": "348b1ecbc418e6bb0d74fd57cb93cf7c2d69006b"
94
94
  }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '1.4.0';
1
+ export const VERSION = '1.4.1';