BlueWallet/blue_modules/analytics.js

43 lines
1.3 KiB
JavaScript
Raw Normal View History

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