{"version":3,"file":"browserTracingIntegration.js","sources":["../../src/browserTracingIntegration.ts"],"sourcesContent":["import {\n browserTracingIntegration as originalBrowserTracingIntegration,\n startBrowserTracingNavigationSpan,\n} from '@sentry/browser';\nimport type { Integration, StartSpanOptions } from '@sentry/core';\nimport { instrumentVueRouter } from './router';\n\n// The following type is an intersection of the Route type from VueRouter v2, v3, and v4.\n// This is not great, but kinda necessary to make it work with all versions at the same time.\nexport type Route = {\n /** Unparameterized URL */\n path: string;\n /**\n * Query params (keys map to null when there is no value associated, e.g. \"?foo\" and to an array when there are\n * multiple query params that have the same key, e.g. \"?foo&foo=bar\")\n */\n query: Record;\n /** Route name (VueRouter provides a way to give routes individual names) */\n name?: string | symbol | null | undefined;\n /** Evaluated parameters */\n params: Record;\n /** All the matched route objects as defined in VueRouter constructor */\n matched: { path: string }[];\n};\n\ninterface VueRouter {\n onError: (fn: (err: Error) => void) => void;\n beforeEach: (fn: (to: Route, from: Route, next?: () => void) => void) => void;\n}\n\ntype VueBrowserTracingIntegrationOptions = Parameters[0] & {\n /**\n * If a router is specified, navigation spans will be created based on the router.\n */\n router?: VueRouter;\n\n /**\n * What to use for route labels.\n * By default, we use route.name (if set) and else the path.\n *\n * Default: 'name'\n */\n routeLabel?: 'name' | 'path';\n};\n\n/**\n * A custom browser tracing integrations for Vue.\n */\nexport function browserTracingIntegration(options: VueBrowserTracingIntegrationOptions = {}): Integration {\n // If router is not passed, we just use the normal implementation\n if (!options.router) {\n return originalBrowserTracingIntegration(options);\n }\n\n const integration = originalBrowserTracingIntegration({\n ...options,\n instrumentNavigation: false,\n });\n\n const { router, instrumentNavigation = true, instrumentPageLoad = true, routeLabel = 'name' } = options;\n\n return {\n ...integration,\n afterAllSetup(client) {\n integration.afterAllSetup(client);\n\n const startNavigationSpan = (options: StartSpanOptions): void => {\n startBrowserTracingNavigationSpan(client, options);\n };\n\n instrumentVueRouter(router, { routeLabel, instrumentNavigation, instrumentPageLoad }, startNavigationSpan);\n },\n };\n}\n"],"names":["originalBrowserTracingIntegration","router","options","startBrowserTracingNavigationSpan","instrumentVueRouter"],"mappings":";;;;;AAgDO,SAAS,yBAAA,CAA0B,OAAA,GAA+C,EAAC,EAAgB;AAExG,EAAA,IAAI,CAAC,QAAQ,MAAA,EAAQ;AACnB,IAAA,OAAOA,kCAAkC,OAAO,CAAA;AAAA,EAClD;AAEA,EAAA,MAAM,cAAcA,iCAAA,CAAkC;AAAA,IACpD,GAAG,OAAA;AAAA,IACH,oBAAA,EAAsB;AAAA,GACvB,CAAA;AAED,EAAA,MAAM,UAAEC,UAAQ,oBAAA,GAAuB,IAAA,EAAM,qBAAqB,IAAA,EAAM,UAAA,GAAa,QAAO,GAAI,OAAA;AAEhG,EAAA,OAAO;AAAA,IACL,GAAG,WAAA;AAAA,IACH,cAAc,MAAA,EAAQ;AACpB,MAAA,WAAA,CAAY,cAAc,MAAM,CAAA;AAEhC,MAAA,MAAM,mBAAA,GAAsB,CAACC,QAAAA,KAAoC;AAC/D,QAAAC,yCAAA,CAAkC,QAAQD,QAAO,CAAA;AAAA,MACnD,CAAA;AAEA,MAAAE,0BAAA,CAAoBH,UAAQ,EAAE,UAAA,EAAY,oBAAA,EAAsB,kBAAA,IAAsB,mBAAmB,CAAA;AAAA,IAC3G;AAAA,GACF;AACF;;;;"}