mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-01-19 00:12:53 +08:00
feat: add analytics-firebase plugin
This commit is contained in:
parent
8e405cc3d3
commit
e374b52c59
78
package-lock.json
generated
78
package-lock.json
generated
@ -3565,6 +3565,7 @@
|
||||
"resolved": false,
|
||||
"integrity": "sha1-E+v+d4oDIFz+A3UUgeu0szAMEmo=",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"inherits": "~2.0.0"
|
||||
}
|
||||
@ -3592,7 +3593,8 @@
|
||||
"version": "1.0.0",
|
||||
"resolved": false,
|
||||
"integrity": "sha1-mXjOMXOIxkmth5MCjDR37wRKi1E=",
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"caseless": {
|
||||
"version": "0.12.0",
|
||||
@ -3612,13 +3614,15 @@
|
||||
"version": "1.1.0",
|
||||
"resolved": false,
|
||||
"integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"combined-stream": {
|
||||
"version": "1.0.5",
|
||||
"resolved": false,
|
||||
"integrity": "sha1-k4NwpXtKUd6ix3wV1cX9+JUWQAk=",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"delayed-stream": "~1.0.0"
|
||||
}
|
||||
@ -3633,19 +3637,22 @@
|
||||
"version": "1.1.0",
|
||||
"resolved": false,
|
||||
"integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=",
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
"resolved": false,
|
||||
"integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"cryptiles": {
|
||||
"version": "2.0.5",
|
||||
"resolved": false,
|
||||
"integrity": "sha1-O9/s3GCBR8HGcgL6KR59ylnqo7g=",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"boom": "2.x.x"
|
||||
}
|
||||
@ -3690,7 +3697,8 @@
|
||||
"version": "1.0.0",
|
||||
"resolved": false,
|
||||
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"delegates": {
|
||||
"version": "1.0.0",
|
||||
@ -3727,7 +3735,8 @@
|
||||
"version": "1.0.2",
|
||||
"resolved": false,
|
||||
"integrity": "sha1-4QgOBljjALBilJkMxw4VAiNf1VA=",
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"forever-agent": {
|
||||
"version": "0.6.1",
|
||||
@ -3864,6 +3873,7 @@
|
||||
"resolved": false,
|
||||
"integrity": "sha1-B4REvXwWQLD+VA0sm3PVlnjo4cQ=",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"boom": "2.x.x",
|
||||
"cryptiles": "2.x.x",
|
||||
@ -3917,6 +3927,7 @@
|
||||
"resolved": false,
|
||||
"integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
@ -3932,7 +3943,8 @@
|
||||
"version": "1.0.0",
|
||||
"resolved": false,
|
||||
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=",
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"isstream": {
|
||||
"version": "0.1.2",
|
||||
@ -4015,13 +4027,15 @@
|
||||
"version": "1.27.0",
|
||||
"resolved": false,
|
||||
"integrity": "sha1-gg9XIpa70g7CXtVeW13oaeVDbrE=",
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"mime-types": {
|
||||
"version": "2.1.15",
|
||||
"resolved": false,
|
||||
"integrity": "sha1-pOv1BkCUVpI3uM9wBGd20J/JKu0=",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"mime-db": "~1.27.0"
|
||||
}
|
||||
@ -4105,7 +4119,8 @@
|
||||
"version": "1.0.1",
|
||||
"resolved": false,
|
||||
"integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=",
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"oauth-sign": {
|
||||
"version": "0.8.2",
|
||||
@ -4172,7 +4187,8 @@
|
||||
"version": "1.0.7",
|
||||
"resolved": false,
|
||||
"integrity": "sha1-FQ4gt1ZZCtP5EJPyWk8q2L/zC6M=",
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"punycode": {
|
||||
"version": "1.4.1",
|
||||
@ -4215,6 +4231,7 @@
|
||||
"resolved": false,
|
||||
"integrity": "sha1-z3jsb0ptHrQ9JkiMrJfwQudLf8g=",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"buffer-shims": "~1.0.0",
|
||||
"core-util-is": "~1.0.0",
|
||||
@ -4269,7 +4286,8 @@
|
||||
"version": "5.0.1",
|
||||
"resolved": false,
|
||||
"integrity": "sha1-0mPKVGls2KMGtcplUekt5XkY++c=",
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"semver": {
|
||||
"version": "5.3.0",
|
||||
@ -4297,6 +4315,7 @@
|
||||
"resolved": false,
|
||||
"integrity": "sha1-ZUEYTMkK7qbG57NeJlkIJEPGYZg=",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"hoek": "2.x.x"
|
||||
}
|
||||
@ -4333,6 +4352,7 @@
|
||||
"resolved": false,
|
||||
"integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
@ -4344,6 +4364,7 @@
|
||||
"resolved": false,
|
||||
"integrity": "sha1-YuIA8DmVWmgQ2N8KM//A8BNmLZg=",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"safe-buffer": "^5.0.1"
|
||||
}
|
||||
@ -4376,6 +4397,7 @@
|
||||
"resolved": false,
|
||||
"integrity": "sha1-jk0qJWwOIYXGsYrWlK7JaLg8sdE=",
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"block-stream": "*",
|
||||
"fstream": "^1.0.2",
|
||||
@ -4437,7 +4459,8 @@
|
||||
"version": "1.0.2",
|
||||
"resolved": false,
|
||||
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=",
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"uuid": {
|
||||
"version": "3.0.1",
|
||||
@ -9486,12 +9509,14 @@
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
@ -9511,7 +9536,8 @@
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
@ -9659,6 +9685,7 @@
|
||||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
@ -12367,12 +12394,14 @@
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
@ -12387,17 +12416,20 @@
|
||||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
@ -12514,7 +12546,8 @@
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
@ -12526,6 +12559,7 @@
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
@ -12540,6 +12574,7 @@
|
||||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
@ -12651,7 +12686,8 @@
|
||||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
@ -12663,6 +12699,7 @@
|
||||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
@ -12784,6 +12821,7 @@
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
|
248
src/@ionic-native/plugins/analytics-firebase/index.ts
Normal file
248
src/@ionic-native/plugins/analytics-firebase/index.ts
Normal file
@ -0,0 +1,248 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Cordova, CordovaProperty, IonicNativePlugin, Plugin } from '@ionic-native/core';
|
||||
|
||||
/**
|
||||
* @name Analytics Firebase
|
||||
* @description
|
||||
* Google Analytics Firebase plugin for Ionic Native apps.
|
||||
*
|
||||
* @usage
|
||||
* ```typescript
|
||||
* import { AnalyticsFirebase } from '@ionic-native/analytics-firebase';
|
||||
*
|
||||
*
|
||||
* constructor(private analyticsFirebase: AnalyticsFirebase) { }
|
||||
*
|
||||
* // Track an event with default events and params
|
||||
* const eventParams = {};
|
||||
* eventParams[this.analyticsFirebase.DEFAULT_PARAMS.LEVEL] = 29;
|
||||
* this.analyticsFirebase.logEvent(this.analyticsFirebase.DEFAULT_EVENTS.LEVEL_UP, eventParams)
|
||||
* .then(() => console.log('Event successfully tracked'))
|
||||
* .catch(err => console.log('Error tracking event:', err));
|
||||
*
|
||||
* // Track an event with custom events and params
|
||||
* const eventParams = {};
|
||||
* eventParams['my-prop'] = 29;
|
||||
* this.analyticsFirebase.logEvent('my-event', eventParams)
|
||||
* .then(() => console.log('Event successfully tracked'))
|
||||
* .catch(err => console.log('Error tracking event:', err));
|
||||
*
|
||||
*
|
||||
* // Reset analytics data
|
||||
* this.analyticsFirebase.resetAnalyticsData()
|
||||
* .then(() => console.log('Analytics data have been reset'))
|
||||
* .catch(err => console.log('Error resetting analytics data:', err));
|
||||
*
|
||||
*
|
||||
* // Track a screen view
|
||||
* this.analyticsFirebase.setCurrentScreen('Home')
|
||||
* .then(() => console.log('View successfully tracked'))
|
||||
* .catch(err => console.log('Error tracking view:', err));
|
||||
*
|
||||
*
|
||||
* // Set user id
|
||||
* this.analyticsFirebase.setUserId('USER-ID')
|
||||
* .then(() => console.log('User id successfully set'))
|
||||
* .catch(err => console.log('Error setting user id:', err));
|
||||
*
|
||||
*
|
||||
* // Set user property from default properties
|
||||
* this.analyticsFirebase.setUserProperty('KEY', 'VALUE')
|
||||
* .then(() => console.log('User property successfully set'))
|
||||
* .catch(err => console.log('Error setting user property:', err));
|
||||
*
|
||||
* ```
|
||||
*/
|
||||
@Plugin({
|
||||
pluginName: 'AnalyticsFirebase',
|
||||
plugin: 'cordova-plugin-analytics',
|
||||
pluginRef: 'analytics',
|
||||
repo: 'https://github.com/appfeel/analytics-google',
|
||||
platforms: ['Android', 'iOS']
|
||||
})
|
||||
@Injectable()
|
||||
export class AnalyticsFirebase extends IonicNativePlugin {
|
||||
/**
|
||||
* This enum represents AnalyticsFirebase default events.
|
||||
* Use one of these default events or a custom event
|
||||
* @readonly
|
||||
*/
|
||||
@CordovaProperty()
|
||||
readonly DEFAULT_EVENTS: {
|
||||
ADD_PAYMENT_INFO: string;
|
||||
ADD_TO_CART: string;
|
||||
ADD_TO_WISHLIST: string;
|
||||
APP_OPEN: string;
|
||||
BEGIN_CHECKOUT: string;
|
||||
CAMPAIGN_DETAILS: string;
|
||||
CHECKOUT_PROGRESS: string;
|
||||
EARN_VIRTUAL_CURRENCY: string;
|
||||
ECOMMERCE_PURCHASE: string;
|
||||
GENERATE_LEAD: string;
|
||||
JOIN_GROUP: string;
|
||||
LEVEL_END: string;
|
||||
LEVEL_START: string;
|
||||
LEVEL_UP: string;
|
||||
LOGIN: string;
|
||||
POST_SCORE: string;
|
||||
PRESENT_OFFER: string;
|
||||
PURCHASE_REFUND: string;
|
||||
REMOVE_FROM_CART: string;
|
||||
SEARCH: string;
|
||||
SELECT_CONTENT: string;
|
||||
SET_CHECKOUT_OPTION: string;
|
||||
SHARE: string;
|
||||
SIGN_UP: string;
|
||||
SPEND_VIRTUAL_CURRENCY: string;
|
||||
TUTORIAL_BEGIN: string;
|
||||
TUTORIAL_COMPLETE: string;
|
||||
UNLOCK_ACHIEVEMENT: string;
|
||||
VIEW_ITEM: string;
|
||||
VIEW_ITEM_LIST: string;
|
||||
VIEW_SEARCH_RESULTS: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* This enum represents AnalyticsFirebase default params.
|
||||
* Use one of these default params or a custom param
|
||||
* @readonly
|
||||
*/
|
||||
@CordovaProperty()
|
||||
readonly DEFAULT_PARAMS: {
|
||||
ACHIEVEMENT_ID: string;
|
||||
ACLID: string;
|
||||
AFFILIATION: string;
|
||||
CAMPAIGN: string;
|
||||
CHARACTER: string;
|
||||
CHECKOUT_OPTION: string;
|
||||
CHECKOUT_STEP: string;
|
||||
CONTENT: string;
|
||||
CONTENT_TYPE: string;
|
||||
COUPON: string;
|
||||
CP1: string;
|
||||
CREATIVE_NAME: string;
|
||||
CREATIVE_SLOT: string;
|
||||
CURRENCY: string;
|
||||
DESTINATION: string;
|
||||
END_DATE: string;
|
||||
FLIGHT_NUMBER: string;
|
||||
GROUP_ID: string;
|
||||
INDEX: string;
|
||||
ITEM_BRAND: string;
|
||||
ITEM_CATEGORY: string;
|
||||
ITEM_ID: string;
|
||||
ITEM_LIST: string;
|
||||
ITEM_LOCATION_ID: string;
|
||||
ITEM_NAME: string;
|
||||
ITEM_VARIANT: string;
|
||||
LEVEL: string;
|
||||
LEVEL_NAME: string;
|
||||
LOCATION: string;
|
||||
MEDIUM: string;
|
||||
METHOD: string;
|
||||
NUMBER_OF_NIGHTS: string;
|
||||
NUMBER_OF_PASSENGERS: string;
|
||||
NUMBER_OF_ROOMS: string;
|
||||
ORIGIN: string;
|
||||
PRICE: string;
|
||||
QUANTITY: string;
|
||||
SCORE: string;
|
||||
SEARCH_TERM: string;
|
||||
SHIPPING: string;
|
||||
SOURCE: string;
|
||||
START_DATE: string;
|
||||
SUCCESS: string;
|
||||
TAX: string;
|
||||
TERM: string;
|
||||
TRANSACTION_ID: string;
|
||||
TRAVEL_CLASS: string;
|
||||
VALUE: string;
|
||||
VIRTUAL_CURRENCY_NAME: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Logs an app event. The event can have up to 25 parameters.
|
||||
* Events with the same name must have the same parameters.
|
||||
* Up to 500 event names are supported.
|
||||
* Using predefined [FirebaseAnalytics.Event](https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html) and/or [FirebaseAnalytics.Param](https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Param.html) is recommended for optimal reporting.
|
||||
*
|
||||
* @param eventName {string} The event name
|
||||
* @param eventParams {object} (Optional) The event params
|
||||
* @return {Promise<any>} Returns a promise that resolves when the event is logged
|
||||
*/
|
||||
@Cordova()
|
||||
logEvent(eventName: string, eventParams?: object): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all analytics data for this app from the device and resets the app instance id
|
||||
* @return {Promise<any>} Returns a promise that resolves when the analytics data is cleared
|
||||
*/
|
||||
@Cordova()
|
||||
resetAnalyticsData(): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether analytics collection is enabled for this app on this device. This setting is persisted across app sessions. By default it is enabled
|
||||
* @param screenName {boolean} The value of the collection
|
||||
* @return {Promise<any>} Returns a promise that resolves when the collection is enabled/disabled
|
||||
*/
|
||||
@Cordova()
|
||||
setAnalyticsCollectionEnabled(enabled: boolean): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the current screen name, which specifies the current visual context in your app.
|
||||
* This helps identify the areas in your app where users spend their time and how they interact with your app
|
||||
* @param screenName {string} The screen name
|
||||
* @return {Promise<any>} Returns a promise that resolves when the current screen is setted
|
||||
*/
|
||||
@Cordova()
|
||||
setCurrentScreen(screenName: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the minimum engagement time required before starting a session. The default value is 10000 (10 seconds)
|
||||
* @param screenName {number} The duration in milliseconds
|
||||
* @return {Promise<any>} Returns a promise that resolves when the minimum session duration is set
|
||||
*/
|
||||
@Cordova()
|
||||
setMinimumSessionDuration(milliseconds: number): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the duration of inactivity that terminates the current session. The default value is 1800000 (30 minutes)
|
||||
* @param screenName {number} The duration in milliseconds
|
||||
* @return {Promise<any>} Returns a promise that resolves when the session timeout duration is set
|
||||
*/
|
||||
@Cordova()
|
||||
setSessionTimeoutDuration(milliseconds: number): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the user ID property. This feature must be used in accordance with Google's Privacy Policy
|
||||
* @param userId {string} The user id
|
||||
* @return {Promise<any>} Returns a promise that resolves when the user id is setted
|
||||
*/
|
||||
@Cordova()
|
||||
setUserId(userId: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a user property to a given value. Up to 25 user property names are supported. Once set, user property values persist throughout the app lifecycle and across sessions
|
||||
* @param userPropertyName {string} The user property name
|
||||
* @param userPropertyValue {string} The user property value
|
||||
* @return {Promise<any>} Returns a promise that resolves when the user property setted
|
||||
*/
|
||||
@Cordova()
|
||||
setUserProperty(userPropertyName: string, userPropertyValue: string): Promise<any> {
|
||||
return;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user