-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
55 lines (51 loc) · 1.36 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/* global __sentry */
import * as Sentry from '@sentry/browser';
import * as Integrations from '@sentry/integrations';
export default {
install: (Vue) => {
if (__sentry.isEnabled) {
Sentry.init({
dsn: __sentry.dsn,
environment: __sentry.environment,
release: __sentry.release,
integrations: [
new Integrations.Vue({
Vue,
attachProps: true
})
]
});
}
Sentry.configureScope((scope) => {
scope.setTag('instance', window.location.hostname);
scope.setTag('event_layer', 'frontend');
});
Vue.$sentry = {
Sentry,
setTag(key, value) {
Sentry.configureScope((scope) => {
scope.setTag(key, value);
});
},
setUser(id, username, name, email) {
const cleanUserObject = {id, username, name, email};
Object.keys(cleanUserObject).forEach((key) => !cleanUserObject[key] && delete cleanUserObject[key]);
Sentry.configureScope((scope) => {
scope.setUser(cleanUserObject);
});
},
setActiveInterfaceLanguage(value) {
Sentry.configureScope((scope) => {
scope.setTag('i18n.locale', value);
});
}
};
Object.defineProperties(Vue.prototype, {
$sentry: {
get() {
return Vue.$sentry;
}
}
});
}
};