react-native-appmetrica/index.js

56 lines
1.3 KiB
JavaScript
Raw Normal View History

2017-09-30 15:41:58 +03:00
// @flow
2017-09-18 10:04:19 +03:00
import { NativeModules } from 'react-native';
const { AppMetrica } = NativeModules;
2018-08-30 12:13:18 +03:00
type ActivationConfig = {
apiKey: string,
sessionTimeout?: number,
firstActivationAsUpdate?: boolean,
};
2017-09-18 10:04:19 +03:00
export default {
/**
* Starts the statistics collection process.
* @param {string} apiKey
*/
2017-09-30 15:41:58 +03:00
activateWithApiKey(apiKey: string) {
2017-09-18 10:04:19 +03:00
AppMetrica.activateWithApiKey(apiKey);
},
2018-08-30 12:13:18 +03:00
/**
* Starts the statistics collection process using config.
* @param {object} params
*/
activateWithConfig(params: ActivationConfig) {
AppMetrica.activateWithConfig(params);
},
2017-09-18 10:04:19 +03:00
/**
* Sends a custom event message and additional parameters (optional).
* @param {string} message
* @param {object} [params=null]
*/
2017-09-30 15:41:58 +03:00
reportEvent(message: string, params: ?Object = null) {
2017-09-18 10:04:19 +03:00
AppMetrica.reportEvent(message, params);
},
2017-09-28 15:06:30 +03:00
/**
* Sends error with reason.
* @param {string} error
* @param {object} reason
*/
2017-09-30 15:41:58 +03:00
reportError(error: string, reason: Object) {
2017-09-28 15:06:30 +03:00
AppMetrica.reportError(error, reason);
},
2018-06-01 18:38:01 +03:00
/**
* Sets the ID of the user profile.
* @param {string} userProfileId
*/
setUserProfileID(userProfileId: string) {
AppMetrica.setUserProfileID(userProfileId);
},
2017-09-18 10:04:19 +03:00
};