Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/* @flow */
import DeviceInfo from 'react-native-device-info';
import {Analytics, Hits as GAHits} from 'react-native-google-analytics';
import appPackage from '../../../package.json'; // eslint-disable-line import/extensions
const splitRegExp = /[\.-]/i;
const VERSION = appPackage.version || 'dev.dev.dev-dev';
const [major, minor, patch, build] = VERSION.split(splitRegExp);
const patchPart = parseInt(patch) === 0 ? '' : `.${patch}`;
export const VERSION_STRING = `${major}.${minor}${patchPart} (build ${build})`;
export const USER_AGENT = `YouTrackMobile/${major}.${minor}${patchPart} (${DeviceInfo.getBrand()} ${DeviceInfo.getSystemName()} ${DeviceInfo.getSystemVersion()})`;
const googleAnalyiticsId = appPackage.config.ANALYTICS_ID;
let isAnalyticsEnabled = false;
const clientId = DeviceInfo.getUniqueID();
const ga = new Analytics(googleAnalyiticsId, clientId, 1, DeviceInfo.getUserAgent());
const usage = {
init(statisticsEnabled: boolean) {
isAnalyticsEnabled = statisticsEnabled;
},
trackScreenView(screenName: string) {
if (!isAnalyticsEnabled) {
return;
import AppUtil from '@lib/util';
// We'll use JWT for API Authentication
// const Token = {};
const Token = new JWT();
// Config
const HOSTNAME = APIConfig.hostname;
const ENDPOINTS = APIConfig.endpoints;
let USER_AGENT;
try {
// Build user agent string
USER_AGENT = `${AppConfig.appName} ` +
`${DeviceInfo.getVersion()}; ${DeviceInfo.getSystemName()} ` +
`${DeviceInfo.getSystemVersion()}; ${DeviceInfo.getBrand()} ` +
`${DeviceInfo.getDeviceId()}`;
} catch (e) {
USER_AGENT = `${AppConfig.appName}`;
}
// Enable debug output when in Debug mode
const DEBUG_MODE = AppConfig.DEV;
// Number each API request (used for debugging)
let requestCounter = 0;
/* Helper Functions ==================================================================== */
/**
* Debug or not to debug
*/
handleOnSubmitFeedback = () => {
const {
i18n,
addError,
navigation: { goBack },
} = this.props;
const { feedback, email } = this.state;
Keyboard.dismiss();
this.setState({ loading: true });
this.ref
.push()
.set({
platform: DeviceInfo.getSystemName(),
manufacturer: DeviceInfo.getManufacturer(),
brand: DeviceInfo.getBrand(),
model: DeviceInfo.getModel(),
systemVersion: DeviceInfo.getSystemVersion(),
appVersion: DeviceInfo.getVersion(),
appBuildNumber: DeviceInfo.getBuildNumber(),
locale: DeviceInfo.getDeviceLocale(),
createdAt: firebase.database.ServerValue.TIMESTAMP,
feedback,
email,
})
.then(() => {
this.setState({ loading: false });
goBack();
InteractionManager.runAfterInteractions(() => {
DeviceEventEmitter.emit('showToast', i18n.feedbackSuccess);
});
})
onFeedback = () => {
let body = `\n\n-------------\nWrite above this line\n${Device.getManufacturer()} | ${Device.getBrand()} | `
body += `${Device.getModel()} | ${Device.getDeviceId()}\n`
body += `${Device.getSystemName()} ${Device.getSystemVersion()} | Build: ${Device.getReadableVersion()} ${Device.getDeviceLocale()}`
Linking.openURL(`mailto:${mail}?subject=[${appName}]%20Feedback&body=${body}`).catch(err => console.log('About:onFeedback', err))
}
t = t + `${JSON.stringify(dataDump.data[cache], null, 2)}\n`
ds = ds + t
} catch (e) {
console.error(e)
}
}
ds = ds + '------------------ End of Wallet Data Dump ------------------\n\n'
walletDump = walletDump + ds
}
}
}
const appInfo = `App version: ${packageJson.version}
App build: ${DeviceInfo.getReadableVersion()}
os: ${Platform.OS} ${Platform.Version}
device: ${DeviceInfo.getBrand()} ${DeviceInfo.getDeviceId()}
`
return LOGGER.log('SENDING LOGS WITH MESSAGE: ' + text)
.then(() => LOGGER.log(appInfo))
.then(() => LOGGER.log(walletDump))
.then(() => LOGGER.readLogs())
.then(logs => LOGS_API.sendLogs(logs))
.then(result => dispatch({ type: 'LOGS/SEND_LOGS_SUCCESS', result }))
.catch(error => {
dispatch({ type: 'LOGS/SEND_LOGS_FAILURE', error })
throw new Error(s.strings.settings_modal_send_logs_failure)
})
}
const getDeviceInfo = () => `
----- Please do not edit below here -----
${DeviceInfo.getBrand()} ${DeviceInfo.getModel()}
${DeviceInfo.getDeviceId()}
${DeviceInfo.getSystemName()} ${version}
${DeviceInfo.getReadableVersion()}
`
constructor() {
this.config = new Configuration(appPackage.bugsnag.token);
this.config.automaticallyCollectBreadcrumbs = false;
this.config.appVersion = appPackage.bugsnag.version;
this.exceptionReporter = new Client(this.config);
this.exceptionReporter.setUser(
DeviceInfo.getBrand(),
DeviceInfo.getSystemName(),
DeviceInfo.getSystemVersion()
);
log.info(`Exception reporter instance created`);
}
_getDeviceInfos() {
const infos = [];
infos.push({label:"Device Manufacturer", data: DeviceInfo.getManufacturer()});
infos.push({label:"Device Brand", data: DeviceInfo.getBrand()});
infos.push({label:"Device Model", data: DeviceInfo.getModel()});
infos.push({label:"Device ID", data: DeviceInfo.getDeviceId()});
infos.push({label:"System Name", data: DeviceInfo.getSystemName()});
infos.push({label:"System Version", data: DeviceInfo.getSystemVersion()});
infos.push({label:"Bundle ID", data: DeviceInfo.getBundleId()});
infos.push({label:"Build Number", data: DeviceInfo.getBuildNumber()});
infos.push({label:"App Version", data: DeviceInfo.getVersion()});
infos.push({label:"App Version Readable", data: DeviceInfo.getReadableVersion()});
infos.push({label:"Device name", data: DeviceInfo.getDeviceName()});
infos.push({label:"User Agent", data: DeviceInfo.getUserAgent()});
infos.push({label:"Device Locale", data: DeviceInfo.getDeviceLocale()});
infos.push({label:"Device Country", data: DeviceInfo.getDeviceCountry()});
infos.push({label:"Unique ID", data: DeviceInfo.getUniqueID()});
infos.push({label:"App Instance ID", data: DeviceInfo.getInstanceID()});
const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2});