mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-05-03 00:24:46 +08:00
fix(flurry-analytics): fix plugin wrapper
This commit is contained in:
parent
e84359b2b1
commit
14959c1162
@ -1,4 +1,4 @@
|
|||||||
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';
|
import { Plugin, CordovaInstance, checkAvailability, IonicNativePlugin } from '@ionic-native/core';
|
||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
|
|
||||||
export interface FlurryAnalyticsOptions {
|
export interface FlurryAnalyticsOptions {
|
||||||
@ -72,91 +72,47 @@ export interface FlurryAnalyticsLocation {
|
|||||||
horizontalAccuracy?: number;
|
horizontalAccuracy?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
export class FlurryAnalyticsObject {
|
||||||
* @name Flurry Analytics
|
|
||||||
* @description
|
|
||||||
* This plugin connects to Flurry Analytics SDK
|
|
||||||
*
|
|
||||||
* @usage
|
|
||||||
* ```typescript
|
|
||||||
* 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: 'FlurryAnalytics',
|
|
||||||
repo: 'https://github.com/blakgeek/cordova-plugin-flurryanalytics.git',
|
|
||||||
platforms: ['Android', 'iOS', 'Browser']
|
|
||||||
})
|
|
||||||
@Injectable()
|
|
||||||
export class FlurryAnalytics extends IonicNativePlugin {
|
|
||||||
|
|
||||||
/**
|
constructor(private _objectInstance: any) { }
|
||||||
* Set the setting for Flurry Analytics
|
|
||||||
* @param appKey {string} API key is required
|
|
||||||
* @param options {FlurryAnalyticsOptions} is optional
|
|
||||||
* @return {Promise<any>}
|
|
||||||
*/
|
|
||||||
@Cordova()
|
|
||||||
init(appKey: string, options?: FlurryAnalyticsOptions): Promise<any> {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function set the Event
|
* This function set the Event
|
||||||
* @param eventName {string} The param to configure name of Event
|
* @param eventName {string} Name of the event
|
||||||
* @param params {Object} optional
|
* @param [params] {Object} Optional params
|
||||||
* @return {Promise<any>} Returns a promise that resolves when event is set
|
* @return {Promise<any>} Returns a promise that resolves when event is sent
|
||||||
*/
|
*/
|
||||||
@Cordova({
|
@CordovaInstance({
|
||||||
successIndex: 1,
|
successIndex: 2,
|
||||||
errorIndex: 0
|
errorIndex: 3
|
||||||
})
|
})
|
||||||
logEvent(eventName: string, params?: any): Promise<any> {
|
logEvent(eventName: string, params?: any): Promise<any> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function start a timed event
|
* Start a timed event
|
||||||
* @param eventName
|
* @param eventName {string} Name of the event
|
||||||
* @param params {Object} optional
|
* @param [params] {Object} Optional params
|
||||||
* @return {Promise<any>} Returns a promise that resolves when timed event is started tracking
|
* @return {Promise<any>} Returns a promise that resolves when timed event is started tracking
|
||||||
*/
|
*/
|
||||||
@Cordova({
|
@CordovaInstance({
|
||||||
successIndex: 1,
|
successIndex: 2,
|
||||||
errorIndex: 0
|
errorIndex: 3
|
||||||
})
|
})
|
||||||
startTimedEvent(eventName: string, params?: Object): Promise<any> {
|
startTimedEvent(eventName: string, params?: Object): Promise<any> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function complete a timed event
|
* Complete a timed event
|
||||||
* @param eventName
|
* @param eventName {string} Name of the event
|
||||||
* @param params {Object} optional
|
* @param [params] {Object} Optional params
|
||||||
* @return {Promise<any>} Returns a promise that resolves when timed event is ended tracking
|
* @return {Promise<any>} Returns a promise that resolves when timed event is ended tracking
|
||||||
*/
|
*/
|
||||||
@Cordova({
|
@CordovaInstance({
|
||||||
successIndex: 1,
|
successIndex: 2,
|
||||||
errorIndex: 0
|
errorIndex: 3
|
||||||
})
|
})
|
||||||
endTimedEvent(eventName: string, params?: Object): Promise<any> {
|
endTimedEvent(eventName: string, params?: Object): Promise<any> {
|
||||||
return;
|
return;
|
||||||
@ -168,11 +124,8 @@ export class FlurryAnalytics extends IonicNativePlugin {
|
|||||||
* @param message
|
* @param message
|
||||||
* @return {Promise<any>}
|
* @return {Promise<any>}
|
||||||
*/
|
*/
|
||||||
@Cordova({
|
@CordovaInstance()
|
||||||
successIndex: 1,
|
logError(code: any, message: any): Promise<any> {
|
||||||
errorIndex: 0
|
|
||||||
})
|
|
||||||
logError(code, message): Promise<any> {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +133,7 @@ export class FlurryAnalytics extends IonicNativePlugin {
|
|||||||
* This function log a page view
|
* This function log a page view
|
||||||
* @return {Promise<any>}
|
* @return {Promise<any>}
|
||||||
*/
|
*/
|
||||||
@Cordova()
|
@CordovaInstance()
|
||||||
logPageView(): Promise<any> {
|
logPageView(): Promise<any> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -188,14 +141,12 @@ export class FlurryAnalytics extends IonicNativePlugin {
|
|||||||
/**
|
/**
|
||||||
* This function set the location for the event
|
* This function set the location for the event
|
||||||
* (this is will only be used for very course grained statistics like city)
|
* (this is will only be used for very course grained statistics like city)
|
||||||
* @param location
|
* @param location {FlurryAnalyticsLocation}
|
||||||
|
* @param message {string}
|
||||||
* @return {Promise<any>}
|
* @return {Promise<any>}
|
||||||
*/
|
*/
|
||||||
@Cordova({
|
@CordovaInstance()
|
||||||
successIndex: 1,
|
setLocation(location: FlurryAnalyticsLocation, message: string): Promise<any> {
|
||||||
errorIndex: 0
|
|
||||||
})
|
|
||||||
setLocation(location: FlurryAnalyticsLocation): Promise<any> {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +155,7 @@ export class FlurryAnalytics extends IonicNativePlugin {
|
|||||||
* Only needed for older versions of Android
|
* Only needed for older versions of Android
|
||||||
* @return {Promise<any>}
|
* @return {Promise<any>}
|
||||||
*/
|
*/
|
||||||
@Cordova()
|
@CordovaInstance()
|
||||||
startSession(): Promise<any> {
|
startSession(): Promise<any> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -214,8 +165,70 @@ export class FlurryAnalytics extends IonicNativePlugin {
|
|||||||
* Only needed for older versions of Android
|
* Only needed for older versions of Android
|
||||||
* @return {Promise<any>}
|
* @return {Promise<any>}
|
||||||
*/
|
*/
|
||||||
@Cordova()
|
@CordovaInstance()
|
||||||
endSession(): Promise<any> {
|
endSession(): Promise<any> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name Flurry Analytics
|
||||||
|
* @description
|
||||||
|
* This plugin connects to Flurry Analytics SDK
|
||||||
|
*
|
||||||
|
* @usage
|
||||||
|
* ```typescript
|
||||||
|
* import { FlurryAnalytics, FlurryAnalyticsObject, FlurryAnalyticsOptions } from 'ionic-native/flurry-analytics';
|
||||||
|
*
|
||||||
|
* constructor(private flurryAnalytics: FlurryAnalytics) { }
|
||||||
|
*
|
||||||
|
* ...
|
||||||
|
*
|
||||||
|
* const options: FlurryAnalyticsOptions = {
|
||||||
|
* appKey: '<your app key>', // REQUIRED
|
||||||
|
* reportSessionsOnClose: true,
|
||||||
|
* enableLogging: true
|
||||||
|
* };
|
||||||
|
*
|
||||||
|
* let fa: FlurryAnalyticsObject = this.flurryAnalytics.create(options);
|
||||||
|
*
|
||||||
|
* fa.logEvent('event name')
|
||||||
|
* .then(() => console.log('Logged an event!'))
|
||||||
|
* .catch(e => console.log('Error logging the event', e));
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* @interfaces
|
||||||
|
* FlurryAnalyticsOptions
|
||||||
|
* FlurryAnalyticsLocation
|
||||||
|
* @classes
|
||||||
|
* FlurryAnalyticsObject
|
||||||
|
*/
|
||||||
|
@Plugin({
|
||||||
|
pluginName: 'FlurryAnalytics',
|
||||||
|
plugin: 'cordova-plugin-flurryanalytics',
|
||||||
|
pluginRef: 'FlurryAnalytics',
|
||||||
|
repo: 'https://github.com/blakgeek/cordova-plugin-flurryanalytics.git',
|
||||||
|
platforms: ['Android', 'iOS', 'Browser']
|
||||||
|
})
|
||||||
|
@Injectable()
|
||||||
|
export class FlurryAnalytics extends IonicNativePlugin {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance of FlurryAnalyticsObject
|
||||||
|
* @param options {FlurryAnalyticsOptions} options
|
||||||
|
* @return {FlurryAnalyticsObject}
|
||||||
|
*/
|
||||||
|
create(options: FlurryAnalyticsOptions): FlurryAnalyticsObject {
|
||||||
|
|
||||||
|
let instance: any;
|
||||||
|
|
||||||
|
if (checkAvailability(FlurryAnalytics.pluginRef, null, FlurryAnalytics.pluginName) === true) {
|
||||||
|
instance = new (window as any).FlurryAnalaytics(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new FlurryAnalyticsObject(instance);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user