diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c75746..6776844 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 2.2.3 +* Bump iOS (7.2.0) and Android (2.29.2) Amplitude SDK versions +* Add `setUseDynamicConfig` API to dynamically adjust server URL + ## 2.2.2 * Fix - Fixing crash on iOS. Thanks @nishiths23! * Misc - Migrated plugin to android v2 embedding. Thanks @sergey-triputsco! diff --git a/android/build.gradle b/android/build.gradle index 9c0b98b..355a78f 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.27.0" + implementation "com.amplitude:android-sdk:2.29.2" 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 25dac9b..577c1fc 100644 --- a/android/src/main/kotlin/com/amplitude/amplitude_flutter/AmplitudeFlutterPlugin.kt +++ b/android/src/main/kotlin/com/amplitude/amplitude_flutter/AmplitudeFlutterPlugin.kt @@ -87,6 +87,12 @@ class AmplitudeFlutterPlugin : FlutterPlugin, MethodCallHandler { result.success("trackingSessionEvents called..") } + "setUseDynamicConfig" -> { + val client = Amplitude.getInstance(instanceName) + client.trackSessionEvents(json.getBoolean("useDynamicConfig")) + + result.success("setUseDynamicConfig called..") + } "setUserId" -> { val client = Amplitude.getInstance(instanceName) client.setUserId(json.optString("userId", null)) diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 2bfab5c..5fe03dc 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,7 +1,7 @@ PODS: - - Amplitude (5.2.1) + - Amplitude (7.2.0) - amplitude_flutter (0.0.1): - - Amplitude (= 5.2.1) + - Amplitude (= 7.2.0) - Flutter - Flutter (1.0.0) @@ -20,10 +20,10 @@ EXTERNAL SOURCES: :path: Flutter SPEC CHECKSUMS: - Amplitude: 9774e93d48d9f41f271a4479e06369a30ab31db1 - amplitude_flutter: 5b9cab3f48db637a37d67b93e5dc49fa9b206686 + Amplitude: c948c6f99c7f798c196523b2a5584367401d910f + amplitude_flutter: 5c934cf8331619b62bbd5a69f3cfea9090b3ca94 Flutter: 0e3d915762c693b495b44d77113d4970485de6ec -PODFILE CHECKSUM: 7c0562dd817e722f66e06d0beb6e4108968d2c23 +PODFILE CHECKSUM: aafe91acc616949ddb318b77800a7f51bffa2a4c COCOAPODS: 1.9.1 diff --git a/example/lib/my_app.dart b/example/lib/my_app.dart index 590945a..e459186 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.setUseDynamicConfig(true); analytics.setServerUrl("https://api2.amplitude.com"); analytics.init(widget.apiKey); analytics.enableCoppaControl(); diff --git a/example/pubspec.lock b/example/pubspec.lock index 5b94e3f..a334769 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,7 +7,7 @@ packages: path: ".." relative: true source: path - version: "2.2.2" + version: "2.2.3" async: dependency: transitive description: diff --git a/ios/Classes/SwiftAmplitudeFlutterPlugin.swift b/ios/Classes/SwiftAmplitudeFlutterPlugin.swift index 68badf1..e4adf52 100644 --- a/ios/Classes/SwiftAmplitudeFlutterPlugin.swift +++ b/ios/Classes/SwiftAmplitudeFlutterPlugin.swift @@ -35,31 +35,35 @@ import Amplitude } let userId = args["userId"] as! String? - Amplitude.instance(withName: instanceName)?.initializeApiKey(apiKey, userId: userId) + Amplitude.instance(withName: instanceName).initializeApiKey(apiKey, userId: userId) result(true) // Setters case "enableCoppaControl": - Amplitude.instance(withName: instanceName)?.enableCoppaControl(); + Amplitude.instance(withName: instanceName).enableCoppaControl(); result(true) case "disableCoppaControl": - Amplitude.instance(withName: instanceName)?.disableCoppaControl(); + Amplitude.instance(withName: instanceName).disableCoppaControl(); result(true) case "setOptOut": let optOut = args["optOut"] as! Bool - Amplitude.instance(withName: instanceName)?.optOut = optOut + Amplitude.instance(withName: instanceName).optOut = optOut result(true) case "setLibraryName": let libraryName = args["libraryName"] as! String - Amplitude.instance(withName: instanceName)?.libraryName = libraryName + Amplitude.instance(withName: instanceName).libraryName = libraryName result(true) case "setLibraryVersion": let libraryVersion = args["libraryVersion"] as! String - Amplitude.instance(withName: instanceName)?.libraryVersion = libraryVersion + Amplitude.instance(withName: instanceName).libraryVersion = libraryVersion result(true) case "trackingSessionEvents": let trackingSessionEvents = args["trackingSessionEvents"] as! Bool - Amplitude.instance(withName: instanceName)?.trackingSessionEvents = trackingSessionEvents + Amplitude.instance(withName: instanceName).trackingSessionEvents = trackingSessionEvents + result(true) + case "setUseDynamicConfig": + let useDynamicConfig = args["useDynamicConfig"] as! Bool + Amplitude.instance(withName: instanceName).useDynamicConfig = useDynamicConfig result(true) case "setUserId": var userId: String? = nil @@ -68,15 +72,15 @@ import Amplitude } let startNewSession = args["startNewSession"] == nil ? false : (args["startNewSession"] as! Bool) - Amplitude.instance(withName: instanceName)?.setUserId(userId, startNewSession: startNewSession) + 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? + if let serverUrl = args["serverUrl"] as! String? { + Amplitude.instance(withName: instanceName).setServerUrl(serverUrl) + } } - Amplitude.instance(withName: instanceName)?.setServerUrl(serverUrl) result(true) // Event logging @@ -85,7 +89,7 @@ import Amplitude let eventProperties = args["eventProperties"] as! [String: Any]? let outOfSession = args["outOfSession"] == nil ? false : (args["outOfSession"] as! Bool) - Amplitude.instance(withName: instanceName)?.logEvent(eventType, + Amplitude.instance(withName: instanceName).logEvent(eventType, withEventProperties: eventProperties, outOfSession: outOfSession) result(true) @@ -94,27 +98,27 @@ import Amplitude let quantity = args["quantity"] as! Int let price = args["price"] as! Double - Amplitude.instance(withName: instanceName)?.logRevenue(productIdentifier, + Amplitude.instance(withName: instanceName).logRevenue(productIdentifier, quantity: quantity, price: NSNumber(value: price)) result(true) case "logRevenueAmount": let amount = args["amount"] as! Double - Amplitude.instance(withName: instanceName)?.logRevenue(NSNumber(value: amount)) + Amplitude.instance(withName: instanceName).logRevenue(NSNumber(value: amount)) result(true) case "identify": let userProperties = args["userProperties"] as! [String: [String : NSObject]] let identify: AMPIdentify = createIdentify(userProperties) - Amplitude.instance(withName: instanceName)?.identify(identify) + Amplitude.instance(withName: instanceName).identify(identify) result(true) case "setGroup": let groupType = args["groupType"] as! String let groupName = args["groupName"] as! NSObject - Amplitude.instance(withName: instanceName)?.setGroup(groupType, groupName: groupName) + Amplitude.instance(withName: instanceName).setGroup(groupType, groupName: groupName) result(true) case "groupIdentify": @@ -123,7 +127,7 @@ import Amplitude let userProperties = args["userProperties"] as! [String: [String : NSObject]] let outOfSession = args["outOfSession"] == nil ? false : (args["outOfSession"] as! Bool) let identify: AMPIdentify = createIdentify(userProperties) - Amplitude.instance(withName: instanceName)?.groupIdentify(withGroupType: groupType, + Amplitude.instance(withName: instanceName).groupIdentify(withGroupType: groupType, groupName: groupName, groupIdentify: identify, outOfSession: outOfSession) @@ -131,15 +135,15 @@ import Amplitude // User properties case "setUserProperties": - let userProperties = args["userProperties"] as! [String: Any]? - Amplitude.instance(withName: instanceName)?.setUserProperties(userProperties) + let userProperties = args["userProperties"] as! [String: Any]? ?? [:] + Amplitude.instance(withName: instanceName).setUserProperties(userProperties) result(true) case "clearUserProperties": - Amplitude.instance(withName: instanceName)?.clearUserProperties() + Amplitude.instance(withName: instanceName).clearUserProperties() result(true) case "uploadEvents": - Amplitude.instance(withName: instanceName)?.uploadEvents() + Amplitude.instance(withName: instanceName).uploadEvents() result(true) default: diff --git a/ios/amplitude_flutter.podspec b/ios/amplitude_flutter.podspec index e4bb9b2..ebb64fa 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.2.1' + s.dependency 'Amplitude', '7.2.0' s.ios.deployment_target = '10.0' end diff --git a/lib/amplitude.dart b/lib/amplitude.dart index 704a25c..dd72038 100644 --- a/lib/amplitude.dart +++ b/lib/amplitude.dart @@ -96,6 +96,14 @@ class Amplitude extends _Amplitude { return await _channel.invokeMethod('setServerUrl', jsonEncode(properties)); } + /// Dynamically adjust server URL + Future setUseDynamicConfig(bool useDynamicConfig) async { + Map properties = _baseProperties(); + properties['useDynamicConfig'] = useDynamicConfig; + + return await _channel.invokeMethod('setUseDynamicConfig', 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 b09dd98..e20b2e1 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -1,4 +1,4 @@ class Constants { static const packageName = 'amplitude-flutter'; - static const packageVersion = '2.2.1'; + static const packageVersion = '2.2.2'; } diff --git a/pubspec.yaml b/pubspec.yaml index 8ef3ee0..0123a5a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: amplitude_flutter description: Amplitude Flutter plugin -version: 2.2.2 +version: 2.2.3 homepage: https://www.amplitude.com environment: