Skip to content

Commit 524fbf5

Browse files
authored
Update analytics.md
1 parent b6483d5 commit 524fbf5

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed

Diff for: docs/api/analytics.md

+87
Original file line numberDiff line numberDiff line change
@@ -1 +1,88 @@
1+
# Analytics
12

3+
Integrating Firebase analytics is super simple using Firestack. A number of methods are provided to help tailor analytics specifically for your
4+
own app. The Firebase SDK includes a number of pre-set events which are automatically handled, and cannot be used with custom events:
5+
6+
```
7+
'app_clear_data',
8+
'app_uninstall',
9+
'app_update',
10+
'error',
11+
'first_open',
12+
'in_app_purchase',
13+
'notification_dismiss',
14+
'notification_foreground',
15+
'notification_open',
16+
'notification_receive',
17+
'os_update',
18+
'session_start',
19+
'user_engagement',
20+
```
21+
22+
#### logEvent(event: string, params?: Object)
23+
24+
Log a custom event with optional params. Returns a Promise.
25+
26+
```javascript
27+
firestack.analytics()
28+
.logEvent('clicked_advert', { id: 1337 })
29+
.then(() => {
30+
console.log('Event has been logged successfully');
31+
});
32+
```
33+
34+
#### setAnalyticsCollectionEnabled(enabled: boolean)
35+
36+
Sets whether analytics collection is enabled for this app on this device.
37+
38+
```javascript
39+
firestack.analytics()
40+
.setAnalyticsCollectionEnabled(false);
41+
```
42+
43+
#### setCurrentScreen(screenName: string, screenClassOverride: string)
44+
45+
Sets the current screen name, which specifies the current visual context in your app.
46+
47+
```javascript
48+
firestack.analytics()
49+
.setCurrentScreen('user_profile');
50+
```
51+
52+
#### setMinimumSessionDuration(miliseconds: number)
53+
54+
Sets the minimum engagement time required before starting a session. The default value is 10000 (10 seconds).
55+
56+
```javascript
57+
firestack.analytics()
58+
.setMinimumSessionDuration(15000);
59+
```
60+
61+
#### setSessionTimeoutDuration(miliseconds: number)
62+
63+
Sets the duration of inactivity that terminates the current session. The default value is 1800000 (30 minutes).
64+
65+
```javascript
66+
firestack.analytics()
67+
.setSessionTimeoutDuration(900000);
68+
```
69+
70+
#### setUserId(id: string)
71+
72+
Gives a user a uniqiue identificaition.
73+
74+
```javascript
75+
const id = firestack.auth().currentUser.uid;
76+
77+
firestack.analytics()
78+
.setUserId(id);
79+
```
80+
81+
#### setUserProperty(name: string, value: string)
82+
83+
Sets a key/value pair of data on the current user.
84+
85+
```javascript
86+
firestack.analytics()
87+
.setUserProperty('nickname', 'foobar');
88+
```

0 commit comments

Comments
 (0)