cordova-plugin-firebase-analytics
Advanced tools
Comparing version
{ | ||
"name": "cordova-plugin-firebase-analytics", | ||
"version": "6.1.0", | ||
"version": "7.0.0", | ||
"description": "Cordova plugin for Firebase Analytics", | ||
"types": "./types/index.d.ts", | ||
"cordova": { | ||
@@ -32,5 +33,13 @@ "id": "cordova-plugin-firebase-analytics", | ||
"scripts": { | ||
"version": "perl -p -i -e 's/(version=)\"\\d+\\.\\d+\\.\\d+\"/$1\"'$npm_package_version'\"$2/' plugin.xml && git add plugin.xml", | ||
"postversion": "git push && git push --tags" | ||
"preversion": "npm run docs && rm -rf ./docs", | ||
"version": "perl -i -pe 's/(version=)\"\\d+\\.\\d+\\.\\d+\"/$1\"'$npm_package_version'\"$2/' plugin.xml && git add plugin.xml README.md", | ||
"postversion": "git push && git push --tags", | ||
"predocs": "tsc www/* --declaration --allowJs --emitDeclarationOnly --outDir types", | ||
"docs": "typedoc ./types", | ||
"postdocs": "cat ./docs/modules/FirebaseAnalytics.md >> README.md && perl -i -0pe 's/(## Methods).*(## Functions)/$1/gms' README.md" | ||
}, | ||
"devDependencies": { | ||
"@colony/typedoc-plugin-markdown": "3.16.0", | ||
"typedoc": "^0.23.9" | ||
} | ||
} |
184
README.md
@@ -8,2 +8,10 @@ # Cordova plugin for [Firebase Analytics](https://firebase.google.com/docs/analytics/) | ||
[npm-url]: https://www.npmjs.com/package/cordova-plugin-firebase-analytics | ||
[npm-version]: https://img.shields.io/npm/v/cordova-plugin-firebase-analytics.svg | ||
[npm-downloads]: https://img.shields.io/npm/dm/cordova-plugin-firebase-analytics.svg | ||
[npm-total-downloads]: https://img.shields.io/npm/dt/cordova-plugin-firebase-analytics.svg?label=total+downloads | ||
[twitter-url]: https://twitter.com/chemerisuk | ||
[twitter-follow]: https://img.shields.io/twitter/follow/chemerisuk.svg?style=social&label=Follow%20me | ||
[donate-url]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4SVTMPKTAD9QC&source=url | ||
## Index | ||
@@ -32,5 +40,5 @@ | ||
Use variables `ANDROID_FIREBASE_ANALYTICS_VERSION` or `IOS_FIREBASE_ANALYTICS_VERSION` to override dependency versions for Firebase SDKs: | ||
Use variables `ANDROID_FIREBASE_BOM_VERSION` or `IOS_FIREBASE_ANALYTICS_VERSION` to override dependency versions for Firebase SDKs: | ||
$ cordova plugin add cordova-plugin-firebase-analytics --variable IOS_FIREBASE_POD_VERSION="~> 8.8.0" --variable ANDROID_FIREBASE_CRASHLYTICS_VERSION="19.0.+" | ||
$ cordova plugin add cordova-plugin-firebase-analytics --variable IOS_FIREBASE_POD_VERSION="9.3.0" --variable ANDROID_FIREBASE_BOM_VERSION="30.3.1" | ||
@@ -73,57 +81,159 @@ NOTE: on iOS in order to collect demographic, age, gender data etc. you should additionally [include `AdSupport.framework`](https://firebase.google.com/support/guides/analytics-adsupport) into your project. | ||
## Methods | ||
Every method returns a promise that fulfills when a call was successful. | ||
### logEvent(_name_, _params_) | ||
### ▸ **logEvent**(`name`, `params`): `Promise`<`void`\> | ||
Logs an app event. | ||
```js | ||
**`Example`** | ||
```ts | ||
cordova.plugins.firebase.analytics.logEvent("my_event", {param1: "value1"}); | ||
``` | ||
Be aware of [automatically collected events](https://support.google.com/firebase/answer/6317485). | ||
#### Parameters | ||
### setUserId(_id_) | ||
Sets the user ID property. | ||
```js | ||
cordova.plugins.firebase.analytics.setUserId("12345"); | ||
``` | ||
This feature must be used in accordance with [Google's Privacy Policy](https://www.google.com/policies/privacy). | ||
| Name | Type | Description | | ||
| :------ | :------ | :------ | | ||
| `name` | `string` | Enent name | | ||
| `params` | `Record`<`string`, `any`\> | Event parameters | | ||
### setUserProperty(_name_, _value_) | ||
Sets a user property to a given value. | ||
```js | ||
cordova.plugins.firebase.analytics.setUserProperty("name1", "value1"); | ||
#### Returns | ||
`Promise`<`void`\> | ||
Callback when operation is completed | ||
### ▸ **resetAnalyticsData**(): `Promise`<`void`\> | ||
Clears all analytics data for this instance from the device and resets the app instance ID. | ||
**`Example`** | ||
```ts | ||
cordova.plugins.firebase.analytics.resetAnalyticsData(); | ||
``` | ||
Be aware of [automatically collected user properties](https://support.google.com/firebase/answer/6317486?hl=en&ref_topic=6317484). | ||
#### Returns | ||
### setCurrentScreen(_name_) | ||
`Promise`<`void`\> | ||
Callback when operation is completed | ||
### ▸ **setCurrentScreen**(`screenName`): `Promise`<`void`\> | ||
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. | ||
```js | ||
cordova.plugins.firebase.analytics.setCurrentScreen("User profile"); | ||
**`Example`** | ||
```ts | ||
cordova.plugins.firebase.analytics.setCurrentScreen("User dashboard"); | ||
``` | ||
### setEnabled(_enabled_) | ||
#### Parameters | ||
| Name | Type | Description | | ||
| :------ | :------ | :------ | | ||
| `screenName` | `string` | Current screen name | | ||
#### Returns | ||
`Promise`<`void`\> | ||
Callback when operation is completed | ||
### ▸ **setDefaultEventParameters**(`defaults`): `Promise`<`void`\> | ||
Adds parameters that will be set on every event logged from the SDK, including automatic ones. | ||
**`Example`** | ||
```ts | ||
cordova.plugins.firebase.analytics.setDefaultEventParameters({foo: "bar"}); | ||
``` | ||
#### Parameters | ||
| Name | Type | Description | | ||
| :------ | :------ | :------ | | ||
| `defaults` | `Record`<`string`, `any`\> | Key-value default parameters map | | ||
#### Returns | ||
`Promise`<`void`\> | ||
Callback when operation is completed | ||
### ▸ **setEnabled**(`enabled`): `Promise`<`void`\> | ||
Sets whether analytics collection is enabled for this app on this device. | ||
```js | ||
**`Example`** | ||
```ts | ||
cordova.plugins.firebase.analytics.setEnabled(false); | ||
``` | ||
### resetAnalyticsData() | ||
Clears all analytics data for this instance from the device and resets the app instance ID. | ||
```js | ||
cordova.plugins.firebase.analytics.resetAnalyticsData(); | ||
#### Parameters | ||
| Name | Type | Description | | ||
| :------ | :------ | :------ | | ||
| `enabled` | `boolean` | Flag that specifies new state | | ||
#### Returns | ||
`Promise`<`void`\> | ||
Callback when operation is completed | ||
### ▸ **setUserId**(`userId`): `Promise`<`void`\> | ||
Sets the user ID property. This feature must be used in accordance with Google's Privacy Policy. | ||
**`See`** | ||
https://www.google.com/policies/privacy | ||
**`Example`** | ||
```ts | ||
cordova.plugins.firebase.analytics.setUserId("12345"); | ||
``` | ||
### setDefaultEventParameters(_params_) | ||
Adds parameters that will be set on every event logged from the SDK, including automatic ones. | ||
```js | ||
cordova.plugins.firebase.analytics.setDefaultEventParameters({foo: "bar"}); | ||
#### Parameters | ||
| Name | Type | Description | | ||
| :------ | :------ | :------ | | ||
| `userId` | `string` | User's indentifier string | | ||
#### Returns | ||
`Promise`<`void`\> | ||
Callback when operation is completed | ||
### ▸ **setUserProperty**(`name`, `value`): `Promise`<`void`\> | ||
Sets a user property to a given value. Be aware of automatically collected user properties. | ||
**`See`** | ||
https://support.google.com/firebase/answer/6317486?hl=en&ref_topic=6317484 | ||
**`Example`** | ||
```ts | ||
cordova.plugins.firebase.analytics.setUserProperty("name1", "value1"); | ||
``` | ||
[npm-url]: https://www.npmjs.com/package/cordova-plugin-firebase-analytics | ||
[npm-version]: https://img.shields.io/npm/v/cordova-plugin-firebase-analytics.svg | ||
[npm-downloads]: https://img.shields.io/npm/dm/cordova-plugin-firebase-analytics.svg | ||
[npm-total-downloads]: https://img.shields.io/npm/dt/cordova-plugin-firebase-analytics.svg?label=total+downloads | ||
[twitter-url]: https://twitter.com/chemerisuk | ||
[twitter-follow]: https://img.shields.io/twitter/follow/chemerisuk.svg?style=social&label=Follow%20me | ||
[donate-url]: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4SVTMPKTAD9QC&source=url | ||
#### Parameters | ||
| Name | Type | Description | | ||
| :------ | :------ | :------ | | ||
| `name` | `string` | Property name | | ||
| `value` | `string` | Property value | | ||
#### Returns | ||
`Promise`<`void`\> | ||
Callback when operation is completed |
@@ -5,3 +5,15 @@ var exec = require("cordova/exec"); | ||
module.exports = { | ||
logEvent: function(name, params) { | ||
logEvent: | ||
/** | ||
* | ||
* Logs an app event. | ||
* | ||
* @param {string} name Enent name | ||
* @param {Record<string, object>} params Event parameters | ||
* @returns {Promise<void>} Callback when operation is completed | ||
* | ||
* @example | ||
* cordova.plugins.firebase.analytics.logEvent("my_event", {param1: "value1"}); | ||
*/ | ||
function(name, params) { | ||
return new Promise(function(resolve, reject) { | ||
@@ -11,3 +23,16 @@ exec(resolve, reject, PLUGIN_NAME, "logEvent", [name, params || {}]); | ||
}, | ||
setUserId: function(userId) { | ||
setUserId: | ||
/** | ||
* | ||
* Sets the user ID property. This feature must be used in accordance with Google's Privacy Policy. | ||
* | ||
* @param {string} userId User's indentifier string | ||
* @returns {Promise<void>} Callback when operation is completed | ||
* | ||
* @see https://www.google.com/policies/privacy | ||
* | ||
* @example | ||
* cordova.plugins.firebase.analytics.setUserId("12345"); | ||
*/ | ||
function(userId) { | ||
return new Promise(function(resolve, reject) { | ||
@@ -17,3 +42,17 @@ exec(resolve, reject, PLUGIN_NAME, "setUserId", [userId]); | ||
}, | ||
setUserProperty: function(name, value) { | ||
setUserProperty: | ||
/** | ||
* | ||
* Sets a user property to a given value. Be aware of automatically collected user properties. | ||
* | ||
* @param {string} name Property name | ||
* @param {string} value Property value | ||
* @returns {Promise<void>} Callback when operation is completed | ||
* | ||
* @see https://support.google.com/firebase/answer/6317486?hl=en&ref_topic=6317484 | ||
* | ||
* @example | ||
* cordova.plugins.firebase.analytics.setUserProperty("name1", "value1"); | ||
*/ | ||
function(name, value) { | ||
return new Promise(function(resolve, reject) { | ||
@@ -31,3 +70,13 @@ if (typeof name !== "string") { | ||
}, | ||
resetAnalyticsData: function() { | ||
resetAnalyticsData: | ||
/** | ||
* | ||
* Clears all analytics data for this instance from the device and resets the app instance ID. | ||
* | ||
* @returns {Promise<void>} Callback when operation is completed | ||
* | ||
* @example | ||
* cordova.plugins.firebase.analytics.resetAnalyticsData(); | ||
*/ | ||
function() { | ||
return new Promise(function(resolve, reject) { | ||
@@ -37,3 +86,14 @@ exec(resolve, reject, PLUGIN_NAME, "resetAnalyticsData", []); | ||
}, | ||
setEnabled: function(enabled) { | ||
setEnabled: | ||
/** | ||
* | ||
* Sets whether analytics collection is enabled for this app on this device. | ||
* | ||
* @param {boolean} enabled Flag that specifies new state | ||
* @returns {Promise<void>} Callback when operation is completed | ||
* | ||
* @example | ||
* cordova.plugins.firebase.analytics.setEnabled(false); | ||
*/ | ||
function(enabled) { | ||
return new Promise(function(resolve, reject) { | ||
@@ -43,8 +103,29 @@ exec(resolve, reject, PLUGIN_NAME, "setEnabled", [enabled]); | ||
}, | ||
setCurrentScreen: function(name) { | ||
setCurrentScreen: | ||
/** | ||
* | ||
* 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 {string} screenName Current screen name | ||
* @returns {Promise<void>} Callback when operation is completed | ||
* | ||
* @example | ||
* cordova.plugins.firebase.analytics.setCurrentScreen("User dashboard"); | ||
*/ | ||
function(screenName) { | ||
return new Promise(function(resolve, reject) { | ||
exec(resolve, reject, PLUGIN_NAME, "setCurrentScreen", [name]); | ||
exec(resolve, reject, PLUGIN_NAME, "setCurrentScreen", [screenName]); | ||
}); | ||
}, | ||
setDefaultEventParameters: function(defaults) { | ||
setDefaultEventParameters: | ||
/** | ||
* | ||
* Adds parameters that will be set on every event logged from the SDK, including automatic ones. | ||
* @param {Record<string, object>} defaults Key-value default parameters map | ||
* @returns {Promise<void>} Callback when operation is completed | ||
* | ||
* @example | ||
* cordova.plugins.firebase.analytics.setDefaultEventParameters({foo: "bar"}); | ||
*/ | ||
function(defaults) { | ||
return new Promise(function(resolve, reject) { | ||
@@ -51,0 +132,0 @@ if (typeof defaults !== "object") { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
28725
41.52%12
33.33%312
147.62%237
86.61%2
Infinity%