-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathindex.js
90 lines (79 loc) · 2.49 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
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
import {NativeModules, Platform} from 'react-native';
const {YandexAppmetrica} = NativeModules;
export default YandexAppmetrica;
export class YandexMetrica {
static activateWithApiKey(apiKey) {
YandexAppmetrica.activateWithApiKey(apiKey);
}
/**
* Starts the statistics collection process using config.
* @param {object} params
*/
static activateWithConfig(params: Object) {
YandexAppmetrica.activateWithConfig(params);
}
/**
* Sends a custom event message and additional parameters (optional).
* @param {string} message
*/
static reportEvent(message: string) {
YandexAppmetrica.reportEvent(message);
}
/**
* Sends a custom event message and additional parameters (optional).
* @param {string} message
* @param {object} [params=null]
*/
static reportEvent(message: string, params: Object) {
YandexAppmetrica.reportEvent(message, params);
}
/**
* Sends error with reason.
* @param {string} name
* @param {object || string} exception
*/
static reportError(name: string, exception: string | Object) {
YandexAppmetrica.reportError(name, exception);
}
/**
* Sends a Rvenue event message.
* @param {string} productId
* @param {number} price
* @param {number} quantity
*/
static reportRevenue(productId: string, price: number, quantity: number) {
YandexAppmetrica.reportRevenue(productId, price, quantity);
}
/**
* Sets the ID of the user profile.
* @param {string} userProfileId
*/
static setUserProfileID(userProfileId: string) {
YandexAppmetrica.setUserProfileID(userProfileId);
}
/**
* Sets attributes of the user profile.
* @param {object} attributes
*/
static setUserProfileAttributes(attributes: Object) {
const readyAttributes = {};
Object.keys(attributes).forEach(key => {
if (
key === 'birthDate' &&
typeof attributes.birthDate === 'object' &&
typeof attributes.birthDate.getTime === 'function'
) {
readyAttributes.birthDate = attributes.birthDate.getTime();
} else {
readyAttributes[key] = attributes[key];
}
});
YandexAppmetrica.setUserProfileAttributes(readyAttributes);
}
/**
* Sends saved events from buffer.
*/
static sendEventsBuffer() {
YandexAppmetrica.sendEventsBuffer();
}
}