From 9dad7b352458c13f6271f61dc93d1eca9ec1909f Mon Sep 17 00:00:00 2001 From: haoliu Date: Wed, 15 Jul 2020 19:17:13 -0700 Subject: [PATCH] Added `setServerUrl` API to customize destination server. Bump to 2.2.0 --- CHANGELOG.md | 3 +++ android/build.gradle | 2 +- .../amplitude_flutter/AmplitudeFlutterPlugin.kt | 6 ++++++ example/ios/Podfile | 2 +- example/ios/Podfile.lock | 10 +++++----- example/lib/my_app.dart | 1 + example/pubspec.lock | 2 +- ios/Classes/SwiftAmplitudeFlutterPlugin.swift | 8 ++++++++ ios/amplitude_flutter.podspec | 2 +- lib/amplitude.dart | 8 ++++++++ lib/constants.dart | 2 +- pubspec.yaml | 2 +- 12 files changed, 37 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a5240b..9cbb599 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2.2.0 +* Add `setServerUrl` API to customize server destination. + ## 2.1.1 * Fix calling `setUserId` with null crashes on iOS. diff --git a/android/build.gradle b/android/build.gradle index 1dc91df..9c0b98b 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -40,6 +40,6 @@ android { } dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" - implementation "com.amplitude:android-sdk:2.25.1" + implementation "com.amplitude:android-sdk:2.27.0" implementation "com.squareup.okhttp3:okhttp:4.2.2" } \ No newline at end of file diff --git a/android/src/main/kotlin/com/amplitude/amplitude_flutter/AmplitudeFlutterPlugin.kt b/android/src/main/kotlin/com/amplitude/amplitude_flutter/AmplitudeFlutterPlugin.kt index 09a593c..716487b 100644 --- a/android/src/main/kotlin/com/amplitude/amplitude_flutter/AmplitudeFlutterPlugin.kt +++ b/android/src/main/kotlin/com/amplitude/amplitude_flutter/AmplitudeFlutterPlugin.kt @@ -79,6 +79,12 @@ class AmplitudeFlutterPlugin : MethodCallHandler { result.success("setUserId called..") } + "setServerUrl" -> { + val client = Amplitude.getInstance(instanceName) + client.setServerUrl(json.optString("serverUrl", null)) + + result.success("setServerUrl called..") + } // Event logging "logEvent" -> { diff --git a/example/ios/Podfile b/example/ios/Podfile index 8bf1bfd..4ebe395 100644 --- a/example/ios/Podfile +++ b/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project - platform :ios, '10.0' +platform :ios, '10.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 995c49b..fb993bd 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,7 +1,7 @@ PODS: - - Amplitude (5.1.0) + - Amplitude (5.2.1) - amplitude_flutter (0.0.1): - - Amplitude (= 5.1.0) + - Amplitude (= 5.2.1) - Flutter - Flutter (1.0.0) @@ -20,10 +20,10 @@ EXTERNAL SOURCES: :path: Flutter SPEC CHECKSUMS: - Amplitude: 1d3d18f82ba9852011aa7b9a741eac616d78fa82 - amplitude_flutter: 3341d2e7cf7321353140e2230531be45f5471bb2 + Amplitude: 9774e93d48d9f41f271a4479e06369a30ab31db1 + amplitude_flutter: 5b9cab3f48db637a37d67b93e5dc49fa9b206686 Flutter: 0e3d915762c693b495b44d77113d4970485de6ec -PODFILE CHECKSUM: 781964779c4d3a08769886e28094ffd2a1e5bcb2 +PODFILE CHECKSUM: f45d293502bdcca725aca7bc62af43ad173e1292 COCOAPODS: 1.9.1 diff --git a/example/lib/my_app.dart b/example/lib/my_app.dart index d3786b5..590945a 100644 --- a/example/lib/my_app.dart +++ b/example/lib/my_app.dart @@ -28,6 +28,7 @@ class _MyAppState extends State { super.initState(); analytics = Amplitude.getInstance(instanceName: "project"); + analytics.setServerUrl("https://api2.amplitude.com"); analytics.init(widget.apiKey); analytics.enableCoppaControl(); analytics.setUserId("test_user"); diff --git a/example/pubspec.lock b/example/pubspec.lock index 19e5d8d..8616be3 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,7 +7,7 @@ packages: path: ".." relative: true source: path - version: "2.1.1" + version: "2.2.0" async: dependency: transitive description: diff --git a/ios/Classes/SwiftAmplitudeFlutterPlugin.swift b/ios/Classes/SwiftAmplitudeFlutterPlugin.swift index 356987d..68badf1 100644 --- a/ios/Classes/SwiftAmplitudeFlutterPlugin.swift +++ b/ios/Classes/SwiftAmplitudeFlutterPlugin.swift @@ -70,6 +70,14 @@ import Amplitude Amplitude.instance(withName: instanceName)?.setUserId(userId, startNewSession: startNewSession) result(true) + case "setServerUrl": + var serverUrl: String? = nil + if !(args["serverUrl"] is NSNull) { + serverUrl = args["serverUrl"] as! String? + } + + Amplitude.instance(withName: instanceName)?.setServerUrl(serverUrl) + result(true) // Event logging case "logEvent": diff --git a/ios/amplitude_flutter.podspec b/ios/amplitude_flutter.podspec index 2b7188d..e4bb9b2 100644 --- a/ios/amplitude_flutter.podspec +++ b/ios/amplitude_flutter.podspec @@ -12,7 +12,7 @@ Pod::Spec.new do |s| s.source_files = 'Classes/**/*' s.public_header_files = 'Classes/**/*.h' s.dependency 'Flutter' - s.dependency 'Amplitude', '5.1.0' + s.dependency 'Amplitude', '5.2.1' s.ios.deployment_target = '10.0' end diff --git a/lib/amplitude.dart b/lib/amplitude.dart index 3967429..fc5a762 100644 --- a/lib/amplitude.dart +++ b/lib/amplitude.dart @@ -88,6 +88,14 @@ class Amplitude extends _Amplitude { return await _channel.invokeMethod('setUserId', jsonEncode(properties)); } + /// Customize the destination for server url. + Future setServerUrl(String serverUrl) async { + Map properties = _baseProperties(); + properties['serverUrl'] = serverUrl; + + return await _channel.invokeMethod('setServerUrl', jsonEncode(properties)); + } + /// Tracks an event. Events are saved locally. /// /// Uploads are batched to occur every 30 events or every 30 seconds diff --git a/lib/constants.dart b/lib/constants.dart index 529fc6f..81a4587 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -1,4 +1,4 @@ class Constants { static const packageName = 'amplitude-flutter'; - static const packageVersion = '2.1.1'; + static const packageVersion = '2.2.0'; } diff --git a/pubspec.yaml b/pubspec.yaml index c0f274a..bcae9da 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: amplitude_flutter description: Amplitude Flutter plugin -version: 2.1.1 +version: 2.2.0 homepage: https://www.amplitude.com environment: