1 | import * as Sentry from '@sentry/browser'
|
2 |
|
3 | export default function (ctx, inject) {
|
4 | const sentryMock = {}
|
5 | function createMockFunction (key) {
|
6 | return (...params) => {
|
7 | // eslint-disable-next-line no-console
|
8 | console.warn(`$sentry.${key}() called, but sentry plugin is disabled. Arguments:`, params)
|
9 | }
|
10 | }
|
11 |
|
12 | for (const [key, value] of Object.entries(Sentry)) {
|
13 | if (typeof value === 'function') {
|
14 | sentryMock[key] = createMockFunction(key)
|
15 | }
|
16 | }
|
17 |
|
18 | // Inject mocked sentry to the context as $sentry (this is used in case sentry is disabled)
|
19 | inject('sentry', sentryMock)
|
20 | ctx.$sentry = sentryMock
|
21 | }
|