2021-05-07 17:55:17 +02:00
|
|
|
import * as Sentry from '@sentry/react-native';
|
2019-07-20 15:27:36 +02:00
|
|
|
import amplitude from 'amplitude-js';
|
2021-05-18 13:54:18 +02:00
|
|
|
import { getVersion, getSystemName, getUniqueId } from 'react-native-device-info';
|
2019-11-29 00:16:04 +01:00
|
|
|
import { Platform } from 'react-native';
|
2021-05-07 17:55:17 +02:00
|
|
|
const BlueApp = require('../BlueApp');
|
2019-01-10 16:04:16 +01:00
|
|
|
|
2021-05-18 13:54:18 +02:00
|
|
|
if (process.env.NODE_ENV !== 'development') {
|
|
|
|
Sentry.init({
|
|
|
|
dsn: 'https://23377936131848ca8003448a893cb622@sentry.io/1295736',
|
|
|
|
});
|
|
|
|
Sentry.setUser({ id: getUniqueId() });
|
|
|
|
}
|
|
|
|
|
2019-07-20 15:27:36 +02:00
|
|
|
amplitude.getInstance().init('8b7cf19e8eea3cdcf16340f5fbf16330', null, {
|
|
|
|
useNativeDeviceInfo: true,
|
2020-08-16 18:20:09 +02:00
|
|
|
platform: getSystemName().toLocaleLowerCase().includes('mac') ? getSystemName() : Platform.OS,
|
2019-07-20 15:27:36 +02:00
|
|
|
});
|
2019-11-29 00:16:04 +01:00
|
|
|
amplitude.getInstance().setVersionName(getVersion());
|
2020-10-15 15:28:44 +02:00
|
|
|
amplitude.getInstance().options.apiEndpoint = 'api2.amplitude.com';
|
2021-05-07 17:55:17 +02:00
|
|
|
BlueApp.isDoNotTrackEnabled().then(value => {
|
|
|
|
if (value) Sentry.close();
|
|
|
|
amplitude.getInstance().setOptOut(value);
|
|
|
|
});
|
2019-01-10 16:04:16 +01:00
|
|
|
|
2020-06-01 14:54:23 +02:00
|
|
|
const A = async event => {
|
2019-11-30 21:12:35 +01:00
|
|
|
console.log('posting analytics...', event);
|
2019-08-04 08:42:05 +02:00
|
|
|
try {
|
2019-11-30 21:12:35 +01:00
|
|
|
amplitude.getInstance().logEvent(event);
|
2019-08-04 08:42:05 +02:00
|
|
|
} catch (err) {
|
|
|
|
console.log(err);
|
|
|
|
}
|
2019-01-10 16:04:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
A.ENUM = {
|
|
|
|
INIT: 'INIT',
|
|
|
|
GOT_NONZERO_BALANCE: 'GOT_NONZERO_BALANCE',
|
2019-11-29 00:16:04 +01:00
|
|
|
GOT_ZERO_BALANCE: 'GOT_ZERO_BALANCE',
|
2019-01-10 16:04:16 +01:00
|
|
|
CREATED_WALLET: 'CREATED_WALLET',
|
|
|
|
CREATED_LIGHTNING_WALLET: 'CREATED_LIGHTNING_WALLET',
|
2019-11-29 00:16:04 +01:00
|
|
|
APP_UNSUSPENDED: 'APP_UNSUSPENDED',
|
2020-03-26 18:26:13 +01:00
|
|
|
NAVIGATED_TO_WALLETS_HODLHODL: 'NAVIGATED_TO_WALLETS_HODLHODL',
|
2019-01-10 16:04:16 +01:00
|
|
|
};
|
|
|
|
|
2021-05-07 17:55:17 +02:00
|
|
|
A.setOptOut = value => {
|
|
|
|
if (value) Sentry.close();
|
|
|
|
return amplitude.getInstance().setOptOut(value);
|
|
|
|
};
|
|
|
|
|
2019-01-10 16:04:16 +01:00
|
|
|
module.exports = A;
|