Skip to content

Commit 678c50c

Browse files
committed
raven filtering
1 parent 6c0bfab commit 678c50c

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ module.exports = {
2323
NODE_ENV: '"production"',
2424
RELEASE: `"${version}"`,
2525
SOCKET_API_URL: '"https://socket.tutorcruncher.com"',
26+
GRECAPTCHA_KEY: '"6LdyXRgUAAAAADUNhMVKJDXiRr6DUN8TGOgllqbt"',
27+
RAVEN_DSN: '"https://[email protected]/128441"',
2628
},
2729
build_dir: prod_build_dir,
2830
public_path: prod_public_path,
@@ -45,6 +47,9 @@ module.exports = {
4547
RELEASE: '"development"',
4648
// SOCKET_API_URL: '"api/"',
4749
SOCKET_API_URL: '"https://socket.tutorcruncher.com"',
50+
GRECAPTCHA_KEY: '"6LdyXRgUAAAAADUNhMVKJDXiRr6DUN8TGOgllqbt"',
51+
// RAVEN_DSN: 'false',
52+
RAVEN_DSN: '"https://[email protected]/128441"',
4853
},
4954
port: 5000,
5055
build_dir: path.resolve(__dirname, 'dev'),
@@ -56,6 +61,8 @@ module.exports = {
5661
NODE_ENV: '"testing"',
5762
RELEASE: '"testing"',
5863
SOCKET_API_URL: '""',
64+
GRECAPTCHA_KEY: 'null',
65+
RAVEN_DSN: 'false',
5966
},
6067
build_dir: path.resolve(__dirname, 'dist-test'),
6168
css_source_map: true,

src/main.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@ import grid from './components/grid'
1010
import con_modal from './components/con-modal'
1111
import {to_markdown, clean, auto_url_root} from './utils'
1212

13-
let dsn = process.env.NODE_ENV === 'production' && 'https://[email protected]/128441'
1413
let raven_config = {
1514
release: process.env.RELEASE,
1615
tags: {
1716
host: window.location.host,
17+
},
18+
shouldSendCallback: (data) => {
19+
// if no culprit this a message and came from socket
20+
let culprit = data.culprit || '/socket.js'
21+
return culprit.indexOf('/socket.js') > 0
1822
}
1923
}
20-
Raven.config(dsn, raven_config).addPlugin(RavenVue, Vue).install()
24+
Raven.config(process.env.RAVEN_DSN, raven_config).addPlugin(RavenVue, Vue).install()
2125

2226
Vue.use(VueRouter)
2327

@@ -87,6 +91,11 @@ const ROUTER_MODES = ['hash', 'history']
8791

8892
module.exports = function (public_key, config) {
8993
config = config || {}
94+
Raven.setExtraContext({
95+
public_key: public_key,
96+
config: config,
97+
})
98+
9099
let error = null
91100
if (config.mode === undefined) {
92101
config.mode = 'grid'
@@ -135,14 +144,13 @@ module.exports = function (public_key, config) {
135144
config[k] = STRINGS[k]
136145
}
137146
}
138-
Raven.setUserContext(config)
139147

140148
return new Vue({
141149
el: config.element,
142150
router: ConfiguredVueRouter(config),
143151
render: h => h(app),
144152
data: {
145-
grecaptcha_key: process.env.NODE_ENV === 'testing' ? null : '6LdyXRgUAAAAADUNhMVKJDXiRr6DUN8TGOgllqbt',
153+
grecaptcha_key: process.env.GRECAPTCHA_KEY,
146154
contractors: [],
147155
contractors_extra: {},
148156
config: config,
@@ -164,7 +172,10 @@ module.exports = function (public_key, config) {
164172
handle_error: function (error_message) {
165173
this.error = error_message || 'unknown'
166174
config.console.error('SOCKET: ' + this.error)
167-
Raven.captureException(new Error(this.error))
175+
Raven.captureMessage(this.error, {
176+
level: 'error',
177+
fingerprint: ['{{ default }}', public_key],
178+
})
168179
},
169180
get_list: function () {
170181
// if an error already exists show that and return

0 commit comments

Comments
 (0)