@amplitude/analytics-react-native 1.3.6 → 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.
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  # @amplitude/analytics-react-native
9
9
 
10
- Official Amplitude SDK for React Native (Beta)
10
+ Official Amplitude SDK for React Native
11
11
 
12
12
  # Installation and Quick Start
13
13
 
@@ -1,59 +1,108 @@
1
1
  buildscript {
2
- ext.kotlinVersion = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : "1.5.30"
3
- repositories {
4
- google()
5
- jcenter()
6
- }
2
+ // Buildscript is evaluated before everything else so we can't use getExtOrDefault
3
+ def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["AmplitudeReactNative_kotlinVersion"]
7
4
 
8
- dependencies {
9
- classpath 'com.android.tools.build:gradle:3.5.3'
10
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
11
- }
5
+ repositories {
6
+ google()
7
+ mavenCentral()
8
+ }
9
+
10
+ dependencies {
11
+ classpath "com.android.tools.build:gradle:7.2.1"
12
+ // noinspection DifferentKotlinGradleVersion
13
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
+ }
15
+ }
16
+
17
+ def isNewArchitectureEnabled() {
18
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
19
+ }
20
+
21
+ apply plugin: "com.android.library"
22
+ apply plugin: "kotlin-android"
23
+
24
+
25
+ def appProject = rootProject.allprojects.find { it.plugins.hasPlugin('com.android.application') }
26
+
27
+ if (isNewArchitectureEnabled()) {
28
+ apply plugin: "com.facebook.react"
12
29
  }
13
30
 
14
- apply plugin: 'com.android.library'
15
- apply plugin: 'kotlin-android'
31
+ def getExtOrDefault(name) {
32
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["AmplitudeReactNative_" + name]
33
+ }
16
34
 
17
- def safeExtGet(prop, fallback) {
18
- rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
35
+ def getExtOrIntegerDefault(name) {
36
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["AmplitudeReactNative_" + name]).toInteger()
37
+ }
38
+
39
+ def supportsNamespace() {
40
+ def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
41
+ def major = parsed[0].toInteger()
42
+ def minor = parsed[1].toInteger()
43
+
44
+ // Namespace support was added in 7.3.0
45
+ if (major == 7 && minor >= 3) {
46
+ return true
47
+ }
48
+
49
+ return major >= 8
19
50
  }
20
51
 
21
52
  android {
22
- compileSdkVersion safeExtGet('compileSdkVersion', 29)
23
- buildToolsVersion safeExtGet('buildToolsVersion', '29.0.2')
24
- defaultConfig {
25
- minSdkVersion safeExtGet('minSdkVersion', 16)
26
- targetSdkVersion safeExtGet('targetSdkVersion', 29)
27
- versionCode 1
28
- versionName "1.0"
53
+ if (supportsNamespace()) {
54
+ namespace "com.amplitude.reactnative"
29
55
 
56
+ sourceSets {
57
+ main {
58
+ manifest.srcFile "src/main/AndroidManifestNew.xml"
59
+ }
30
60
  }
61
+ }
31
62
 
32
- buildTypes {
33
- release {
34
- minifyEnabled false
35
- }
36
- }
37
- lintOptions {
38
- disable 'GradleCompatible'
39
- }
40
- compileOptions {
41
- sourceCompatibility JavaVersion.VERSION_1_8
42
- targetCompatibility JavaVersion.VERSION_1_8
63
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
64
+
65
+ defaultConfig {
66
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
67
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
68
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
69
+ }
70
+ buildTypes {
71
+ release {
72
+ minifyEnabled false
43
73
  }
74
+ }
75
+
76
+ lintOptions {
77
+ disable "GradleCompatible"
78
+ }
79
+
80
+ compileOptions {
81
+ sourceCompatibility JavaVersion.VERSION_1_8
82
+ targetCompatibility JavaVersion.VERSION_1_8
83
+ }
84
+
44
85
  }
45
86
 
46
87
  repositories {
47
- mavenLocal()
48
- maven {
49
- // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
50
- url("$rootDir/../node_modules/react-native/android")
51
- }
52
- google()
53
- jcenter()
88
+ mavenCentral()
89
+ google()
54
90
  }
55
91
 
92
+ def kotlin_version = getExtOrDefault("kotlinVersion")
93
+
56
94
  dependencies {
57
- //noinspection GradleDynamicVersion
58
- implementation "com.facebook.react:react-native:+" // From node_modules
95
+ // For < 0.71, this will be from the local maven repo
96
+ // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
97
+ //noinspection GradleDynamicVersion
98
+ implementation "com.facebook.react:react-native:+"
99
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
100
+ }
101
+
102
+ if (isNewArchitectureEnabled()) {
103
+ react {
104
+ jsRootDir = file("../src/")
105
+ libraryName = "AmplitudeReactNative"
106
+ codegenJavaPackageName = "com.amplitude.reactnative"
107
+ }
59
108
  }
@@ -1,3 +1,5 @@
1
- android.useAndroidX=true
2
- android.enableJetifier=true
3
- kotlin.code.style=official
1
+ AmplitudeReactNative_kotlinVersion=1.7.0
2
+ AmplitudeReactNative_minSdkVersion=21
3
+ AmplitudeReactNative_targetSdkVersion=31
4
+ AmplitudeReactNative_compileSdkVersion=31
5
+ AmplitudeReactNative_ndkversion=21.4.7075529
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -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.3.6';
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.3.6';
1
+ export const VERSION = '1.4.1';
2
2
  //# sourceMappingURL=version.js.map
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.3.6";
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.3.6",
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": "83cf780dec45f8e8dfcc7310c70ffb4ffe67788e"
93
+ "gitHead": "348b1ecbc418e6bb0d74fd57cb93cf7c2d69006b"
94
94
  }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '1.3.6';
1
+ export const VERSION = '1.4.1';