Skip to content

Commit af32802

Browse files
authored
Merge pull request #13 from amplitude/set_server_url
Added `setServerUrl` API to customize destination server. Bump to 2.2.0
2 parents b317527 + 9dad7b3 commit af32802

File tree

12 files changed

+37
-11
lines changed

12 files changed

+37
-11
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 2.2.0
2+
* Add `setServerUrl` API to customize server destination.
3+
14
## 2.1.1
25
* Fix calling `setUserId` with null crashes on iOS.
36

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ android {
4040
}
4141
dependencies {
4242
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
43-
implementation "com.amplitude:android-sdk:2.25.1"
43+
implementation "com.amplitude:android-sdk:2.27.0"
4444
implementation "com.squareup.okhttp3:okhttp:4.2.2"
4545
}

android/src/main/kotlin/com/amplitude/amplitude_flutter/AmplitudeFlutterPlugin.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ class AmplitudeFlutterPlugin : MethodCallHandler {
7979

8080
result.success("setUserId called..")
8181
}
82+
"setServerUrl" -> {
83+
val client = Amplitude.getInstance(instanceName)
84+
client.setServerUrl(json.optString("serverUrl", null))
85+
86+
result.success("setServerUrl called..")
87+
}
8288

8389
// Event logging
8490
"logEvent" -> {

example/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Uncomment this line to define a global platform for your project
2-
platform :ios, '10.0'
2+
platform :ios, '10.0'
33

44
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
55
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

example/ios/Podfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PODS:
2-
- Amplitude (5.1.0)
2+
- Amplitude (5.2.1)
33
- amplitude_flutter (0.0.1):
4-
- Amplitude (= 5.1.0)
4+
- Amplitude (= 5.2.1)
55
- Flutter
66
- Flutter (1.0.0)
77

@@ -20,10 +20,10 @@ EXTERNAL SOURCES:
2020
:path: Flutter
2121

2222
SPEC CHECKSUMS:
23-
Amplitude: 1d3d18f82ba9852011aa7b9a741eac616d78fa82
24-
amplitude_flutter: 3341d2e7cf7321353140e2230531be45f5471bb2
23+
Amplitude: 9774e93d48d9f41f271a4479e06369a30ab31db1
24+
amplitude_flutter: 5b9cab3f48db637a37d67b93e5dc49fa9b206686
2525
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
2626

27-
PODFILE CHECKSUM: 781964779c4d3a08769886e28094ffd2a1e5bcb2
27+
PODFILE CHECKSUM: f45d293502bdcca725aca7bc62af43ad173e1292
2828

2929
COCOAPODS: 1.9.1

example/lib/my_app.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class _MyAppState extends State<MyApp> {
2828
super.initState();
2929

3030
analytics = Amplitude.getInstance(instanceName: "project");
31+
analytics.setServerUrl("https://api2.amplitude.com");
3132
analytics.init(widget.apiKey);
3233
analytics.enableCoppaControl();
3334
analytics.setUserId("test_user");

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages:
77
path: ".."
88
relative: true
99
source: path
10-
version: "2.1.1"
10+
version: "2.2.0"
1111
async:
1212
dependency: transitive
1313
description:

ios/Classes/SwiftAmplitudeFlutterPlugin.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ import Amplitude
7070

7171
Amplitude.instance(withName: instanceName)?.setUserId(userId, startNewSession: startNewSession)
7272
result(true)
73+
case "setServerUrl":
74+
var serverUrl: String? = nil
75+
if !(args["serverUrl"] is NSNull) {
76+
serverUrl = args["serverUrl"] as! String?
77+
}
78+
79+
Amplitude.instance(withName: instanceName)?.setServerUrl(serverUrl)
80+
result(true)
7381

7482
// Event logging
7583
case "logEvent":

ios/amplitude_flutter.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Pod::Spec.new do |s|
1212
s.source_files = 'Classes/**/*'
1313
s.public_header_files = 'Classes/**/*.h'
1414
s.dependency 'Flutter'
15-
s.dependency 'Amplitude', '5.1.0'
15+
s.dependency 'Amplitude', '5.2.1'
1616

1717
s.ios.deployment_target = '10.0'
1818
end

lib/amplitude.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ class Amplitude extends _Amplitude {
8888
return await _channel.invokeMethod('setUserId', jsonEncode(properties));
8989
}
9090

91+
/// Customize the destination for server url.
92+
Future<void> setServerUrl(String serverUrl) async {
93+
Map<String, dynamic> properties = _baseProperties();
94+
properties['serverUrl'] = serverUrl;
95+
96+
return await _channel.invokeMethod('setServerUrl', jsonEncode(properties));
97+
}
98+
9199
/// Tracks an event. Events are saved locally.
92100
///
93101
/// Uploads are batched to occur every 30 events or every 30 seconds

lib/constants.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
class Constants {
22
static const packageName = 'amplitude-flutter';
3-
static const packageVersion = '2.1.1';
3+
static const packageVersion = '2.2.0';
44
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: amplitude_flutter
22
description: Amplitude Flutter plugin
3-
version: 2.1.1
3+
version: 2.2.0
44
homepage: https://www.amplitude.com
55

66
environment:

0 commit comments

Comments
 (0)