diff --git a/CHANGELOG.md b/CHANGELOG.md index 62a8f66..9422b7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,14 @@ * [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/) +## v3.3.0 (2023-08-28) + +#### Features + +* Upgrade Flurry Android SDK version to 14.4.0 +* Upgrade Flurry iOS SDK version to 12.4.0 +* Support Timed event logging APIs with the 2nd key + ## v3.2.0 (2023-04-02) #### Features diff --git a/README.md b/README.md index 23b77cd..b00aa0b 100644 --- a/README.md +++ b/README.md @@ -405,10 +405,14 @@ See [Android](https://flurry.github.io/flurry-android-sdk/analytics/index.html)- Future Flurry.logEvent(String eventId); Future Flurry.logEventWithParameters(String eventId, Map parameters); Future Flurry.logTimedEvent(String eventId, bool timed); - Future Flurry.logTimedEventWithParamters(String eventId, Map parameters, bool timed); + Future Flurry.logTimedEventWithParameters(String eventId, Map parameters, bool timed); + Future Flurry.logTimedEventId(String eventId, String timedId); + Future Flurry.logTimedEventIdWithParameters(String eventId, Map parameters, String timedId); void Flurry.endTimedEvent(String eventId); void Flurry.endTimedEventWithParameters(String eventId, Map parameters); + void Flurry.endTimedEventId(String eventId, String timedId); + void Flurry.endTimedEventIdWithParameters(String eventId, Map parameters, String timedId); Future Flurry.logStandardEvent(StandardEventId id, Param param); diff --git a/android/build.gradle b/android/build.gradle index 4841972..a9bfde3 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -22,6 +22,8 @@ rootProject.allprojects { apply plugin: 'com.android.library' android { + namespace "com.flurry.android.flutter" + compileSdkVersion 33 defaultConfig { @@ -32,6 +34,6 @@ android { dependencies { // implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) - implementation 'com.flurry.android:analytics:14.2.0' - implementation 'com.flurry.android:marketing:14.2.0' + implementation 'com.flurry.android:analytics:14.4.0' + implementation 'com.flurry.android:marketing:14.4.0' } diff --git a/android/src/main/AndroidManifest.xml b/android/src/main/AndroidManifest.xml index 83c2022..a2f47b6 100644 --- a/android/src/main/AndroidManifest.xml +++ b/android/src/main/AndroidManifest.xml @@ -1,3 +1,2 @@ - + diff --git a/android/src/main/java/com/flurry/android/flutter/FlurryFlutterPlugin.java b/android/src/main/java/com/flurry/android/flutter/FlurryFlutterPlugin.java index c9b3084..24df231 100644 --- a/android/src/main/java/com/flurry/android/flutter/FlurryFlutterPlugin.java +++ b/android/src/main/java/com/flurry/android/flutter/FlurryFlutterPlugin.java @@ -55,7 +55,7 @@ public class FlurryFlutterPlugin implements FlutterPlugin, MethodCallHandler, Ac private static final String TAG = "FlurryFlutterPlugin"; private static final String ORIGIN_NAME = "flutter-flurry-sdk"; - private static final String ORIGIN_VERSION = "3.2.0"; + private static final String ORIGIN_VERSION = "3.3.0"; private Context context; @@ -385,6 +385,19 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) { status = logTimedEventWithParameters(eventId, parameters, timed); result.success(status); break; + case "logTimedEventId": + eventId = call.argument("eventId"); + String timedId = call.argument("timedId"); + status = logTimedEventId(eventId, timedId); + result.success(status); + break; + case "logTimedEventIdWithParameters": + eventId = call.argument("eventId"); + parameters = call.argument("parameters"); + timedId = call.argument("timedId"); + status = logTimedEventIdWithParameters(eventId, parameters, timedId); + result.success(status); + break; case "endTimedEvent": eventId = call.argument("eventId"); endTimedEvent(eventId); @@ -394,6 +407,17 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) { parameters = call.argument("parameters"); endTimedEventWithParameters(eventId, parameters); break; + case "endTimedEventId": + eventId = call.argument("eventId"); + timedId = call.argument("timedId"); + endTimedEventId(eventId, timedId); + break; + case "endTimedEventIdWithParameters": + eventId = call.argument("eventId"); + parameters = call.argument("parameters"); + timedId = call.argument("timedId"); + endTimedEventIdWithParameters(eventId, parameters, timedId); + break; case "logStandardEvent": int standardId = call.argument("id"); Map flurryParam = call.>argument("flurryParam"); @@ -692,6 +716,16 @@ public int logTimedEventWithParameters(String eventId, Map param return (status != null) ? status.ordinal() : 0; } + public int logTimedEventId(String eventId, String timedId) { + FlurryEventRecordStatus status = FlurryAgent.logEvent(eventId, timedId); + return (status != null) ? status.ordinal() : 0; + } + + public int logTimedEventIdWithParameters(String eventId, Map parameters, String timedId) { + FlurryEventRecordStatus status = FlurryAgent.logEvent(eventId, parameters, timedId); + return (status != null) ? status.ordinal() : 0; + } + public void endTimedEvent(String eventId) { FlurryAgent.endTimedEvent(eventId); } @@ -700,6 +734,14 @@ public void endTimedEventWithParameters(String eventId, Map para FlurryAgent.endTimedEvent(eventId, parameters); } + public void endTimedEventId(String eventId, String timedId) { + FlurryAgent.endTimedEvent(eventId, timedId); + } + + public void endTimedEventIdWithParameters(String eventId, Map parameters, String timedId) { + FlurryAgent.endTimedEvent(eventId, parameters, timedId); + } + public int logStandardEvent(int standardId, Map flurryParam, Map userParam) { // Find the standard event ID. if ((standardId < 0) || (standardId >= FlurryFlutterEvent.EVENTS.length)) { @@ -923,7 +965,7 @@ private static Handler getHandler() { */ static class FlutterFlurryConfigListener implements FlurryConfigListener { - enum EventType { + public enum EventType { FetchSuccess("FetchSuccess"), FetchNoChange("FetchNoChange"), FetchError("FetchError"), diff --git a/example/android/app/build.gradle b/example/android/app/build.gradle index dc45833..1449953 100644 --- a/example/android/app/build.gradle +++ b/example/android/app/build.gradle @@ -26,6 +26,8 @@ apply plugin: 'com.google.gms.google-services' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { + namespace "com.example.flutter_flurry_sdk_example" + compileSdkVersion flutter.compileSdkVersion defaultConfig { @@ -53,8 +55,8 @@ flutter { dependencies { // implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar']) - implementation 'com.flurry.android:analytics:14.2.0' - implementation 'com.flurry.android:marketing:14.2.0' + implementation 'com.flurry.android:analytics:14.4.0' + implementation 'com.flurry.android:marketing:14.4.0' implementation 'com.google.android.gms:play-services-ads-identifier:18.0.1' implementation 'com.google.firebase:firebase-messaging:21.1.0' diff --git a/example/android/app/src/main/AndroidManifest.xml b/example/android/app/src/main/AndroidManifest.xml index c35c4df..128d092 100644 --- a/example/android/app/src/main/AndroidManifest.xml +++ b/example/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,4 @@ - + diff --git a/example/android/build.gradle b/example/android/build.gradle index aa0c088..0879e4b 100644 --- a/example/android/build.gradle +++ b/example/android/build.gradle @@ -24,6 +24,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 074e251..8a05690 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -1,16 +1,16 @@ PODS: - - Flurry-iOS-SDK/CrashReporter (12.2.0) - - Flurry-iOS-SDK/FlurryConfig (12.2.0): + - Flurry-iOS-SDK/CrashReporter (12.4.0) + - Flurry-iOS-SDK/FlurryConfig (12.4.0): - Flurry-iOS-SDK/FlurrySDK - - Flurry-iOS-SDK/FlurryMessaging (12.2.0): + - Flurry-iOS-SDK/FlurryMessaging (12.4.0): - Flurry-iOS-SDK/FlurrySDK - - Flurry-iOS-SDK/FlurrySDK (12.2.0): + - Flurry-iOS-SDK/FlurrySDK (12.4.0): - Flurry-iOS-SDK/CrashReporter - Flutter (1.0.0) - flutter_flurry_sdk (0.0.1): - - Flurry-iOS-SDK/FlurryConfig (~> 12.2.0) - - Flurry-iOS-SDK/FlurryMessaging (~> 12.2.0) - - Flurry-iOS-SDK/FlurrySDK (~> 12.2.0) + - Flurry-iOS-SDK/FlurryConfig (~> 12.4.0) + - Flurry-iOS-SDK/FlurryMessaging (~> 12.4.0) + - Flurry-iOS-SDK/FlurrySDK (~> 12.4.0) - Flutter DEPENDENCIES: @@ -28,9 +28,9 @@ EXTERNAL SOURCES: :path: ".symlinks/plugins/flutter_flurry_sdk/ios" SPEC CHECKSUMS: - Flurry-iOS-SDK: acac6eb6761fc39f7accbf1f8c4859ef297c7ee9 + Flurry-iOS-SDK: 402045d874e9e330d2fbcdf48d82727292ade109 Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 - flutter_flurry_sdk: 1fe3874c8fd55c820d0563fa0297930ed74e35b9 + flutter_flurry_sdk: 5693523848e564298997124810571f0d93590d09 PODFILE CHECKSUM: 1d5103e59c34489a395ae7f46690437f27451f42 diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj index 48be331..3e46ceb 100644 --- a/example/ios/Runner.xcodeproj/project.pbxproj +++ b/example/ios/Runner.xcodeproj/project.pbxproj @@ -167,7 +167,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -237,6 +237,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 3db53b6..b52b2e6 100644 --- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ =2.12.0 <3.0.0" + sdk: ">=2.12.0 <4.0.0" dependencies: flutter: diff --git a/ios/Classes/FlurryFlutterPlugin.m b/ios/Classes/FlurryFlutterPlugin.m index 4614e25..213ee44 100644 --- a/ios/Classes/FlurryFlutterPlugin.m +++ b/ios/Classes/FlurryFlutterPlugin.m @@ -11,7 +11,7 @@ #endif NSString *originName = @"flutter-flurry-sdk"; -NSString *originVersion = @"3.2.0"; +NSString *originVersion = @"3.3.0"; static FlurryFlutterPlugin* sharedInstance; @@ -259,10 +259,6 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { [self flurryAddSessionProperty:call.arguments]; } else if([@"deleteData" isEqualToString:call.method]) { [self flurrySetDelete]; - } else if([@"endTimedEvent" isEqualToString:call.method]) { - [self flurryEndTimedEvent:call.arguments]; - } else if([@"endTimedEventWithParameters" isEqualToString:call.method]) { - [self flurryEndTimedEventWithParameters:call.arguments]; } else if([@"getAgentVersion" isEqualToString:call.method]) { NSNumber* agentVersion = [NSNumber numberWithLong:[self flurryGetAgentVersion]]; result(agentVersion); @@ -280,14 +276,29 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { } else if([@"logEventWithParameters" isEqualToString:call.method]) { NSNumber* logEvent = [NSNumber numberWithLong:[self flurryLogEventWithParameters:call.arguments]]; result(logEvent); - } else if([@"logPayment" isEqualToString:call.method]) { - NSNumber* num = [NSNumber numberWithLong:[self flurryLogPayment:call.arguments]]; - result(num); } else if([@"logTimedEvent" isEqualToString:call.method]) { - [self flurryLogTimedEvent:call.arguments]; + NSNumber* logEvent = [NSNumber numberWithLong:[self flurryLogTimedEvent:call.arguments]]; + result(logEvent); } else if([@"logTimedEventWithParameters" isEqualToString:call.method]) { NSNumber* logEvent = [NSNumber numberWithLong:[self flurryLogTimedEventWithParameters:call.arguments]]; result(logEvent); + } else if([@"logTimedEventId" isEqualToString:call.method]) { + NSNumber* logEvent = [NSNumber numberWithLong:[self flurryLogTimedEventId:call.arguments]]; + result(logEvent); + } else if([@"logTimedEventIdWithParameters" isEqualToString:call.method]) { + NSNumber* logEvent = [NSNumber numberWithLong:[self flurryLogTimedEventIdWithParameters:call.arguments]]; + result(logEvent); + } else if([@"endTimedEvent" isEqualToString:call.method]) { + [self flurryEndTimedEvent:call.arguments]; + } else if([@"endTimedEventWithParameters" isEqualToString:call.method]) { + [self flurryEndTimedEventWithParameters:call.arguments]; + } else if([@"endTimedEventId" isEqualToString:call.method]) { + [self flurryEndTimedEventId:call.arguments]; + } else if([@"endTimedEventIdWithParameters" isEqualToString:call.method]) { + [self flurryEndTimedEventIdWithParameters:call.arguments]; + } else if([@"logPayment" isEqualToString:call.method]) { + NSNumber* num = [NSNumber numberWithLong:[self flurryLogPayment:call.arguments]]; + result(num); } else if([@"onError" isEqualToString:call.method]) { [self flurryLogError:call.arguments]; } else if([@"onErrorWithParameters" isEqualToString:call.method]) { @@ -505,18 +516,6 @@ -(void) flurrySetDelete { [FlurryCCPA setDelete]; } --(void) flurryEndTimedEvent:(NSDictionary*) event { - NSString* eventId = event[@"eventId"]; - [Flurry endTimedEvent:eventId withParameters:nil]; -} - --(void) flurryEndTimedEventWithParameters:(NSDictionary*)event { - NSString* eventId = event[@"eventId"]; - NSMutableDictionary* params = event[@"parameters"]; - - [Flurry endTimedEvent:eventId withParameters: params]; -} - -(NSInteger) flurryGetAgentVersion { NSString* str = [Flurry getFlurryAgentVersion]; NSArray *arrayOfComponents = [str componentsSeparatedByString:@"_"]; @@ -551,6 +550,56 @@ -(NSInteger) flurryLogEventWithParameters:(NSDictionary*)event { return [Flurry logEvent:eventId withParameters:params]; } +-(NSInteger) flurryLogTimedEvent:(NSDictionary*)event { + NSString* eventId = event[@"eventId"]; + BOOL timed = event[@"timed"]; + return [Flurry logEvent:eventId withParameters:nil timed:timed]; +} + +-(NSInteger) flurryLogTimedEventWithParameters:(NSDictionary*)event { + NSString* eventId = event[@"eventId"]; + BOOL timed = event[@"timed"]; + NSDictionary* params = event[@"parameters"]; + return [Flurry logEvent:eventId withParameters:params timed:timed]; +} + +-(NSInteger) flurryLogTimedEventId:(NSDictionary*)event { + NSString* eventId = event[@"eventId"]; + NSString* timedId = event[@"timedId"]; + return [Flurry logEvent:eventId withEventId:timedId]; +} + +-(NSInteger) flurryLogTimedEventIdWithParameters:(NSDictionary*)event { + NSString* eventId = event[@"eventId"]; + NSString* timedId = event[@"timedId"]; + NSDictionary* params = event[@"parameters"]; + return [Flurry logEvent:eventId withEventId:timedId withParameters:params]; +} + +-(void) flurryEndTimedEvent:(NSDictionary*) event { + NSString* eventId = event[@"eventId"]; + [Flurry endTimedEvent:eventId withParameters:nil]; +} + +-(void) flurryEndTimedEventWithParameters:(NSDictionary*)event { + NSString* eventId = event[@"eventId"]; + NSMutableDictionary* params = event[@"parameters"]; + [Flurry endTimedEvent:eventId withParameters: params]; +} + +-(void) flurryEndTimedEventId:(NSDictionary*) event { + NSString* eventId = event[@"eventId"]; + NSString* timedId = event[@"timedId"]; + [Flurry endTimedEvent:eventId withEventId:timedId withParameters:nil]; +} + +-(void) flurryEndTimedEventIdWithParameters:(NSDictionary*)event { + NSString* eventId = event[@"eventId"]; + NSString* timedId = event[@"timedId"]; + NSMutableDictionary* params = event[@"parameters"]; + [Flurry endTimedEvent:eventId withEventId:timedId withParameters: params]; +} + -(NSInteger) flurryLogPayment:(NSDictionary*)payment { NSString* productName = payment[@"productName"]; NSString* productId = payment[@"productId"]; @@ -569,20 +618,6 @@ -(NSInteger) flurryLogPayment:(NSDictionary*)payment { return transactionStatus; } --(void) flurryLogTimedEvent:(NSDictionary*)event { - NSString* eventId = event[@"eventId"]; - BOOL timed = event[@"timed"]; - [Flurry logEvent:eventId withParameters:nil timed:timed]; -} - --(NSInteger) flurryLogTimedEventWithParameters:(NSDictionary*)event { - NSString* eventId = event[@"eventId"]; - BOOL timed = event[@"timed"]; - NSDictionary* params = event[@"parameters"]; - - return [Flurry logEvent:eventId withParameters:params timed:timed]; -} - -(void) flurryLogError:(NSDictionary*)errorDict { NSString* errorId = errorDict[@"errorId"]; NSString* message = errorDict[@"message"]; diff --git a/ios/flutter_flurry_sdk.podspec b/ios/flutter_flurry_sdk.podspec index 53685f4..86c7aea 100644 --- a/ios/flutter_flurry_sdk.podspec +++ b/ios/flutter_flurry_sdk.podspec @@ -3,7 +3,7 @@ # Run `pod lib lint flutter_flurry_sdk.podspec` to validate before publishing. # -sdkVersion = '12.2.0' +sdkVersion = '12.4.0' Pod::Spec.new do |s| s.name = 'flutter_flurry_sdk' diff --git a/lib/flurry.dart b/lib/flurry.dart index 9c7c1ca..9cdb86c 100644 --- a/lib/flurry.dart +++ b/lib/flurry.dart @@ -254,6 +254,22 @@ class Flurry { return EventRecordStatus.eventRecorded; } + /// Records an event named [eventId] with parameters. + /// + /// 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 { + if (flurryAgent != null) { + int eventRecordStatus = + await flurryAgent!.logEventWithParameters(eventId, parameters); + return EventRecordStatus.values[eventRecordStatus]; + } + + return EventRecordStatus.eventRecorded; + } + /// Records a custom timed event named [eventId] /// /// Logs [eventId] as a non timed event or a timed event based on boolean @@ -268,16 +284,52 @@ class Flurry { return EventRecordStatus.eventRecorded; } - /// Records an event named [eventId] with parameters. + /// Records a timed event named [eventId] with parameters. /// - /// 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 { + /// 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 { + if (flurryAgent != null) { + int eventRecordStatus = await flurryAgent! + .logTimedEventWithParameters(eventId, parameters, timed); + return EventRecordStatus.values[eventRecordStatus]; + } + + return EventRecordStatus.eventRecorded; + } + + /// Records a custom timed event named [eventId] + /// + /// Logs [eventId] as a timed event with the second key [timedId]. + /// Returns the event recording status of the logged event. + /// + /// Example for timed event logging with the 2nd key: + /// 0 1 2 3 4 5 6 sec. + /// ID1 ID2 ID3 + /// - - - ID2: 3 sec. + /// - - ID3: 2 sec. + /// - - - - - - ID1: 6 sec. + /// + /// Flurry.logTimedEventId('TimedEventName', 'InstanceId1'); + /// // sleep 1 sec. + /// Flurry.logTimedEventId('TimedEventName', 'InstanceId2'); + /// // sleep 2 sec. + /// Flurry.logTimedEventId('TimedEventName', 'InstanceId3'); + /// + /// // sleep 1 sec. + /// Flurry.endTimedEventId('TimedEventName', 'InstanceId2'); // ID2 duration: 3 sec. + /// // sleep 1 sec. + /// Flurry.endTimedEventId('TimedEventName', 'InstanceId3'); // ID3 duration: 2 sec. + /// // sleep 1 sec. + /// Flurry.endTimedEventId('TimedEventName', 'InstanceId1'); // ID1 duration: 6 sec. + /// + static Future logTimedEventId( + String eventId, String timedId) async { if (flurryAgent != null) { int eventRecordStatus = - await flurryAgent!.logEventWithParameters(eventId, parameters); + await flurryAgent!.logTimedEventId(eventId, timedId); return EventRecordStatus.values[eventRecordStatus]; } @@ -286,14 +338,14 @@ class Flurry { /// Records a timed event named [eventId] with parameters. /// - /// 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 + /// Logs [eventId] as a timed event with the second key [timedId]. + /// 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 logTimedEventIdWithParameters( + String eventId, Map parameters, String timedId) async { if (flurryAgent != null) { int eventRecordStatus = await flurryAgent! - .logTimedEventWithParameters(eventId, parameters, timed); + .logTimedEventIdWithParameters(eventId, parameters, timedId); return EventRecordStatus.values[eventRecordStatus]; } @@ -318,34 +370,38 @@ class Flurry { flurryAgent?.endTimedEventWithParameters(eventId, parameters); } - /// Records an app exception. + /// Ends an existing timed event named [eventId]. /// - /// Commonly used to catch unhandled exceptions. Specifies error name using - /// [errorId], and error message in [message]. Specifies exception attributes - /// like exception name and exception reason in [errorClass]. - static void onError(String errorId, String message, String errorClass) { - flurryAgent?.onError(errorId, message, errorClass); + /// Ends the timed event [eventId] with the second key [timedId]. + /// Ignores the action if event named [eventId] is already terminated. + static void endTimedEventId(String eventId, String timedId) { + flurryAgent?.endTimedEventId(eventId, timedId); } - /// Records an app exception with parameters. + /// Ends a timed event and updated parameters. /// - /// Commonly used to catch unhandled exceptions. Specifies error name using - /// [errorId], and error message in [message]. Specifies exception attributes - /// like exception name and exception reason in [errorClass]. Specify custom - /// parameters associated with the exception. - static void onErrorWithParameters(String errorId, String message, - String errorClass, Map parameters) { - flurryAgent?.onErrorWithParameters( - errorId, message, errorClass, parameters); + /// Ends the timed event [eventId] with the second key [timedId] + /// if the event was not terminated already. Updates the + /// 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 endTimedEventIdWithParameters( + String eventId, Map parameters, String timedId) { + flurryAgent?.endTimedEventIdWithParameters(eventId, parameters, timedId); } - /// Logs the breadcrumb. + /// Records a Flurry standard event. /// - /// Captures [crashBreadcrumb] of 250 characters. The last 207 recorded - /// breadcrumbs are included in crash and error logs. Breadcrumbs are reset - /// at every application launch. - static void logBreadcrumb(String crashBreadcrumb) { - flurryAgent?.logBreadcrumb(crashBreadcrumb); + /// 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 { + if (flurryAgent != null) { + int eventRecordStatus = await flurryAgent!.logStandardEvent(id, param); + return EventRecordStatus.values[eventRecordStatus]; + } + return EventRecordStatus.eventFailed; } /// Logs a payment. @@ -370,18 +426,34 @@ class Flurry { return EventRecordStatus.eventRecorded; } - /// Records a Flurry standard event. + /// Records an app exception. /// - /// 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 { - if (flurryAgent != null) { - int eventRecordStatus = await flurryAgent!.logStandardEvent(id, param); - return EventRecordStatus.values[eventRecordStatus]; - } - return EventRecordStatus.eventFailed; + /// Commonly used to catch unhandled exceptions. Specifies error name using + /// [errorId], and error message in [message]. Specifies exception attributes + /// like exception name and exception reason in [errorClass]. + static void onError(String errorId, String message, String errorClass) { + flurryAgent?.onError(errorId, message, errorClass); + } + + /// Records an app exception with parameters. + /// + /// Commonly used to catch unhandled exceptions. Specifies error name using + /// [errorId], and error message in [message]. Specifies exception attributes + /// like exception name and exception reason in [errorClass]. Specify custom + /// parameters associated with the exception. + static void onErrorWithParameters(String errorId, String message, + String errorClass, Map parameters) { + flurryAgent?.onErrorWithParameters( + errorId, message, errorClass, parameters); + } + + /// Logs the breadcrumb. + /// + /// Captures [crashBreadcrumb] of 250 characters. The last 207 recorded + /// breadcrumbs are included in crash and error logs. Breadcrumbs are reset + /// at every application launch. + static void logBreadcrumb(String crashBreadcrumb) { + flurryAgent?.logBreadcrumb(crashBreadcrumb); } /// Enables implicit recording of In-App transactions. diff --git a/lib/src/flurry_agent.dart b/lib/src/flurry_agent.dart index 36c636a..73697e8 100644 --- a/lib/src/flurry_agent.dart +++ b/lib/src/flurry_agent.dart @@ -105,17 +105,6 @@ class FlurryAgent { _agentChannel.invokeMethod('deleteData'); } - void endTimedEvent(String eventId) { - _agentChannel - .invokeMethod('endTimedEvent', {'eventId': eventId}); - } - - void endTimedEventWithParameters( - String eventId, Map parameters) { - _agentChannel.invokeMethod('endTimedEventWithParameters', - {'eventId': eventId, 'parameters': parameters}); - } - Future getAgentVersion() async { return await _agentChannel.invokeMethod('getAgentVersion'); } @@ -144,25 +133,6 @@ class FlurryAgent { {'eventId': eventId, 'parameters': parameters}); } - Future logPayment( - String productName, - String productId, - int quantity, - double price, - String currency, - String transactionId, - Map parameters) async { - return await _agentChannel.invokeMethod('logPayment', { - 'productName': productName, - 'productId': productId, - 'quantity': quantity, - 'price': price, - 'currency': currency, - 'transactionId': transactionId, - 'parameters': parameters - }); - } - Future logTimedEvent(String eventId, bool timed) async { return await _agentChannel.invokeMethod( 'logTimedEvent', {'eventId': eventId, 'timed': timed}); @@ -178,6 +148,47 @@ class FlurryAgent { }); } + Future logTimedEventId(String eventId, String timedId) async { + return await _agentChannel.invokeMethod('logTimedEventId', + {'eventId': eventId, 'timedId': timedId}); + } + + Future logTimedEventIdWithParameters( + String eventId, Map parameters, String timedId) async { + return await _agentChannel.invokeMethod( + 'logTimedEventIdWithParameters', { + 'eventId': eventId, + 'parameters': parameters, + 'timedId': timedId + }); + } + + void endTimedEvent(String eventId) { + _agentChannel + .invokeMethod('endTimedEvent', {'eventId': eventId}); + } + + void endTimedEventWithParameters( + String eventId, Map parameters) { + _agentChannel.invokeMethod('endTimedEventWithParameters', + {'eventId': eventId, 'parameters': parameters}); + } + + void endTimedEventId(String eventId, String timedId) { + _agentChannel.invokeMethod('endTimedEventId', + {'eventId': eventId, 'timedId': timedId}); + } + + void endTimedEventIdWithParameters( + String eventId, Map parameters, String timedId) { + _agentChannel.invokeMethod( + 'endTimedEventIdWithParameters', { + 'eventId': eventId, + 'parameters': parameters, + 'timedId': timedId + }); + } + Future logStandardEvent(FlurryEvent id, Param param) async { Map flurryParamMap = {}; Map userParamMap = {}; @@ -202,6 +213,25 @@ class FlurryAgent { }); } + Future logPayment( + String productName, + String productId, + int quantity, + double price, + String currency, + String transactionId, + Map parameters) async { + return await _agentChannel.invokeMethod('logPayment', { + 'productName': productName, + 'productId': productId, + 'quantity': quantity, + 'price': price, + 'currency': currency, + 'transactionId': transactionId, + 'parameters': parameters + }); + } + void onError(String errorId, String message, String errorClass) { _agentChannel.invokeMethod('onError', { 'errorId': errorId, diff --git a/pubspec.yaml b/pubspec.yaml index a004525..4ba53e8 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,11 +1,11 @@ name: flutter_flurry_sdk 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: 3.2.0 +version: 3.3.0 homepage: https://www.flurry.com/ repository: https://github.com/flurry/flutter-flurry-sdk environment: - sdk: ">=2.12.0 <3.0.0" + sdk: ">=2.12.0 <4.0.0" flutter: ">=2.5.0" dependencies: diff --git a/test/flutter_flurry_sdk_test.dart b/test/flutter_flurry_sdk_test.dart index 91cff86..dd915ba 100644 --- a/test/flutter_flurry_sdk_test.dart +++ b/test/flutter_flurry_sdk_test.dart @@ -8,13 +8,13 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); setUp(() { - channel.setMockMethodCallHandler((MethodCall methodCall) async { + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(channel, (MethodCall methodCall) async { return '42'; }); }); tearDown(() { - channel.setMockMethodCallHandler(null); + TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler(channel, null); }); test('getPlatformVersion', () async {