Skip to content

Commit

Permalink
Merge pull request #13 from amplitude/set_server_url
Browse files Browse the repository at this point in the history
Added `setServerUrl` API to customize destination server. Bump to 2.2.0
  • Loading branch information
haoliu-amp authored Jul 16, 2020
2 parents b317527 + 9dad7b3 commit af32802
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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" -> {
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Podfile
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
10 changes: 5 additions & 5 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -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
1 change: 1 addition & 0 deletions example/lib/my_app.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class _MyAppState extends State<MyApp> {
super.initState();

analytics = Amplitude.getInstance(instanceName: "project");
analytics.setServerUrl("https://api2.amplitude.com");
analytics.init(widget.apiKey);
analytics.enableCoppaControl();
analytics.setUserId("test_user");
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
path: ".."
relative: true
source: path
version: "2.1.1"
version: "2.2.0"
async:
dependency: transitive
description:
Expand Down
8 changes: 8 additions & 0 deletions ios/Classes/SwiftAmplitudeFlutterPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down
2 changes: 1 addition & 1 deletion ios/amplitude_flutter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions lib/amplitude.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ class Amplitude extends _Amplitude {
return await _channel.invokeMethod('setUserId', jsonEncode(properties));
}

/// Customize the destination for server url.
Future<void> setServerUrl(String serverUrl) async {
Map<String, dynamic> 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
Expand Down
2 changes: 1 addition & 1 deletion lib/constants.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class Constants {
static const packageName = 'amplitude-flutter';
static const packageVersion = '2.1.1';
static const packageVersion = '2.2.0';
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit af32802

Please sign in to comment.