From d5969226fd3c221d77c74528dbd85db21843a50c Mon Sep 17 00:00:00 2001 From: Po-Ting Wu Date: Wed, 2 Feb 2022 13:12:40 -0800 Subject: [PATCH] Update for v1.2.1 - Update secure links, and installation instructions in README - Improve codes static analysis, and format libraries codes --- CHANGELOG.md | 7 + README.md | 58 ++--- example/lib/main.dart | 23 +- lib/flurry.dart | 262 ++++++++++++---------- lib/{ => src}/flurry_agent.dart | 370 +++++++++++++++----------------- pubspec.yaml | 4 +- 6 files changed, 360 insertions(+), 364 deletions(-) rename lib/{ => src}/flurry_agent.dart (66%) diff --git a/CHANGELOG.md b/CHANGELOG.md index bc93968..152c0c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ * [Flurry Android SDK Release Notes](https://developer.yahoo.com/flurry/docs/releasenotes/android/) * [Flurry iOS SDK Release Notes](https://developer.yahoo.com/flurry/docs/releasenotes/ios/) +### v1.2.1 (2022-02-06) + +#### Bug Fixes + +* Update secure links, and installation instructions in README +* Improve codes static analysis, and format libraries codes + ## v1.2.0 (2022-02-02) #### Features diff --git a/README.md b/README.md index ebc3b52..eabb53c 100644 --- a/README.md +++ b/README.md @@ -17,34 +17,17 @@ A Flutter plugin for Flurry SDK ## Installation -1. Install Flurry Flutter plugin from [https://github.com/flurry/flutter-flurry-sdk](https://github.com/flurry/flutter-flurry-sdk) or add it as a dependency from Github. +1. Install Flutter Flurry SDK plugin by running this command in the terminal from the directory containing `pubspec.yaml` file. -2. Open the pubspec.yaml file in your project and add "flutter_flurry_sdk" as a dependency to your project. ```bash - dependencies: - flutter_flurry_sdk: + $ flutter pub add flutter_flurry_sdk + ``` + +2. Flutter Flurry SDK has been added as a dependency. Now, import the `flurry.dart` class in the files calling Flurry SDK APIs. + + ```dart + import 'package:flutter_flurry_sdk/flurry.dart'; ``` - 1. If you want to specify a version range: - 1. Using range constraints: ```flutter_flurry_sdk: `>=1.0.0 <2.0.0` ``` - 2. Using range constraints with caret syntax: ```flutter_flurry_sdk: `^1.0.0` ``` -3. Specify path under the flutter_flurry_sdk plugin dependency in pubspec.yaml - 1. Flutter plugin from local directories: - ``` - path: /path/to/flutter_flurry_sdk - ``` - 2. Flutter plugin from Github: - ``` - git: - url: git://github.com/flutter_flurry_sdk.git - ``` -4. run ``` flutter pub get``` in the terminal from the directory containing pubspec.yaml file or click "Packages get" in -Intellij or Android Studio. - -5. Flutter Flurry SDK has been added as a dependency. Now, import the flurry.dart class in the -files calling Flurry SDK APIs. -```dart -import 'package:flutter_flurry_sdk/flurry.dart'; -``` ### Android @@ -113,11 +96,11 @@ import 'package:flutter_flurry_sdk/flurry.dart'; To set up Flurry Push, please take the following steps. 1. Open your `.xcworkspace` file which is under the `ios` folder. Go to "Capabilities" tab and enable Push Notifications. - ![push_ios_1](images/push_ios_1.png) + ![push_ios_1](https://github.com/flurry/flutter-flurry-sdk/raw/main/images/push_ios_1.png) 2. Enable Background Modes (Background Fetch and Remote Notifications turned on). - ![push_ios_2](images/push_ios_2.png) + ![push_ios_2](https://github.com/flurry/flutter-flurry-sdk/raw/main/images/push_ios_2.png) Now your `Info.plist` should contain the following items. For more information, please see [Push Setup](https://developer.yahoo.com/flurry/docs/push/integration/ios/). - ![push_ios_3](images/push_ios_3.png) + ![push_ios_3](https://github.com/flurry/flutter-flurry-sdk/raw/main/images/push_ios_3.png) 3. Set up "iOS Authorization" in Flurry [Push Authorization](https://developer.yahoo.com/flurry/docs/push/authorization/). ### tvOS @@ -142,8 +125,9 @@ import 'package:flutter_flurry_sdk/flurry.dart'; .withCrashReporting(true) .withLogEnabled(true) .withLogLevel(LogLevel.debug) - .build(androidAPIKey: FLURRY_ANDROID_API_KEY, - iosAPIKey: FLURRY_IOS_API_KEY); + .build( + androidAPIKey: FLURRY_ANDROID_API_KEY, + iosAPIKey: FLURRY_IOS_API_KEY); ``` - `lib/example.dart` @@ -245,13 +229,13 @@ import 'package:flutter_flurry_sdk/flurry.dart'; class MyMessagingListener with MessagingListener { @override - bool onNotificationClicked(Message message){ + bool onNotificationClicked(Message message) { printMessage("onNotificationClicked", message); return false; } @override - bool onNotificationReceived(Message message){ + bool onNotificationReceived(Message message) { printMessage("onNotificationReceived", message); return false; } @@ -262,7 +246,7 @@ import 'package:flutter_flurry_sdk/flurry.dart'; } @override - void onTokenRefresh(String token){ + void onTokenRefresh(String token) { print("Flurry Messaging Type: onTokenRefresh" + "\n Token: " + token); } @@ -293,8 +277,8 @@ import 'package:flutter_flurry_sdk/flurry.dart'; ## API Reference -See [Android](http://flurry.github.io/flurry-android-sdk/analytics/index.html)-[(FlurryAgent)](http://flurry.github.io/flurry-android-sdk/analytics/com/flurry/android/FlurryAgent.html) / -[iOS](http://flurry.github.io/flurry-ios-sdk/Flurry%20Analytics%20API%20Documentation/index.html)-[(Flurry)](http://flurry.github.io/flurry-ios-sdk/Flurry%20Analytics%20API%20Documentation/interface_flurry.html) for the Flurry references. +See [Android](https://flurry.github.io/flurry-android-sdk/analytics/index.html)-[(FlurryAgent)](https://flurry.github.io/flurry-android-sdk/analytics/com/flurry/android/FlurryAgent.html) / +[iOS](https://flurry.github.io/flurry-ios-sdk/Flurry%20Analytics%20API%20Documentation/index.html)-[(Flurry)](https://flurry.github.io/flurry-ios-sdk/Flurry%20Analytics%20API%20Documentation/interface_flurry.html) for the Flurry references. - **Methods in Flurry.builder to initialize Flurry Agent** @@ -840,6 +824,6 @@ See [Android](http://flurry.github.io/flurry-android-sdk/analytics/index.html)-[ ## License -Copyright 2018 Oath Inc. +Copyright 2022 Yahoo Inc. -This project is licensed under the terms of the [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0) open source license. Please refer to [LICENSE](https://github.com/flurry/flutter-flurry-sdk/blob/main/LICENSE) for the full terms. +This project is licensed under the terms of the [Apache 2.0](https://www.apache.org/licenses/LICENSE-2.0) open source license. Please refer to [LICENSE](https://raw.githubusercontent.com/flurry/flutter-flurry-sdk/main/LICENSE) for the full terms. diff --git a/example/lib/main.dart b/example/lib/main.dart index adb9023..8cdfcc3 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -32,11 +32,11 @@ class MyAppState extends State { } Future initPlatformState() async { - // Init and run Flurry APIs asynchronously. - await FlurryExample.init(); - await FlurryExample.example(); - await FlurryExample.config(); - await FlurryExample.publisherSegmentation(); + // Init and run Flurry APIs. + FlurryExample.init(); + FlurryExample.example(); + FlurryExample.config(); + FlurryExample.publisherSegmentation(); } @override @@ -56,7 +56,7 @@ class MyAppState extends State { class FlurryExample { static const String FLURRY_ANDROID_API_KEY = 'C9R699NJWSMJVPQWJ273'; - static const String FLURRY_IOS_API_KEY = 'RPBHT5CJFFJ9WCS3C5R6'; + static const String FLURRY_IOS_API_KEY = 'RPBHT5CJFFJ9WCS3C5R6'; static void init() { // Init Flurry once as early as possible recommended in main.dart. @@ -68,11 +68,12 @@ class FlurryExample { .withLogEnabled(true) .withLogLevel(LogLevel.debug) .withMessaging(true, new MyMessagingListener()) - .build(androidAPIKey: FLURRY_ANDROID_API_KEY, - iosAPIKey: FLURRY_IOS_API_KEY); + .build( + androidAPIKey: FLURRY_ANDROID_API_KEY, + iosAPIKey: FLURRY_IOS_API_KEY); } - static Future example() async { + static void example() async { // Example to get Flurry versions. int agentVersion = await Flurry.getAgentVersion(); print("Agent Version: $agentVersion"); @@ -156,13 +157,13 @@ class MyConfigListener with ConfigListener { class MyMessagingListener with MessagingListener { @override - bool onNotificationClicked(Message message){ + bool onNotificationClicked(Message message) { printMessage("onNotificationClicked", message); return false; } @override - bool onNotificationReceived(Message message){ + bool onNotificationReceived(Message message) { printMessage("onNotificationReceived", message); return false; } diff --git a/lib/flurry.dart b/lib/flurry.dart index d99e814..b443f33 100644 --- a/lib/flurry.dart +++ b/lib/flurry.dart @@ -12,22 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -import 'dart:async'; -import 'dart:core'; import 'dart:io'; - import 'package:flutter/services.dart'; -import 'flurry_agent.dart'; +import 'src/flurry_agent.dart'; -enum LogLevel { - verbose, - debug, - info, - warn, - error, - assertion -} +enum LogLevel { verbose, debug, info, warn, error, assertion } /// Constants for logging post install events using Flurry's FlurrySKAdNetwork class. enum SKAdNetworkEvent { @@ -50,10 +40,7 @@ enum EventRecordStatus { } /// Constants for setting user gender in analytics SDK. -enum Gender { - male, - female -} +enum Gender { male, female } /// A Flutter plugin for Flurry SDK. /// @@ -63,14 +50,17 @@ enum Gender { /// Set of methods that allow developers to capture detailed, aggregate information /// regarding the use of their app by end users. class Flurry { - static const MethodChannel _channel = const MethodChannel('flurry_flutter_plugin'); + static const MethodChannel _channel = + const MethodChannel('flurry_flutter_plugin'); - static final FlurryAgent flurryAgent = (Platform.isAndroid || Platform.isIOS) ? new FlurryAgent() : null; + static final FlurryAgent flurryAgent = + (Platform.isAndroid || Platform.isIOS) ? new FlurryAgent() : null; static final Builder builder = Builder(); static final UserProperties userProperties = UserProperties(); static final Performance performance = Performance(); static final Config config = Config(); - static final PublisherSegmentation publisherSegmentation = PublisherSegmentation(); + static final PublisherSegmentation publisherSegmentation = + PublisherSegmentation(); static Future getPlatformVersion() async { String version = await _channel.invokeMethod('getPlatformVersion'); @@ -79,7 +69,7 @@ class Flurry { /// Get constants for setting log level in analytics SDK. int getLogLevel(LogLevel logLevel) { - switch(logLevel) { + switch (logLevel) { case LogLevel.verbose: case LogLevel.debug: case LogLevel.info: @@ -117,9 +107,11 @@ class Flurry { /// Set [includeBackgroundSessionsInMetrics] true if this session should be /// added to total sessions/DAUs when application state is inactive or background. /// This API needs to be called before starting session. - static void setIncludeBackgroundSessionsInMetrics([bool includeBackgroundSessionsInMetrics = true]) { + static void setIncludeBackgroundSessionsInMetrics( + [bool includeBackgroundSessionsInMetrics = true]) { if (flurryAgent != null) { - flurryAgent.setIncludeBackgroundSessionsInMetrics(includeBackgroundSessionsInMetrics); + flurryAgent.setIncludeBackgroundSessionsInMetrics( + includeBackgroundSessionsInMetrics); } } @@ -235,8 +227,8 @@ class Flurry { static void addOriginWithParameters(String originName, String originVersion, Map originParameters) { if (flurryAgent != null) { - flurryAgent.addOriginWithParameters(originName, originVersion, - originParameters); + flurryAgent.addOriginWithParameters( + originName, originVersion, originParameters); } } @@ -259,7 +251,7 @@ class Flurry { } /// Returns the release version of the Flurry SDK. - static Future getReleaseVersion() async{ + static Future getReleaseVersion() async { if (flurryAgent != null) { String version = await flurryAgent.getReleaseVersion(); return version; @@ -269,7 +261,7 @@ class Flurry { } /// Returns the session id of the current session. - static Future getSessionId() async{ + static Future getSessionId() async { if (flurryAgent != null) { String sessionId = await flurryAgent.getSessionId(); return sessionId; @@ -293,8 +285,8 @@ class Flurry { /// /// Logs [eventId] as a non timed event or a timed event based on boolean /// [timed]. Returns the event recording status of the logged event. - static Future logTimedEvent(String eventId, bool timed) - async { + static Future logTimedEvent( + String eventId, bool timed) async { if (flurryAgent != null) { int eventRecordStatus = await flurryAgent.logTimedEvent(eventId, timed); return EventRecordStatus.values[eventRecordStatus]; @@ -308,11 +300,11 @@ class Flurry { /// Logs [eventId] with maximum of 10 [parameters] which helps in specifying /// the characteristics of the event. Returns the event recording status /// of the logged event. - static Future logEventWithParameters(String eventId, - Map parameters) async { + static Future logEventWithParameters( + String eventId, Map parameters) async { if (flurryAgent != null) { - int eventRecordStatus = await flurryAgent.logEventWithParameters(eventId, - parameters); + int eventRecordStatus = + await flurryAgent.logEventWithParameters(eventId, parameters); return EventRecordStatus.values[eventRecordStatus]; } @@ -324,10 +316,11 @@ class Flurry { /// Logs [eventId] as a non timed event or a timed event based on boolean /// [timed]. Use maximum of 10 [parameters] to specify the characters of the /// event. Returns the event recording status of the logged event. - static Future logTimedEventWithParameters(String eventId, - Map parameters, bool timed) async { + static Future logTimedEventWithParameters( + String eventId, Map parameters, bool timed) async { if (flurryAgent != null) { - int eventRecordStatus = await flurryAgent.logTimedEventWithParameters(eventId, parameters, timed); + int eventRecordStatus = await flurryAgent.logTimedEventWithParameters( + eventId, parameters, timed); return EventRecordStatus.values[eventRecordStatus]; } @@ -349,8 +342,8 @@ class Flurry { /// existing parameters to the new [parameters] Maximum of 10 unique /// parameters total can be passed for an event, including those passed when /// the event was initiated. - static void endTimedEventWithParameters(String eventId, Map parameters) { + static void endTimedEventWithParameters( + String eventId, Map parameters) { if (flurryAgent != null) { flurryAgent.endTimedEventWithParameters(eventId, parameters); } @@ -376,8 +369,8 @@ class Flurry { static void onErrorWithParameters(String errorId, String message, String errorClass, Map parameters) { if (flurryAgent != null) { - flurryAgent.onErrorWithParameters(errorId, message, errorClass, - parameters); + flurryAgent.onErrorWithParameters( + errorId, message, errorClass, parameters); } } @@ -398,11 +391,16 @@ class Flurry { /// characteristics of the payment. Returns the event recording status of the /// logged event. static Future logPayment( - String productName, String productId, int quantity, double price, - String currency, String transactionId, Map parameters) async { + String productName, + String productId, + int quantity, + double price, + String currency, + String transactionId, + Map parameters) async { if (flurryAgent != null) { - int eventRecordStatus = await flurryAgent.logPayment(productName, productId, quantity, price, - currency, transactionId, parameters); + int eventRecordStatus = await flurryAgent.logPayment(productName, + productId, quantity, price, currency, transactionId, parameters); return EventRecordStatus.values[eventRecordStatus]; } @@ -414,14 +412,15 @@ class Flurry { /// Records a standard parameterized event specified by event type named [id] /// and maximum of 10 parameters passed as [param]. Returns the event recording /// status of the logged standard event. - static Future logStandardEvent(FlurryEvent id, Param param) async{ + static Future logStandardEvent( + FlurryEvent id, Param param) async { if (flurryAgent != null) { int eventRecordStatus = await flurryAgent.logStandardEvent(id, param); return EventRecordStatus.values[eventRecordStatus]; } return EventRecordStatus.eventFailed; } - + /// Enables implicit recording of In-App transactions. /// /// This method needs to be called before any transaction is finalized. @@ -479,10 +478,7 @@ class Builder { } } - void build({ - String androidAPIKey = "", - String iosAPIKey = ""}) { - + void build({String androidAPIKey = "", String iosAPIKey = ""}) { if (builderAgent != null) { Map arguments = {}; arguments.putIfAbsent("androidAPIKey", () => androidAPIKey); @@ -542,9 +538,11 @@ class Builder { /// Set [includeBackgroundSessionsInMetrics] true if this session should be /// added to total sessions/DAUs when application state is inactive or background. /// This API needs to be called before starting session. - Builder withIncludeBackgroundSessionsInMetrics([bool includeBackgroundSessionsInMetrics = true]) { + Builder withIncludeBackgroundSessionsInMetrics( + [bool includeBackgroundSessionsInMetrics = true]) { if (builderAgent != null) { - builderAgent.withIncludeBackgroundSessionsInMetrics(includeBackgroundSessionsInMetrics); + builderAgent.withIncludeBackgroundSessionsInMetrics( + includeBackgroundSessionsInMetrics); } return this; } @@ -588,7 +586,8 @@ class Builder { /// 1) Registers for Notifications. /// 2) Handles device token. /// 3) Listens for callbacks from UIApplication and UNUserNotificationCenter. - Builder withMessaging([bool enableMessaging = true, MessagingListener listener]) { + Builder withMessaging( + [bool enableMessaging = true, MessagingListener listener]) { if (!enableMessaging) { return this; } @@ -599,17 +598,16 @@ class Builder { if (Platform.isIOS) { messagingAgent.withMessaging(); } else { - print("To enable Flurry Push for Android, please duplicate Builder setup in your FlutterApplication class."); + print( + "To enable Flurry Push for Android, please duplicate Builder setup in your FlutterApplication class."); } } return this; } - } /// User Properties class for Flurry class UserProperties { - /// Standard User Property: Currency Preference. /// /// Follow ISO 4217: https://en.wikipedia.org/wiki/ISO_4217 @@ -698,7 +696,8 @@ class UserProperties { /// and does not error void removeValues(String propertyName, List propertyValues) { if (userPropertiesAgent != null) { - userPropertiesAgent.removeUserPropertyValues(propertyName, propertyValues); + userPropertiesAgent.removeUserPropertyValues( + propertyName, propertyValues); } } @@ -766,7 +765,7 @@ class Performance { /// Flurry.Performance.LogResourceLogger("My ID"); /// ``` void startResourceLogger() { - if (performanceAgent!= null) { + if (performanceAgent != null) { performanceAgent.startResourceLogger(); } } @@ -794,14 +793,13 @@ class Message { /// take actions within the App, which is useful when used with the Flurry /// Messaging mixin MessagingListener { - /// Informs the app when Flurry Notification received. /// /// Returns true if you've handled the notification; false if you haven't and /// want Flurry to handle it. /// **For Android only, you might want to return false for iOS.** bool onNotificationReceived(Message message); - + /// Informs the app when Flurry Notification receives an action. /// /// Return true if you've handled the notification; false if you haven't and @@ -823,7 +821,6 @@ mixin MessagingListener { /// A set of actions that allow an observing class to take action based on /// certain events, such as fetch operations or activations. mixin ConfigListener { - /// Informs the app when a fetch is initiated and completed with a change. void onFetchSuccess(); @@ -880,7 +877,7 @@ class Config { configAgent = new ConfigAgent(); } } - + /// Fetches the most recent config from the server for this client. /// /// Upon completion of the fetch, the [ConfigListener] will be called to make @@ -895,7 +892,7 @@ class Config { configAgent.fetchConfig(); } } - + /// Aggressively activates the latest config if it has not been activated. /// /// Puts the latest config directly into use, unlike the typical operation @@ -932,7 +929,7 @@ class Config { /// but all attempts should be made to validate that the returned value is, /// indeed, a fully formed string. If no value is provided in the config the /// [defaultValue] will be chosen. - Future getConfigString(String key, String defaultValue) async{ + Future getConfigString(String key, String defaultValue) async { if (configAgent != null) { String value = await configAgent.getConfigString(key, defaultValue); return value; @@ -941,7 +938,7 @@ class Config { } } -enum FlurryEvent{ +enum FlurryEvent { /// Log this event when a user clicks on an Ad. /// /// Suggested event params: adType @@ -955,7 +952,7 @@ enum FlurryEvent{ /// /// Mandatory event params : none adImpression, - + /// Log this event when a user is granted a reward for viewing a rewarded Ad. /// /// Suggested event params : adType @@ -1361,49 +1358,92 @@ enum FlurryEvent{ /// [EventParam] contains all Flurry defined parameter keys to log standard event. class EventParam { - static final StringParam adType = new StringParam(StandardParam.eventParamAdType); - static final StringParam levelName = new StringParam(StandardParam.eventParamLevelName); - static final IntegerParam levelNumber = new IntegerParam(StandardParam.eventParamLevelNumber); - static final StringParam contentName = new StringParam(StandardParam.eventParamContentName); - static final StringParam contentType = new StringParam(StandardParam.eventParamContentType); - static final StringParam contentId = new StringParam(StandardParam.eventParamContentId); - static final StringParam creditName = new StringParam(StandardParam.eventParamCreditName); - static final StringParam creditType = new StringParam(StandardParam.eventParamCreditType); - static final StringParam creditId = new StringParam(StandardParam.eventParamCreditId); - static final BooleanParam isCurrencySoft = new BooleanParam(StandardParam.eventParamIsCurrencySoft); - static final StringParam currencyType = new StringParam(StandardParam.eventParamCurrencyType); - static final StringParam paymentType = new StringParam(StandardParam.eventParamPaymentType); - static final StringParam itemName = new StringParam(StandardParam.eventParamItemName); - static final StringParam itemType = new StringParam(StandardParam.eventParamItemType); - static final StringParam itemId = new StringParam(StandardParam.eventParamItemId); - static final IntegerParam itemCount = new IntegerParam(StandardParam.eventParamItemCount); - static final StringParam itemCategory = new StringParam(StandardParam.eventParamItemCategory); - static final StringParam itemListType = new StringParam(StandardParam.eventParamItemListType); - static final DoubleParam price = new DoubleParam(StandardParam.eventParamPrice); - static final DoubleParam totalAmount = new DoubleParam(StandardParam.eventParamTotalAmount); - static final StringParam achievementId = new StringParam(StandardParam.eventParamAchievementId); - static final IntegerParam score = new IntegerParam(StandardParam.eventParamScore); - static final StringParam rating = new StringParam(StandardParam.eventParamRating); - static final StringParam transactionId = new StringParam(StandardParam.eventParamTransactionId); - static final BooleanParam success = new BooleanParam(StandardParam.eventParamSuccess); - static final BooleanParam isAnnualSubscription = new BooleanParam(StandardParam.eventParamIsAnnualSubscription); - static final StringParam subscriptionCountry = new StringParam(StandardParam.eventParamSubscriptionCountry); - static final IntegerParam trialDays = new IntegerParam(StandardParam.eventParamTrialDays); - static final StringParam predictedLTV = new StringParam(StandardParam.eventParamPredictedLTV); - static final StringParam groupName = new StringParam(StandardParam.eventParamGroupName); - static final StringParam tutorialName = new StringParam(StandardParam.eventParamTutorialName); - static final IntegerParam stepNumber = new IntegerParam(StandardParam.eventParamStepNumber); - static final StringParam userId = new StringParam(StandardParam.eventParamUserId); - static final StringParam method = new StringParam(StandardParam.eventParamMethod); - static final StringParam query = new StringParam(StandardParam.eventParamQuery); - static final StringParam searchType = new StringParam(StandardParam.eventParamSearchType); - static final StringParam socialContentName = new StringParam(StandardParam.eventParamSocialContentName); - static final StringParam socialContentId = new StringParam(StandardParam.eventParamSocialContentId); - static final StringParam likeType = new StringParam(StandardParam.eventParamLikeType); - static final StringParam mediaName = new StringParam(StandardParam.eventParamMediaName); - static final StringParam mediaType = new StringParam(StandardParam.eventParamMediaType); - static final StringParam mediaId = new StringParam(StandardParam.eventParamMediaId); - static final IntegerParam duration = new IntegerParam(StandardParam.eventParamDuration); + static final StringParam adType = + new StringParam(StandardParam.eventParamAdType); + static final StringParam levelName = + new StringParam(StandardParam.eventParamLevelName); + static final IntegerParam levelNumber = + new IntegerParam(StandardParam.eventParamLevelNumber); + static final StringParam contentName = + new StringParam(StandardParam.eventParamContentName); + static final StringParam contentType = + new StringParam(StandardParam.eventParamContentType); + static final StringParam contentId = + new StringParam(StandardParam.eventParamContentId); + static final StringParam creditName = + new StringParam(StandardParam.eventParamCreditName); + static final StringParam creditType = + new StringParam(StandardParam.eventParamCreditType); + static final StringParam creditId = + new StringParam(StandardParam.eventParamCreditId); + static final BooleanParam isCurrencySoft = + new BooleanParam(StandardParam.eventParamIsCurrencySoft); + static final StringParam currencyType = + new StringParam(StandardParam.eventParamCurrencyType); + static final StringParam paymentType = + new StringParam(StandardParam.eventParamPaymentType); + static final StringParam itemName = + new StringParam(StandardParam.eventParamItemName); + static final StringParam itemType = + new StringParam(StandardParam.eventParamItemType); + static final StringParam itemId = + new StringParam(StandardParam.eventParamItemId); + static final IntegerParam itemCount = + new IntegerParam(StandardParam.eventParamItemCount); + static final StringParam itemCategory = + new StringParam(StandardParam.eventParamItemCategory); + static final StringParam itemListType = + new StringParam(StandardParam.eventParamItemListType); + static final DoubleParam price = + new DoubleParam(StandardParam.eventParamPrice); + static final DoubleParam totalAmount = + new DoubleParam(StandardParam.eventParamTotalAmount); + static final StringParam achievementId = + new StringParam(StandardParam.eventParamAchievementId); + static final IntegerParam score = + new IntegerParam(StandardParam.eventParamScore); + static final StringParam rating = + new StringParam(StandardParam.eventParamRating); + static final StringParam transactionId = + new StringParam(StandardParam.eventParamTransactionId); + static final BooleanParam success = + new BooleanParam(StandardParam.eventParamSuccess); + static final BooleanParam isAnnualSubscription = + new BooleanParam(StandardParam.eventParamIsAnnualSubscription); + static final StringParam subscriptionCountry = + new StringParam(StandardParam.eventParamSubscriptionCountry); + static final IntegerParam trialDays = + new IntegerParam(StandardParam.eventParamTrialDays); + static final StringParam predictedLTV = + new StringParam(StandardParam.eventParamPredictedLTV); + static final StringParam groupName = + new StringParam(StandardParam.eventParamGroupName); + static final StringParam tutorialName = + new StringParam(StandardParam.eventParamTutorialName); + static final IntegerParam stepNumber = + new IntegerParam(StandardParam.eventParamStepNumber); + static final StringParam userId = + new StringParam(StandardParam.eventParamUserId); + static final StringParam method = + new StringParam(StandardParam.eventParamMethod); + static final StringParam query = + new StringParam(StandardParam.eventParamQuery); + static final StringParam searchType = + new StringParam(StandardParam.eventParamSearchType); + static final StringParam socialContentName = + new StringParam(StandardParam.eventParamSocialContentName); + static final StringParam socialContentId = + new StringParam(StandardParam.eventParamSocialContentId); + static final StringParam likeType = + new StringParam(StandardParam.eventParamLikeType); + static final StringParam mediaName = + new StringParam(StandardParam.eventParamMediaName); + static final StringParam mediaType = + new StringParam(StandardParam.eventParamMediaType); + static final StringParam mediaId = + new StringParam(StandardParam.eventParamMediaId); + static final IntegerParam duration = + new IntegerParam(StandardParam.eventParamDuration); } enum StandardParam { @@ -1656,7 +1696,6 @@ class BooleanParam extends ParamBase { /// Provides listener method for receiving callbacks related to publisher data /// is fetched mixin PublisherSegmentationListener { - /// Informs the app when publisher data is fetched. /// /// [data] is a Map of key-value paired configuration for publisher segmentation @@ -1674,7 +1713,7 @@ class PublisherSegmentation { } /// Indicates whether the publisher data is fetched and ready to use. - Future isFetchFinished() async{ + Future isFetchFinished() async { if (publisherSegmentationAgent != null) { return await publisherSegmentationAgent.isFetchFinished(); } @@ -1709,11 +1748,10 @@ class PublisherSegmentation { /// /// Returns a map of key-value paired configuration for publisher segmentation /// data. If not yet fetched, it will return the cached segments data. - Future> getPublisherData() async{ + Future> getPublisherData() async { if (publisherSegmentationAgent != null) { return await publisherSegmentationAgent.getPublisherData(); } return null; } } - diff --git a/lib/flurry_agent.dart b/lib/src/flurry_agent.dart similarity index 66% rename from lib/flurry_agent.dart rename to lib/src/flurry_agent.dart index d847b75..9427ea9 100644 --- a/lib/flurry_agent.dart +++ b/lib/src/flurry_agent.dart @@ -12,78 +12,74 @@ // See the License for the specific language governing permissions and // limitations under the License. -import 'dart:core'; import 'dart:io'; import 'package:flutter/services.dart'; -import 'flurry.dart'; +import '../flurry.dart'; class FlurryAgent { - - static const MethodChannel _agentChannel = const MethodChannel('flurry_flutter_plugin'); + static const MethodChannel _agentChannel = + const MethodChannel('flurry_flutter_plugin'); void setContinueSessionMillis(int sessionMillis) { if (Platform.isIOS) { int seconds = sessionMillis ~/ 1000; String secondsStr = seconds.toString(); - _agentChannel.invokeMethod('setContinueSessionMillis', { - 'secondsStr': secondsStr - }); + _agentChannel.invokeMethod('setContinueSessionMillis', + {'secondsStr': secondsStr}); } else if (Platform.isAndroid) { String sessionMillisStr = sessionMillis.toString(); - _agentChannel.invokeMethod('setContinueSessionMillis', { - 'sessionMillisStr': sessionMillisStr - }); + _agentChannel.invokeMethod('setContinueSessionMillis', + {'sessionMillisStr': sessionMillisStr}); } } void setCrashReporting(bool crashReporting) { - _agentChannel.invokeMethod('setCrashReporting', { - 'crashReporting': crashReporting - }); + _agentChannel.invokeMethod('setCrashReporting', + {'crashReporting': crashReporting}); } - void setIncludeBackgroundSessionsInMetrics(bool includeBackgroundSessionsInMetrics) { - _agentChannel.invokeMethod('setIncludeBackgroundSessionsInMetrics', { + void setIncludeBackgroundSessionsInMetrics( + bool includeBackgroundSessionsInMetrics) { + _agentChannel.invokeMethod( + 'setIncludeBackgroundSessionsInMetrics', { 'includeBackgroundSessionsInMetrics': includeBackgroundSessionsInMetrics }); } void setLogEnabled(bool enableLog) { - _agentChannel.invokeMethod('setLogEnabled', { - 'enableLog': enableLog - }); + _agentChannel.invokeMethod( + 'setLogEnabled', {'enableLog': enableLog}); } void setLogLevel(LogLevel logLevel) { int logLevelInt = Flurry().getLogLevel(logLevel); String logLevelStr = logLevelInt.toString(); - _agentChannel.invokeMethod('setLogLevel', { - 'logLevelStr': logLevelStr - }); + _agentChannel.invokeMethod( + 'setLogLevel', {'logLevelStr': logLevelStr}); } void setSslPinningEnabled(bool sslPinningEnabled) { if (Platform.isIOS) { print("Flurry iOS SDK does not implement setSslPinningEnabled method"); } else { - _agentChannel.invokeMethod('setSslPinningEnabled', { - 'sslPinningEnabled': sslPinningEnabled - }); + _agentChannel.invokeMethod('setSslPinningEnabled', + {'sslPinningEnabled': sslPinningEnabled}); } } void addOrigin(String originName, String originVersion) { - _agentChannel.invokeMethod('addOrigin', { + _agentChannel.invokeMethod('addOrigin', { 'originName': originName, 'originVersion': originVersion }); } - void addOriginWithParameters(String originName, String originVersion, Map originParameters) { + void addOriginWithParameters(String originName, String originVersion, + Map originParameters) { String keysStr = keysToString(originParameters); String valuesStr = valuesToString(originParameters); - _agentChannel.invokeMethod('addOriginWithParameters', { + _agentChannel.invokeMethod('addOriginWithParameters', { 'originName': originName, 'originVersion': originVersion, 'keysStr': keysStr, @@ -92,10 +88,8 @@ class FlurryAgent { } void addSessionProperty(String name, String value) { - _agentChannel.invokeMethod('addSessionProperty', { - 'name': name, - 'value': value - }); + _agentChannel.invokeMethod( + 'addSessionProperty', {'name': name, 'value': value}); } void deleteData() { @@ -103,15 +97,15 @@ class FlurryAgent { } void endTimedEvent(String eventId) { - _agentChannel.invokeMethod('endTimedEvent', { - 'eventId': eventId - }); + _agentChannel + .invokeMethod('endTimedEvent', {'eventId': eventId}); } - void endTimedEventWithParameters(String eventId, Map parameters) { + void endTimedEventWithParameters( + String eventId, Map parameters) { String keysStr = keysToString(parameters); String valuesStr = valuesToString(parameters); - _agentChannel.invokeMethod('endTimedEventWithParameters', { + _agentChannel.invokeMethod('endTimedEventWithParameters', { 'eventId': eventId, 'keysStr': keysStr, 'valuesStr': valuesStr @@ -131,33 +125,38 @@ class FlurryAgent { } void logBreadcrumb(String crashBreadcrumb) { - _agentChannel.invokeMethod('logBreadcrumb', { - 'crashBreadcrumb': crashBreadcrumb - }); + _agentChannel.invokeMethod( + 'logBreadcrumb', {'crashBreadcrumb': crashBreadcrumb}); } Future logEvent(String eventId) async { - return await _agentChannel.invokeMethod('logEvent', { - 'eventId': eventId - }); + return await _agentChannel + .invokeMethod('logEvent', {'eventId': eventId}); } - Future logEventWithParameters(String eventId, Map parameters) async { + Future logEventWithParameters( + String eventId, Map parameters) async { String keysStr = keysToString(parameters); String valuesStr = valuesToString(parameters); - return await _agentChannel.invokeMethod('logEventWithParameters', { + return await _agentChannel.invokeMethod( + 'logEventWithParameters', { 'eventId': eventId, 'keysStr': keysStr, 'valuesStr': valuesStr }); } - Future logPayment(String productName, String productId, int quantity, - double price, String currency, String transactionId, + Future logPayment( + String productName, + String productId, + int quantity, + double price, + String currency, + String transactionId, Map parameters) async { String keysStr = keysToString(parameters); String valuesStr = valuesToString(parameters); - return await _agentChannel.invokeMethod('logPayment', { + return await _agentChannel.invokeMethod('logPayment', { 'productName': productName, 'productId': productId, 'quantity': quantity, @@ -170,18 +169,16 @@ class FlurryAgent { } Future logTimedEvent(String eventId, bool timed) async { - return await _agentChannel.invokeMethod('logTimedEvent', { - 'eventId': eventId, - 'timed': timed - }); + return await _agentChannel.invokeMethod( + 'logTimedEvent', {'eventId': eventId, 'timed': timed}); } - Future logTimedEventWithParameters(String eventId, - Map parameters, bool timed) async { + Future logTimedEventWithParameters( + String eventId, Map parameters, bool timed) async { String keysStr = keysToString(parameters); String valuesStr = valuesToString(parameters); - return await _agentChannel.invokeMethod('logTimedEventWithParameters', - { + return await _agentChannel.invokeMethod( + 'logTimedEventWithParameters', { 'eventId': eventId, 'keysStr': keysStr, 'valuesStr': valuesStr, @@ -202,15 +199,16 @@ class FlurryAgent { flurryParamMap.putIfAbsent(p.id.index, () => e.value); } } - return await _agentChannel.invokeMethod('logStandardEvent', { - 'id' : id.index, + return await _agentChannel.invokeMethod( + 'logStandardEvent', { + 'id': id.index, 'flurryParam': flurryParamMap, 'userParam': userParamMap }); } void onError(String errorId, String message, String errorClass) { - _agentChannel.invokeMethod('onError', { + _agentChannel.invokeMethod('onError', { 'errorId': errorId, 'message': message, 'errorClass': errorClass @@ -221,7 +219,7 @@ class FlurryAgent { Map parameters) { String keysStr = keysToString(parameters); String valuesStr = valuesToString(parameters); - _agentChannel.invokeMethod('onErrorWithParameters', { + _agentChannel.invokeMethod('onErrorWithParameters', { 'errorId': errorId, 'message': message, 'errorClass': errorClass, @@ -236,81 +234,66 @@ class FlurryAgent { void setAge(int age) { String ageStr = age.toString(); - _agentChannel.invokeMethod('setAge', { + _agentChannel.invokeMethod('setAge', { 'ageStr': ageStr, }); } void setGender(Gender gender) { if (gender == Gender.male) { - _agentChannel.invokeMethod('setGender', { - 'gender': "m" - }); + _agentChannel.invokeMethod('setGender', {'gender': "m"}); } else if (gender == Gender.female) { - _agentChannel.invokeMethod('setGender', { - 'gender': "f" - }); + _agentChannel.invokeMethod('setGender', {'gender': "f"}); } } void setDataSaleOptOut(bool isOptOut) { - _agentChannel.invokeMethod('setDataSaleOptOut', { - 'isOptOut': isOptOut - }); + _agentChannel.invokeMethod( + 'setDataSaleOptOut', {'isOptOut': isOptOut}); } void setIAPReportingEnabled(bool enableIAP) { - _agentChannel.invokeMethod('setIAPReportingEnabled', { - 'enableIAP': enableIAP - }); + _agentChannel.invokeMethod( + 'setIAPReportingEnabled', {'enableIAP': enableIAP}); } void setReportLocation(bool reportLocation) { if (Platform.isIOS) { print("This method is applied based on the user permissions of the app."); } else { - _agentChannel.invokeMethod('setReportLocation', { - 'reportLocation': reportLocation - }); + _agentChannel.invokeMethod('setReportLocation', + {'reportLocation': reportLocation}); } } void setSessionOrigin(String originName, String deepLink) { - _agentChannel.invokeMethod('setSessionOrigin', { - 'originName': originName, - 'deepLink': deepLink - }); + _agentChannel.invokeMethod('setSessionOrigin', + {'originName': originName, 'deepLink': deepLink}); } void setUserId(String userId) { - _agentChannel.invokeMethod('setUserId', { - 'userId': userId - }); + _agentChannel + .invokeMethod('setUserId', {'userId': userId}); } void setVersionName(String versionName) { - _agentChannel.invokeMethod('setVersionName', { - 'versionName': versionName - }); + _agentChannel.invokeMethod( + 'setVersionName', {'versionName': versionName}); } void updateConversionValue(int conversionValue) { if (Platform.isIOS) { String conversionValueStr = conversionValue.toString(); - _agentChannel.invokeMethod( - 'updateConversionValue', { - 'conversionValueStr': conversionValueStr - }); + _agentChannel.invokeMethod('updateConversionValue', + {'conversionValueStr': conversionValueStr}); } } void updateConversionValueWithEvent(SKAdNetworkEvent flurryEvent) { if (Platform.isIOS) { String flurryEventStr = flurryEvent.toString(); - _agentChannel.invokeMethod( - 'updateConversionValueWithEvent', { - 'flurryEventStr': flurryEventStr - }); + _agentChannel.invokeMethod('updateConversionValueWithEvent', + {'flurryEventStr': flurryEventStr}); } } @@ -318,11 +301,11 @@ class FlurryAgent { String keysToString(Map map) { var keyStr = new StringBuffer(); - for(String key in map.keys) { + for (String key in map.keys) { keyStr.write(key); keyStr.write("\n"); } - if(keyStr.length > 0){ + if (keyStr.length > 0) { var str = keyStr.toString(); return str.substring(0, str.length - 1); } @@ -333,11 +316,11 @@ class FlurryAgent { String valuesToString(Map map) { var valueStr = new StringBuffer(); - for(String value in map.values) { + for (String value in map.values) { valueStr.write(value); valueStr.write("\n"); } - if(valueStr.length > 0){ + if (valueStr.length > 0) { var str = valueStr.toString(); return str.substring(0, str.length - 1); } @@ -346,7 +329,8 @@ class FlurryAgent { } class BuilderAgent { - static const MethodChannel _agentBuilderChannel = const MethodChannel('flurry_flutter_plugin'); + static const MethodChannel _agentBuilderChannel = + const MethodChannel('flurry_flutter_plugin'); //cannot have async call to objective c method from constructor BuilderAgent() { @@ -360,73 +344,65 @@ class BuilderAgent { } else if (Platform.isAndroid) { apiKey = apiKeys["androidAPIKey"]; } - _agentBuilderChannel.invokeMethod('buildFlurryBuilder', { + _agentBuilderChannel.invokeMethod('buildFlurryBuilder', { 'apiKey': apiKey, }); } void withAppVersion(String appVersion) { - _agentBuilderChannel.invokeMethod('withAppVersion', { - 'appVersion': appVersion - }); + _agentBuilderChannel.invokeMethod( + 'withAppVersion', {'appVersion': appVersion}); } void withContinueSessionMillis(int sessionMillis) { if (Platform.isIOS) { int seconds = sessionMillis ~/ 1000; String secondsStr = seconds.toString(); - _agentBuilderChannel.invokeMethod( - 'withContinueSessionMillis', { - 'secondsStr': secondsStr - }); + _agentBuilderChannel.invokeMethod('withContinueSessionMillis', + {'secondsStr': secondsStr}); } else if (Platform.isAndroid) { String sessionMillisStr = sessionMillis.toString(); - _agentBuilderChannel.invokeMethod( - 'withContinueSessionMillis', { - 'sessionMillisStr': sessionMillisStr - }); + _agentBuilderChannel.invokeMethod('withContinueSessionMillis', + {'sessionMillisStr': sessionMillisStr}); } } void withCrashReporting(bool crashReporting) { - _agentBuilderChannel.invokeMethod('withCrashReporting', { - 'crashReporting': crashReporting - }); + _agentBuilderChannel.invokeMethod('withCrashReporting', + {'crashReporting': crashReporting}); } void withDataSaleOptOut(bool isOptOut) { - _agentBuilderChannel.invokeMethod('withDataSaleOptOut', { - 'isOptOut': isOptOut - }); + _agentBuilderChannel.invokeMethod( + 'withDataSaleOptOut', {'isOptOut': isOptOut}); } - void withIncludeBackgroundSessionsInMetrics(bool includeBackgroundSessionsInMetrics) { - _agentBuilderChannel.invokeMethod('withIncludeBackgroundSessionsInMetrics', { + void withIncludeBackgroundSessionsInMetrics( + bool includeBackgroundSessionsInMetrics) { + _agentBuilderChannel.invokeMethod( + 'withIncludeBackgroundSessionsInMetrics', { 'includeBackgroundSessionsInMetrics': includeBackgroundSessionsInMetrics }); } void withLogEnabled(bool enableLog) { - _agentBuilderChannel.invokeMethod('withLogEnabled', { - 'enableLog': enableLog - }); + _agentBuilderChannel.invokeMethod( + 'withLogEnabled', {'enableLog': enableLog}); } void withLogLevel(LogLevel logLevel) { int logLevelInt = Flurry().getLogLevel(logLevel); String logLevelStr = logLevelInt.toString(); - _agentBuilderChannel.invokeMethod('withLogLevel', { - 'logLevelStr': logLevelStr - }); + _agentBuilderChannel.invokeMethod( + 'withLogLevel', {'logLevelStr': logLevelStr}); } void withPerformanceMetrics(int performanceMetrics) { if (Platform.isIOS) { print("Flurry iOS SDK does not implement withPerformanceMetrics method"); } else { - _agentBuilderChannel.invokeMethod('withPerformanceMetrics', { - 'performanceMetrics': performanceMetrics - }); + _agentBuilderChannel.invokeMethod('withPerformanceMetrics', + {'performanceMetrics': performanceMetrics}); } } @@ -434,18 +410,19 @@ class BuilderAgent { if (Platform.isIOS) { print("Flurry iOS SDK does not implement withSslPinningEnabled method"); } else { - _agentBuilderChannel.invokeMethod('withSslPinningEnabled', { - 'sslPinningEnabled': sslPinningEnabled - }); + _agentBuilderChannel.invokeMethod('withSslPinningEnabled', + {'sslPinningEnabled': sslPinningEnabled}); } } } class UserPropertiesAgent { - static const MethodChannel _agentUserPropertiesIOSChannel = const MethodChannel('flurry_flutter_plugin'); + static const MethodChannel _agentUserPropertiesIOSChannel = + const MethodChannel('flurry_flutter_plugin'); void addUserPropertyValue(String propertyName, String propertyValue) { - _agentUserPropertiesIOSChannel.invokeMethod('addUserPropertyValue', { + _agentUserPropertiesIOSChannel.invokeMethod( + 'addUserPropertyValue', { 'propertyName': propertyName, 'propertyValue': propertyValue }); @@ -453,41 +430,44 @@ class UserPropertiesAgent { void addUserPropertyValues(String propertyName, List propertyValues) { String propertyValuesStr = propertyValues.join('\n'); - _agentUserPropertiesIOSChannel.invokeMethod('addUserPropertyValues', { + _agentUserPropertiesIOSChannel.invokeMethod( + 'addUserPropertyValues', { 'propertyName': propertyName, 'propertyValuesStr': propertyValuesStr }); } void flagUserProperty(String propertyName) { - _agentUserPropertiesIOSChannel.invokeMethod('flagUserProperty', { - 'propertyName': propertyName - }); + _agentUserPropertiesIOSChannel.invokeMethod( + 'flagUserProperty', {'propertyName': propertyName}); } void removeUserProperty(String propertyName) { - _agentUserPropertiesIOSChannel.invokeMethod('removeUserProperty', { - 'propertyName': propertyName - }); + _agentUserPropertiesIOSChannel.invokeMethod( + 'removeUserProperty', {'propertyName': propertyName}); } void removeUserPropertyValue(String propertyName, String propertyValue) { - _agentUserPropertiesIOSChannel.invokeMethod('removeUserPropertyValue', { + _agentUserPropertiesIOSChannel.invokeMethod( + 'removeUserPropertyValue', { 'propertyName': propertyName, 'propertyValue': propertyValue }); } - void removeUserPropertyValues(String propertyName, List propertyValues) { + void removeUserPropertyValues( + String propertyName, List propertyValues) { String propertyValuesStr = propertyValues.join('\n'); - _agentUserPropertiesIOSChannel.invokeMethod('removeUserPropertyValues', { + _agentUserPropertiesIOSChannel.invokeMethod( + 'removeUserPropertyValues', { 'propertyName': propertyName, 'propertyValuesStr': propertyValuesStr }); } void setUserPropertyValue(String propertyName, String propertyValue) { - _agentUserPropertiesIOSChannel.invokeMethod('setUserPropertyValue', { + _agentUserPropertiesIOSChannel.invokeMethod( + 'setUserPropertyValue', { 'propertyName': propertyName, 'propertyValue': propertyValue }); @@ -495,7 +475,8 @@ class UserPropertiesAgent { void setUserPropertyValues(String propertyName, List propertyValues) { String propertyValuesStr = propertyValues.join('\n'); - _agentUserPropertiesIOSChannel.invokeMethod('setUserPropertyValues', { + _agentUserPropertiesIOSChannel.invokeMethod( + 'setUserPropertyValues', { 'propertyName': propertyName, 'propertyValuesStr': propertyValuesStr }); @@ -503,7 +484,8 @@ class UserPropertiesAgent { } class PerformanceAgent { - static const MethodChannel _agentPerformanceChannel = const MethodChannel('flurry_flutter_plugin'); + static const MethodChannel _agentPerformanceChannel = + const MethodChannel('flurry_flutter_plugin'); void reportFullyDrawn() { if (Platform.isIOS) { @@ -525,17 +507,17 @@ class PerformanceAgent { if (Platform.isIOS) { print("Flurry iOS SDK does not implement LogResourseLogger method."); } else if (Platform.isAndroid) { - _agentPerformanceChannel.invokeMethod('logResourceLogger', { - 'id': id - }); + _agentPerformanceChannel + .invokeMethod('logResourceLogger', {'id': id}); } } - } -class MessagingAgent{ - static const MethodChannel _messagingChannel = const MethodChannel('flurry_flutter_plugin'); - static const EventChannel _eventChannel = EventChannel('flurry_flutter_plugin_event_messaging'); +class MessagingAgent { + static const MethodChannel _messagingChannel = + const MethodChannel('flurry_flutter_plugin'); + static const EventChannel _eventChannel = + EventChannel('flurry_flutter_plugin_event_messaging'); static const String notificationReceived = 'NotificationReceived'; static const String notificationClicked = 'NotificationClicked'; @@ -563,7 +545,7 @@ class MessagingAgent{ if (e is Map) { Map event = new Map.from(e); if (event.containsKey('type')) { - switch(event['type'] as String) { + switch (event['type'] as String) { case notificationReceived: print("Flurry Messaging received callback triggered"); if (Platform.isIOS) { @@ -572,10 +554,10 @@ class MessagingAgent{ } } else if (Platform.isAndroid) { if (listener != null) { - bool willHandle = listener.onNotificationReceived(convertToMessage(event)); - _messagingChannel.invokeMethod('willHandleMessage', { - 'willHandle': willHandle - }); + bool willHandle = + listener.onNotificationReceived(convertToMessage(event)); + _messagingChannel.invokeMethod('willHandleMessage', + {'willHandle': willHandle}); } } break; @@ -587,10 +569,10 @@ class MessagingAgent{ } } else if (Platform.isAndroid) { if (listener != null) { - bool willHandle = listener.onNotificationClicked(convertToMessage(event)); - _messagingChannel.invokeMethod('willHandleMessage', { - 'willHandle': willHandle - }); + bool willHandle = + listener.onNotificationClicked(convertToMessage(event)); + _messagingChannel.invokeMethod('willHandleMessage', + {'willHandle': willHandle}); } } break; @@ -622,13 +604,15 @@ class MessagingAgent{ } void _onError(Object error) { - print("error receiving push callbacks"); + print("error receiving push callbacks"); } } class ConfigAgent { - static const MethodChannel _configChannel = const MethodChannel('flurry_flutter_plugin'); - static const EventChannel _eventChannel = EventChannel('flurry_flutter_plugin_event_config'); + static const MethodChannel _configChannel = + const MethodChannel('flurry_flutter_plugin'); + static const EventChannel _eventChannel = + EventChannel('flurry_flutter_plugin_event_config'); static const String fetchSuccess = 'FetchSuccess'; static const String fetchNoChange = 'FetchNoChange'; @@ -666,49 +650,34 @@ class ConfigAgent { String type = event['type']; if (type == fetchSuccess) { print("onFetchSuccess() triggered"); - _listeners.forEach((element) => - element.onFetchSuccess() - ); - } - else if (type == fetchNoChange) { + _listeners.forEach((element) => element.onFetchSuccess()); + } else if (type == fetchNoChange) { print("onFetchNoChange() triggered"); - _listeners.forEach((element) => - element.onFetchNoChange() - ); - } - - else if (type == fetchError) { + _listeners.forEach((element) => element.onFetchNoChange()); + } else if (type == fetchError) { print("onFetchError() triggered"); if (Platform.isIOS) { - _listeners.forEach((element) => - element.onFetchError(false) - ); + _listeners.forEach((element) => element.onFetchError(false)); } else if (Platform.isAndroid) { bool isRetrying = false; if (event.containsKey('isRetrying')) { String value = event['isRetrying']; isRetrying = value.toLowerCase() == 'true'; } - _listeners.forEach((element) => - element.onFetchError(isRetrying) - ); + _listeners.forEach((element) => element.onFetchError(isRetrying)); } - } - else if (type == activateComplete) { + } else if (type == activateComplete) { print("onActivateComplete() triggered"); if (Platform.isIOS) { - _listeners.forEach((element) => - element.onActivateComplete(false) - ); + _listeners.forEach((element) => element.onActivateComplete(false)); } else if (Platform.isAndroid) { bool isCache = false; if (event.containsKey('isCache')) { String value = event['isCache']; isCache = value.toLowerCase() == 'true'; } - _listeners.forEach((element) => - element.onActivateComplete(isCache) - ); + _listeners + .forEach((element) => element.onActivateComplete(isCache)); } } } @@ -720,15 +689,12 @@ class ConfigAgent { } Future getConfigString(String key, String defaultValue) async { - return await _configChannel.invokeMethod('getConfigString', { - 'key': key, - 'defaultValue': defaultValue - }); + return await _configChannel.invokeMethod('getConfigString', + {'key': key, 'defaultValue': defaultValue}); } } class ParamBuilderAgent { - Map _map; ParamBuilderAgent() { @@ -736,7 +702,7 @@ class ParamBuilderAgent { } void putAll(Param param) { - for(MapEntry e in param.builderAgent._map.entries) { + for (MapEntry e in param.builderAgent._map.entries) { _map.putIfAbsent(e.key, () => e.value); } } @@ -791,8 +757,10 @@ class ParamBuilderAgent { } class PublisherSegmentationAgent { - static const MethodChannel _publisherChannel = const MethodChannel('flurry_flutter_plugin'); - static const EventChannel _eventChannel = EventChannel('flurry_flutter_plugin_event_ps'); + static const MethodChannel _publisherChannel = + const MethodChannel('flurry_flutter_plugin'); + static const EventChannel _eventChannel = + EventChannel('flurry_flutter_plugin_event_ps'); List _listeners; @@ -823,9 +791,7 @@ class PublisherSegmentationAgent { if (e is Map) { Map event = new Map.from(e); print("Publisher Segmentation onFetched triggered"); - _listeners.forEach((element) => - element.onFetched(event) - ); + _listeners.forEach((element) => element.onFetched(event)); } } @@ -834,8 +800,8 @@ class PublisherSegmentationAgent { } Future> getPublisherData() async { - Map data = await _publisherChannel.invokeMethod('getPublisherData'); + Map data = + await _publisherChannel.invokeMethod('getPublisherData'); return new Map.from(data); } } - diff --git a/pubspec.yaml b/pubspec.yaml index 0aa68af..a74c2d4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_flurry_sdk -description: A Flutter plugin for Flurry SDK. -version: 1.2.0 +description: A Flutter plugin for Flurry Analytics SDK. Flurry Push for messaging and Flurry Config for remote configuration are supported by our plugin as well! +version: 1.2.1 homepage: https://www.flurry.com/ repository: https://github.com/flurry/flutter-flurry-sdk