@nuxtjs/sentry
Advanced tools
| import * as NodeSentry from '@sentry/node' | ||
| import * as BrowserSentry from '@sentry/vue' | ||
| import { BrowserTracing } from '@sentry/tracing' | ||
| import type { ModuleConfiguration } from './sentry' | ||
| const moduleConfig: ModuleConfiguration = { | ||
| tracing: { | ||
| }, | ||
| } | ||
| const browserTracing = new BrowserTracing({ | ||
| routingInstrumentation: BrowserSentry.vueRouterInstrumentation(null), | ||
| }) | ||
| NodeSentry.init({ | ||
| integrations: [browserTracing], | ||
| tracesSampleRate: 1, | ||
| }) | ||
| BrowserSentry.init({ | ||
| integrations: [browserTracing], | ||
| trackComponents: true, | ||
| }) |
@@ -101,6 +101,4 @@ import merge from 'lodash.mergewith' | ||
| tracesSampleRate: 1, | ||
| hooks: ['mount', 'update'], | ||
| timeout: 2000, | ||
| trackComponents: true, | ||
| tracePropagationTargets: ['localhost', /^\//], | ||
| browserTracing: {}, | ||
| }, | ||
@@ -107,0 +105,0 @@ userOptions, |
+22
-15
@@ -25,7 +25,9 @@ import Vue from 'vue' | ||
| Vue, | ||
| <%= Object.entries(options.config).map(([key, option]) => | ||
| typeof option === 'function' | ||
| ? `${key}:${serializeFunction(option)}` | ||
| : `${key}:${serialize(option)}` | ||
| ).join(',\n ') %>, | ||
| <%= Object | ||
| .entries(options.config) | ||
| .map(([key, option]) => { | ||
| const value = typeof option === 'function' ? serializeFunction(option) : serialize(option) | ||
| return `${key}:${value}` | ||
| }) | ||
| .join(',\n ') %>, | ||
| } | ||
@@ -39,16 +41,21 @@ | ||
| config.integrations = [ | ||
| <%= Object.entries(options.integrations).map(([name, integration]) => { | ||
| const integrationOptions = Object.entries(integration).map(([key, option]) => | ||
| typeof option === 'function' | ||
| ? `${key}:${serializeFunction(option)}` | ||
| : `${key}:${serialize(option)}` | ||
| ) | ||
| <%= Object | ||
| .entries(options.integrations) | ||
| .filter(([name]) => name !== 'Vue') | ||
| .map(([name, integration]) => { | ||
| const integrationOptions = Object | ||
| .entries(integration) | ||
| .map(([key, option]) => { | ||
| const value = typeof option === 'function' ? serializeFunction(option) : serialize(option) | ||
| return `${key}:${value}` | ||
| }) | ||
| return `new ${name}(${integrationOptions.length ? '{' + integrationOptions.join(',') + '}' : ''})` | ||
| }).join(',\n ')%>, | ||
| return `new ${name}(${integrationOptions.length ? '{' + integrationOptions.join(',') + '}' : ''})` | ||
| }) | ||
| .join(',\n ') %>, | ||
| ] | ||
| <% if (options.tracing) { %> | ||
| // eslint-disable-next-line prefer-regex-literals | ||
| const { tracePropagationTargets, ...tracingOptions } = <%= serialize(options.tracing) %> | ||
| config.integrations.push(new BrowserTracing({ tracePropagationTargets })) | ||
| const { browserTracing, ...tracingOptions } = <%= serialize(options.tracing) %> | ||
| config.integrations.push(new BrowserTracing(browserTracing)) | ||
| merge(config, tracingOptions) | ||
@@ -55,0 +62,0 @@ <% } %> |
+35
-15
@@ -1,2 +0,2 @@ | ||
| import VueLib from 'vue' | ||
| import Vue from 'vue' | ||
@@ -23,5 +23,5 @@ <% if (options.lazy.injectMock) { %> | ||
| const vueErrorHandler = VueLib.config.errorHandler | ||
| const vueErrorHandler = Vue.config.errorHandler | ||
| VueLib.config.errorHandler = (error, vm, info) => { | ||
| Vue.config.errorHandler = (error, vm, info) => { | ||
| if (!loadCompleted) { | ||
@@ -32,4 +32,4 @@ if (vm) { | ||
| if (VueLib.util) { | ||
| VueLib.util.warn(`Error in ${info}: "${error.toString()}"`, vm) | ||
| if (Vue.util) { | ||
| Vue.util.warn(`Error in ${info}: "${error.toString()}"`, vm) | ||
| } | ||
@@ -124,6 +124,20 @@ console.error(error) | ||
| <%} | ||
| const serializedConfig = Object | ||
| .entries({ | ||
| ...options.config, | ||
| ...options.integrations.Vue, | ||
| ...(options.tracing ? options.tracing.vueOptions.tracingOptions : {}), | ||
| }) | ||
| .map(([key, option]) => { | ||
| const value = typeof option === 'function' ? serializeFunction(option) : serialize(option) | ||
| return`${key}: ${value}` | ||
| }) | ||
| .join(',\n ') | ||
| %> | ||
| /* eslint-disable object-curly-spacing, quote-props, quotes, key-spacing, comma-spacing */ | ||
| const config = <%= serialize(options.config) %> | ||
| config.Vue = VueLib | ||
| const config = { | ||
| Vue, | ||
| <%= serializedConfig %>, | ||
| } | ||
@@ -137,12 +151,18 @@ const runtimeConfigKey = <%= serialize(options.runtimeConfigKey) %> | ||
| config.integrations = [ | ||
| <%= Object.entries(options.integrations).map(([name, integration]) => { | ||
| const integrationOptions = Object.entries(integration).map(([key, option]) => | ||
| typeof option === 'function' | ||
| ? `${key}:${serializeFunction(option)}` | ||
| : `${key}:${serialize(option)}` | ||
| ) | ||
| <%= Object | ||
| .entries(options.integrations) | ||
| .filter(([name]) => name !== 'Vue') | ||
| .map(([name, integration]) => { | ||
| const integrationOptions = Object | ||
| .entries(integration) | ||
| .map(([key, option]) => { | ||
| const value = typeof option === 'function' ? serializeFunction(option) : serialize(option) | ||
| return `${key}:${value}` | ||
| }) | ||
| return `new ${name}(${integrationOptions.length ? '{' + integrationOptions.join(',') + '}' : ''})` | ||
| }).join(',\n ')%>, | ||
| return `new ${name}(${integrationOptions.length ? '{' + integrationOptions.join(',') + '}' : ''})` | ||
| }).join(',\n ') | ||
| %>, | ||
| ] | ||
| <%if (options.customClientIntegrations) {%> | ||
@@ -149,0 +169,0 @@ const customIntegrations = (await import(/* <%= magicComments.join(', ') %> */ '<%= options.customClientIntegrations %>').then(m => m.default || m))(ctx) |
+1
-1
| { | ||
| "name": "@nuxtjs/sentry", | ||
| "version": "7.0.0-beta.0", | ||
| "version": "7.0.0-beta.1", | ||
| "description": "Sentry module for Nuxt.js", | ||
@@ -5,0 +5,0 @@ "repository": "nuxt-community/sentry-module", |
+4
-19
| /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
| import { IncomingMessage, ServerResponse } from 'http' | ||
| import { Options as WebpackOptions } from 'webpack' | ||
| import { BrowserTracing } from '@sentry/tracing' | ||
| import { Options as SentryOptions } from '@sentry/types' | ||
| import type { Options as SentryVueOptions } from '@sentry/vue/types/types' | ||
| import { Options as SentryVueOptions, TracingOptions as SentryVueTracingOptions } from '@sentry/vue/types/types' | ||
| import { SentryCliPluginOptions } from '@sentry/webpack-plugin' | ||
@@ -25,20 +26,4 @@ import { Handlers } from '@sentry/node' | ||
| declare type Operation = 'activate' | 'create' | 'destroy' | 'mount' | 'update' | ||
| export interface TracingConfiguration { | ||
| tracesSampleRate?: number | ||
| /** | ||
| * Decides whether to track components by hooking into its lifecycle methods. | ||
| * Can be either set to `boolean` to enable/disable tracking for all of them. | ||
| * Or to an array of specific component names (case-sensitive). | ||
| */ | ||
| trackComponents: boolean | string[] | ||
| /** How long to wait until the tracked root activity is marked as finished and sent of to Sentry */ | ||
| timeout: number | ||
| /** | ||
| * List of hooks to keep track of during component lifecycle. | ||
| * Available hooks: 'activate' | 'create' | 'destroy' | 'mount' | 'update' | ||
| * Based on https://vuejs.org/v2/api/#Options-Lifecycle-Hooks | ||
| */ | ||
| hooks: Operation[] | ||
| tracePropagationTargets: (string|RegExp)[] | ||
| export interface TracingConfiguration extends Partial<SentryVueTracingOptions>, Pick<SentryOptions, 'tracesSampleRate'> { | ||
| browserTracing?: Partial<BrowserTracing['options']> | ||
| } | ||
@@ -45,0 +30,0 @@ |
42580
1.06%17
6.25%938
2.96%