Skip to content
This repository has been archived by the owner on Mar 15, 2024. It is now read-only.

Commit

Permalink
Update for v1.1.0
Browse files Browse the repository at this point in the history
- Upgrade Flurry Android SDK version to 13.1.0
- Upgrade Flurry iOS SDK version to 11.4.0
- Support Agent setters API
- Support Standard Event API
- Support Publisher Segmentation API
- Support Messaging callback return value for Android
- Fixed null check for logging return status
  • Loading branch information
poting-oath committed Dec 7, 2021
1 parent d785749 commit 6ff39fb
Show file tree
Hide file tree
Showing 10 changed files with 298 additions and 45 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
* [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.1.0 (2021-12-06)

#### Features

* Upgrade Flurry Android SDK version to 13.1.0
* Upgrade Flurry iOS SDK version to 11.4.0
* Support Agent setters API
* Support Standard Event API
* Support Publisher Segmentation API

## 0.1.0 (2021-09-30)

* Create flutter-flurry-sdk package
Expand Down
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ import 'package:flutter_flurry_sdk/Flurry.dart';
Flurry.builder
.withCrashReporting(true)
.withLogEnabled(true)
.withLogLevel(LogLevel.verbose)
.withLogLevel(LogLevel.debug)
.build(androidAPIKey: FLURRY_ANDROID_API_KEY,
iosAPIKey: FLURRY_IOS_API_KEY);
```
Expand All @@ -162,6 +162,10 @@ import 'package:flutter_flurry_sdk/Flurry.dart';
String sessionId = await Flurry.getSessionId();
print("Session Id: $sessionId");
// Set Flurry preferences.
Flurry.setLogEnabled(true);
Flurry.setLogLevel(LogLevel.verbose);
// Set user preferences.
Flurry.setAge(36);
Flurry.setGender(Gender.female);
Expand Down Expand Up @@ -296,19 +300,31 @@ See [Android](http://flurry.github.io/flurry-android-sdk/)-[(FlurryAgent)](http:
- **Methods in Flurry.builder to initialize Flurry Agent**

```dart
Builder withAppVersion(String versionName);
Builder withAppVersion(String versionName); // iOS only. For Android, please use Flurry.setVersionName() instead.
Builder withContinueSessionMillis(int sessionMillis);
Builder withCrashReporting(bool crashReporting);
Builder withDataSaleOptOut(bool isOptOut);
Builder withIncludeBackgroundSessionsInMetrics(bool includeBackgroundSessionsInMetrics);
Builder withLogEnabled(bool enableLog);
Builder withLogLevel(LogLevel logLevel);
Builder withLogLevel(LogLevel logLevel); // LogLevel = { verbose, debug, info, warn, error, assertion }
Builder withMessaging(bool enableMessaging, MessagingListener listener);
Builder withPerformanceMetrics(int performanceMetrics);
Builder withPerformanceMetrics(int performanceMetrics); // Performance = { none, coldStart, screenTime, all }
Builder withSslPinningEnabled(bool sslPinningEnabled); // Android only
void build(String androidAPIKey, String iosAPIKey);
```

- **Methods to set Flurry preferences**

```javascript
void Flurry.setContinueSessionMillis(int sessionMillis);
void Flurry.setCrashReporting(bool crashReporting);
void Flurry.setIncludeBackgroundSessionsInMetrics(bool includeBackgroundSessionsInMetrics);
void Flurry.setLogEnabled(bool enableLog);
void Flurry.setLogLevel(LogLevel logLevel); // LogLevel = { verbose, debug, info, warn, error, assertion }
void Flurry.setSslPinningEnabled(bool sslPinningEnabled); // Android only
```

- **Methods to set user preferences**

```dart
Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ android {
dependencies {
// implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])

implementation 'com.flurry.android:analytics:13.0.0'
implementation 'com.flurry.android:marketing:13.0.0'
implementation 'com.flurry.android:analytics:13.1.0'
implementation 'com.flurry.android:marketing:13.1.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import android.content.Context;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.util.Log;

Expand Down Expand Up @@ -55,7 +56,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 = "1.0.0";
private static final String ORIGIN_VERSION = "1.1.0";

private Context context;

Expand Down Expand Up @@ -191,12 +192,42 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
withLogLevel(logLevelStr);
break;
case "withPerformanceMetrics":
int performanceMetrics = call.<Integer>argument("perfomanceMetrics");
int performanceMetrics = call.<Integer>argument("performanceMetrics");
withPerformanceMetrics(performanceMetrics);
break;
case "withSslPinningEnabled":
boolean sslPinningEnabled = call.<Boolean>argument("sslPinningEnabled");
builder.withSslPinningEnabled(sslPinningEnabled);
break;
case "withMessaging":
withMessaging();
break;
case "setContinueSessionMillis":
sessionMillisStr = call.argument("sessionMillisStr");
long millis = Long.parseLong(sessionMillisStr);
FlurryAgent.setContinueSessionMillis(millis);
break;
case "setCrashReporting":
crashReporting = call.<Boolean>argument("crashReporting");
FlurryAgent.setCaptureUncaughtExceptions(crashReporting);
break;
case "setIncludeBackgroundSessionsInMetrics":
includeBackgroundSessionsInMetrics = call.<Boolean>argument("includeBackgroundSessionsInMetrics");
FlurryAgent.setIncludeBackgroundSessionsInMetrics(includeBackgroundSessionsInMetrics);
break;
case "setLogEnabled":
enableLog = call.<Boolean>argument("enableLog");
FlurryAgent.setLogEnabled(enableLog);
break;
case "setLogLevel":
logLevelStr = call.argument("logLevelStr");
int logLevel = Integer.parseInt(logLevelStr);
FlurryAgent.setLogLevel(logLevel);
break;
case "setSslPinningEnabled":
sslPinningEnabled = call.<Boolean>argument("sslPinningEnabled");
FlurryAgent.setSslPinningEnabled(sslPinningEnabled);
break;
case "addUserPropertyValue":
String propertyName = call.argument("propertyName");
String propertyValue = call.argument("propertyValue");
Expand Down Expand Up @@ -408,6 +439,10 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
case "setMessagingListener":
// no-op
break;
case "willHandleMessage":
boolean willHandle = call.<Boolean>argument("willHandle");
FlutterFlurryMessagingListener.notifyCallbackReturn(willHandle);
break;
case "isPublisherDataFetched":
boolean fetched = FlurryPublisherSegmentation.isFetchFinished();
result.success(fetched);
Expand Down Expand Up @@ -616,21 +651,25 @@ public String getSessionId() {
}

public int logEvent(String eventId) {
return FlurryAgent.logEvent(eventId).ordinal();
FlurryEventRecordStatus status = FlurryAgent.logEvent(eventId);
return (status != null) ? status.ordinal() : 0;
}

public int logEventWithParameters(String eventId, String keysStr, String valuesStr) {
Map<String, String> parameters = keyValueToMap(keysStr, valuesStr);
return FlurryAgent.logEvent(eventId, parameters).ordinal();
FlurryEventRecordStatus status = FlurryAgent.logEvent(eventId, parameters);
return (status != null) ? status.ordinal() : 0;
}

public int logTimedEvent(String eventId, boolean timed) {
return FlurryAgent.logEvent(eventId, timed).ordinal();
FlurryEventRecordStatus status = FlurryAgent.logEvent(eventId, timed);
return (status != null) ? status.ordinal() : 0;
}

public int logTimedEventWithParameters(String eventId, String keysStr, String valuesStr, boolean timed) {
Map<String, String> parameters = keyValueToMap(keysStr, valuesStr);
return FlurryAgent.logEvent(eventId, parameters, timed).ordinal();
FlurryEventRecordStatus status = FlurryAgent.logEvent(eventId, parameters, timed);
return (status != null) ? status.ordinal() : 0;
}

public void endTimedEvent(String eventId) {
Expand Down Expand Up @@ -665,7 +704,8 @@ public int logStandardEvent(int standardId, Map<Integer, String> flurryParam, Ma
paramMap.put(entry.getKey(), entry.getValue());
}

return FlurryAgent.logEvent(event, params).ordinal();
FlurryEventRecordStatus status = FlurryAgent.logEvent(event, params);
return (status != null) ? status.ordinal() : 0;
}

public void onError(String errorId, String message, String errorClass) {
Expand All @@ -684,8 +724,9 @@ public void logBreadcrumb(String crashBreadcrumb) {
public int logPayment(String productName, String productId, int quantity, double price,
String currency, String transactionId, String keysStr, String valuesStr) {
Map<String, String> parameters = keyValueToMap(keysStr, valuesStr);
return FlurryAgent.logPayment(productName, productId, quantity, price, currency,
transactionId, parameters).ordinal();
FlurryEventRecordStatus status = FlurryAgent.logPayment(productName, productId, quantity, price, currency,
transactionId, parameters);
return (status != null) ? status.ordinal() : 0;
}

public List<String> stringToList(String listStr) {
Expand Down Expand Up @@ -821,7 +862,7 @@ public Builder withMessaging(final boolean enableMessaging, FlurryMessagingListe

FlurryMarketingOptions messagingOptions = new FlurryMarketingOptions.Builder()
.setupMessagingWithAutoIntegration()
.withFlurryMessagingListener(messagingListener)
.withFlurryMessagingListener(messagingListener, getHandler())
// Define yours if needed
// .withDefaultNotificationChannelId(NOTIFICATION_CHANNEL_ID)
// .withDefaultNotificationIconResourceId(R.mipmap.ic_launcher_round)
Expand Down Expand Up @@ -854,8 +895,9 @@ public Builder withMessaging(final boolean enableMessaging, FlurryMarketingOptio
} else {
builder.setupMessagingWithManualIntegration(messagingOptions.getToken());
}

messagingOptions = builder
.withFlurryMessagingListener(new FlutterFlurryMessagingListener())
.withFlurryMessagingListener(new FlutterFlurryMessagingListener(), getHandler())
.withDefaultNotificationChannelId(messagingOptions.getNotificationChannelId())
.withDefaultNotificationIconResourceId(messagingOptions.getDefaultNotificationIconResourceId())
.withDefaultNotificationIconAccentColor(messagingOptions.getDefaultNotificationIconAccentColor())
Expand All @@ -868,6 +910,15 @@ public Builder withMessaging(final boolean enableMessaging, FlurryMarketingOptio
return this;
}

private Handler getHandler() {
// Use non-UI thread to notify the messaging listeners.
HandlerThread handlerThread = new HandlerThread("FlurryHandlerThread");
handlerThread.start();
Handler handler = new Handler(handlerThread.getLooper());

return handler;
}

public void build(final Context context, final String apiKey) {
mFlurryAgentBuilder
.withSessionForceStart(true)
Expand Down Expand Up @@ -960,6 +1011,8 @@ public static FlurryMessagingListener getFlurryMessagingListener() {
*/
static class FlutterFlurryMessagingListener implements FlurryMessagingListener {
private static EventChannel.EventSink eventSink;
private static boolean sCallbackReturnValue = false;
private static boolean sIsCallbackReturn = false;
private static String sToken = null;

enum EventType {
Expand Down Expand Up @@ -1031,6 +1084,9 @@ private static boolean sendEvent(EventType type, FlurryMessage flurryMessage, bo
params.put("clickAction", flurryMessage.getClickAction());
params.put("appData", flurryMessage.getAppData());

sCallbackReturnValue = false;
sIsCallbackReturn = !waitReturn;

// Run Flutter event channel on the UI main thread.
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
Expand All @@ -1039,8 +1095,8 @@ public void run() {
}
});

// user specify value not supported yet.
return false;
waitCallbackReturn();
return sCallbackReturnValue;
}

private static void sendEvent(EventType type, String token) {
Expand All @@ -1057,6 +1113,26 @@ public void run() {
});
}

private static void waitCallbackReturn() {
synchronized (eventSink) {
if (!sIsCallbackReturn) {
try {
eventSink.wait(300);
} catch (InterruptedException e) {
Log.e(TAG, "Interrupted Exception!", e);
}
}
}
}

public static void notifyCallbackReturn(boolean returnValue) {
synchronized (eventSink) {
sCallbackReturnValue = returnValue;
sIsCallbackReturn = true;
eventSink.notifyAll();
}
}

}

/**
Expand Down
4 changes: 2 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ flutter {
dependencies {
// implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])

implementation 'com.flurry.android:analytics:13.0.0'
implementation 'com.flurry.android:marketing:13.0.0'
implementation 'com.flurry.android:analytics:13.1.0'
implementation 'com.flurry.android:marketing:13.1.0'

implementation 'com.google.android.gms:play-services-ads-identifier:17.0.1'
implementation 'com.google.firebase:firebase-messaging:20.1.0'
Expand Down
10 changes: 5 additions & 5 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
PODS:
- Flurry-iOS-SDK/FlurryConfig (11.3.0):
- Flurry-iOS-SDK/FlurryConfig (11.4.0):
- Flurry-iOS-SDK/FlurrySDK
- Flurry-iOS-SDK/FlurryMessaging (11.3.0):
- Flurry-iOS-SDK/FlurryMessaging (11.4.0):
- Flurry-iOS-SDK/FlurrySDK
- Flurry-iOS-SDK/FlurrySDK (11.3.0)
- Flurry-iOS-SDK/FlurrySDK (11.4.0)
- Flutter (1.0.0)
- flutter_flurry_sdk (0.0.1):
- Flurry-iOS-SDK/FlurryConfig
Expand All @@ -26,10 +26,10 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/flutter_flurry_sdk/ios"

SPEC CHECKSUMS:
Flurry-iOS-SDK: 494e340b623f1413711603dc0184f1fd4183e0d3
Flurry-iOS-SDK: a1dbf099040d71e89a11cdf3a30c8723c1de950f
Flutter: 434fef37c0980e73bb6479ef766c45957d4b510c
flutter_flurry_sdk: f89256f7cfc503abdbec20608960d9c300c03b8f

PODFILE CHECKSUM: 1d5103e59c34489a395ae7f46690437f27451f42

COCOAPODS: 1.10.1
COCOAPODS: 1.11.0
11 changes: 10 additions & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class MyHomePage extends StatefulWidget {
_MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> with MessagingListener, PublisherSegmentationListener{
class _MyHomePageState extends State<MyHomePage> with MessagingListener, PublisherSegmentationListener {
String _platformVersion = 'Unknown';

@override
Expand All @@ -60,9 +60,18 @@ class _MyHomePageState extends State<MyHomePage> with MessagingListener, Publish
.withAppVersion("1.0.0")
.withIncludeBackgroundSessionsInMetrics(true)
.withMessaging(true, this)
.withSslPinningEnabled(true)
.withPerformanceMetrics(Performance.all)
.build(androidAPIKey: 'C9R699NJWSMJVPQWJ273',
iosAPIKey: 'RPBHT5CJFFJ9WCS3C5R6');

Flurry.setContinueSessionMillis(10000);
Flurry.setCrashReporting(true);
Flurry.setIncludeBackgroundSessionsInMetrics(true);
Flurry.setLogEnabled(true);
Flurry.setLogLevel(LogLevel.verbose);
Flurry.setSslPinningEnabled(true);

// ios test config use - RPBHT5CJFFJ9WCS3C5R6
// ios use default - VSWDMD4N49ZZ8ZNWWVCB
// android use default - C9R699NJWSMJVPQWJ273
Expand Down
Loading

0 comments on commit 6ff39fb

Please sign in to comment.