diff --git a/android/build.gradle b/android/build.gradle index 6619741..abcc973 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -21,16 +21,10 @@ rootProject.allprojects { } } -ext { - PUBLISH_VERSION = '4.0.0-beta.0' -} - apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - buildFeatures.buildConfig true - compileSdkVersion 34 // Condition for namespace compatibility in AGP 8 if (project.android.hasProperty("namespace")) { @@ -42,9 +36,6 @@ android { } defaultConfig { minSdkVersion 16 - - buildConfigField 'String', 'SDK_VERSION', "\"${PUBLISH_VERSION}\"" - testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } lintOptions { 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 c55f443..7eebba1 100644 --- a/android/src/main/kotlin/com/amplitude/amplitude_flutter/AmplitudeFlutterPlugin.kt +++ b/android/src/main/kotlin/com/amplitude/amplitude_flutter/AmplitudeFlutterPlugin.kt @@ -28,7 +28,6 @@ class AmplitudeFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { private lateinit var channel: MethodChannel - companion object { private const val methodChannelName = "amplitude_flutter" } @@ -66,7 +65,7 @@ class AmplitudeFlutterPlugin : FlutterPlugin, MethodCallHandler, ActivityAware { amplitude = Amplitude(configuration) // Set library - amplitude.add(FlutterLibraryPlugin()) + amplitude.add(FlutterLibraryPlugin(call.argument("library")!!)) call.argument("logLevel")?.let { amplitude.logger.logMode = Logger.LogMode.valueOf(it.uppercase()) diff --git a/android/src/main/kotlin/com/amplitude/amplitude_flutter/FlutterLibraryPlugin.kt b/android/src/main/kotlin/com/amplitude/amplitude_flutter/FlutterLibraryPlugin.kt index 8f15a30..c5b853e 100644 --- a/android/src/main/kotlin/com/amplitude/amplitude_flutter/FlutterLibraryPlugin.kt +++ b/android/src/main/kotlin/com/amplitude/amplitude_flutter/FlutterLibraryPlugin.kt @@ -3,19 +3,13 @@ package com.amplitude.amplitude_flutter import com.amplitude.core.Amplitude import com.amplitude.core.events.BaseEvent import com.amplitude.core.platform.Plugin -import com.amplitude.amplitude_flutter.BuildConfig -class FlutterLibraryPlugin: Plugin { +class FlutterLibraryPlugin(val library: String): Plugin { override val type: Plugin.Type = Plugin.Type.Before override lateinit var amplitude: Amplitude - companion object { - const val SDK_LIBRARY = "amplitude-flutter" - const val SDK_VERSION = BuildConfig.SDK_VERSION - } - override fun execute(event: BaseEvent): BaseEvent? { - event.library = "$SDK_LIBRARY/$SDK_VERSION" + event.library = library return super.execute(event) } } diff --git a/ios/Classes/FlutterLibraryPlugin.swift b/ios/Classes/FlutterLibraryPlugin.swift index 18d3618..d505751 100644 --- a/ios/Classes/FlutterLibraryPlugin.swift +++ b/ios/Classes/FlutterLibraryPlugin.swift @@ -2,12 +2,14 @@ import Foundation import AmplitudeSwift class FlutterLibraryPlugin: BeforePlugin { - static let sdkLibrary = "amplitude-flutter" - // Version is managed automatically by semantic-release in release.config.js, please don't change it manually - static let sdkVersion = "4.0.0-beta.0" + let library: String + + init(library: String) { + self.library = library + } override func execute(event: BaseEvent) -> BaseEvent? { - event.library = "\(FlutterLibraryPlugin.sdkLibrary)/\(FlutterLibraryPlugin.sdkVersion)" + event.library = library return event } diff --git a/ios/Classes/SwiftAmplitudeFlutterPlugin.swift b/ios/Classes/SwiftAmplitudeFlutterPlugin.swift index 536d7a5..8e1d5de 100644 --- a/ios/Classes/SwiftAmplitudeFlutterPlugin.swift +++ b/ios/Classes/SwiftAmplitudeFlutterPlugin.swift @@ -27,7 +27,7 @@ import AmplitudeSwift } // Set library - amplitude?.add(plugin: FlutterLibraryPlugin()) + amplitude?.add(plugin: FlutterLibraryPlugin(library: args["library"] as! String)) amplitude?.logger?.debug(message: "Amplitude has been successfully initialized.") diff --git a/ios/amplitude_flutter.podspec b/ios/amplitude_flutter.podspec index 9888653..169a40b 100644 --- a/ios/amplitude_flutter.podspec +++ b/ios/amplitude_flutter.podspec @@ -1,12 +1,9 @@ # # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html # - -amplitude_version = "4.0.0-beta.0" # Version is managed automatically by semantic-release, please don't change it manually - Pod::Spec.new do |s| s.name = 'amplitude_flutter' - s.version = amplitude_version + s.version = '0.0.1' s.summary = 'A new flutter plugin project.' s.homepage = 'http://example.com' s.license = { :file => '../LICENSE' } diff --git a/lib/configuration.dart b/lib/configuration.dart index ce89b9f..958c2f0 100644 --- a/lib/configuration.dart +++ b/lib/configuration.dart @@ -93,6 +93,9 @@ class Configuration { 'useAdvertisingIdForDeviceId': useAdvertisingIdForDeviceId, 'useAppSetIdForDeviceId': useAppSetIdForDeviceId, 'appVersion': appVersion, + // This field doesn't belong to Configuration + // Pass it for FlutterLibraryPlugin + 'library': "${Constants.packageName}/${Constants.packageVersion}" }; } } diff --git a/lib/constants.dart b/lib/constants.dart index a11aab5..bc9480e 100644 --- a/lib/constants.dart +++ b/lib/constants.dart @@ -1,4 +1,6 @@ class Constants { + static const packageName = "amplitude-flutter"; + static const packageVersion = "3.16.1"; static const identify_event = "\$identify"; static const group_identify_event = "\$groupidentify"; static const revenue_event = "revenue_amount"; diff --git a/release.config.js b/release.config.js index 03a5a8f..28bebf7 100644 --- a/release.config.js +++ b/release.config.js @@ -63,34 +63,6 @@ module.exports = { ], "countMatches": true }, - { - "files": ["android/build.gradle"], - "from": "PUBLISH_VERSION = \'.*\'", - "to": "PUBLISH_VERSION = \'${nextRelease.version}\'", - "results": [ - { - "file": "android/build.gradle", - "hasChanged": true, - "numMatches": 1, - "numReplacements": 1 - } - ], - "countMatches": true - }, - { - "files": ["ios/Classes/FlutterLibraryPlugin.swift"], - "from": "static let sdkVersion = \".*\"", - "to": "static let sdkVersion = \"${nextRelease.version}\"", - "results": [ - { - "file": "ios/Classes/FlutterLibraryPlugin.swift", - "hasChanged": true, - "numMatches": 1, - "numReplacements": 1 - } - ], - "countMatches": true - }, ] } ], diff --git a/test/amplitude_test.dart b/test/amplitude_test.dart index 34c7724..a089422 100644 --- a/test/amplitude_test.dart +++ b/test/amplitude_test.dart @@ -83,6 +83,9 @@ void main() { "useAdvertisingIdForDeviceId": false, "useAppSetIdForDeviceId": false, "appVersion": null, + // This field doesn't belong to Configuration + // Pass it for FlutterLibraryPlugin + "library": "${Constants.packageName}/${Constants.packageVersion}" }; final testEvent = BaseEvent(eventType: "testEvent"); final testEventMap = {