diff --git a/ios/Classes/FlutterLibraryPlugin.swift b/ios/Classes/FlutterLibraryPlugin.swift new file mode 100644 index 0000000..52524ef --- /dev/null +++ b/ios/Classes/FlutterLibraryPlugin.swift @@ -0,0 +1,18 @@ +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" + + override func setup(amplitude: Amplitude) { + super.setup(amplitude: amplitude) + } + + override func execute(event: BaseEvent) -> BaseEvent? { + event.library = "\(FlutterLibraryPlugin.sdkLibrary)/\(FlutterLibraryPlugin.sdkVersion)" + + return event + } +} diff --git a/ios/Classes/SwiftAmplitudeFlutterPlugin.swift b/ios/Classes/SwiftAmplitudeFlutterPlugin.swift index 967fc9c..1133a38 100644 --- a/ios/Classes/SwiftAmplitudeFlutterPlugin.swift +++ b/ios/Classes/SwiftAmplitudeFlutterPlugin.swift @@ -18,10 +18,12 @@ import AmplitudeSwift amplitude = Amplitude(configuration: getConfiguration(call: call)) - // TODO(xinyi): add library plugin + // Set library + amplitude?.add(plugin: FlutterLibraryPlugin()) + amplitude?.logger?.debug(message: "Amplitude has been successfully initialized.") - // TODO(xinyi): check app lifecycle events + // TODO(xinyi): add app lifecycle events result("init called..") @@ -171,7 +173,7 @@ import AmplitudeSwift case "debug": return .DEBUG default: - return .WARN + return .DEBUG } } diff --git a/ios/amplitude_flutter.podspec b/ios/amplitude_flutter.podspec index 169a40b..9888653 100644 --- a/ios/amplitude_flutter.podspec +++ b/ios/amplitude_flutter.podspec @@ -1,9 +1,12 @@ # # 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 = '0.0.1' + s.version = amplitude_version s.summary = 'A new flutter plugin project.' s.homepage = 'http://example.com' s.license = { :file => '../LICENSE' } diff --git a/release.config.js b/release.config.js index 7b5b234..03a5a8f 100644 --- a/release.config.js +++ b/release.config.js @@ -77,6 +77,20 @@ module.exports = { ], "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 + }, ] } ],