forked from firebase/snippets-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
52 lines (43 loc) · 1.35 KB
/
index.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
import firebase from "firebase/app";
import "firebase/analytics";
function initialize() {
// [START analytics_initialize]
const analytics = firebase.analytics();
// [END analytics_initialize]
}
function logEvent() {
// [START analytics_log_event]
firebase.analytics().logEvent('notification_received');
// [END analytics_log_event]
}
function logEventParams() {
const analytics = firebase.analytics();
// [START analytics_log_event_params]
analytics.logEvent('select_content', {
content_type: 'image',
content_id: 'P12453',
items: [{ name: 'Kittens' }]
});
// [END analytics_log_event_params]
}
function logEventCustomParams() {
const analytics = firebase.analytics();
// [START analytics_log_event_custom_params]
analytics.logEvent('goal_completion', { name: 'lever_puzzle'});
// [END analytics_log_event_custom_params]
}
function setUserProperties() {
// [START analytics_set_user_properties]
firebase.analytics().setUserProperties({favorite_food: 'apples'});
// [END analytics_set_user_properties]
}
function recordScreenView() {
const screenName = '<SCREEN_NAME>';
const screenClass = '<SCREEN_CLASS>';
// [START analytics_record_screen_view]
firebase.analytics().logEvent('screen_view', {
firebase_screen: screenName,
firebase_screen_class: screenClass
});
// [END analytics_record_screen_view]
}