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

Commit

Permalink
Update for v8.3.0
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
poting-oath committed Aug 28, 2023
1 parent dcaf0d7 commit e41ac28
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 57 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)

## v8.3.0 (2023-08-22)

#### 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

## v8.2.0 (2023-04-02)

#### Features
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ A React Native plugin for Flurry SDK
- **Flurry Push**</br>
To set up Flurry Push, please take the following steps.
1. Open your Podfile, which is located under the `ios` folder of your project.

2. Add the following line in your target section before `use_native_modules!`

```ruby
Expand Down Expand Up @@ -154,11 +155,14 @@ A React Native plugin for Flurry SDK

4. 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)

5. Enable Background Modes (Background Fetch and Remote Notifications turned on).
![push_ios_2](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)

6. Set up "iOS Authorization" in Flurry [Push Authorization](https://developer.yahoo.com/flurry/docs/push/authorization/).

7. In order to handle notifications from a cold start, Flurry Push requires to be initialized from AppDelegate as early as possible. Please open `AppDelegate.m`, import the header file

```objc
Expand Down Expand Up @@ -412,9 +416,13 @@ See [Android](https://flurry.github.io/flurry-android-sdk/analytics/index.html)-
Flurry.logEvent(eventId: string, parameters: { [key: string]: string; });
Flurry.logEvent(eventId: string, timed: boolean);
Flurry.logEvent(eventId: string, parameters: { [key: string]: string; }, timed: boolean);
Flurry.logEvent(eventId: string, timedId: string);
Flurry.logEvent(eventId: string, parameters: { [key: string]: string; }, timedId: string);

Flurry.endTimedEvent(eventId: string);
Flurry.endTimedEvent(eventId: string, parameters: { [key: string]: string; });
Flurry.endTimedEvent(eventId: string, timedId: string);
Flurry.endTimedEvent(eventId: string, parameters: { [key: string]: string; }, timedId: string);

Flurry.logStandardEvent(eventId: Flurry.Event);
Flurry.logStandardEvent(eventId: Flurry.Event, parameters: { [key: Flurry.EventParam]: object; });
Expand Down
5 changes: 3 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def safeExtGet(prop, fallback) {
android {
compileSdkVersion safeExtGet('compileSdkVersion', 31)

namespace "com.flurry.android.reactnative"
defaultConfig {
minSdkVersion safeExtGet('minSdkVersion', 16)
targetSdkVersion safeExtGet('targetSdkVersion', 31)
Expand All @@ -43,7 +44,7 @@ dependencies {
// implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])

implementation 'com.facebook.react:react-native:+'
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'
}

3 changes: 1 addition & 2 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.flurry.android.reactnative">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class FlurryModule extends ReactContextBaseJavaModule {
private static final String FLURRY_MESSAGING_EVENT = "FlurryMessagingEvent";

private static final String ORIGIN_NAME = "react-native-flurry-sdk";
private static final String ORIGIN_VERSION = "8.2.0";
private static final String ORIGIN_VERSION = "8.3.0";

private FlurryAgent.Builder mFlurryAgentBuilder;

Expand Down Expand Up @@ -417,6 +417,17 @@ public void logEventParamsTimed(String eventId, ReadableMap parameters,
FlurryAgent.logEvent(eventId, toMap(parameters), timed);
}

@ReactMethod
public void logEventTimedId(String eventId, String timedId) {
FlurryAgent.logEvent(eventId, timedId);
}

@ReactMethod
public void logEventParamsTimedId(String eventId, ReadableMap parameters,
String timedId) {
FlurryAgent.logEvent(eventId, toMap(parameters), timedId);
}

@ReactMethod
public void logStandardEvent(double eventId, ReadableMap parameters) {
int id = (int) eventId;
Expand Down Expand Up @@ -491,13 +502,6 @@ private static void addStandardEventParams(FlurryEvent.Params params, String key
Log.e(TAG, "Wrong Standard parameter type: {" + key + ", " + value + "}.");
}

@ReactMethod
public void logPayment(String productName, String productId, double quantity, double price,
String currency, String transactionId, ReadableMap parameters) {
FlurryAgent.logPayment(productName, productId, (int) quantity, price, currency, transactionId,
toMap(parameters));
}

@ReactMethod
public void endTimedEvent(String eventId) {
FlurryAgent.endTimedEvent(eventId);
Expand All @@ -508,6 +512,23 @@ public void endTimedEventParams(String eventId, ReadableMap parameters) {
FlurryAgent.endTimedEvent(eventId, toMap(parameters));
}

@ReactMethod
public void endTimedEventId(String eventId, String timedId) {
FlurryAgent.endTimedEvent(eventId, timedId);
}

@ReactMethod
public void endTimedEventParamsId(String eventId, ReadableMap parameters, String timedId) {
FlurryAgent.endTimedEvent(eventId, toMap(parameters), timedId);
}

@ReactMethod
public void logPayment(String productName, String productId, double quantity, double price,
String currency, String transactionId, ReadableMap parameters) {
FlurryAgent.logPayment(productName, productId, (int) quantity, price, currency, transactionId,
toMap(parameters));
}

@ReactMethod
public void onError(String errorId, String message, String errorClass) {
FlurryAgent.onError(errorId, message, errorClass);
Expand Down
94 changes: 63 additions & 31 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,36 +357,63 @@ declare module 'react-native-flurry-sdk' {
/**
* Log an event.
*
* There are two overloads,
* There are three overloads,
* ```javascript
* e.g., Flurry.logEvent('eventId');
* Flurry.logEvent('eventId', true);
* Flurry.logEvent('eventId', 'timedId');
* ```
* - logEvent(eventId)
* - logEvent(eventId, timed)
*
* @param eventId The name/id of the event.
* @param timed True if this event is timed, false otherwise.
* - logEvent(eventId, timedId)
*
* @param eventId The name/id of the event.
* @param timed True if this event is timed, false otherwise.
* @param timedId The 2nd key for timed event.
*/
static logEvent(eventId: string, timed?: boolean): void;
static logEvent(eventId: string, timed?: boolean, timedId?: string): void;

/**
* Log an event with parameters.
*
* There are two overloads,
* There are three overloads,
* ```javascript
* e.g., Flurry.logEvent('eventId', {param: 'true'});
* Flurry.logEvent('eventId', {param: 'true'}, true);
* Flurry.logEvent('eventId', {param: 'true'}, 'timedId');
* ```
* Example for timed event logging with the 2nd key:
* ```javascript
* // 0 1 2 3 4 5 6 sec.
* // ID1 ID2 ID3
* // - - - ID2: 3 sec.
* // - - ID3: 2 sec.
* // - - - - - - ID1: 6 sec.
*
* Flurry.logEvent('TimedEventName', 'InstanceId1');
* // sleep 1 sec.
* Flurry.logEvent('TimedEventName', 'InstanceId2');
* // sleep 2 sec.
* Flurry.logEvent('TimedEventName', 'InstanceId3');
*
* // sleep 1 sec.
* Flurry.endTimedEvent('TimedEventName', 'InstanceId2'); // ID2 duration: 3 sec.
* // sleep 1 sec.
* Flurry.endTimedEvent('TimedEventName', 'InstanceId3'); // ID3 duration: 2 sec.
* // sleep 1 sec.
* Flurry.endTimedEvent('TimedEventName', 'InstanceId1'); // ID1 duration: 6 sec.
* ```
* - logEvent(eventId, parameters)
* - logEvent(eventId, parameters, timed)
*
* @param eventId The name/id of the event.
* @param parameters A {@code Map<String, String>} of parameters to log with this event.
* @param timed True if this event is timed, false otherwise.
* - logEvent(eventId, parameters, timedId)
*
* @param eventId The name/id of the event.
* @param parameters A {@code Map<String, String>} of parameters to log with this event.
* @param timed True if this event is timed, false otherwise.
* @param timedId The 2nd key for timed event.
*/
static logEvent(eventId: string, parameters: { [key: string]: string; }, timed?: boolean): void;
static logEvent(eventId: string, parameters: Map<string, string>, timed?: boolean): void;
static logEvent(eventId: string, parameters: { [key: string]: string; }, timed?: boolean, timedId?: string): void;
static logEvent(eventId: string, parameters: Map<string, string>, timed?: boolean, timedId?: string): void;

/**
* Log a standard event with parameters.
Expand All @@ -402,12 +429,34 @@ declare module 'react-native-flurry-sdk' {
* Flurry.logStandardEvent(Flurry.Event.PURCHASED, params);
* ```
*
* @param eventId The id {@code Flurry.Event} of the event.
* @param parameters A {@code Map<string|Flurry.EventParam, string|number|boolean>} of parameters to log with this event.
* @param eventId The id {@code Flurry.Event} of the event.
* @param parameters A {@code Map<string|Flurry.EventParam, string|number|boolean>} of parameters to log with this event.
*/
static logStandardEvent(eventId: number, parameters?: { [key: string]: string|number|boolean; }): void;
static logStandardEvent(eventId: number, parameters?: Map<string, string|number|boolean> ): void;

/**
* End a timed event.
*
* There are four overloads,
* ```javascript
* e.g., Flurry.endTimedEvent('eventId');
* Flurry.endTimedEvent('eventId', 'timedId');
* Flurry.endTimedEvent('eventId', {param: 'true'});
* Flurry.endTimedEvent('eventId', {param: 'true'}, 'timedId');
* ```
* - endTimedEvent(eventId)
* - endTimedEvent(eventId, timedId)
* - endTimedEvent(eventId, parameters)
* - endTimedEvent(eventId, parameters, timedId)
*
* @param eventId The name/id of the event.
* @param parameters A {@code Map<String, String>} of parameters to log with this event.
* @param timedId The 2nd key for timed event.
*/
static endTimedEvent(eventId: string, parameters?: { [key: string]: string; }): void;
static endTimedEvent(eventId: string, parameters?: Map<string, string> ): void;

/**
* Log a payment.
*
Expand All @@ -429,23 +478,6 @@ declare module 'react-native-flurry-sdk' {
static logPayment(productName: string, productId: string, quantity: number, price: number,
currency: string, transactionId: string, parameters: Map<string, string> ): void;

/**
* End a timed event.
*
* There are two overloads,
* ```javascript
* e.g., Flurry.endTimedEvent('eventId');
* Flurry.endTimedEvent('eventId', {param: 'true'});
* ```
* - endTimedEvent(eventId)
* - endTimedEvent(eventId, parameters)
*
* @param eventId The name/id of the event.
* @param parameters A {@code Map<String, String>} of parameters to log with this event.
*/
static endTimedEvent(eventId: string, parameters?: { [key: string]: string; }): void;
static endTimedEvent(eventId: string, parameters?: Map<string, string> ): void;

/**
* Report errors that your app catches.
*
Expand Down
38 changes: 31 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,10 @@ export default class Flurry {
* There are four overloads
* - logEvent(eventId)
* - logEvent(eventId, timed)
* - logEvent(eventId, timedId)
* - logEvent(eventId, parameters)
* - logEvent(eventId, parameters, timed)
* - logEvent(eventId, parameters, timedId)
*/
static logEvent(eventId, timedOrParameters, timed) {
if (typeof eventId !== 'string') {
Expand All @@ -698,26 +700,38 @@ export default class Flurry {
} else if (arguments.length === 2) {
if (typeof timedOrParameters === 'boolean') {
ReactNativeFlurry.logEventTimed(eventId, timedOrParameters);
} else if (typeof timedOrParameters === 'string') {
ReactNativeFlurry.logEventTimedId(eventId, timedOrParameters);
} else if (Object.prototype.toString.call(timedOrParameters).includes('Object')) {
ReactNativeFlurry.logEventParams(eventId, timedOrParameters);
} else if (Object.prototype.toString.call(timedOrParameters).includes('Map')) {
ReactNativeFlurry.logEventParams(eventId, Object.fromEntries(timedOrParameters));
}
} else if (arguments.length === 3) {
if (Object.prototype.toString.call(timedOrParameters).includes('Object')) {
ReactNativeFlurry.logEventParamsTimed(eventId, timedOrParameters, timed);
if (typeof timed === 'boolean') {
ReactNativeFlurry.logEventParamsTimed(eventId, timedOrParameters, timed);
} else if (typeof timed === 'string') {
ReactNativeFlurry.logEventParamsTimedId(eventId, timedOrParameters, timed);
}
} else if (Object.prototype.toString.call(timedOrParameters).includes('Map')) {
ReactNativeFlurry.logEventParamsTimed(eventId, Object.fromEntries(timedOrParameters), timed);
if (typeof timed === 'boolean') {
ReactNativeFlurry.logEventParamsTimed(eventId, Object.fromEntries(timedOrParameters), timed);
} else if (typeof timed === 'string') {
ReactNativeFlurry.logEventParamsTimedId(eventId, Object.fromEntries(timedOrParameters), timed);
}
}
}
}

/**
* There are two overloads
* - endTimedEvent(eventId)
* - endTimedEvent(eventId, timedId)
* - endTimedEvent(eventId, parameters)
* - endTimedEvent(eventId, parameters, timedId)
*/
static endTimedEvent(eventId, parameters) {
static endTimedEvent(eventId, timedIdOrParameters, timedId) {
if (typeof eventId !== 'string') {
console.error(`Flurry.logEvent: endTimedEvent must be a string. Got ${eventId}`);
return;
Expand All @@ -726,10 +740,20 @@ export default class Flurry {
if (arguments.length === 1) {
ReactNativeFlurry.endTimedEvent(eventId);
} else if (arguments.length === 2) {
if (Object.prototype.toString.call(parameters).includes('Object')) {
ReactNativeFlurry.endTimedEventParams(eventId, parameters);
} else if (Object.prototype.toString.call(parameters).includes('Map')) {
ReactNativeFlurry.endTimedEventParams(eventId, Object.fromEntries(parameters));
if (typeof timedIdOrParameters === 'string') {
ReactNativeFlurry.endTimedEventId(eventId, timedIdOrParameters);
} else if (Object.prototype.toString.call(timedIdOrParameters).includes('Object')) {
ReactNativeFlurry.endTimedEventParams(eventId, timedIdOrParameters);
} else if (Object.prototype.toString.call(timedIdOrParameters).includes('Map')) {
ReactNativeFlurry.endTimedEventParams(eventId, Object.fromEntries(timedIdOrParameters));
}
} else if (arguments.length === 3) {
if (typeof timedId === 'string') {
if (Object.prototype.toString.call(timedIdOrParameters).includes('Object')) {
ReactNativeFlurry.endTimedEventParamsId(eventId, timedIdOrParameters, timedId);
} else if (Object.prototype.toString.call(timedIdOrParameters).includes('Map')) {
ReactNativeFlurry.endTimedEventParamsId(eventId, Object.fromEntries(timedIdOrParameters), timedId);
}
}
}
}
Expand Down
Loading

0 comments on commit e41ac28

Please sign in to comment.