2016-04-01 03:38:19 +08:00
|
|
|
import {Plugin, Cordova} from './plugin';
|
|
|
|
|
|
|
|
declare var window;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Google Analytics
|
|
|
|
* @description
|
|
|
|
* This plugin connects to Google's native Universal Analytics SDK
|
|
|
|
* Prerequisites:
|
|
|
|
* - A Cordova 3.0+ project for iOS and/or Android
|
|
|
|
* - A Mobile App property through the Google Analytics Admin Console
|
|
|
|
* - (Android) Google Play Services SDK installed via [Android SDK Manager](https://developer.android.com/sdk/installing/adding-packages.html)
|
|
|
|
*/
|
|
|
|
@Plugin({
|
|
|
|
plugin: 'cordova-plugin-google-analytics',
|
|
|
|
pluginRef: 'analytics',
|
|
|
|
repo: 'https://github.com/danwilson/google-analytics-plugin',
|
|
|
|
platforms: ['Android', 'iOS']
|
|
|
|
})
|
|
|
|
export class GoogleAnalytics {
|
|
|
|
/**
|
|
|
|
* In your 'deviceready' handler, set up your Analytics tracker.
|
|
|
|
* https://developers.google.com/analytics/devguides/collection/analyticsjs/
|
|
|
|
* @param {string} id Your Google Analytics Mobile App property
|
|
|
|
*/
|
|
|
|
@Cordova()
|
2016-04-30 11:56:49 +08:00
|
|
|
static startTrackerWithId(id: string): Promise<any> { return; }
|
|
|
|
|
2016-04-01 03:38:19 +08:00
|
|
|
/**
|
|
|
|
* Track a screen
|
|
|
|
* https://developers.google.com/analytics/devguides/collection/analyticsjs/screens
|
2016-04-30 11:56:49 +08:00
|
|
|
*
|
2016-04-01 03:38:19 +08:00
|
|
|
* @param {string} title Screen title
|
|
|
|
*/
|
|
|
|
@Cordova()
|
2016-04-30 11:56:49 +08:00
|
|
|
static trackView(title: string): Promise<any> { return; }
|
|
|
|
|
2016-04-01 03:38:19 +08:00
|
|
|
/**
|
|
|
|
* Track an event
|
|
|
|
* https://developers.google.com/analytics/devguides/collection/analyticsjs/events
|
|
|
|
* @param {string} category
|
|
|
|
* @param {string} action
|
|
|
|
* @param {string} label
|
|
|
|
* @param {number} value
|
|
|
|
*/
|
|
|
|
@Cordova()
|
2016-04-30 11:56:49 +08:00
|
|
|
static trackEvent(category: string, action: string, label?: string, value?: number): Promise<any> { return; }
|
|
|
|
|
2016-04-01 03:38:19 +08:00
|
|
|
/**
|
|
|
|
* Track an exception
|
|
|
|
* @param {string} description
|
|
|
|
* @param {boolean} fatal
|
|
|
|
*/
|
|
|
|
@Cordova()
|
2016-04-30 11:56:49 +08:00
|
|
|
static trackException(description: string, fatal: boolean): Promise<any> { return; }
|
|
|
|
|
2016-04-01 03:38:19 +08:00
|
|
|
/**
|
|
|
|
* Track User Timing (App Speed)
|
|
|
|
* @param {string} category
|
|
|
|
* @param {number} intervalInMilliseconds
|
|
|
|
* @param {string} variable
|
|
|
|
* @param {string} label
|
|
|
|
*/
|
|
|
|
@Cordova()
|
2016-04-30 11:56:49 +08:00
|
|
|
static trackTiming(category: string, intervalInMilliseconds: number, variable: string, label: string): Promise<any> { return; }
|
|
|
|
|
2016-04-01 03:38:19 +08:00
|
|
|
/**
|
|
|
|
* Add a Transaction (Ecommerce)
|
|
|
|
* https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce#addTrans
|
|
|
|
* @param {string} id
|
|
|
|
* @param {string} affiliation
|
|
|
|
* @param {number} revenue
|
|
|
|
* @param {number} tax
|
|
|
|
* @param {number} shipping
|
|
|
|
* @param {string} currencyCode
|
|
|
|
*/
|
|
|
|
@Cordova()
|
2016-04-30 11:56:49 +08:00
|
|
|
static addTransaction(id: string, affiliation: string, revenue: number, tax: number, shipping: number, currencyCode: string): Promise<any> { return; }
|
|
|
|
|
2016-04-01 03:38:19 +08:00
|
|
|
/**
|
|
|
|
* Add a Transaction Item (Ecommerce)
|
|
|
|
* https://developers.google.com/analytics/devguides/collection/analyticsjs/ecommerce#addItem
|
|
|
|
* @param {string} id
|
|
|
|
* @param {string} name
|
|
|
|
* @param {string} sku
|
|
|
|
* @param {string} category
|
|
|
|
* @param {number} price
|
|
|
|
* @param {number} quantity
|
|
|
|
* @param {string} currencyCode
|
|
|
|
*/
|
|
|
|
@Cordova()
|
2016-04-30 11:56:49 +08:00
|
|
|
static addTransactionItem(id: string, name: string, sku: string, category: string, price: number, quantity: number, currencyCode: string): Promise<any> { return; }
|
|
|
|
|
2016-04-01 03:38:19 +08:00
|
|
|
/**
|
|
|
|
* Add a Custom Dimension
|
|
|
|
* https://developers.google.com/analytics/devguides/platform/customdimsmets
|
|
|
|
* @param {string} key
|
|
|
|
* @param {string} value
|
|
|
|
*/
|
|
|
|
@Cordova()
|
2016-04-30 11:56:49 +08:00
|
|
|
static addCustomDimension(key: number, value: string): Promise<any> { return; }
|
|
|
|
|
2016-04-01 03:38:19 +08:00
|
|
|
/**
|
|
|
|
* Set a UserId
|
|
|
|
* https://developers.google.com/analytics/devguides/collection/analyticsjs/user-id
|
|
|
|
* @param {string} id
|
|
|
|
*/
|
|
|
|
@Cordova()
|
2016-04-30 11:56:49 +08:00
|
|
|
static setUserId(id: string): Promise<any> { return; }
|
|
|
|
|
2016-04-01 03:38:19 +08:00
|
|
|
/**
|
|
|
|
* Enable verbose logging
|
|
|
|
*/
|
|
|
|
@Cordova()
|
2016-04-30 11:56:49 +08:00
|
|
|
static debugMode(): Promise<any> { return; }
|
|
|
|
|
2016-04-01 03:38:19 +08:00
|
|
|
/**
|
|
|
|
* Enable/disable automatic reporting of uncaught exceptions
|
|
|
|
* @param {boolean} shouldEnable
|
|
|
|
*/
|
|
|
|
@Cordova()
|
2016-04-30 11:56:49 +08:00
|
|
|
static enableUncaughtExceptionReporting(shouldEnable: boolean): Promise<any> { return; }
|
2016-04-01 03:38:19 +08:00
|
|
|
}
|