{"version":3,"file":"integration.js","sources":["../../src/integration.ts"],"sourcesContent":["import { consoleSandbox, defineIntegration, GLOBAL_OBJ, hasSpansEnabled } from '@sentry/core';\nimport { DEFAULT_HOOKS, DEFAULT_ROOT_SPAN_TIMEOUT } from './constants';\nimport { DEBUG_BUILD } from './debug-build';\nimport { attachErrorHandler } from './errorhandler';\nimport { instrumentAppMountWithoutMixin } from './rootInstrumentation';\nimport { createTracingMixins } from './tracing';\nimport type { Options, TracingOptions, Vue, VueOptions } from './types';\n\nconst globalWithVue = GLOBAL_OBJ as typeof GLOBAL_OBJ & { Vue: Vue };\n\nconst DEFAULT_CONFIG: VueOptions = {\n Vue: globalWithVue.Vue,\n attachProps: true,\n attachErrorHandler: true,\n tracingOptions: {\n hooks: DEFAULT_HOOKS,\n timeout: DEFAULT_ROOT_SPAN_TIMEOUT,\n trackComponents: false,\n },\n};\n\nconst INTEGRATION_NAME = 'Vue' as const;\n\nexport type VueIntegrationOptions = Partial;\n\nexport const vueIntegration = defineIntegration((integrationOptions: Partial = {}) => {\n return {\n name: INTEGRATION_NAME,\n setup(client) {\n const options: Options = { ...DEFAULT_CONFIG, ...client.getOptions(), ...integrationOptions };\n if (!options.Vue && !options.app) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n '[@sentry/vue]: Misconfigured SDK. Vue specific errors will not be captured. Update your `Sentry.init` call with an appropriate config option: `app` (Application Instance - Vue 3) or `Vue` (Vue Constructor - Vue 2).',\n );\n });\n return;\n }\n\n if (options.app) {\n const apps = Array.isArray(options.app) ? options.app : [options.app];\n apps.forEach(app => vueInit(app, options));\n } else if (options.Vue) {\n vueInit(options.Vue, options);\n }\n },\n };\n});\n\nconst vueInit = (app: Vue, options: Options): void => {\n if (DEBUG_BUILD) {\n // Check app is not mounted yet - should be mounted _after_ init()!\n // This is _somewhat_ private, but in the case that this doesn't exist we simply ignore it\n // See: https://github.com/vuejs/core/blob/eb2a83283caa9de0a45881d860a3cbd9d0bdd279/packages/runtime-core/src/component.ts#L394\n const appWithInstance = app as Vue & {\n _instance?: {\n isMounted?: boolean;\n };\n };\n\n const isMounted = appWithInstance._instance?.isMounted;\n if (isMounted === true) {\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n '[@sentry/vue]: Misconfigured SDK. Vue app is already mounted. Make sure to call `app.mount()` after `Sentry.init()`.',\n );\n });\n }\n }\n\n if (options.attachErrorHandler) {\n attachErrorHandler(app, options);\n }\n\n if (hasSpansEnabled(options)) {\n const mixins = createTracingMixins(options.tracingOptions);\n app.mixin(mixins);\n if (!mixinWasApplied(app, mixins)) {\n instrumentAppMountWithoutMixin(app, mixins);\n warnAboutLostComponentTracking(app, options.tracingOptions);\n }\n }\n};\n\n/**\n * Reads back whether Vue accepted the mixin, because `app.mixin()` fails silently when the Options\n * API is disabled (the Nuxt 5 default). A Vue 2 constructor has no `_context` and no Options API\n * flag, so the mixin always applies there.\n *\n * See: https://github.com/vuejs/core/blob/v3.5.41/packages/runtime-core/src/apiCreateApp.ts\n */\nfunction mixinWasApplied(app: Vue, mixin: unknown): boolean {\n const mixins = (app as Vue & { _context?: { mixins?: unknown[] } })._context?.mixins;\n return !mixins || mixins.includes(mixin);\n}\n\n/**\n * Warns only when the dropped mixin loses component tracking the user opted into. The default\n * spans still work through the `app.mount()` wrap, so a default config stays silent.\n */\nfunction warnAboutLostComponentTracking(app: Vue, tracingOptions: Partial | undefined): void {\n const trackComponents = tracingOptions?.trackComponents;\n const losesComponentSpans =\n trackComponents === true || (Array.isArray(trackComponents) && trackComponents.length > 0);\n\n if (!losesComponentSpans) {\n return;\n }\n\n // `createNuxtApp()` sets `$nuxt` on the Vue app before it calls the `app:created` hook (where Nuxt SDK adds this integration).\n const fix =\n '$nuxt' in app\n ? 'Set `vue: { optionsApi: true }` in your `nuxt.config.ts`.'\n : 'Set `__VUE_OPTIONS_API__` to `true` in the `define` config of your bundler.';\n\n consoleSandbox(() => {\n // eslint-disable-next-line no-console\n console.warn(\n `[@sentry/vue]: The Vue Options API is disabled (\\`__VUE_OPTIONS_API__: false\\`). Sentry still records the \\`Application Render\\` and root component mount spans, but component tracking (\\`trackComponents\\`) needs the Options API. ${fix}`,\n );\n });\n}\n"],"names":["GLOBAL_OBJ","DEFAULT_HOOKS","DEFAULT_ROOT_SPAN_TIMEOUT","defineIntegration","consoleSandbox","DEBUG_BUILD","attachErrorHandler","hasSpansEnabled","createTracingMixins","instrumentAppMountWithoutMixin"],"mappings":";;;;;;;;;AAQA,MAAM,aAAA,GAAgBA,eAAA;AAEtB,MAAM,cAAA,GAA6B;AAAA,EACjC,KAAK,aAAA,CAAc,GAAA;AAAA,EACnB,WAAA,EAAa,IAAA;AAAA,EACb,kBAAA,EAAoB,IAAA;AAAA,EACpB,cAAA,EAAgB;AAAA,IACd,KAAA,EAAOC,uBAAA;AAAA,IACP,OAAA,EAASC,mCAAA;AAAA,IACT,eAAA,EAAiB;AAAA;AAErB,CAAA;AAEA,MAAM,gBAAA,GAAmB,KAAA;AAIlB,MAAM,cAAA,GAAiBC,sBAAA,CAAkB,CAAC,kBAAA,GAA0C,EAAC,KAAM;AAChG,EAAA,OAAO;AAAA,IACL,IAAA,EAAM,gBAAA;AAAA,IACN,MAAM,MAAA,EAAQ;AACZ,MAAA,MAAM,OAAA,GAAmB,EAAE,GAAG,cAAA,EAAgB,GAAG,MAAA,CAAO,UAAA,EAAW,EAAG,GAAG,kBAAA,EAAmB;AAC5F,MAAA,IAAI,CAAC,OAAA,CAAQ,GAAA,IAAO,CAAC,QAAQ,GAAA,EAAK;AAChC,QAAAC,mBAAA,CAAe,MAAM;AAEnB,UAAA,OAAA,CAAQ,IAAA;AAAA,YACN;AAAA,WACF;AAAA,QACF,CAAC,CAAA;AACD,QAAA;AAAA,MACF;AAEA,MAAA,IAAI,QAAQ,GAAA,EAAK;AACf,QAAA,MAAM,IAAA,GAAO,KAAA,CAAM,OAAA,CAAQ,OAAA,CAAQ,GAAG,IAAI,OAAA,CAAQ,GAAA,GAAM,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