Skip to content

Instantly share code, notes, and snippets.

@flurrydev
Last active February 18, 2022 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flurrydev/5e62086ce77bb8a5732ecff4c703b4d4 to your computer and use it in GitHub Desktop.
Save flurrydev/5e62086ce77bb8a5732ecff4c703b4d4 to your computer and use it in GitHub Desktop.
Flurry APIs for Flutter
// Methods in Flurry.builder to initialize Flurry Agent
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); // LogLevel = { verbose, debug, info, warn, error, assertion }
Builder withMessaging(bool enableMessaging, MessagingListener listener);
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
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
void Flurry.setAge(int age);
void Flurry.setGender(Gender gender);
void Flurry.setReportLocation(bool reportLocation);
void Flurry.setSessionOrigin(String originName, String deepLink);
void Flurry.setUserId(String userId);
void Flurry.setVersionName(String versionName);
void Flurry.addOrigin(String originName, String originVersion);
void Flurry.addOriginWithParameters(String originName, String originVersion, Map<String, String> parameters);
void Flurry.addSessionProperty(String propertyName, String propertyValue);
// Methods to set privacy preferences
void Flurry.setDataSaleOptOut(bool isOptOut);
void Flurry.deleteData();
void Flurry.openPrivacyDashboard();
// Methods in Flurry.userProperties to set user properties
// Standard User Properties: UserProperties = {
// propertyCurrencyPreference, propertyPurchaser, propertyRegisteredUser, propertySubscriber }
void setValue (String propertyName, String propertyValue);
void setValues (String propertyName, List<String> propertyValues);
void addValue (String propertyName, String propertyValue);
void addValues (String propertyName, List<String> propertyValues);
void remove (String propertyName);
void removeValue (String propertyName, String propertyValue);
void removeValues(String propertyName, List<String> propertyValues);
void flag (String propertyName);
// Methods to get Flurry versions and publisher segmentation
Future<int> Flurry.getAgentVersion();
Future<String?> Flurry.getReleaseVersion();
Future<String?> Flurry.getSessionId();
Future<String> Flurry.getPlatformVersion();
mixin PublisherSegmentationListener {
void onFetched(Map<String, String> data);
}
// in Flurry.publisherSegmentation
void registerListener (PublisherSegmentationListener listener);
void unregisterListener(PublisherSegmentationListener listener);
Future<bool> isFetchFinished();
void fetch();
Future<Map<String, String>?> getPublisherData();
// Methods to log Flurry events
enum EventRecordStatus {
eventFailed,
eventRecorded,
eventUniqueCountExceeded,
eventParamsCountExceeded,
eventLoggingDelayed,
eventAnalyticsDisabled,
eventParametersMismatched
}
Future<EventRecordStatus> Flurry.logEvent(String eventId);
Future<EventRecordStatus> Flurry.logEventWithParameters(String eventId, Map<String, String> parameters);
Future<EventRecordStatus> Flurry.logTimedEvent(String eventId, bool timed);
Future<EventRecordStatus> Flurry.logTimedEventWithParamters(String eventId, Map<String, String> parameters, bool timed);
void Flurry.endTimedEvent(String eventId);
void Flurry.endTimedEventWithParameters(String eventId, Map<String, String> parameters);
Future<EventRecordStatus> Flurry.logStandardEvent(StandardEventId id, Param param);
void Flurry.onError(String errorId, String message, String errorClass);
void Flurry.onErrorWithParameters(String errorId, String message, String errorClass, Map<String, String> parameters);
void Flurry.logBreadcrumb(String crashBreadcrumb);
Future<EventRecordStatus> Flurry.logPayment(String productName, String productId, int quantity, double price,
String currency, String transactionId, Map<String, String> parameters);
// Methods to enable IAP reporting(iOS)
void Flurry.setIAPReportingEnabled(bool enableIAP);
// Methods to set the iOS conversion value sent to Apple through SKAdNetwork (iOS)
void Flurry.updateConversionValue(int conversionValue);
void Flurry.updateConversionValueWithEvent(SKAdNetworkEvent flurryEvent);
// Methods in Flurry.performance to log Flurry Performance Metrics
void startResourceLogger();
void logResourceLogger();
void reportFullyDrawn();
// Methods in Flurry.config for Flurry Config
mixin ConfigListener{
void onFetchSuccess();
void onFetchNoChange();
void onFetchError(bool isRetrying);
void onActivateComplete(bool isCache);
}
void registerListener (ConfigListener listener);
void unregisterListener(ConfigListener listener);
void fetchConfig();
void activateConfig();
Future<String> getConfigString(String key, String defaultValue);
// Methods for Messaging Listener
mixin MessagingListener{
bool onNotificationReceived(Message message);
bool onNotificationClicked(Message message);
void onNotificationCancelled(Message message);
void onTokenRefresh(String token);
}
class Message {
String title;
String body;
String clickAction;
Map<String, String> appData;
}
// Methods for Standard Event - Param (builder setters and getters)
Map<dynamic, String> getParameters();
Param clear();
Param removeParam(ParamBase param);
Param remove(String key);
Param putAll(Param param);
Param putStringParam(StringParam key, String value);
Param putString(String key, String value);
Param putIntegerParam(IntegerParam key, int value);
Param putInteger(String key, int value);
Param putDoubleParam(DoubleParam key, double value);
Param putDouble(String key, double value);
Param putBooleanParam(BooleanParam key, bool value);
Param putBoolen(String key, bool value);
// FlurryEvent enum for Standard Event Id (Event Name)
enum FlurryEvent{
/// Log this event when a user clicks on an Ad.
/// Suggested event params: adType
/// Mandatory event params: none
adClick,
/// Log this event when a user views an Ad impression.
/// Suggested event params: adType
/// Mandatory event params: none
adImpression,
/// Log this event when a user is granted a reward for viewing a rewarded Ad.
/// Suggested event params: adType
/// Mandatory event params: none
adRewarded,
/// Log this event when a user skips an Ad
/// Suggested event params: adType
/// Mandatory event params: none
adSkipped,
/// Log this event when a user spends credit in the app
/// Suggested event params: levelNumber, totalAmount, isCurrencySoft, creditType, creditId, creditName, currencyType
/// Mandatory event params: totalAmount
creditsSpent,
/// Log this event when a user purchases credit in the app
/// Suggested event params: levelNumber, totalAmount, isCurrencySoft, creditType, creditId, creditName, currencyType
/// Mandatory event params: totalAmount
creditsPurchased,
/// Log this event when a user earns credit in the app
/// Suggested event params: levelNumber, totalAmount, isCurrencySoft, creditType, creditId, creditName, currencyType
/// Mandatory event params: totalAmount
creditsEarned,
/// Log this event when a user unlocks an achievement in the app
/// Suggested event params: achievementId
/// Mandatory event params: none
achievementUnlocked,
/// Log this event when an App user completes a level
/// Suggested event params: levelNumber, levelName
/// Mandatory event params: levelNumber
levelCompleted,
/// Log this event when an App user fails a level
/// Suggested event params: levelNumber, levelName
/// Mandatory event params: levelNumber
levelFailed,
/// Log this event when an App user levels up
/// Suggested event params: levelNumber, levelName
/// Mandatory event params: levelNumber
levelUp,
/// Log this event when an App user starts a level
/// Suggested event params: levelNumber, levelName
/// Mandatory event params: levelNumber
levelStarted,
/// Log this event when an App user skips a level
/// Suggested event params: levelNumber, levelName
/// Mandatory event params: levelNumber
levelSkip,
/// Log this event when an App user posts his score
/// Suggested event params: score, levelNumber
/// Mandatory event params: score
scorePosted,
/// Log this event when a user rates a content in the App
/// Suggested event params: contentId, contentType, contentName, rating
/// Mandatory event params: contentId, rating
contentRated,
/// Log this event when a specific content is viewed by a user
/// Suggested event params: contentId, contentType, contentName
/// Mandatory event params: contentId
contentViewed,
/// Log this event when a user saves the content in the App
/// Suggested event params: contentId, contentType, contentName
/// Mandatory event params: contentId
contentSaved,
/// Log this event when a user customizes the App/product
/// Suggested event params: none
/// Mandatory event params: none
productCustomized,
/// Log this event when the App is activated
/// Suggested event params: none
/// Mandatory event params: none
appActivated,
/// Log this event when a user submits an application through the App
/// Suggested event params: none
/// Mandatory event params: none
applicationSubmitted,
/// Log this event when an item is added to the cart
/// Suggested event params: itemCount, price, itemId, itemName, itemType
/// Mandatory event params: itemCount, price
addItemToCart,
/// Log this event when an item is added to the wish list
/// Suggested event params: itemCount, price, itemId, itemName, itemType
/// Mandatory event params: itemCount, price
addItemToWishList,
/// Log this event when checkout is completed or transaction is successfully completed
/// Suggested event params: itemCount, totalAmount, currencyType, transactionId
/// Mandatory event params: itemCount, totalAmount
completedCheckout,
/// Log this event when payment information is added during a checkout process
/// Suggested event params: success, paymentType
/// Mandatory event params: none
paymentInfoAdded,
/// Log this event when an item is viewed
/// Suggested event params: itemId, itemName, itemType, price
/// Mandatory event params: itemId
itemViewed,
/// Log this event when a list of items is viewed
/// Suggested event params: itemListType
/// Mandatory event params: none
itemListViewed,
/// Log this event when a user does a purchase in the App
/// Suggested event params: itemCount, totalAmount, itemId, success, itemName, itemType, currencyType, transactionId
/// Mandatory event params: totalAmount
purchased,
/// Log this event when a purchase is refunded
/// Suggested event params: price, currencyType
/// Mandatory event params: price
purchaseRefunded,
/// Log this event when a user removes an item from the cart
/// Suggested event params: itemId, price, itemName, itemType
/// Mandatory event params: itemId
removeItemFromCart,
/// Log this event when a user starts checkout
/// Suggested event params: itemCount, totalAmount
/// Mandatory event params: itemCount, totalAmount
checkoutInitiated,
/// Log this event when a user donates fund to your App or through the App
/// Suggested event params: price, currencyType
/// Mandatory event params: price
fundsDonated,
/// Log this event when user schedules an appointment using the App
/// Suggested event params: none
/// Mandatory event params: none
userScheduled,
/// Log this event when an offer is presented to the user
/// Suggested event params: itemId, itemName, itemCategory, price
/// Mandatory event params: itemId, price
offerPresented,
/// Log this event at the start of a paid subscription for a service or product
/// Suggested event params: price, isAnnualSubscription, trialDays, predictedLTV, currencyType, subscriptionCountry
/// Mandatory event params: price, isAnnualSubscription
subscriptionStarted,
/// Log this event when a user unsubscribes from a paid subscription
/// for a service or product
/// Suggested event params: isAnnualSubscription, currencyType, subscriptionCountry
/// Mandatory event params: isAnnualSubscription
subscriptionEnded,
/// Log this event when user joins a group.
/// Suggested event params: groupName
/// Mandatory event params: none
groupJoined,
/// Log this event when user leaves a group
/// Suggested event params: groupName
/// Mandatory event params: none
groupLeft,
/// Log this event when a user starts a tutorial
/// Suggested event params: tutorialName
/// Mandatory event params: none
tutorialStarted,
/// Log this event when a user completes a tutorial
/// Suggested event params: tutorialName
/// Mandatory event params: none
tutorialCompleted,
/// Log this event when a specific tutorial step is completed
/// Suggested event params: stepNumber, tutorialName
/// Mandatory event params: stepNumber
tutorialStepCompleted,
/// Log this event when user skips the tutorial
/// Suggested event params: stepNumber, tutorialName
/// Mandatory event params: stepNumber
tutorialSkipped,
/// Log this event when a user login on the App
/// Suggested event params: userId, method
/// Mandatory event params: none
login,
/// Log this event when a user logout of the App
/// Suggested event params: userId, method
/// Mandatory event params: none
logout,
/// Log the event when a user registers (signup). Helps capture the method
/// used to sign-up (sign up with google / apple or email address)
/// Suggested event params: userId, method
/// Mandatory event params: none
userRegistered,
/// Log this event when user views search results
/// Suggested event params: query, searchType (e.g. voice, text)
/// Mandatory event params: none
searchResultViewed,
/// Log this event when a user searches for a keyword using Search
/// Suggested event params: query, searchType (e.g. voice, text)
/// Mandatory event params: none
keywordSearched,
/// Log this event when a user searches for a location using Search
/// Suggested event params: query
/// Mandatory event params: none
locationSearched,
/// Log this event when a user invites another user
/// Suggested event params: userId, method
/// Mandatory event params: none
invite,
/// Log this event when a user shares content with another user in the App
/// Suggested event params: socialContentId, socialContentName, method
/// Mandatory event params: socialContentId
share,
/// Log this event when a user likes a social content. e.g. likeType captures
/// what kind of like is logged ("celebrate", "insightful", etc)
/// Suggested event params: socialContentId, socialContentName, likeType
/// Mandatory event params: socialContentId
like,
/// Log this event when a user comments or replies on a social post
/// Suggested event params: socialContentId, socialContentName
/// Mandatory event params: socialContentId
comment,
/// Log this event when an image, audio or a video is captured
/// Suggested event params: mediaId, mediaName, mediaType
/// Mandatory event params: none
mediaCaptured,
/// Log this event when an audio or video starts
/// Suggested event params: mediaId, mediaName, mediaType
/// Mandatory event params: none
mediaStarted,
/// Log this event when an audio or video is stopped
/// Suggested event params: mediaId, duration (in seconds), mediaName, mediaType
/// Mandatory event params: duration (in seconds)
mediaStopped,
/// Log this event when an audio or video is paused
/// Suggested event params: mediaId, duration (in seconds), mediaName, mediaType
/// Mandatory event params: duration (in seconds)
mediaPaused,
/// Log this event when a privacy prompt is displayed
/// Suggested event params: none
/// Mandatory event params: none
privacyPromptDisplayed,
/// Log this event when a user opts in (on the privacy prompt)
/// Suggested event params: none
/// Mandatory event params: none
privacyOptIn,
/// Log this event when a user opts out (on the privacy prompt)
/// Suggested event params: none
/// Mandatory event params: none
privacyOptOut
}
// EventParam types for Standard Event parameter (Param Type)
StringParam adType;
StringParam levelName;
IntegerParam levelNumber;
StringParam contentName;
StringParam contentType;
StringParam contentId;
StringParam creditName;
StringParam creditType;
StringParam creditId;
StringParam currencyType;
BooleanParam isCurrencySoft;
StringParam itemName;
StringParam itemType;
StringParam itemId;
IntegerParam itemCount;
StringParam itemCategory;
StringParam itemListType;
DoubleParam price;
DoubleParam totalAmount;
StringParam achievementId;
IntegerParam score;
StringParam rating;
StringParam transactionId;
BooleanParam success;
StringParam paymentType;
BooleanParam isAnnualSubscription;
StringParam subscriptionCountry;
IntegerParam trialDays;
StringParam predictedLTV;
StringParam groupName;
IntegerParam stepNumber;
StringParam tutorialName;
StringParam userId;
StringParam method;
StringParam query;
StringParam searchType;
StringParam socialContentName;
StringParam socialContentId;
StringParam likeType;
StringParam mediaName;
StringParam mediaType;
StringParam mediaId;
IntegerParam duration;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment