-
-
Notifications
You must be signed in to change notification settings - Fork 308
/
FirebaseAnalytics.js
119 lines (112 loc) · 3.69 KB
/
FirebaseAnalytics.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
var PLUGIN_NAME = "FirebaseAnalytics";
// @ts-ignore
var exec = require("cordova/exec");
exports.logEvent =
/**
* Logs an app event.
*
* @param {string} name Enent name
* @param {Record<string, number | string | Array<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) {
exec(resolve, reject, PLUGIN_NAME, "logEvent", [name, params || {}]);
});
};
exports.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) {
exec(resolve, reject, PLUGIN_NAME, "setUserId", [userId]);
});
};
exports.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) {
exec(resolve, reject, PLUGIN_NAME, "setUserProperty", [name, value]);
});
};
exports.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) {
exec(resolve, reject, PLUGIN_NAME, "resetAnalyticsData", []);
});
};
exports.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) {
exec(resolve, reject, PLUGIN_NAME, "setEnabled", [enabled]);
});
};
exports.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", [screenName]);
});
};
exports.setDefaultEventParameters =
/**
* Adds parameters that will be set on every event logged from the SDK, including automatic ones.
* @param {Record<string, number | string | Array<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) {
exec(resolve, reject, PLUGIN_NAME, "setDefaultEventParameters", [defaults || {}]);
});
};