@sentry/svelte 8.54.0 → 9.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2022-2024 Functional Software, Inc. dba Sentry
3
+ Copyright (c) 2022 Functional Software, Inc. dba Sentry
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const preprocessors = require('./preprocessors.js');
4
4
 
@@ -30,7 +30,7 @@ function withSentryConfig(
30
30
  // see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
31
31
  const sentryPreprocessors = new Map();
32
32
 
33
- const shouldTrackComponents = mergedOptions.componentTracking && mergedOptions.componentTracking.trackComponents;
33
+ const shouldTrackComponents = mergedOptions.componentTracking?.trackComponents;
34
34
  if (shouldTrackComponents) {
35
35
  const firstPassPreproc = preprocessors.componentTrackingPreprocessor(mergedOptions.componentTracking);
36
36
  sentryPreprocessors.set(firstPassPreproc.sentryId || '', firstPassPreproc);
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../src/config.ts"],"sourcesContent":["import type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';\n\nimport { componentTrackingPreprocessor, defaultComponentTrackingOptions } from './preprocessors';\nimport type { SentryPreprocessorGroup, SentrySvelteConfigOptions, SvelteConfig } from './types';\n\nconst DEFAULT_SENTRY_OPTIONS: SentrySvelteConfigOptions = {\n componentTracking: defaultComponentTrackingOptions,\n};\n\n/**\n * Add Sentry options to the Svelte config to be exported from the user's `svelte.config.js` file.\n *\n * @param originalConfig The existing config to be exported prior to adding Sentry\n * @param sentryOptions The configuration of the Sentry-added options\n *\n * @return The wrapped and modified config to be exported\n */\nexport function withSentryConfig(\n originalConfig: SvelteConfig,\n sentryOptions?: SentrySvelteConfigOptions,\n): SvelteConfig {\n const mergedOptions = {\n ...DEFAULT_SENTRY_OPTIONS,\n ...sentryOptions,\n };\n\n const originalPreprocessors = getOriginalPreprocessorArray(originalConfig);\n\n // Map is insertion-order-preserving. It's important to add preprocessors\n // to this map in the right order we want to see them being executed.\n // see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map\n const sentryPreprocessors = new Map<string, SentryPreprocessorGroup>();\n\n const shouldTrackComponents = mergedOptions.componentTracking && mergedOptions.componentTracking.trackComponents;\n if (shouldTrackComponents) {\n const firstPassPreproc: SentryPreprocessorGroup = componentTrackingPreprocessor(mergedOptions.componentTracking);\n sentryPreprocessors.set(firstPassPreproc.sentryId || '', firstPassPreproc);\n }\n\n // We prioritize user-added preprocessors, so we don't insert sentry processors if they\n // have already been added by users.\n originalPreprocessors.forEach((p: SentryPreprocessorGroup) => {\n if (p.sentryId) {\n sentryPreprocessors.delete(p.sentryId);\n }\n });\n\n const mergedPreprocessors = [...sentryPreprocessors.values(), ...originalPreprocessors];\n\n return {\n ...originalConfig,\n preprocess: mergedPreprocessors,\n };\n}\n\n/**\n * Standardizes the different ways the user-provided preprocessor option can be specified.\n * Users can specify an array of preprocessors, a single one or no preprocessor.\n *\n * @param originalConfig the user-provided svelte config oject\n * @return an array of preprocessors or an empty array if no preprocessors were specified\n */\nfunction getOriginalPreprocessorArray(originalConfig: SvelteConfig): PreprocessorGroup[] {\n if (originalConfig.preprocess) {\n if (Array.isArray(originalConfig.preprocess)) {\n return originalConfig.preprocess;\n }\n return [originalConfig.preprocess];\n }\n return [];\n}\n"],"names":["defaultComponentTrackingOptions","componentTrackingPreprocessor"],"mappings":";;;;AAKA,MAAM,sBAAsB,GAA8B;AAC1D,EAAE,iBAAiB,EAAEA,6CAA+B;AACpD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AAC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AC,cAAc,CAAC,UAAU,CAAC;AACtC;AACA,EAAE,OAAO,EAAE;AACX;;;;"}
1
+ {"version":3,"file":"config.js","sources":["../../src/config.ts"],"sourcesContent":["import type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';\n\nimport { componentTrackingPreprocessor, defaultComponentTrackingOptions } from './preprocessors';\nimport type { SentryPreprocessorGroup, SentrySvelteConfigOptions, SvelteConfig } from './types';\n\nconst DEFAULT_SENTRY_OPTIONS: SentrySvelteConfigOptions = {\n componentTracking: defaultComponentTrackingOptions,\n};\n\n/**\n * Add Sentry options to the Svelte config to be exported from the user's `svelte.config.js` file.\n *\n * @param originalConfig The existing config to be exported prior to adding Sentry\n * @param sentryOptions The configuration of the Sentry-added options\n *\n * @return The wrapped and modified config to be exported\n */\nexport function withSentryConfig(\n originalConfig: SvelteConfig,\n sentryOptions?: SentrySvelteConfigOptions,\n): SvelteConfig {\n const mergedOptions = {\n ...DEFAULT_SENTRY_OPTIONS,\n ...sentryOptions,\n };\n\n const originalPreprocessors = getOriginalPreprocessorArray(originalConfig);\n\n // Map is insertion-order-preserving. It's important to add preprocessors\n // to this map in the right order we want to see them being executed.\n // see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map\n const sentryPreprocessors = new Map<string, SentryPreprocessorGroup>();\n\n const shouldTrackComponents = mergedOptions.componentTracking?.trackComponents;\n if (shouldTrackComponents) {\n const firstPassPreproc: SentryPreprocessorGroup = componentTrackingPreprocessor(mergedOptions.componentTracking);\n sentryPreprocessors.set(firstPassPreproc.sentryId || '', firstPassPreproc);\n }\n\n // We prioritize user-added preprocessors, so we don't insert sentry processors if they\n // have already been added by users.\n originalPreprocessors.forEach((p: SentryPreprocessorGroup) => {\n if (p.sentryId) {\n sentryPreprocessors.delete(p.sentryId);\n }\n });\n\n const mergedPreprocessors = [...sentryPreprocessors.values(), ...originalPreprocessors];\n\n return {\n ...originalConfig,\n preprocess: mergedPreprocessors,\n };\n}\n\n/**\n * Standardizes the different ways the user-provided preprocessor option can be specified.\n * Users can specify an array of preprocessors, a single one or no preprocessor.\n *\n * @param originalConfig the user-provided svelte config oject\n * @return an array of preprocessors or an empty array if no preprocessors were specified\n */\nfunction getOriginalPreprocessorArray(originalConfig: SvelteConfig): PreprocessorGroup[] {\n if (originalConfig.preprocess) {\n if (Array.isArray(originalConfig.preprocess)) {\n return originalConfig.preprocess;\n }\n return [originalConfig.preprocess];\n }\n return [];\n}\n"],"names":["defaultComponentTrackingOptions","componentTrackingPreprocessor"],"mappings":";;;;AAKA,MAAM,sBAAsB,GAA8B;AAC1D,EAAE,iBAAiB,EAAEA,6CAA+B;AACpD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gBAAgB;AAChC,EAAE,cAAc;AAChB,EAAE,aAAa;AACf,EAAgB;AAChB,EAAE,MAAM,gBAAgB;AACxB,IAAI,GAAG,sBAAsB;AAC7B,IAAI,GAAG,aAAa;AACpB,GAAG;;AAEH,EAAE,MAAM,qBAAsB,GAAE,4BAA4B,CAAC,cAAc,CAAC;;AAE5E;AACA;AACA;AACA,EAAE,MAAM,mBAAoB,GAAE,IAAI,GAAG,EAAmC;;AAExE,EAAE,MAAM,qBAAsB,GAAE,aAAa,CAAC,iBAAiB,EAAE,eAAe;AAChF,EAAE,IAAI,qBAAqB,EAAE;AAC7B,IAAI,MAAM,gBAAgB,GAA4BC,2CAA6B,CAAC,aAAa,CAAC,iBAAiB,CAAC;AACpH,IAAI,mBAAmB,CAAC,GAAG,CAAC,gBAAgB,CAAC,QAAA,IAAY,EAAE,EAAE,gBAAgB,CAAC;AAC9E;;AAEA;AACA;AACA,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC,KAA8B;AAChE,IAAI,IAAI,CAAC,CAAC,QAAQ,EAAE;AACpB,MAAM,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC5C;AACA,GAAG,CAAC;;AAEJ,EAAE,MAAM,mBAAA,GAAsB,CAAC,GAAG,mBAAmB,CAAC,MAAM,EAAE,EAAE,GAAG,qBAAqB,CAAC;;AAEzF,EAAE,OAAO;AACT,IAAI,GAAG,cAAc;AACrB,IAAI,UAAU,EAAE,mBAAmB;AACnC,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,4BAA4B,CAAC,cAAc,EAAqC;AACzF,EAAE,IAAI,cAAc,CAAC,UAAU,EAAE;AACjC,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE;AAClD,MAAM,OAAO,cAAc,CAAC,UAAU;AACtC;AACA,IAAI,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC;AACtC;AACA,EAAE,OAAO,EAAE;AACX;;;;"}
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const UI_SVELTE_INIT = 'ui.svelte.init';
4
4
 
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const browser = require('@sentry/browser');
4
4
  const sdk = require('./sdk.js');
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const browser = require('@sentry/browser');
4
4
  const svelte = require('svelte');
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const MagicString = require('magic-string');
4
4
 
package/build/cjs/sdk.js CHANGED
@@ -1,4 +1,4 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
 
3
3
  const browser = require('@sentry/browser');
4
4
  const core = require('@sentry/core');
@@ -56,8 +56,7 @@ function detectAndReportSvelteKit() {
56
56
  * @see https://github.com/sveltejs/kit/issues/307 for more information
57
57
  */
58
58
  function isSvelteKitApp() {
59
- // eslint-disable-next-line deprecation/deprecation
60
- return core.getDomElement('div#svelte-announcer') !== null;
59
+ return !!browser.WINDOW.document.querySelector('div#svelte-announcer');
61
60
  }
62
61
 
63
62
  exports.detectAndReportSvelteKit = detectAndReportSvelteKit;
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { BrowserOptions } from '@sentry/browser';\nimport { addEventProcessor, init as browserInit } from '@sentry/browser';\nimport type { Client, EventProcessor } from '@sentry/core';\nimport { applySdkMetadata, getDomElement } from '@sentry/core';\n/**\n * Inits the Svelte SDK\n */\nexport function init(options: BrowserOptions): Client | undefined {\n const opts = {\n ...options,\n };\n\n applySdkMetadata(opts, 'svelte');\n\n const client = browserInit(opts);\n\n detectAndReportSvelteKit();\n\n return client;\n}\n\n/**\n * Adds a global event processor to detect if the SDK is initialized in a SvelteKit frontend,\n * in which case we add SvelteKit an event.modules entry to outgoing events.\n * SvelteKit detection is performed only once, when the event processor is called for the\n * first time. We cannot perform this check upfront (directly when init is called) because\n * at this time, the HTML element might not yet be accessible.\n */\nexport function detectAndReportSvelteKit(): void {\n let detectedSvelteKit: boolean | undefined = undefined;\n\n const svelteKitProcessor: EventProcessor = event => {\n if (detectedSvelteKit === undefined) {\n detectedSvelteKit = isSvelteKitApp();\n }\n if (detectedSvelteKit) {\n event.modules = {\n svelteKit: 'latest',\n ...event.modules,\n };\n }\n return event;\n };\n svelteKitProcessor.id = 'svelteKitProcessor';\n\n addEventProcessor(svelteKitProcessor);\n}\n\n/**\n * To actually detect a SvelteKit frontend, we search the DOM for a special\n * div that's inserted by SvelteKit when the page is rendered. It's identified\n * by its id, 'svelte-announcer', and it's used to improve page accessibility.\n * This div is not present when only using Svelte without SvelteKit.\n *\n * @see https://github.com/sveltejs/kit/issues/307 for more information\n */\nexport function isSvelteKitApp(): boolean {\n // eslint-disable-next-line deprecation/deprecation\n return getDomElement('div#svelte-announcer') !== null;\n}\n"],"names":["applySdkMetadata","browserInit","addEventProcessor","getDomElement"],"mappings":";;;;;AAIA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAsC;AAClE,EAAE,MAAM,OAAO;AACf,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAEA,qBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC;;AAElC,EAAE,MAAM,MAAO,GAAEC,YAAW,CAAC,IAAI,CAAC;;AAElC,EAAE,wBAAwB,EAAE;;AAE5B,EAAE,OAAO,MAAM;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,wBAAwB,GAAS;AACjD,EAAE,IAAI,iBAAiB,GAAwB,SAAS;;AAExD,EAAE,MAAM,kBAAkB,GAAmB,SAAS;AACtD,IAAI,IAAI,iBAAkB,KAAI,SAAS,EAAE;AACzC,MAAM,iBAAkB,GAAE,cAAc,EAAE;AAC1C;AACA,IAAI,IAAI,iBAAiB,EAAE;AAC3B,MAAM,KAAK,CAAC,OAAA,GAAU;AACtB,QAAQ,SAAS,EAAE,QAAQ;AAC3B,QAAQ,GAAG,KAAK,CAAC,OAAO;AACxB,OAAO;AACP;AACA,IAAI,OAAO,KAAK;AAChB,GAAG;AACH,EAAE,kBAAkB,CAAC,EAAG,GAAE,oBAAoB;;AAE9C,EAAEC,yBAAiB,CAAC,kBAAkB,CAAC;AACvC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc,GAAY;AAC1C;AACA,EAAE,OAAOC,kBAAa,CAAC,sBAAsB,CAAA,KAAM,IAAI;AACvD;;;;;;"}
1
+ {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { BrowserOptions } from '@sentry/browser';\nimport { WINDOW } from '@sentry/browser';\nimport { addEventProcessor, init as browserInit } from '@sentry/browser';\nimport type { Client, EventProcessor } from '@sentry/core';\nimport { applySdkMetadata } from '@sentry/core';\n/**\n * Inits the Svelte SDK\n */\nexport function init(options: BrowserOptions): Client | undefined {\n const opts = {\n ...options,\n };\n\n applySdkMetadata(opts, 'svelte');\n\n const client = browserInit(opts);\n\n detectAndReportSvelteKit();\n\n return client;\n}\n\n/**\n * Adds a global event processor to detect if the SDK is initialized in a SvelteKit frontend,\n * in which case we add SvelteKit an event.modules entry to outgoing events.\n * SvelteKit detection is performed only once, when the event processor is called for the\n * first time. We cannot perform this check upfront (directly when init is called) because\n * at this time, the HTML element might not yet be accessible.\n */\nexport function detectAndReportSvelteKit(): void {\n let detectedSvelteKit: boolean | undefined = undefined;\n\n const svelteKitProcessor: EventProcessor = event => {\n if (detectedSvelteKit === undefined) {\n detectedSvelteKit = isSvelteKitApp();\n }\n if (detectedSvelteKit) {\n event.modules = {\n svelteKit: 'latest',\n ...event.modules,\n };\n }\n return event;\n };\n svelteKitProcessor.id = 'svelteKitProcessor';\n\n addEventProcessor(svelteKitProcessor);\n}\n\n/**\n * To actually detect a SvelteKit frontend, we search the DOM for a special\n * div that's inserted by SvelteKit when the page is rendered. It's identified\n * by its id, 'svelte-announcer', and it's used to improve page accessibility.\n * This div is not present when only using Svelte without SvelteKit.\n *\n * @see https://github.com/sveltejs/kit/issues/307 for more information\n */\nexport function isSvelteKitApp(): boolean {\n return !!WINDOW.document.querySelector('div#svelte-announcer');\n}\n"],"names":["applySdkMetadata","browserInit","addEventProcessor","WINDOW"],"mappings":";;;;;AAKA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAsC;AAClE,EAAE,MAAM,OAAO;AACf,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAEA,qBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC;;AAElC,EAAE,MAAM,MAAO,GAAEC,YAAW,CAAC,IAAI,CAAC;;AAElC,EAAE,wBAAwB,EAAE;;AAE5B,EAAE,OAAO,MAAM;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,wBAAwB,GAAS;AACjD,EAAE,IAAI,iBAAiB,GAAwB,SAAS;;AAExD,EAAE,MAAM,kBAAkB,GAAmB,SAAS;AACtD,IAAI,IAAI,iBAAkB,KAAI,SAAS,EAAE;AACzC,MAAM,iBAAkB,GAAE,cAAc,EAAE;AAC1C;AACA,IAAI,IAAI,iBAAiB,EAAE;AAC3B,MAAM,KAAK,CAAC,OAAA,GAAU;AACtB,QAAQ,SAAS,EAAE,QAAQ;AAC3B,QAAQ,GAAG,KAAK,CAAC,OAAO;AACxB,OAAO;AACP;AACA,IAAI,OAAO,KAAK;AAChB,GAAG;AACH,EAAE,kBAAkB,CAAC,EAAG,GAAE,oBAAoB;;AAE9C,EAAEC,yBAAiB,CAAC,kBAAkB,CAAC;AACvC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc,GAAY;AAC1C,EAAE,OAAO,CAAC,CAACC,cAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,sBAAsB,CAAC;AAChE;;;;;;"}
@@ -28,7 +28,7 @@ function withSentryConfig(
28
28
  // see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map
29
29
  const sentryPreprocessors = new Map();
30
30
 
31
- const shouldTrackComponents = mergedOptions.componentTracking && mergedOptions.componentTracking.trackComponents;
31
+ const shouldTrackComponents = mergedOptions.componentTracking?.trackComponents;
32
32
  if (shouldTrackComponents) {
33
33
  const firstPassPreproc = componentTrackingPreprocessor(mergedOptions.componentTracking);
34
34
  sentryPreprocessors.set(firstPassPreproc.sentryId || '', firstPassPreproc);
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../src/config.ts"],"sourcesContent":["import type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';\n\nimport { componentTrackingPreprocessor, defaultComponentTrackingOptions } from './preprocessors';\nimport type { SentryPreprocessorGroup, SentrySvelteConfigOptions, SvelteConfig } from './types';\n\nconst DEFAULT_SENTRY_OPTIONS: SentrySvelteConfigOptions = {\n componentTracking: defaultComponentTrackingOptions,\n};\n\n/**\n * Add Sentry options to the Svelte config to be exported from the user's `svelte.config.js` file.\n *\n * @param originalConfig The existing config to be exported prior to adding Sentry\n * @param sentryOptions The configuration of the Sentry-added options\n *\n * @return The wrapped and modified config to be exported\n */\nexport function withSentryConfig(\n originalConfig: SvelteConfig,\n sentryOptions?: SentrySvelteConfigOptions,\n): SvelteConfig {\n const mergedOptions = {\n ...DEFAULT_SENTRY_OPTIONS,\n ...sentryOptions,\n };\n\n const originalPreprocessors = getOriginalPreprocessorArray(originalConfig);\n\n // Map is insertion-order-preserving. It's important to add preprocessors\n // to this map in the right order we want to see them being executed.\n // see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map\n const sentryPreprocessors = new Map<string, SentryPreprocessorGroup>();\n\n const shouldTrackComponents = mergedOptions.componentTracking && mergedOptions.componentTracking.trackComponents;\n if (shouldTrackComponents) {\n const firstPassPreproc: SentryPreprocessorGroup = componentTrackingPreprocessor(mergedOptions.componentTracking);\n sentryPreprocessors.set(firstPassPreproc.sentryId || '', firstPassPreproc);\n }\n\n // We prioritize user-added preprocessors, so we don't insert sentry processors if they\n // have already been added by users.\n originalPreprocessors.forEach((p: SentryPreprocessorGroup) => {\n if (p.sentryId) {\n sentryPreprocessors.delete(p.sentryId);\n }\n });\n\n const mergedPreprocessors = [...sentryPreprocessors.values(), ...originalPreprocessors];\n\n return {\n ...originalConfig,\n preprocess: mergedPreprocessors,\n };\n}\n\n/**\n * Standardizes the different ways the user-provided preprocessor option can be specified.\n * Users can specify an array of preprocessors, a single one or no preprocessor.\n *\n * @param originalConfig the user-provided svelte config oject\n * @return an array of preprocessors or an empty array if no preprocessors were specified\n */\nfunction getOriginalPreprocessorArray(originalConfig: SvelteConfig): PreprocessorGroup[] {\n if (originalConfig.preprocess) {\n if (Array.isArray(originalConfig.preprocess)) {\n return originalConfig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zF,EAAE,IAAI,cAAc,CAAC,UAAU,EAAE;AACjC,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE;AAClD,MAAM,OAAO,cAAc,CAAC,UAAU;AACtC;AACA,IAAI,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC;AACtC;AACA,EAAE,OAAO,EAAE;AACX;;;;"}
1
+ {"version":3,"file":"config.js","sources":["../../src/config.ts"],"sourcesContent":["import type { PreprocessorGroup } from 'svelte/types/compiler/preprocess';\n\nimport { componentTrackingPreprocessor, defaultComponentTrackingOptions } from './preprocessors';\nimport type { SentryPreprocessorGroup, SentrySvelteConfigOptions, SvelteConfig } from './types';\n\nconst DEFAULT_SENTRY_OPTIONS: SentrySvelteConfigOptions = {\n componentTracking: defaultComponentTrackingOptions,\n};\n\n/**\n * Add Sentry options to the Svelte config to be exported from the user's `svelte.config.js` file.\n *\n * @param originalConfig The existing config to be exported prior to adding Sentry\n * @param sentryOptions The configuration of the Sentry-added options\n *\n * @return The wrapped and modified config to be exported\n */\nexport function withSentryConfig(\n originalConfig: SvelteConfig,\n sentryOptions?: SentrySvelteConfigOptions,\n): SvelteConfig {\n const mergedOptions = {\n ...DEFAULT_SENTRY_OPTIONS,\n ...sentryOptions,\n };\n\n const originalPreprocessors = getOriginalPreprocessorArray(originalConfig);\n\n // Map is insertion-order-preserving. It's important to add preprocessors\n // to this map in the right order we want to see them being executed.\n // see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map\n const sentryPreprocessors = new Map<string, SentryPreprocessorGroup>();\n\n const shouldTrackComponents = mergedOptions.componentTracking?.trackComponents;\n if (shouldTrackComponents) {\n const firstPassPreproc: SentryPreprocessorGroup = componentTrackingPreprocessor(mergedOptions.componentTracking);\n sentryPreprocessors.set(firstPassPreproc.sentryId || '', firstPassPreproc);\n }\n\n // We prioritize user-added preprocessors, so we don't insert sentry processors if they\n // have already been added by users.\n originalPreprocessors.forEach((p: SentryPreprocessorGroup) => {\n if (p.sentryId) {\n sentryPreprocessors.delete(p.sentryId);\n }\n });\n\n const mergedPreprocessors = [...sentryPreprocessors.values(), ...originalPreprocessors];\n\n return {\n ...originalConfig,\n preprocess: mergedPreprocessors,\n };\n}\n\n/**\n * Standardizes the different ways the user-provided preprocessor option can be specified.\n * Users can specify an array of preprocessors, a single one or no preprocessor.\n *\n * @param originalConfig the user-provided svelte config oject\n * @return an array of preprocessors or an empty array if no preprocessors were specified\n */\nfunction getOriginalPreprocessorArray(originalConfig: SvelteConfig): PreprocessorGroup[] {\n if (originalConfig.preprocess) {\n if (Array.isArray(originalConfig.preprocess)) {\n return originalConfig.preprocess;\n }\n return [originalConfig.preprocess];\n }\n return [];\n}\n"],"names":[],"mappings":";;AAKA,MAAM,sBAAsB,GAA8B;AAC1D,EAAE,iBAAiB,EAAE,+BAA+B;AACpD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,gBAAgB;AAChC,EAAE,cAAc;AAChB,EAAE,aAAa;AACf,EAAgB;AAChB,EAAE,MAAM,gBAAgB;AACxB,IAAI,GAAG,sBAAsB;AAC7B,IAAI,GAAG,aAAa;AACpB,GAAG;;AAEH,EAAE,MAAM,qBAAsB,GAAE,4BAA4B,CAAC,cAAc,CAAC;;AAE5E;AACA;AACA;AACA,EAAE,MAAM,mBAAoB,GAAE,IAAI,GAAG,EAAmC;;AAExE,EAAE,MAAM,qBAAsB,GAAE,aAAa,CAAC,iBAAiB,EAAE,eAAe;AAChF,EAAE,IAAI,qBAAqB,EAAE;AAC7B,IAAI,MAAM,gBAAgB,GAA4B,6BAA6B,CAAC,aAAa,CAAC,iBAAiB,CAAC;AACpH,IAAI,mBAAmB,CAAC,GAAG,CAAC,gBAAgB,CAAC,QAAA,IAAY,EAAE,EAAE,gBAAgB,CAAC;AAC9E;;AAEA;AACA;AACA,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAC,KAA8B;AAChE,IAAI,IAAI,CAAC,CAAC,QAAQ,EAAE;AACpB,MAAM,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC;AAC5C;AACA,GAAG,CAAC;;AAEJ,EAAE,MAAM,mBAAA,GAAsB,CAAC,GAAG,mBAAmB,CAAC,MAAM,EAAE,EAAE,GAAG,qBAAqB,CAAC;;AAEzF,EAAE,OAAO;AACT,IAAI,GAAG,cAAc;AACrB,IAAI,UAAU,EAAE,mBAAmB;AACnC,GAAG;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAAS,4BAA4B,CAAC,cAAc,EAAqC;AACzF,EAAE,IAAI,cAAc,CAAC,UAAU,EAAE;AACjC,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE;AAClD,MAAM,OAAO,cAAc,CAAC,UAAU;AACtC;AACA,IAAI,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC;AACtC;AACA,EAAE,OAAO,EAAE;AACX;;;;"}
@@ -1 +1 @@
1
- {"type":"module","version":"8.54.0","sideEffects":false}
1
+ {"type":"module","version":"9.0.0-alpha.1","sideEffects":false}
package/build/esm/sdk.js CHANGED
@@ -1,5 +1,5 @@
1
- import { init as init$1, addEventProcessor } from '@sentry/browser';
2
- import { applySdkMetadata, getDomElement } from '@sentry/core';
1
+ import { init as init$1, addEventProcessor, WINDOW } from '@sentry/browser';
2
+ import { applySdkMetadata } from '@sentry/core';
3
3
 
4
4
  /**
5
5
  * Inits the Svelte SDK
@@ -54,8 +54,7 @@ function detectAndReportSvelteKit() {
54
54
  * @see https://github.com/sveltejs/kit/issues/307 for more information
55
55
  */
56
56
  function isSvelteKitApp() {
57
- // eslint-disable-next-line deprecation/deprecation
58
- return getDomElement('div#svelte-announcer') !== null;
57
+ return !!WINDOW.document.querySelector('div#svelte-announcer');
59
58
  }
60
59
 
61
60
  export { detectAndReportSvelteKit, init, isSvelteKitApp };
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { BrowserOptions } from '@sentry/browser';\nimport { addEventProcessor, init as browserInit } from '@sentry/browser';\nimport type { Client, EventProcessor } from '@sentry/core';\nimport { applySdkMetadata, getDomElement } from '@sentry/core';\n/**\n * Inits the Svelte SDK\n */\nexport function init(options: BrowserOptions): Client | undefined {\n const opts = {\n ...options,\n };\n\n applySdkMetadata(opts, 'svelte');\n\n const client = browserInit(opts);\n\n detectAndReportSvelteKit();\n\n return client;\n}\n\n/**\n * Adds a global event processor to detect if the SDK is initialized in a SvelteKit frontend,\n * in which case we add SvelteKit an event.modules entry to outgoing events.\n * SvelteKit detection is performed only once, when the event processor is called for the\n * first time. We cannot perform this check upfront (directly when init is called) because\n * at this time, the HTML element might not yet be accessible.\n */\nexport function detectAndReportSvelteKit(): void {\n let detectedSvelteKit: boolean | undefined = undefined;\n\n const svelteKitProcessor: EventProcessor = event => {\n if (detectedSvelteKit === undefined) {\n detectedSvelteKit = isSvelteKitApp();\n }\n if (detectedSvelteKit) {\n event.modules = {\n svelteKit: 'latest',\n ...event.modules,\n };\n }\n return event;\n };\n svelteKitProcessor.id = 'svelteKitProcessor';\n\n addEventProcessor(svelteKitProcessor);\n}\n\n/**\n * To actually detect a SvelteKit frontend, we search the DOM for a special\n * div that's inserted by SvelteKit when the page is rendered. It's identified\n * by its id, 'svelte-announcer', and it's used to improve page accessibility.\n * This div is not present when only using Svelte without SvelteKit.\n *\n * @see https://github.com/sveltejs/kit/issues/307 for more information\n */\nexport function isSvelteKitApp(): boolean {\n // eslint-disable-next-line deprecation/deprecation\n return getDomElement('div#svelte-announcer') !== null;\n}\n"],"names":["browserInit"],"mappings":";;;AAIA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAsC;AAClE,EAAE,MAAM,OAAO;AACf,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAE,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC;;AAElC,EAAE,MAAM,MAAO,GAAEA,MAAW,CAAC,IAAI,CAAC;;AAElC,EAAE,wBAAwB,EAAE;;AAE5B,EAAE,OAAO,MAAM;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,wBAAwB,GAAS;AACjD,EAAE,IAAI,iBAAiB,GAAwB,SAAS;;AAExD,EAAE,MAAM,kBAAkB,GAAmB,SAAS;AACtD,IAAI,IAAI,iBAAkB,KAAI,SAAS,EAAE;AACzC,MAAM,iBAAkB,GAAE,cAAc,EAAE;AAC1C;AACA,IAAI,IAAI,iBAAiB,EAAE;AAC3B,MAAM,KAAK,CAAC,OAAA,GAAU;AACtB,QAAQ,SAAS,EAAE,QAAQ;AAC3B,QAAQ,GAAG,KAAK,CAAC,OAAO;AACxB,OAAO;AACP;AACA,IAAI,OAAO,KAAK;AAChB,GAAG;AACH,EAAE,kBAAkB,CAAC,EAAG,GAAE,oBAAoB;;AAE9C,EAAE,iBAAiB,CAAC,kBAAkB,CAAC;AACvC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc,GAAY;AAC1C;AACA,EAAE,OAAO,aAAa,CAAC,sBAAsB,CAAA,KAAM,IAAI;AACvD;;;;"}
1
+ {"version":3,"file":"sdk.js","sources":["../../src/sdk.ts"],"sourcesContent":["import type { BrowserOptions } from '@sentry/browser';\nimport { WINDOW } from '@sentry/browser';\nimport { addEventProcessor, init as browserInit } from '@sentry/browser';\nimport type { Client, EventProcessor } from '@sentry/core';\nimport { applySdkMetadata } from '@sentry/core';\n/**\n * Inits the Svelte SDK\n */\nexport function init(options: BrowserOptions): Client | undefined {\n const opts = {\n ...options,\n };\n\n applySdkMetadata(opts, 'svelte');\n\n const client = browserInit(opts);\n\n detectAndReportSvelteKit();\n\n return client;\n}\n\n/**\n * Adds a global event processor to detect if the SDK is initialized in a SvelteKit frontend,\n * in which case we add SvelteKit an event.modules entry to outgoing events.\n * SvelteKit detection is performed only once, when the event processor is called for the\n * first time. We cannot perform this check upfront (directly when init is called) because\n * at this time, the HTML element might not yet be accessible.\n */\nexport function detectAndReportSvelteKit(): void {\n let detectedSvelteKit: boolean | undefined = undefined;\n\n const svelteKitProcessor: EventProcessor = event => {\n if (detectedSvelteKit === undefined) {\n detectedSvelteKit = isSvelteKitApp();\n }\n if (detectedSvelteKit) {\n event.modules = {\n svelteKit: 'latest',\n ...event.modules,\n };\n }\n return event;\n };\n svelteKitProcessor.id = 'svelteKitProcessor';\n\n addEventProcessor(svelteKitProcessor);\n}\n\n/**\n * To actually detect a SvelteKit frontend, we search the DOM for a special\n * div that's inserted by SvelteKit when the page is rendered. It's identified\n * by its id, 'svelte-announcer', and it's used to improve page accessibility.\n * This div is not present when only using Svelte without SvelteKit.\n *\n * @see https://github.com/sveltejs/kit/issues/307 for more information\n */\nexport function isSvelteKitApp(): boolean {\n return !!WINDOW.document.querySelector('div#svelte-announcer');\n}\n"],"names":["browserInit"],"mappings":";;;AAKA;AACA;AACA;AACO,SAAS,IAAI,CAAC,OAAO,EAAsC;AAClE,EAAE,MAAM,OAAO;AACf,IAAI,GAAG,OAAO;AACd,GAAG;;AAEH,EAAE,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC;;AAElC,EAAE,MAAM,MAAO,GAAEA,MAAW,CAAC,IAAI,CAAC;;AAElC,EAAE,wBAAwB,EAAE;;AAE5B,EAAE,OAAO,MAAM;AACf;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,wBAAwB,GAAS;AACjD,EAAE,IAAI,iBAAiB,GAAwB,SAAS;;AAExD,EAAE,MAAM,kBAAkB,GAAmB,SAAS;AACtD,IAAI,IAAI,iBAAkB,KAAI,SAAS,EAAE;AACzC,MAAM,iBAAkB,GAAE,cAAc,EAAE;AAC1C;AACA,IAAI,IAAI,iBAAiB,EAAE;AAC3B,MAAM,KAAK,CAAC,OAAA,GAAU;AACtB,QAAQ,SAAS,EAAE,QAAQ;AAC3B,QAAQ,GAAG,KAAK,CAAC,OAAO;AACxB,OAAO;AACP;AACA,IAAI,OAAO,KAAK;AAChB,GAAG;AACH,EAAE,kBAAkB,CAAC,EAAG,GAAE,oBAAoB;;AAE9C,EAAE,iBAAiB,CAAC,kBAAkB,CAAC;AACvC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc,GAAY;AAC1C,EAAE,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,sBAAsB,CAAC;AAChE;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,cAAc,CAAC;AAE3D;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,SAAS,CAYhE;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAkB/C;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAGxC"}
1
+ {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGtD,OAAO,KAAK,EAAE,MAAM,EAAkB,MAAM,cAAc,CAAC;AAE3D;;GAEG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,GAAG,SAAS,CAYhE;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAkB/C;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,IAAI,OAAO,CAExC"}
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@sentry/svelte",
3
- "version": "8.54.0",
3
+ "version": "9.0.0-alpha.1",
4
4
  "description": "Official Sentry SDK for Svelte",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/svelte",
7
7
  "author": "Sentry",
8
8
  "license": "MIT",
9
9
  "engines": {
10
- "node": ">=14.18"
10
+ "node": ">=18"
11
11
  },
12
12
  "files": [
13
13
  "/build"
@@ -29,7 +29,7 @@
29
29
  }
30
30
  },
31
31
  "typesVersions": {
32
- "<4.9": {
32
+ "<5.0": {
33
33
  "build/types/index.d.ts": [
34
34
  "build/types-ts3.8/index.d.ts"
35
35
  ]
@@ -39,8 +39,8 @@
39
39
  "access": "public"
40
40
  },
41
41
  "dependencies": {
42
- "@sentry/browser": "8.54.0",
43
- "@sentry/core": "8.54.0",
42
+ "@sentry/browser": "9.0.0-alpha.1",
43
+ "@sentry/core": "9.0.0-alpha.1",
44
44
  "magic-string": "^0.30.0"
45
45
  },
46
46
  "peerDependencies": {