@sentry/svelte 7.104.0 → 8.0.0-alpha.2

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/README.md CHANGED
@@ -10,28 +10,29 @@
10
10
  [![npm dm](https://img.shields.io/npm/dm/@sentry/svelte.svg)](https://www.npmjs.com/package/@sentry/svelte)
11
11
  [![npm dt](https://img.shields.io/npm/dt/@sentry/svelte.svg)](https://www.npmjs.com/package/@sentry/svelte)
12
12
 
13
- This SDK currently only supports [Svelte](https://svelte.dev/) apps in the browser.
14
- If you're using SvelteKit, we recommend using our dedicated [Sentry SvelteKit SDK](https://github.com/getsentry/sentry-javascript/tree/develop/packages/sveltekit).
13
+ This SDK currently only supports [Svelte](https://svelte.dev/) apps in the browser. If you're using SvelteKit, we
14
+ recommend using our dedicated
15
+ [Sentry SvelteKit SDK](https://github.com/getsentry/sentry-javascript/tree/develop/packages/sveltekit).
15
16
 
16
17
  ## General
17
18
 
18
- This package is a wrapper around `@sentry/browser`, providing error monitoring and basic performance monitoring
19
- features for [Svelte](https://svelte.dev/).
19
+ This package is a wrapper around `@sentry/browser`, providing error monitoring and basic performance monitoring features
20
+ for [Svelte](https://svelte.dev/).
20
21
 
21
22
  To use the SDK, initialize Sentry in your Svelte entry point `main.js` before you bootstrap your Svelte app:
22
23
 
23
24
  ```ts
24
25
  // main.js / main.ts
25
26
 
26
- import App from "./App.svelte";
27
+ import App from './App.svelte';
27
28
 
28
- import * as Sentry from "@sentry/svelte";
29
+ import * as Sentry from '@sentry/svelte';
29
30
 
30
31
  // Initialize the Sentry SDK here
31
32
  Sentry.init({
32
- dsn: "__DSN__",
33
- release: "my-project-name@2.3.12",
34
- integrations: [new Sentry.BrowserTracing()],
33
+ dsn: '__DSN__',
34
+ release: 'my-project-name@2.3.12',
35
+ integrations: [Sentry.browserTracingIntegration()],
35
36
 
36
37
  // Set tracesSampleRate to 1.0 to capture 100%
37
38
  // of transactions for performance monitoring.
@@ -41,19 +42,25 @@ Sentry.init({
41
42
 
42
43
  // Then bootstrap your Svelte app
43
44
  const app = new App({
44
- target: document.getElementById("app"),
45
+ target: document.getElementById('app'),
45
46
  });
46
47
 
47
48
  export default app;
48
49
  ```
49
50
 
50
- The Sentry Svelte SDK supports all features from the `@sentry/browser` SDK. Until it becomes more stable, please refer to the Sentry [Browser SDK documentation](https://docs.sentry.io/platforms/javascript/) for more information and usage instructions.
51
+ The Sentry Svelte SDK supports all features from the `@sentry/browser` SDK. Until it becomes more stable, please refer
52
+ to the Sentry [Browser SDK documentation](https://docs.sentry.io/platforms/javascript/) for more information and usage
53
+ instructions.
51
54
 
52
55
  ## Sourcemaps and Releases
53
56
 
54
- To generate source maps of your Svelte app bundle, check our guide [how to configure your bundler](https://docs.sentry.io/platforms/javascript/guides/svelte/sourcemaps/generating/) to emit source maps.
57
+ To generate source maps of your Svelte app bundle, check our guide
58
+ [how to configure your bundler](https://docs.sentry.io/platforms/javascript/guides/svelte/sourcemaps/generating/) to
59
+ emit source maps.
55
60
 
56
- To [create releases and upload source maps](https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/cli/) to Sentry, we recommend using [`sentry-cli`](https://github.com/getsentry/sentry-cli). You can for instance create a bash script to take care of creating a release, uploading source maps and finalizing the release:
61
+ To [create releases and upload source maps](https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/cli/) to
62
+ Sentry, we recommend using [`sentry-cli`](https://github.com/getsentry/sentry-cli). You can for instance create a bash
63
+ script to take care of creating a release, uploading source maps and finalizing the release:
57
64
 
58
65
  ```bash
59
66
  #!/bin/bash
@@ -69,6 +76,12 @@ sentry-cli releases files $VERSION upload-sourcemaps $SOURCEMAPS_PATH --org $ORG
69
76
  sentry-cli releases finalize $VERSION --org $ORG --project $PROJECT
70
77
  ```
71
78
 
72
- Please note that the paths provided in this example work for a typical Svelte project that adheres to the project structure set by [create-vite](https://www.npmjs.com/package/create-vite) with the `svelte(-ts)` template. If your project setup differs from this template, your configuration may need adjustments. Please refer to our documentation of [Advanced `sentry-cli` Sourcemaps Options](https://docs.sentry.io/product/cli/releases/#sentry-cli-sourcemaps) and to our [Sourcemaps Troubleshooting Guide](https://docs.sentry.io/platforms/javascript/sourcemaps/troubleshooting_js/).
79
+ Please note that the paths provided in this example work for a typical Svelte project that adheres to the project
80
+ structure set by [create-vite](https://www.npmjs.com/package/create-vite) with the `svelte(-ts)` template. If your
81
+ project setup differs from this template, your configuration may need adjustments. Please refer to our documentation of
82
+ [Advanced `sentry-cli` Sourcemaps Options](https://docs.sentry.io/product/cli/releases/#sentry-cli-sourcemaps) and to
83
+ our [Sourcemaps Troubleshooting Guide](https://docs.sentry.io/platforms/javascript/sourcemaps/troubleshooting_js/).
73
84
 
74
- Check out our [Svelte source maps uploading](https://docs.sentry.io/platforms/javascript/guides/svelte/sourcemaps/uploading/) guide for more information.
85
+ Check out our
86
+ [Svelte source maps uploading](https://docs.sentry.io/platforms/javascript/guides/svelte/sourcemaps/uploading/) guide
87
+ for more information.
@@ -48,7 +48,7 @@ function recordInitSpan(transaction, componentName) {
48
48
  // eslint-disable-next-line deprecation/deprecation
49
49
  const initSpan = transaction.startChild({
50
50
  op: constants.UI_SVELTE_INIT,
51
- description: componentName,
51
+ name: componentName,
52
52
  origin: 'auto.ui.svelte',
53
53
  });
54
54
 
@@ -74,11 +74,12 @@ function recordUpdateSpans(componentName, initSpan) {
74
74
  const parentSpan =
75
75
  initSpan && initSpan.isRecording() && core.getRootSpan(initSpan) === transaction ? initSpan : transaction;
76
76
 
77
- // eslint-disable-next-line deprecation/deprecation
78
- updateSpan = parentSpan.startChild({
79
- op: constants.UI_SVELTE_UPDATE,
80
- description: componentName,
81
- origin: 'auto.ui.svelte',
77
+ updateSpan = core.withActiveSpan(parentSpan, () => {
78
+ return core.startInactiveSpan({
79
+ op: constants.UI_SVELTE_UPDATE,
80
+ name: componentName,
81
+ origin: 'auto.ui.svelte',
82
+ });
82
83
  });
83
84
  });
84
85
 
@@ -1 +1 @@
1
- {"version":3,"file":"performance.js","sources":["../../src/performance.ts"],"sourcesContent":["import { getCurrentScope } from '@sentry/browser';\nimport type { Span, Transaction } from '@sentry/types';\nimport { afterUpdate, beforeUpdate, onMount } from 'svelte';\nimport { current_component } from 'svelte/internal';\n\nimport { getRootSpan } from '@sentry/core';\nimport { DEFAULT_COMPONENT_NAME, UI_SVELTE_INIT, UI_SVELTE_UPDATE } from './constants';\nimport type { TrackComponentOptions } from './types';\n\nconst defaultTrackComponentOptions: {\n trackInit: boolean;\n trackUpdates: boolean;\n componentName?: string;\n} = {\n trackInit: true,\n trackUpdates: true,\n};\n\n/**\n * Tracks the Svelte component's intialization and mounting operation as well as\n * updates and records them as spans.\n * This function is injected automatically into your Svelte components' code\n * if you are using the Sentry componentTrackingPreprocessor.\n * Alternatively, you can call it yourself if you don't want to use the preprocessor.\n */\nexport function trackComponent(options?: TrackComponentOptions): void {\n const mergedOptions = { ...defaultTrackComponentOptions, ...options };\n\n const transaction = getActiveTransaction();\n if (!transaction) {\n return;\n }\n\n const customComponentName = mergedOptions.componentName;\n\n // current_component.ctor.name is likely to give us the component's name automatically\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const componentName = `<${customComponentName || current_component.constructor.name || DEFAULT_COMPONENT_NAME}>`;\n\n let initSpan: Span | undefined = undefined;\n if (mergedOptions.trackInit) {\n initSpan = recordInitSpan(transaction, componentName);\n }\n\n if (mergedOptions.trackUpdates) {\n recordUpdateSpans(componentName, initSpan);\n }\n}\n\nfunction recordInitSpan(transaction: Transaction, componentName: string): Span {\n // eslint-disable-next-line deprecation/deprecation\n const initSpan = transaction.startChild({\n op: UI_SVELTE_INIT,\n description: componentName,\n origin: 'auto.ui.svelte',\n });\n\n onMount(() => {\n initSpan.end();\n });\n\n return initSpan;\n}\n\nfunction recordUpdateSpans(componentName: string, initSpan?: Span): void {\n let updateSpan: Span | undefined;\n beforeUpdate(() => {\n // We need to get the active transaction again because the initial one could\n // already be finished or there is currently no transaction going on.\n const transaction = getActiveTransaction();\n if (!transaction) {\n return;\n }\n\n // If we are initializing the component when the update span is started, we start it as child\n // of the init span. Else, we start it as a child of the transaction.\n const parentSpan =\n initSpan && initSpan.isRecording() && getRootSpan(initSpan) === transaction ? initSpan : transaction;\n\n // eslint-disable-next-line deprecation/deprecation\n updateSpan = parentSpan.startChild({\n op: UI_SVELTE_UPDATE,\n description: componentName,\n origin: 'auto.ui.svelte',\n });\n });\n\n afterUpdate(() => {\n if (!updateSpan) {\n return;\n }\n updateSpan.end();\n updateSpan = undefined;\n });\n}\n\nfunction getActiveTransaction(): Transaction | undefined {\n // eslint-disable-next-line deprecation/deprecation\n return getCurrentScope().getTransaction();\n}\n"],"names":["current_component","DEFAULT_COMPONENT_NAME","UI_SVELTE_INIT","onMount","beforeUpdate","getRootSpan","UI_SVELTE_UPDATE","afterUpdate","getCurrentScope"],"mappings":";;;;;;;;AASA,MAAM,4BAA4B;;AAIlC,GAAI;AACJ,EAAE,SAAS,EAAE,IAAI;AACjB,EAAE,YAAY,EAAE,IAAI;AACpB,CAAC,CAAA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc,CAAC,OAAO,EAAgC;AACtE,EAAE,MAAM,gBAAgB,EAAE,GAAG,4BAA4B,EAAE,GAAG,OAAA,EAAS,CAAA;AACvE;AACA,EAAE,MAAM,WAAA,GAAc,oBAAoB,EAAE,CAAA;AAC5C,EAAE,IAAI,CAAC,WAAW,EAAE;AACpB,IAAI,OAAM;AACV,GAAE;AACF;AACA,EAAE,MAAM,mBAAA,GAAsB,aAAa,CAAC,aAAa,CAAA;AACzD;AACA;AACA;AACA,EAAE,MAAM,aAAc,GAAE,CAAC,CAAC,EAAE,mBAAoB,IAAGA,0BAAiB,CAAC,WAAW,CAAC,IAAA,IAAQC,gCAAsB,CAAC,CAAC,CAAC,CAAA;AAClH;AACA,EAAE,IAAI,QAAQ,GAAqB,SAAS,CAAA;AAC5C,EAAE,IAAI,aAAa,CAAC,SAAS,EAAE;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,IAAI,IAAI,CAAC,UAAU,EAAE;AACrB,MAAM,OAAM;AACZ,KAAI;AACJ,IAAI,UAAU,CAAC,GAAG,EAAE,CAAA;AACpB,IAAI,UAAA,GAAa,SAAS,CAAA;AAC1B,GAAG,CAAC,CAAA;AACJ,CAAA;AACA;AACA,SAAS,oBAAoB,GAA4B;AACzD;AACA,EAAE,OAAOC,uBAAe,EAAE,CAAC,cAAc,EAAE,CAAA;AAC3C;;;;"}
1
+ {"version":3,"file":"performance.js","sources":["../../src/performance.ts"],"sourcesContent":["import { getCurrentScope } from '@sentry/browser';\nimport type { Span, Transaction } from '@sentry/types';\nimport { afterUpdate, beforeUpdate, onMount } from 'svelte';\nimport { current_component } from 'svelte/internal';\n\nimport { getRootSpan, startInactiveSpan, withActiveSpan } from '@sentry/core';\nimport { DEFAULT_COMPONENT_NAME, UI_SVELTE_INIT, UI_SVELTE_UPDATE } from './constants';\nimport type { TrackComponentOptions } from './types';\n\nconst defaultTrackComponentOptions: {\n trackInit: boolean;\n trackUpdates: boolean;\n componentName?: string;\n} = {\n trackInit: true,\n trackUpdates: true,\n};\n\n/**\n * Tracks the Svelte component's intialization and mounting operation as well as\n * updates and records them as spans.\n * This function is injected automatically into your Svelte components' code\n * if you are using the Sentry componentTrackingPreprocessor.\n * Alternatively, you can call it yourself if you don't want to use the preprocessor.\n */\nexport function trackComponent(options?: TrackComponentOptions): void {\n const mergedOptions = { ...defaultTrackComponentOptions, ...options };\n\n const transaction = getActiveTransaction();\n if (!transaction) {\n return;\n }\n\n const customComponentName = mergedOptions.componentName;\n\n // current_component.ctor.name is likely to give us the component's name automatically\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const componentName = `<${customComponentName || current_component.constructor.name || DEFAULT_COMPONENT_NAME}>`;\n\n let initSpan: Span | undefined = undefined;\n if (mergedOptions.trackInit) {\n initSpan = recordInitSpan(transaction, componentName);\n }\n\n if (mergedOptions.trackUpdates) {\n recordUpdateSpans(componentName, initSpan);\n }\n}\n\nfunction recordInitSpan(transaction: Transaction, componentName: string): Span {\n // eslint-disable-next-line deprecation/deprecation\n const initSpan = transaction.startChild({\n op: UI_SVELTE_INIT,\n name: componentName,\n origin: 'auto.ui.svelte',\n });\n\n onMount(() => {\n initSpan.end();\n });\n\n return initSpan;\n}\n\nfunction recordUpdateSpans(componentName: string, initSpan?: Span): void {\n let updateSpan: Span | undefined;\n beforeUpdate(() => {\n // We need to get the active transaction again because the initial one could\n // already be finished or there is currently no transaction going on.\n const transaction = getActiveTransaction();\n if (!transaction) {\n return;\n }\n\n // If we are initializing the component when the update span is started, we start it as child\n // of the init span. Else, we start it as a child of the transaction.\n const parentSpan =\n initSpan && initSpan.isRecording() && getRootSpan(initSpan) === transaction ? initSpan : transaction;\n\n updateSpan = withActiveSpan(parentSpan, () => {\n return startInactiveSpan({\n op: UI_SVELTE_UPDATE,\n name: componentName,\n origin: 'auto.ui.svelte',\n });\n });\n });\n\n afterUpdate(() => {\n if (!updateSpan) {\n return;\n }\n updateSpan.end();\n updateSpan = undefined;\n });\n}\n\nfunction getActiveTransaction(): Transaction | undefined {\n // eslint-disable-next-line deprecation/deprecation\n return getCurrentScope().getTransaction();\n}\n"],"names":["current_component","DEFAULT_COMPONENT_NAME","UI_SVELTE_INIT","onMount","beforeUpdate","getRootSpan","withActiveSpan","startInactiveSpan","UI_SVELTE_UPDATE","afterUpdate","getCurrentScope"],"mappings":";;;;;;;;AASA,MAAM,4BAA4B;;AAIlC,GAAI;AACJ,EAAE,SAAS,EAAE,IAAI;AACjB,EAAE,YAAY,EAAE,IAAI;AACpB,CAAC,CAAA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc,CAAC,OAAO,EAAgC;AACtE,EAAE,MAAM,gBAAgB,EAAE,GAAG,4BAA4B,EAAE,GAAG,OAAA,EAAS,CAAA;AACvE;AACA,EAAE,MAAM,WAAA,GAAc,oBAAoB,EAAE,CAAA;AAC5C,EAAE,IAAI,CAAC,WAAW,EAA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AAC,WAAW,EAAG,IAAGC,gBAAW,CAAC,QAAQ,CAAE,KAAI,cAAc,QAAA,GAAW,WAAW,CAAA;AAC1G;AACA,IAAI,UAAA,GAAaC,mBAAc,CAAC,UAAU,EAAE,MAAM;AAClD,MAAM,OAAOC,sBAAiB,CAAC;AAC/B,QAAQ,EAAE,EAAEC,0BAAgB;AAC5B,QAAQ,IAAI,EAAE,aAAa;AAC3B,QAAQ,MAAM,EAAE,gBAAgB;AAChC,OAAO,CAAC,CAAA;AACR,KAAK,CAAC,CAAA;AACN,GAAG,CAAC,CAAA;AACJ;AACA,EAAEC,kBAAW,CAAC,MAAM;AACpB,IAAI,IAAI,CAAC,UAAU,EAAE;AACrB,MAAM,OAAM;AACZ,KAAI;AACJ,IAAI,UAAU,CAAC,GAAG,EAAE,CAAA;AACpB,IAAI,UAAA,GAAa,SAAS,CAAA;AAC1B,GAAG,CAAC,CAAA;AACJ,CAAA;AACA;AACA,SAAS,oBAAoB,GAA4B;AACzD;AACA,EAAE,OAAOC,uBAAe,EAAE,CAAC,cAAc,EAAE,CAAA;AAC3C;;;;"}
@@ -1,7 +1,7 @@
1
1
  import { getCurrentScope } from '@sentry/browser';
2
2
  import { onMount, beforeUpdate, afterUpdate } from 'svelte';
3
3
  import { current_component } from 'svelte/internal';
4
- import { getRootSpan } from '@sentry/core';
4
+ import { getRootSpan, withActiveSpan, startInactiveSpan } from '@sentry/core';
5
5
  import { DEFAULT_COMPONENT_NAME, UI_SVELTE_INIT, UI_SVELTE_UPDATE } from './constants.js';
6
6
 
7
7
  const defaultTrackComponentOptions
@@ -46,7 +46,7 @@ function recordInitSpan(transaction, componentName) {
46
46
  // eslint-disable-next-line deprecation/deprecation
47
47
  const initSpan = transaction.startChild({
48
48
  op: UI_SVELTE_INIT,
49
- description: componentName,
49
+ name: componentName,
50
50
  origin: 'auto.ui.svelte',
51
51
  });
52
52
 
@@ -72,11 +72,12 @@ function recordUpdateSpans(componentName, initSpan) {
72
72
  const parentSpan =
73
73
  initSpan && initSpan.isRecording() && getRootSpan(initSpan) === transaction ? initSpan : transaction;
74
74
 
75
- // eslint-disable-next-line deprecation/deprecation
76
- updateSpan = parentSpan.startChild({
77
- op: UI_SVELTE_UPDATE,
78
- description: componentName,
79
- origin: 'auto.ui.svelte',
75
+ updateSpan = withActiveSpan(parentSpan, () => {
76
+ return startInactiveSpan({
77
+ op: UI_SVELTE_UPDATE,
78
+ name: componentName,
79
+ origin: 'auto.ui.svelte',
80
+ });
80
81
  });
81
82
  });
82
83
 
@@ -1 +1 @@
1
- {"version":3,"file":"performance.js","sources":["../../src/performance.ts"],"sourcesContent":["import { getCurrentScope } from '@sentry/browser';\nimport type { Span, Transaction } from '@sentry/types';\nimport { afterUpdate, beforeUpdate, onMount } from 'svelte';\nimport { current_component } from 'svelte/internal';\n\nimport { getRootSpan } from '@sentry/core';\nimport { DEFAULT_COMPONENT_NAME, UI_SVELTE_INIT, UI_SVELTE_UPDATE } from './constants';\nimport type { TrackComponentOptions } from './types';\n\nconst defaultTrackComponentOptions: {\n trackInit: boolean;\n trackUpdates: boolean;\n componentName?: string;\n} = {\n trackInit: true,\n trackUpdates: true,\n};\n\n/**\n * Tracks the Svelte component's intialization and mounting operation as well as\n * updates and records them as spans.\n * This function is injected automatically into your Svelte components' code\n * if you are using the Sentry componentTrackingPreprocessor.\n * Alternatively, you can call it yourself if you don't want to use the preprocessor.\n */\nexport function trackComponent(options?: TrackComponentOptions): void {\n const mergedOptions = { ...defaultTrackComponentOptions, ...options };\n\n const transaction = getActiveTransaction();\n if (!transaction) {\n return;\n }\n\n const customComponentName = mergedOptions.componentName;\n\n // current_component.ctor.name is likely to give us the component's name automatically\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const componentName = `<${customComponentName || current_component.constructor.name || DEFAULT_COMPONENT_NAME}>`;\n\n let initSpan: Span | undefined = undefined;\n if (mergedOptions.trackInit) {\n initSpan = recordInitSpan(transaction, componentName);\n }\n\n if (mergedOptions.trackUpdates) {\n recordUpdateSpans(componentName, initSpan);\n }\n}\n\nfunction recordInitSpan(transaction: Transaction, componentName: string): Span {\n // eslint-disable-next-line deprecation/deprecation\n const initSpan = transaction.startChild({\n op: UI_SVELTE_INIT,\n description: componentName,\n origin: 'auto.ui.svelte',\n });\n\n onMount(() => {\n initSpan.end();\n });\n\n return initSpan;\n}\n\nfunction recordUpdateSpans(componentName: string, initSpan?: Span): void {\n let updateSpan: Span | undefined;\n beforeUpdate(() => {\n // We need to get the active transaction again because the initial one could\n // already be finished or there is currently no transaction going on.\n const transaction = getActiveTransaction();\n if (!transaction) {\n return;\n }\n\n // If we are initializing the component when the update span is started, we start it as child\n // of the init span. Else, we start it as a child of the transaction.\n const parentSpan =\n initSpan && initSpan.isRecording() && getRootSpan(initSpan) === transaction ? initSpan : transaction;\n\n // eslint-disable-next-line deprecation/deprecation\n updateSpan = parentSpan.startChild({\n op: UI_SVELTE_UPDATE,\n description: componentName,\n origin: 'auto.ui.svelte',\n });\n });\n\n afterUpdate(() => {\n if (!updateSpan) {\n return;\n }\n updateSpan.end();\n updateSpan = undefined;\n });\n}\n\nfunction getActiveTransaction(): Transaction | undefined {\n // eslint-disable-next-line deprecation/deprecation\n return getCurrentScope().getTransaction();\n}\n"],"names":[],"mappings":";;;;;;AASA,MAAM,4BAA4B;;AAIlC,GAAI;AACJ,EAAE,SAAS,EAAE,IAAI;AACjB,EAAE,YAAY,EAAE,IAAI;AACpB,CAAC,CAAA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc,CAAC,OAAO,EAAgC;AACtE,EAAE,MAAM,gBAAgB,EAAE,GAAG,4BAA4B,EAAE,GAAG,OAAA,EAAS,CAAA;AACvE;AACA,EAAE,MAAM,WAAA,GAAc,oBAAoB,EAAE,CAAA;AAC5C,EAAE,IAAI,CAAC,WAAW,EAAE;AACpB,IAAI,OAAM;AACV,GAAE;AACF;AACA,EAAE,MAAM,mBAAA,GAAsB,aAAa,CAAC,aAAa,CAAA;A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A,IAAI,UAAW,GAAE,UAAU,CAAC,UAAU,CAAC;AACvC,MAAM,EAAE,EAAE,gBAAgB;AAC1B,MAAM,WAAW,EAAE,aAAa;AAChC,MAAM,MAAM,EAAE,gBAAgB;AAC9B,KAAK,CAAC,CAAA;AACN,GAAG,CAAC,CAAA;AACJ;AACA,EAAE,WAAW,CAAC,MAAM;AACpB,IAAI,IAAI,CAAC,UAAU,EAAE;AACrB,MAAM,OAAM;AACZ,KAAI;AACJ,IAAI,UAAU,CAAC,GAAG,EAAE,CAAA;AACpB,IAAI,UAAA,GAAa,SAAS,CAAA;AAC1B,GAAG,CAAC,CAAA;AACJ,CAAA;AACA;AACA,SAAS,oBAAoB,GAA4B;AACzD;AACA,EAAE,OAAO,eAAe,EAAE,CAAC,cAAc,EAAE,CAAA;AAC3C;;;;"}
1
+ {"version":3,"file":"performance.js","sources":["../../src/performance.ts"],"sourcesContent":["import { getCurrentScope } from '@sentry/browser';\nimport type { Span, Transaction } from '@sentry/types';\nimport { afterUpdate, beforeUpdate, onMount } from 'svelte';\nimport { current_component } from 'svelte/internal';\n\nimport { getRootSpan, startInactiveSpan, withActiveSpan } from '@sentry/core';\nimport { DEFAULT_COMPONENT_NAME, UI_SVELTE_INIT, UI_SVELTE_UPDATE } from './constants';\nimport type { TrackComponentOptions } from './types';\n\nconst defaultTrackComponentOptions: {\n trackInit: boolean;\n trackUpdates: boolean;\n componentName?: string;\n} = {\n trackInit: true,\n trackUpdates: true,\n};\n\n/**\n * Tracks the Svelte component's intialization and mounting operation as well as\n * updates and records them as spans.\n * This function is injected automatically into your Svelte components' code\n * if you are using the Sentry componentTrackingPreprocessor.\n * Alternatively, you can call it yourself if you don't want to use the preprocessor.\n */\nexport function trackComponent(options?: TrackComponentOptions): void {\n const mergedOptions = { ...defaultTrackComponentOptions, ...options };\n\n const transaction = getActiveTransaction();\n if (!transaction) {\n return;\n }\n\n const customComponentName = mergedOptions.componentName;\n\n // current_component.ctor.name is likely to give us the component's name automatically\n // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access\n const componentName = `<${customComponentName || current_component.constructor.name || DEFAULT_COMPONENT_NAME}>`;\n\n let initSpan: Span | undefined = undefined;\n if (mergedOptions.trackInit) {\n initSpan = recordInitSpan(transaction, componentName);\n }\n\n if (mergedOptions.trackUpdates) {\n recordUpdateSpans(componentName, initSpan);\n }\n}\n\nfunction recordInitSpan(transaction: Transaction, componentName: string): Span {\n // eslint-disable-next-line deprecation/deprecation\n const initSpan = transaction.startChild({\n op: UI_SVELTE_INIT,\n name: componentName,\n origin: 'auto.ui.svelte',\n });\n\n onMount(() => {\n initSpan.end();\n });\n\n return initSpan;\n}\n\nfunction recordUpdateSpans(componentName: string, initSpan?: Span): void {\n let updateSpan: Span | undefined;\n beforeUpdate(() => {\n // We need to get the active transaction again because the initial one could\n // already be finished or there is currently no transaction going on.\n const transaction = getActiveTransaction();\n if (!transaction) {\n return;\n }\n\n // If we are initializing the component when the update span is started, we start it as child\n // of the init span. Else, we start it as a child of the transaction.\n const parentSpan =\n initSpan && initSpan.isRecording() && getRootSpan(initSpan) === transaction ? initSpan : transaction;\n\n updateSpan = withActiveSpan(parentSpan, () => {\n return startInactiveSpan({\n op: UI_SVELTE_UPDATE,\n name: componentName,\n origin: 'auto.ui.svelte',\n });\n });\n });\n\n afterUpdate(() => {\n if (!updateSpan) {\n return;\n }\n updateSpan.end();\n updateSpan = undefined;\n });\n}\n\nfunction getActiveTransaction(): Transaction | undefined {\n // eslint-disable-next-line deprecation/deprecation\n return getCurrentScope().getTransaction();\n}\n"],"names":[],"mappings":";;;;;;AASA,MAAM,4BAA4B;;AAIlC,GAAI;AACJ,EAAE,SAAS,EAAE,IAAI;AACjB,EAAE,YAAY,EAAE,IAAI;AACpB,CAAC,CAAA;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS,cAAc,CAAC,OAAO,EAAgC;AACtE,EAAE,MAAM,gBAAgB,EAAE,GAAG,4BAA4B,EAAE,GAAG,OAAA,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AACtB,MAAM,OAAM;AACZ,KAAI;AACJ;AACA;AACA;AACA,IAAI,MAAM,UAAW;AACrB,MAAM,YAAY,QAAQ,CAAC,WAAW,EAAG,IAAG,WAAW,CAAC,QAAQ,CAAE,KAAI,cAAc,QAAA,GAAW,WAAW,CAAA;AAC1G;AACA,IAAI,UAAA,GAAa,cAAc,CAAC,UAAU,EAAE,MAAM;AAClD,MAAM,OAAO,iBAAiB,CAAC;AAC/B,QAAQ,EAAE,EAAE,gBAAgB;AAC5B,QAAQ,IAAI,EAAE,aAAa;AAC3B,QAAQ,MAAM,EAAE,gBAAgB;AAChC,OAAO,CAAC,CAAA;AACR,KAAK,CAAC,CAAA;AACN,GAAG,CAAC,CAAA;AACJ;AACA,EAAE,WAAW,CAAC,MAAM;AACpB,IAAI,IAAI,CAAC,UAAU,EAAE;AACrB,MAAM,OAAM;AACZ,KAAI;AACJ,IAAI,UAAU,CAAC,GAAG,EAAE,CAAA;AACpB,IAAI,UAAA,GAAa,SAAS,CAAA;AAC1B,GAAG,CAAC,CAAA;AACJ,CAAA;AACA;AACA,SAAS,oBAAoB,GAA4B;AACzD;AACA,EAAE,OAAO,eAAe,EAAE,CAAC,cAAc,EAAE,CAAA;AAC3C;;;;"}
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@sentry/svelte",
3
- "version": "7.104.0",
3
+ "version": "8.0.0-alpha.2",
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": ">=8"
10
+ "node": ">=14.8"
11
11
  },
12
12
  "files": [
13
13
  "cjs",
@@ -29,19 +29,19 @@
29
29
  "access": "public"
30
30
  },
31
31
  "dependencies": {
32
- "@sentry/browser": "7.104.0",
33
- "@sentry/core": "7.104.0",
34
- "@sentry/types": "7.104.0",
35
- "@sentry/utils": "7.104.0",
32
+ "@sentry/browser": "8.0.0-alpha.2",
33
+ "@sentry/core": "8.0.0-alpha.2",
34
+ "@sentry/types": "8.0.0-alpha.2",
35
+ "@sentry/utils": "8.0.0-alpha.2",
36
36
  "magic-string": "^0.30.0"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "svelte": "3.x || 4.x"
40
40
  },
41
41
  "devDependencies": {
42
+ "@sveltejs/vite-plugin-svelte": "1.4.0",
42
43
  "@testing-library/svelte": "^3.2.1",
43
- "svelte": "3.49.0",
44
- "svelte-jester": "^2.3.2"
44
+ "svelte": "3.49.0"
45
45
  },
46
46
  "sideEffects": false
47
47
  }
package/types/types.d.ts CHANGED
@@ -51,6 +51,11 @@ export type ComponentTrackingInitOptions = {
51
51
  trackComponents?: boolean | string[];
52
52
  } & SpanOptions;
53
53
  export type TrackComponentOptions = {
54
+ /**
55
+ * The name of the component to be used in the recorded spans.
56
+ *
57
+ * @default to <Svelte Component> if not specified
58
+ */
54
59
  componentName?: string;
55
60
  } & SpanOptions;
56
61
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAI1E,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,iBAAiB,EAAE,GAAG,iBAAiB,CAAC;IACrD,eAAe,CAAC,EAAE,cAAc,CAAC;CAClC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,iBAAiB,CAAC,EAAE,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EAAE,CAAC;CACtC,GAAG,WAAW,CAAC;AAEhB,MAAM,MAAM,qBAAqB,GAAG;IAClC;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GAAG,WAAW,CAAC"}
@@ -51,6 +51,11 @@ export type ComponentTrackingInitOptions = {
51
51
  trackComponents?: boolean | string[];
52
52
  } & SpanOptions;
53
53
  export type TrackComponentOptions = {
54
+ /**
55
+ * The name of the component to be used in the recorded spans.
56
+ *
57
+ * @default to <Svelte Component> if not specified
58
+ */
54
59
  componentName?: string;
55
60
  } & SpanOptions;
56
61
  //# sourceMappingURL=types.d.ts.map