From 8add83612dec978ae297b7efd54b142f14700a68 Mon Sep 17 00:00:00 2001 From: anastasia Date: Fri, 31 Mar 2017 17:36:09 +0300 Subject: [PATCH 1/2] added flurry analytics wrapper --- .../plugins/flurry-analytics/index.ts | 212 ++++++++++++++++++ 1 file changed, 212 insertions(+) create mode 100644 src/@ionic-native/plugins/flurry-analytics/index.ts diff --git a/src/@ionic-native/plugins/flurry-analytics/index.ts b/src/@ionic-native/plugins/flurry-analytics/index.ts new file mode 100644 index 00000000..cbef4aff --- /dev/null +++ b/src/@ionic-native/plugins/flurry-analytics/index.ts @@ -0,0 +1,212 @@ +import { Plugin, Cordova } from '@ionic-native/core'; +import { Injectable } from '@angular/core'; + +export interface FlurryAnalyticsOptions { + /** Flurry API key is required */ + appKey?: string; + /** + * Optional parameters + */ + /** Overrides the version of the app */ + version?: string; + /** + * How long can the app be paused before a new session is created, + * must be less than or equal to five for Android devices + */ + continueSessionSeconds?: number; + /** + * Set id of the user + */ + userId?: string; + /** + * Set gender of the user + * Valid values are "m", "M", "f" and "F" + */ + gender?: string; + /** + * Set age of the user + */ + age?: number; + /** + * Set error for log + * Values: VERBOSE, DEBUG, INFO, WARN, ERROR + */ + logLevel?: string; + /** + * Defaults to false + */ + enableLogging?: boolean; + /** + * Should every event show up the app's log, defaults to true + */ + enableEventLogging?: boolean; + /** + * Should app crashes be recorded in flurry, defaults to false, iOS only + */ + enableCrashReporting?: boolean; + /** + * Should the session continue when the app is the background, defaults to false, iOS only + */ + enableBackgroundSessions?: boolean; + /** + * Should data be pushed to flurry when the app closes, defaults to true, iOS only + */ + reportSessionsOnClose?: boolean; + /** + * Should data be pushed to flurry when the app is paused, defaults to true, iOS only + */ + reportSessionsOnPause?: boolean; +} + +export interface FlurryAnalyticsLocation { + latitude: number; + longitude: number; + verticalAccuracy?: number; // optional iOS only + horizontalAccuracy?: number; // optional iOS only +} + +/** + * @name Flurry Analytics + * @description + * This plugin connects to Flurry Analytics SDK + * + * @usage + * ``` + * import { FlurryAnalytics } from 'ionic-native/flurry-analytics'; + * + * constructor(private flurryAnalytics: FlurryAnalytics) { } + * + * ... + * + * constant options: FlurryAnalyticsOptions = { + * reportSessionsOnClose: true, + * enableLogging: true + * } + * + * FlurryAnalytics.init('12345678965412303214', options) + * .then((something: any) => doSomething(something)) + * .catch((error: any) => console.log(error)); + * + * ``` + * @interfaces + * FlurryAnalyticsOptions + * FlurryAnalyticsLocation + */ +@Plugin({ + pluginName: 'FlurryAnalyticsPlugin', + plugin: 'cordova-plugin-flurryanalytics', + pluginRef: 'fa', + repo: 'https://github.com/blakgeek/cordova-plugin-flurryanalytics.git', + platforms: ['Android', 'iOS', 'Browser'] +}) +@Injectable() +export class FlurryAnalytics { + + /** + * Set the setting for Flurry Analytics + * @param appKey {string} API key is required + * @param options {FlurryAnalyticsOptions} is optional + */ + @Cordova() + init(appKey: string, options?: FlurryAnalyticsOptions): Promise { + return; + } + + /** + * This function set the Event + * @param eventName {string} The param to configure name of Event + * @param params is optional + * @return {Promise} Returns a promise that resolves when something happens + */ + @Cordova() + logEvent(eventName: string, params?: any): Promise { + if (!eventName || typeof eventName !== 'string') { + console.error(`FlurryAnalytics.logEvent: eventName must be a string. Got ${eventName}`); + return; + } + + return; + } + + /** + * This function start a timed event + * @param eventName + * @param params is optional + */ + @Cordova() + startTimedEvent(eventName: string, params?: any): Promise { + if (!eventName || typeof eventName !== 'string') { + console.error(`FlurryAnalytics.startTimedEvent: eventName must be a string. Got ${eventName}`); + return; + } + + return; + } + + /** + * This function complete a timed event + * @param eventName + * @param params is optional + */ + @Cordova() + endTimedEvent(eventName: string, params?: any): Promise { + if (!eventName || typeof eventName !== 'string') { + console.error(`FlurryAnalytics.endTimedEvent: eventName must be a string. Got ${eventName}`); + return; + } + + return; + } + + /** + * This function log an error + * @param code + * @param message + */ + @Cordova() + logError(code, message): Promise { + if ((!code || typeof code !== 'string') || (!message || typeof message !== 'string')) { + console.error(`FlurryAnalytics.logError: code must be a string. Got ${code}`); + return; + } + + return; + } + + /** + * This function log a page view + */ + @Cordova() + logPageView(): Promise { + return; + } + + /** + * This function set the location for the event + * (this is will only be used for very course grained statistics like city) + * @param location + */ + @Cordova() + setLocation(location: FlurryAnalyticsLocation): Promise { + return; + } + + + /** + * This function start the session + * Only needed for older versions of Android + */ + @Cordova() + startSession(): Promise { + return; + } + + /** + * This function end the session + * Only needed for older versions of Android + */ + @Cordova() + endSession(): Promise { + return; + } +} From ebb47ce5911ad814d723f2661236d3bb7480843f Mon Sep 17 00:00:00 2001 From: anastasia Date: Mon, 3 Apr 2017 13:14:08 +0300 Subject: [PATCH 2/2] fixed doc of flurry analytics wrapper --- .../plugins/flurry-analytics/index.ts | 83 ++++++++++--------- 1 file changed, 46 insertions(+), 37 deletions(-) diff --git a/src/@ionic-native/plugins/flurry-analytics/index.ts b/src/@ionic-native/plugins/flurry-analytics/index.ts index cbef4aff..2f687fa6 100644 --- a/src/@ionic-native/plugins/flurry-analytics/index.ts +++ b/src/@ionic-native/plugins/flurry-analytics/index.ts @@ -3,11 +3,10 @@ import { Injectable } from '@angular/core'; export interface FlurryAnalyticsOptions { /** Flurry API key is required */ - appKey?: string; + appKey: string; /** - * Optional parameters + * Overrides the version of the app */ - /** Overrides the version of the app */ version?: string; /** * How long can the app be paused before a new session is created, @@ -61,8 +60,16 @@ export interface FlurryAnalyticsOptions { export interface FlurryAnalyticsLocation { latitude: number; longitude: number; - verticalAccuracy?: number; // optional iOS only - horizontalAccuracy?: number; // optional iOS only + /** + * Set altitude + * It is optional and use only for iOS + */ + verticalAccuracy?: number; + /** + * Set radius about 2d point + * It is optional and use only for iOS + */ + horizontalAccuracy?: number; } /** @@ -106,6 +113,7 @@ export class FlurryAnalytics { * Set the setting for Flurry Analytics * @param appKey {string} API key is required * @param options {FlurryAnalyticsOptions} is optional + * @return {Promise} */ @Cordova() init(appKey: string, options?: FlurryAnalyticsOptions): Promise { @@ -115,46 +123,42 @@ export class FlurryAnalytics { /** * This function set the Event * @param eventName {string} The param to configure name of Event - * @param params is optional - * @return {Promise} Returns a promise that resolves when something happens + * @param params {Object} optional + * @return {Promise} Returns a promise that resolves when event is set */ - @Cordova() + @Cordova({ + successIndex: 1, + errorIndex: 0 + }) logEvent(eventName: string, params?: any): Promise { - if (!eventName || typeof eventName !== 'string') { - console.error(`FlurryAnalytics.logEvent: eventName must be a string. Got ${eventName}`); - return; - } - return; } /** * This function start a timed event * @param eventName - * @param params is optional + * @param params {Object} optional + * @return {Promise} Returns a promise that resolves when timed event is started tracking */ - @Cordova() - startTimedEvent(eventName: string, params?: any): Promise { - if (!eventName || typeof eventName !== 'string') { - console.error(`FlurryAnalytics.startTimedEvent: eventName must be a string. Got ${eventName}`); - return; - } - + @Cordova({ + successIndex: 1, + errorIndex: 0 + }) + startTimedEvent(eventName: string, params?: Object): Promise { return; } /** * This function complete a timed event * @param eventName - * @param params is optional + * @param params {Object} optional + * @return {Promise} Returns a promise that resolves when timed event is ended tracking */ - @Cordova() - endTimedEvent(eventName: string, params?: any): Promise { - if (!eventName || typeof eventName !== 'string') { - console.error(`FlurryAnalytics.endTimedEvent: eventName must be a string. Got ${eventName}`); - return; - } - + @Cordova({ + successIndex: 1, + errorIndex: 0 + }) + endTimedEvent(eventName: string, params?: Object): Promise { return; } @@ -162,19 +166,19 @@ export class FlurryAnalytics { * This function log an error * @param code * @param message + * @return {Promise} */ - @Cordova() + @Cordova({ + successIndex: 1, + errorIndex: 0 + }) logError(code, message): Promise { - if ((!code || typeof code !== 'string') || (!message || typeof message !== 'string')) { - console.error(`FlurryAnalytics.logError: code must be a string. Got ${code}`); - return; - } - return; } /** * This function log a page view + * @return {Promise} */ @Cordova() logPageView(): Promise { @@ -185,16 +189,20 @@ export class FlurryAnalytics { * This function set the location for the event * (this is will only be used for very course grained statistics like city) * @param location + * @return {Promise} */ - @Cordova() + @Cordova({ + successIndex: 1, + errorIndex: 0 + }) setLocation(location: FlurryAnalyticsLocation): Promise { return; } - /** * This function start the session * Only needed for older versions of Android + * @return {Promise} */ @Cordova() startSession(): Promise { @@ -204,6 +212,7 @@ export class FlurryAnalytics { /** * This function end the session * Only needed for older versions of Android + * @return {Promise} */ @Cordova() endSession(): Promise {