diff --git a/CHANGELOG.md b/CHANGELOG.md index 893f5442..73c8a750 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 6.9.0 +### Enhancement +* Issue #244 - Support for setting customer_event_alias for BranchEvent + ## 6.8.0 * Updated Native `Android` SDKs: * Android Native SDK Update 5.7.+ - [Android Version History](https://github.com/BranchMetrics/android-branch-deep-linking-attribution/releases) diff --git a/README.md b/README.md index 25b64694..a2eb0c34 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Branch.io helps mobile apps grow with deep links that power referral systems, sh Supports Android, iOS and Web. -* Android - Branch SDK Version >= 5.6.+ [Android Version History](https://github.com/BranchMetrics/android-branch-deep-linking-attribution/releases) +* Android - Branch SDK Version >= 5.7.+ [Android Version History](https://github.com/BranchMetrics/android-branch-deep-linking-attribution/releases) * iOS - Branch SDK Version >= 2.2.+ [iOS Version History](https://github.com/BranchMetrics/ios-branch-deep-linking-attribution/releases) Implemented functions in plugin: diff --git a/android/src/main/java/br/com/rsmarques/flutter_branch_sdk/FlutterBranchSdkHelper.java b/android/src/main/java/br/com/rsmarques/flutter_branch_sdk/FlutterBranchSdkHelper.java index f5be7455..d5a8af5c 100644 --- a/android/src/main/java/br/com/rsmarques/flutter_branch_sdk/FlutterBranchSdkHelper.java +++ b/android/src/main/java/br/com/rsmarques/flutter_branch_sdk/FlutterBranchSdkHelper.java @@ -176,7 +176,6 @@ BranchEvent convertToEvent(HashMap eventMap) { } else { event = new BranchEvent((String) eventMap.get("eventName")); } - if (eventMap.containsKey("transactionID")) event.setTransactionID((String) eventMap.get("transactionID")); if (eventMap.containsKey("currency")) @@ -202,6 +201,9 @@ BranchEvent convertToEvent(HashMap eventMap) { event.addCustomDataProperty(customData.getKey(), customData.getValue()); } } + if (eventMap.containsKey("alias")) { + event.setCustomerEventAlias((String) eventMap.get("alias")); + } return event; } diff --git a/android/src/main/java/br/com/rsmarques/flutter_branch_sdk/FlutterBranchSdkInit.java b/android/src/main/java/br/com/rsmarques/flutter_branch_sdk/FlutterBranchSdkInit.java index bdf6b4a9..b4138a3e 100644 --- a/android/src/main/java/br/com/rsmarques/flutter_branch_sdk/FlutterBranchSdkInit.java +++ b/android/src/main/java/br/com/rsmarques/flutter_branch_sdk/FlutterBranchSdkInit.java @@ -8,7 +8,7 @@ public class FlutterBranchSdkInit { private static final String DEBUG_NAME = "FlutterBranchSDK"; private static final String PLUGIN_NAME = "Flutter"; - private static final String PLUGIN_VERSION = "6.8.0"; + private static final String PLUGIN_VERSION = "6.9.0"; public static void init(Context context) { ApplicationInfoHelper applicationInfoHelper = new ApplicationInfoHelper(context); diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index f935ae78..9bea9db5 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -2,7 +2,7 @@ package="br.com.rsmarques.flutter_branch_sdk_example"> 2.2.1) - Flutter @@ -22,8 +22,8 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: BranchSDK: cb046c2714b03e573484ce9e349e2ddbad7016e8 Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 - flutter_branch_sdk: 4abdebac9688050516f1fba611c60539ab8557e1 + flutter_branch_sdk: 938f6f386a976356ee7e5f60969e53d4ae5704d9 PODFILE CHECKSUM: 7368163408c647b7eb699d0d788ba6718e18fb8d -COCOAPODS: 1.11.3 +COCOAPODS: 1.12.1 diff --git a/example/pubspec.lock b/example/pubspec.lock index 07872b2b..054b8959 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -68,7 +68,7 @@ packages: path: ".." relative: true source: path - version: "6.8.0" + version: "6.9.0" flutter_lints: dependency: "direct dev" description: diff --git a/ios/Classes/FlutterBranchIoSdkHelper.swift b/ios/Classes/FlutterBranchIoSdkHelper.swift index 0f398ba8..e1ef44ed 100644 --- a/ios/Classes/FlutterBranchIoSdkHelper.swift +++ b/ios/Classes/FlutterBranchIoSdkHelper.swift @@ -194,6 +194,9 @@ func convertToEvent(dict: [String: Any?]) -> BranchEvent? { event.customData[customData.key] = (customData.value as! String) } } + if let alias = dict["alias"] as? String { + event.alias = alias + } return event } diff --git a/ios/Classes/SwiftFlutterBranchSdkPlugin.swift b/ios/Classes/SwiftFlutterBranchSdkPlugin.swift index 4be4d11b..f398fe51 100644 --- a/ios/Classes/SwiftFlutterBranchSdkPlugin.swift +++ b/ios/Classes/SwiftFlutterBranchSdkPlugin.swift @@ -10,7 +10,7 @@ let MESSAGE_CHANNEL = "flutter_branch_sdk/message"; let EVENT_CHANNEL = "flutter_branch_sdk/event"; let ERROR_CODE = "FLUTTER_BRANCH_SDK_ERROR"; let PLUGIN_NAME = "Flutter"; -let PLUGIN_VERSION = "6.8.0" +let PLUGIN_VERSION = "6.9.0" public class SwiftFlutterBranchSdkPlugin: NSObject, FlutterPlugin, FlutterStreamHandler { var eventSink: FlutterEventSink? diff --git a/lib/src/flutter_branch_sdk_web.dart b/lib/src/flutter_branch_sdk_web.dart index 902a7197..9a84c5eb 100644 --- a/lib/src/flutter_branch_sdk_web.dart +++ b/lib/src/flutter_branch_sdk_web.dart @@ -204,15 +204,23 @@ class FlutterBranchSdkWeb extends FlutterBranchSdkPlatform { void trackContent( {required List buo, required BranchEvent branchEvent}) { - js.JsArray contentItems = js.JsArray(); + List contentItems = []; for (var element in buo) { contentItems.add(_dartObjectToJsObject(element.toMap())); } try { - BranchJS.logEvent(branchEvent.eventName, - _dartObjectToJsObject(branchEvent.toMap()), contentItems); + if (branchEvent.alias.isNotEmpty) { + BranchJS.logEvent( + branchEvent.eventName, + _dartObjectToJsObject(branchEvent.toMap()), + contentItems, + branchEvent.alias); + } else { + BranchJS.logEvent(branchEvent.eventName, + _dartObjectToJsObject(branchEvent.toMap()), contentItems); + } } catch (e) { debugPrint('trackContent() error: ${e.toString()}'); } diff --git a/lib/src/objects/branch_event.dart b/lib/src/objects/branch_event.dart index ed1753d1..682378f0 100644 --- a/lib/src/objects/branch_event.dart +++ b/lib/src/objects/branch_event.dart @@ -60,6 +60,7 @@ class BranchEvent { String searchQuery = ''; BranchEventAdType? adType; final Map _customData = {}; + String alias = ''; BranchEvent.standardEvent(BranchStandardEvent branchStandardEvent) { _eventName = getBranchStandardEventString(branchStandardEvent); @@ -82,59 +83,60 @@ class BranchEvent { } Map toMap() { - Map ret = {}; + Map data = {}; if (!kIsWeb) { - ret["eventName"] = _eventName; - ret["isStandardEvent"] = _isStandardEvent; + data["eventName"] = _eventName; + data["isStandardEvent"] = _isStandardEvent; if (transactionID.isNotEmpty) { - ret["transactionID"] = transactionID; + data["transactionID"] = transactionID; } if (currency != null) { - ret["currency"] = getCurrencyTypeString(currency!); + data["currency"] = getCurrencyTypeString(currency!); } - if (revenue != -1) ret["revenue"] = revenue; - if (shipping != -1) ret["shipping"] = shipping; - if (tax != -1) ret["tax"] = tax; - if (coupon.isNotEmpty) ret["coupon"] = coupon; - if (affiliation.isNotEmpty) ret["affiliation"] = affiliation; + if (revenue != -1) data["revenue"] = revenue; + if (shipping != -1) data["shipping"] = shipping; + if (tax != -1) data["tax"] = tax; + if (coupon.isNotEmpty) data["coupon"] = coupon; + if (affiliation.isNotEmpty) data["affiliation"] = affiliation; if (eventDescription.isNotEmpty) { - ret["eventDescription"] = eventDescription; + data["eventDescription"] = eventDescription; } if (searchQuery.isNotEmpty) { - ret["searchQuery"] = searchQuery; + data["searchQuery"] = searchQuery; } if (adType != null) { - ret["adType"] = getBranchEventAdTypeString(adType!); + data["adType"] = getBranchEventAdTypeString(adType!); } - if (_customData.isNotEmpty) ret["customData"] = _customData; + if (_customData.isNotEmpty) data["customData"] = _customData; + if (alias.isNotEmpty) data["alias"] = alias; } else { if (_isStandardEvent) { if (transactionID.isNotEmpty) { - ret["transactionID"] = transactionID; + data["transactionID"] = transactionID; } if (currency != null) { - ret["currency"] = getCurrencyTypeString(currency!); + data["currency"] = getCurrencyTypeString(currency!); } - if (revenue != -1) ret["revenue"] = revenue; - if (shipping != -1) ret["shipping"] = shipping; - if (tax != -1) ret["tax"] = tax; - if (coupon.isNotEmpty) ret["coupon"] = coupon; - if (affiliation.isNotEmpty) ret["affiliation"] = affiliation; + if (revenue != -1) data["revenue"] = revenue; + if (shipping != -1) data["shipping"] = shipping; + if (tax != -1) data["tax"] = tax; + if (coupon.isNotEmpty) data["coupon"] = coupon; + if (affiliation.isNotEmpty) data["affiliation"] = affiliation; if (eventDescription.isNotEmpty) { - ret["eventDescription"] = eventDescription; + data["eventDescription"] = eventDescription; } if (searchQuery.isNotEmpty) { - ret["searchQuery"] = searchQuery; + data["searchQuery"] = searchQuery; } if (adType != null) { - ret["adType"] = getBranchEventAdTypeString(adType!); + data["adType"] = getBranchEventAdTypeString(adType!); } } _customData.forEach((key, value) { - ret[key] = value; + data[key] = value; }); } - return ret; + return data; } } diff --git a/lib/src/web/branch_js.dart b/lib/src/web/branch_js.dart index cc0c64d9..2920df28 100644 --- a/lib/src/web/branch_js.dart +++ b/lib/src/web/branch_js.dart @@ -1,8 +1,6 @@ @JS() library branchjs; -// ignore: avoid_web_libraries_in_flutter -import 'dart:js'; import 'dart:typed_data'; import 'package:js/js.dart'; @@ -757,7 +755,7 @@ class BranchJS { @JS('logEvent') external static void logEvent(String event, [Object eventDataAndCustomData, - JsArray contentItems, + Object contentItems, String customerEventAlias, Function callback]); diff --git a/pubspec.yaml b/pubspec.yaml index 3915141e..62e8176a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_branch_sdk description: Flutter Plugin for create deep link using Brach SDK (https://branch.io). This plugin provides a cross-platform (iOS, Android, Web). -version: 6.8.0 +version: 6.9.0 homepage: https://github.com/RodrigoSMarques/flutter_branch_sdk environment: