diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 27a531f..bfbeee3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -20,6 +20,16 @@ jobs: NEW_VERSION="${NEW_VERSION#v}" ./scripts/bump_version.sh --version "$NEW_VERSION" + - name: Verify version sync + run: | + PUBSPEC_VERSION=$(grep "^version:" pubspec.yaml | sed 's/version: //') + DART_VERSION=$(grep "packageVersion" lib/src/version.dart | sed "s/.*'\(.*\)'.*/\1/") + if [ "$PUBSPEC_VERSION" != "$DART_VERSION" ]; then + echo "::error::Version mismatch: pubspec.yaml ($PUBSPEC_VERSION) != lib/src/version.dart ($DART_VERSION)" + exit 1 + fi + echo "Versions in sync: $PUBSPEC_VERSION" + - name: Install Flutter uses: subosito/flutter-action@v2 with: diff --git a/android/src/main/kotlin/atomic/financial/atomic_transact_flutter/AtomicTransactFlutterPlugin.kt b/android/src/main/kotlin/atomic/financial/atomic_transact_flutter/AtomicTransactFlutterPlugin.kt index 9c152cb..50d5e92 100644 --- a/android/src/main/kotlin/atomic/financial/atomic_transact_flutter/AtomicTransactFlutterPlugin.kt +++ b/android/src/main/kotlin/atomic/financial/atomic_transact_flutter/AtomicTransactFlutterPlugin.kt @@ -34,6 +34,8 @@ class AtomicTransactFlutterPlugin: FlutterPlugin, MethodCallHandler, ActivityAwa if (call.method == "presentTransact") { val transactPath = call.argument("transactPath") as String? ?: "" val apiPath = call.argument("apiPath") as String? ?: "" + val pluginVersion = call.argument("pluginVersion") ?: "" + val suffix = if (pluginVersion.isNotEmpty()) "flutter-$pluginVersion" else "flutter" val debug = call.argument("debug") ?: false val configuration = call.argument>("configuration") val publicToken = configuration?.get("publicToken") as String @@ -71,6 +73,8 @@ class AtomicTransactFlutterPlugin: FlutterPlugin, MethodCallHandler, ActivityAwa webContentsDebuggingEnabled = debug ) + config.platform = Config.Platform.suffixed(suffix) + Transact.registerReceiver(activity, object: TransactBroadcastReceiver() { override fun onClose(data: JSONObject) { channel.invokeMethod("onCompletion", mapOf("type" to "closed", "response" to mapFromTransactResponseData(data))); @@ -93,11 +97,13 @@ class AtomicTransactFlutterPlugin: FlutterPlugin, MethodCallHandler, ActivityAwa }) Transact.present(activity, config) - } + } else if (call.method == "presentAction") { val id = call.argument("id") ?: return val transactPath = call.argument("transactPath") as String? ?: "" val apiPath = call.argument("apiPath") as String? ?: "" + val actionPluginVersion = call.argument("pluginVersion") ?: "" + val actionSuffix = if (actionPluginVersion.isNotEmpty()) "flutter-$actionPluginVersion" else "flutter" val debug = call.argument("debug") ?: false var theme = call.argument>("theme") val config = ActionConfig( @@ -107,6 +113,7 @@ class AtomicTransactFlutterPlugin: FlutterPlugin, MethodCallHandler, ActivityAwa theme = configThemeFromMap(theme), webContentsDebuggingEnabled = debug ) + config.platform = Config.Platform.suffixed(actionSuffix) Transact.registerReceiver(activity, object: TransactBroadcastReceiver() { override fun onClose(data: JSONObject) { diff --git a/ios/atomic_transact_flutter/Sources/atomic_transact_flutter/AtomicTransactFlutterPlugin.swift b/ios/atomic_transact_flutter/Sources/atomic_transact_flutter/AtomicTransactFlutterPlugin.swift index cbb5d13..b51ddc1 100644 --- a/ios/atomic_transact_flutter/Sources/atomic_transact_flutter/AtomicTransactFlutterPlugin.swift +++ b/ios/atomic_transact_flutter/Sources/atomic_transact_flutter/AtomicTransactFlutterPlugin.swift @@ -23,6 +23,7 @@ public class AtomicTransactFlutterPlugin: NSObject, FlutterPlugin { let arguments = call.arguments as! [String: Any] let transactPath = arguments["transactPath"] as! String let apiPath = arguments["apiPath"] as! String + let pluginVersion = arguments["pluginVersion"] as? String ?? "" let debugEnabled = arguments["debug"] as? Bool ?? false let decoder = JSONDecoder() @@ -31,11 +32,8 @@ public class AtomicTransactFlutterPlugin: NSObject, FlutterPlugin { if let configuration = arguments["configuration"] as? [String: Any] { do { var json = configuration - - if var platform = AtomicConfig.Platform().encode() as? [String: Any] { - platform["sdkVersion"] = platform["sdkVersion"] as! String + "-flutter" - json["platform"] = platform - } + let suffix = pluginVersion.isEmpty ? "flutter" : "flutter-\(pluginVersion)" + json["platform"] = AtomicConfig.Platform(suffixed: suffix).encode() guard let data = try? JSONSerialization.data(withJSONObject: json, options: []) else { return } diff --git a/lib/platform_interface/atomic_method_channel.dart b/lib/platform_interface/atomic_method_channel.dart index 3ab44ac..81430f7 100644 --- a/lib/platform_interface/atomic_method_channel.dart +++ b/lib/platform_interface/atomic_method_channel.dart @@ -4,6 +4,7 @@ import 'package:flutter/services.dart'; import '../src/config.dart'; import '../src/types.dart'; +import '../src/version.dart'; import 'atomic_platform_interface.dart'; class AtomicMethodChannel extends AtomicPlatformInterface { @@ -31,6 +32,7 @@ class AtomicMethodChannel extends AtomicPlatformInterface { 'transactPath': environment.transactPath, 'apiPath': environment.apiPath, 'presentationStyleIOS': presentationStyleIOS?.name, + 'pluginVersion': packageVersion, 'debug': debug, }, ); @@ -52,6 +54,7 @@ class AtomicMethodChannel extends AtomicPlatformInterface { 'apiPath': environment.apiPath, 'theme': theme?.toJson(), 'presentationStyleIOS': presentationStyleIOS?.name, + 'pluginVersion': packageVersion, 'debug': debug, }); } diff --git a/lib/src/config.dart b/lib/src/config.dart index a46b9bb..5fe1106 100644 --- a/lib/src/config.dart +++ b/lib/src/config.dart @@ -1,7 +1,5 @@ // ignore_for_file: deprecated_member_use_from_same_package -import 'dart:io' show Platform; - import 'types.dart'; /// Provide colors to customize Transact. @@ -424,12 +422,6 @@ class AtomicConfig { /// Handoff allows views to be handled outside of Transact. final List? handoff; - /// The platform being used - final Map platform = { - 'version': Platform.operatingSystemVersion, - 'name': Platform.operatingSystem - }; - /// Used to override feature flags final AtomicExperiments? experiments; @@ -467,7 +459,6 @@ class AtomicConfig { 'linkedAccount': linkedAccount, 'theme': theme?.toJson(), 'language': language, - 'platform': platform, 'deeplink': deeplink?.toJson(), 'metadata': metadata, 'search': search?.toJson(), diff --git a/lib/src/version.dart b/lib/src/version.dart new file mode 100644 index 0000000..a8dc386 --- /dev/null +++ b/lib/src/version.dart @@ -0,0 +1,3 @@ +// GENERATED — do not edit by hand. +// Updated by scripts/bump_version.sh +const String packageVersion = '3.13.4'; diff --git a/scripts/bump_version.sh b/scripts/bump_version.sh index 59482e9..89abe15 100755 --- a/scripts/bump_version.sh +++ b/scripts/bump_version.sh @@ -4,6 +4,7 @@ set -e PUBSPEC_FILE="pubspec.yaml" PODSPEC_FILE="ios/atomic_transact_flutter.podspec" +VERSION_DART_FILE="lib/src/version.dart" CHANGELOG_FILE="CHANGELOG.md" NEW_VERSION="" @@ -113,6 +114,13 @@ rm "$PUBSPEC_FILE.bak" sed -i.bak "s/s\.version *= *'[^']*'/s.version = '$new_version'/" "$PODSPEC_FILE" rm "$PODSPEC_FILE.bak" +# Update version.dart +cat > "$VERSION_DART_FILE" << DART +// GENERATED — do not edit by hand. +// Updated by scripts/bump_version.sh +const String packageVersion = '$new_version'; +DART + # Update changelog update_changelog "$new_version" @@ -120,4 +128,5 @@ echo "✅ Successfully updated version to $new_version in all files" echo "📝 Updated files:" echo " - $PUBSPEC_FILE" echo " - $PODSPEC_FILE" +echo " - $VERSION_DART_FILE" echo " - $CHANGELOG_FILE"