(l: GoldenLayout)
| 34 | let allowSendCode: boolean; |
| 35 | |
| 36 | export function setSentryLayout(l: GoldenLayout) { |
| 37 | layout = l; |
| 38 | layout.eventHub.on('settingsChange', (newSettings: SiteSettings) => { |
| 39 | allowSendCode = newSettings.allowStoreCodeDebug; |
| 40 | }); |
| 41 | |
| 42 | Sentry.addEventProcessor(event => { |
| 43 | if (!allowSendCode) { |
| 44 | return event; |
| 45 | } |
| 46 | try { |
| 47 | const config = layout.toConfig(); |
| 48 | if (event.extra === undefined) { |
| 49 | event.extra = {}; |
| 50 | } |
| 51 | event.extra['full_url'] = window.location.origin + window.httpRoot + '#' + serialiseState(config); |
| 52 | } catch (e) { |
| 53 | console.log('Error adding full_url to Sentry event', e); |
| 54 | } |
| 55 | return event; |
| 56 | }); |
| 57 | } |
| 58 | |
| 59 | function isEventLike(value: unknown): value is Event { |
| 60 | return value instanceof Event || value?.constructor?.name === 'Event' || value?.constructor?.name === 'CustomEvent'; |
no test coverage detected