-
Notifications
You must be signed in to change notification settings - Fork 131
/
Copy pathanalytics.js
42 lines (34 loc) · 1012 Bytes
/
analytics.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
import {NativeModules, NativeAppEventEmitter} from 'react-native';
const FirestackAnalytics = NativeModules.FirestackAnalytics;
import promisify from '../utils/promisify'
import { Base } from './base'
export class Analytics extends Base {
constructor(firestack, options={}) {
super(firestack, options);
this._addToFirestackInstance(
'logEventWithName'
)
}
/**
* Log an event
* @param {string} name The name of the event
* @param {object} props An object containing string-keys
* @return {Promise}
*/
logEventWithName(name, props) {
return promisify('logEventWithName', FirestackAnalytics)(name, props);
}
enable() {
return promisify('setEnabled', FirestackAnalytics)(true);
}
disable() {
return promisify('setEnabled', FirestackAnalytics)(false);
}
setUser(id, properties={}) {
return promisify('setUserId', FirestackAnalytics)(id, properties);
}
get namespace() {
return 'firestack:analytics'
}
}
export default Analytics