Skip to content

Commit

Permalink
Merge branch 'gniezen/electron-reporting-test' into libre-rollbar
Browse files Browse the repository at this point in the history
  • Loading branch information
krystophv committed Oct 19, 2017
2 parents 82e6869 + f6e4058 commit b0f07fa
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 54 deletions.
1 change: 1 addition & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"babel-plugin-rewire",
["transform-define", {
"__TEST__": "true",
"__VERSION_SHA__": "abcd",
"__DEBUG__": false
}]
]
Expand Down
9 changes: 9 additions & 0 deletions app/actions/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import _ from 'lodash';

import rollbar from '../utils/rollbar';

import * as actionTypes from '../constants/actionTypes';
import * as actionSources from '../constants/actionSources';
Expand Down Expand Up @@ -287,6 +288,14 @@ export function loginRequest() {
export function loginSuccess(results) {
const { user, profile, memberships } = results;
const isClinicAccount = personUtils.userHasRole(user, 'clinic');
rollbar.configure({
payload: {
person: {
id: user.userid,
username: user.username,
}
}
});
return {
type: actionTypes.LOGIN_SUCCESS,
payload: { user, profile, memberships },
Expand Down
1 change: 1 addition & 0 deletions app/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import rollbar from './utils/rollbar';
import _ from 'lodash';
import React from 'react';
import { render } from 'react-dom';
Expand Down
26 changes: 25 additions & 1 deletion app/main.development.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,34 @@
import { app, BrowserWindow, Menu, shell, ipcMain } from 'electron';
/* global __ROLLBAR_POST_TOKEN__ */
import { app, BrowserWindow, Menu, shell, ipcMain, crashReporter } from 'electron';
import os from 'os';
import open from 'open';
import { autoUpdater } from 'electron-updater';
import * as chromeFinder from 'chrome-launcher/chrome-finder';
import { sync as syncActions } from './actions';
import debugMode from '../app/utils/debugMode';
import Rollbar from 'rollbar/src/server/rollbar';

let rollbar;
if(process.env.NODE_ENV === 'production') {
rollbar = new Rollbar({
accessToken: __ROLLBAR_POST_TOKEN__,
captureUncaught: true,
captureUnhandledRejections: true,
payload: {
environment: 'electron_main_process'
}
});
}

crashReporter.start({
productName: 'Uploader',
companyName: 'Tidepool',
submitURL: '',
uploadToServer: false
});

console.log('Crash logs can be found in:',crashReporter.getCrashesDirectory());
console.log('Last crash report:', crashReporter.getLastCrashReport());

let menu;
let template;
Expand Down
33 changes: 33 additions & 0 deletions app/utils/rollbar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* global __VERSION_SHA__ */

import Rollbar from 'rollbar/dist/rollbar.umd';

let rollbar = new Rollbar({
accessToken: '1843589282464f4facd43f794c8201a8',
captureUncaught: true,
payload: {
environment: 'electron_renderer',
client: {
javascript: {
code_version: __VERSION_SHA__,
guess_uncaught_frames: true
}
}
},
// to deal with URI's as local filesystem paths, we use the "many domain" transform:
// https://rollbar.com/docs/source-maps/#using-source-maps-on-many-domains
transform: function(payload) {
var trace = payload.body.trace;
if (trace && trace.frames) {
for (var i = 0; i < trace.frames.length; i++) {
var filename = trace.frames[i].filename;
if (filename) {
trace.frames[i].filename = 'http://dynamichost/dist/bundle.js';
}
}
}
}
}
);

export default rollbar;
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
"redux": "3.6.0",
"redux-form": "5.3.4",
"redux-thunk": "2.2.0",
"rollbar": "2.2.8",
"rollbar-sourcemap-webpack-plugin": "2.2.0",
"semver": "5.3.0",
"source-map-support": "0.4.14",
"stack-trace": "0.0.9",
Expand Down
6 changes: 6 additions & 0 deletions webpack.config.development.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ import webpack from 'webpack';
import validate from 'webpack-validator';
import merge from 'webpack-merge';
import baseConfig from './webpack.config.base';
import cp from 'child_process';

const VERSION_SHA = process.env.CIRCLE_SHA1 ||
process.env.APPVEYOR_REPO_COMMIT ||
cp.execSync('git rev-parse HEAD', { cwd: __dirname, encoding: 'utf8' });

const port = process.env.PORT || 3005;

Expand Down Expand Up @@ -120,6 +125,7 @@ export default validate(merge(baseConfig, {
__DEBUG__: JSON.stringify(JSON.parse(process.env.DEBUG_ERROR || 'false')),
__REDUX_LOG__: JSON.stringify(JSON.parse(process.env.REDUX_LOG || 'false')),
__TEST__: false,
__VERSION_SHA__: JSON.stringify(VERSION_SHA),
'global.GENTLY': false, // http://github.com/visionmedia/superagent/wiki/SuperAgent-for-Webpack for platform-client
})
],
Expand Down
1 change: 1 addition & 0 deletions webpack.config.electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export default validate(merge(baseConfig, {
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
'process.env.BUILD': JSON.stringify(process.env.BUILD) || '"prod"',
__ROLLBAR_POST_TOKEN__: JSON.stringify(process.env.ROLLBAR_POST_TOKEN),
})
],

Expand Down
17 changes: 17 additions & 0 deletions webpack.config.production.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import merge from 'webpack-merge';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import BabiliPlugin from 'babili-webpack-plugin';
import baseConfig from './webpack.config.base';
import RollbarSourceMapPlugin from 'rollbar-sourcemap-webpack-plugin';
import cp from 'child_process';

const VERSION_SHA = process.env.CIRCLE_SHA1 ||
process.env.APPVEYOR_REPO_COMMIT ||
cp.execSync('git rev-parse HEAD', {cwd: __dirname, encoding: 'utf8' });

const ROLLBAR_POST_TOKEN = process.env.ROLLBAR_POST_TOKEN;

if (process.env.DEBUG_ERROR === 'true') {
console.log('~ ~ ~ ~ ~ ~ ~ ~ ~ ~');
Expand Down Expand Up @@ -114,6 +122,8 @@ export default validate(merge(baseConfig, {
__DEBUG__: JSON.stringify(JSON.parse(process.env.DEBUG_ERROR || 'false')),
__REDUX_LOG__: JSON.stringify(JSON.parse(process.env.REDUX_LOG || 'false')),
__TEST__: false,
__VERSION_SHA__: JSON.stringify(VERSION_SHA),
__ROLLBAR_POST_TOKEN__: JSON.stringify(ROLLBAR_POST_TOKEN),
'global.GENTLY': false, // http://github.com/visionmedia/superagent/wiki/SuperAgent-for-Webpack for platform-client
}),

Expand All @@ -134,6 +144,13 @@ export default validate(merge(baseConfig, {
filename: '../app.html',
template: 'app/app.html',
inject: false
}),

/** Upload sourcemap to Rollbar */
new RollbarSourceMapPlugin({
accessToken: ROLLBAR_POST_TOKEN,
version: VERSION_SHA,
publicPath: 'http://dynamichost/dist'
})
],

Expand Down
Loading

0 comments on commit b0f07fa

Please sign in to comment.