@sentry/svelte 8.0.0-alpha.2 → 8.0.0-alpha.3

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/cjs/index.js CHANGED
@@ -12,7 +12,14 @@ exports.init = sdk.init;
12
12
  exports.componentTrackingPreprocessor = preprocessors.componentTrackingPreprocessor;
13
13
  exports.trackComponent = performance.trackComponent;
14
14
  exports.withSentryConfig = config.withSentryConfig;
15
- for (const k in browser) {
16
- if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = browser[k];
17
- }
15
+ Object.prototype.hasOwnProperty.call(browser, '__proto__') &&
16
+ !Object.prototype.hasOwnProperty.call(exports, '__proto__') &&
17
+ Object.defineProperty(exports, '__proto__', {
18
+ enumerable: true,
19
+ value: browser['__proto__']
20
+ });
21
+
22
+ Object.keys(browser).forEach(k => {
23
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = browser[k];
24
+ });
18
25
  //# sourceMappingURL=index.js.map
package/cjs/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
@@ -23,11 +23,6 @@ const defaultTrackComponentOptions
23
23
  function trackComponent(options) {
24
24
  const mergedOptions = { ...defaultTrackComponentOptions, ...options };
25
25
 
26
- const transaction = getActiveTransaction();
27
- if (!transaction) {
28
- return;
29
- }
30
-
31
26
  const customComponentName = mergedOptions.componentName;
32
27
 
33
28
  // current_component.ctor.name is likely to give us the component's name automatically
@@ -36,7 +31,7 @@ function trackComponent(options) {
36
31
 
37
32
  let initSpan = undefined;
38
33
  if (mergedOptions.trackInit) {
39
- initSpan = recordInitSpan(transaction, componentName);
34
+ initSpan = recordInitSpan(componentName);
40
35
  }
41
36
 
42
37
  if (mergedOptions.trackUpdates) {
@@ -44,12 +39,12 @@ function trackComponent(options) {
44
39
  }
45
40
  }
46
41
 
47
- function recordInitSpan(transaction, componentName) {
48
- // eslint-disable-next-line deprecation/deprecation
49
- const initSpan = transaction.startChild({
42
+ function recordInitSpan(componentName) {
43
+ const initSpan = core.startInactiveSpan({
44
+ onlyIfParent: true,
50
45
  op: constants.UI_SVELTE_INIT,
51
46
  name: componentName,
52
- origin: 'auto.ui.svelte',
47
+ attributes: { [browser.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.svelte' },
53
48
  });
54
49
 
55
50
  svelte.onMount(() => {
@@ -64,21 +59,25 @@ function recordUpdateSpans(componentName, initSpan) {
64
59
  svelte.beforeUpdate(() => {
65
60
  // We need to get the active transaction again because the initial one could
66
61
  // already be finished or there is currently no transaction going on.
67
- const transaction = getActiveTransaction();
68
- if (!transaction) {
62
+ const activeSpan = browser.getActiveSpan();
63
+ if (!activeSpan) {
69
64
  return;
70
65
  }
71
66
 
72
67
  // If we are initializing the component when the update span is started, we start it as child
73
68
  // of the init span. Else, we start it as a child of the transaction.
74
69
  const parentSpan =
75
- initSpan && initSpan.isRecording() && core.getRootSpan(initSpan) === transaction ? initSpan : transaction;
70
+ initSpan && initSpan.isRecording() && core.getRootSpan(initSpan) === core.getRootSpan(activeSpan)
71
+ ? initSpan
72
+ : core.getRootSpan(activeSpan);
73
+
74
+ if (!parentSpan) return;
76
75
 
77
76
  updateSpan = core.withActiveSpan(parentSpan, () => {
78
77
  return core.startInactiveSpan({
79
78
  op: constants.UI_SVELTE_UPDATE,
80
79
  name: componentName,
81
- origin: 'auto.ui.svelte',
80
+ attributes: { [browser.SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.svelte' },
82
81
  });
83
82
  });
84
83
  });
@@ -92,10 +91,5 @@ function recordUpdateSpans(componentName, initSpan) {
92
91
  });
93
92
  }
94
93
 
95
- function getActiveTransaction() {
96
- // eslint-disable-next-line deprecation/deprecation
97
- return browser.getCurrentScope().getTransaction();
98
- }
99
-
100
94
  exports.trackComponent = trackComponent;
101
95
  //# sourceMappingURL=performance.js.map
@@ -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, 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,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,WA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/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
+ {"version":3,"file":"performance.js","sources":["../../src/performance.ts"],"sourcesContent":["import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getActiveSpan } from '@sentry/browser';\nimport type { Span } 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 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(componentName);\n }\n\n if (mergedOptions.trackUpdates) {\n recordUpdateSpans(componentName, initSpan);\n }\n}\n\nfunction recordInitSpan(componentName: string): Span | undefined {\n const initSpan = startInactiveSpan({\n onlyIfParent: true,\n op: UI_SVELTE_INIT,\n name: componentName,\n attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_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 activeSpan = getActiveSpan();\n if (!activeSpan) {\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) === getRootSpan(activeSpan)\n ? initSpan\n : getRootSpan(activeSpan);\n\n if (!parentSpan) return;\n\n updateSpan = withActiveSpan(parentSpan, () => {\n return startInactiveSpan({\n op: UI_SVELTE_UPDATE,\n name: componentName,\n attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_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"],"names":["current_component","DEFAULT_COMPONENT_NAME","startInactiveSpan","UI_SVELTE_INIT","SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN","onMount","beforeUpdate","getActiveSpan","getRootSpan","withActiveSpan","UI_SVELTE_UPDATE","afterUpdate"],"mappings":";;;;;;;;AASA,MAAM,4BAA4B;;AAIlC,GAAI;AACJ,EAAE,SAAS,EAAE,IAAI;AACjB,EAAE,YAAY,E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I,MAAM,UAAA,GAAaC,qBAAa,EAAE,CAAA;AACtC,IAAI,IAAI,CAAC,UAAU,EAAE;AACrB,MAAM,OAAM;AACZ,KAAI;AACJ;AACA;AACA;AACA,IAAI,MAAM,UAAW;AACrB,MAAM,QAAS,IAAG,QAAQ,CAAC,WAAW,EAAC,IAAKC,gBAAW,CAAC,QAAQ,CAAA,KAAMA,gBAAW,CAAC,UAAU,CAAA;AAC5F,UAAU,QAAA;AACV,UAAUA,gBAAW,CAAC,UAAU,CAAC,CAAA;AACjC;AACA,IAAI,IAAI,CAAC,UAAU,EAAE,OAAM;AAC3B;AACA,IAAI,UAAA,GAAaC,mBAAc,CAAC,UAAU,EAAE,MAAM;AAClD,MAAM,OAAOP,sBAAiB,CAAC;AAC/B,QAAQ,EAAE,EAAEQ,0BAAgB;AAC5B,QAAQ,IAAI,EAAE,aAAa;AAC3B,QAAQ,UAAU,EAAE,EAAE,CAACN,wCAAgC,GAAG,kBAAkB;AAC5E,OAAO,CAAC,CAAA;AACR,KAAK,CAAC,CAAA;AACN,GAAG,CAAC,CAAA;AACJ;AACA,EAAEO,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;;;;"}
@@ -0,0 +1 @@
1
+ { "type": "module" }
@@ -1,7 +1,7 @@
1
- import { getCurrentScope } from '@sentry/browser';
1
+ import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getActiveSpan } from '@sentry/browser';
2
2
  import { onMount, beforeUpdate, afterUpdate } from 'svelte';
3
3
  import { current_component } from 'svelte/internal';
4
- import { getRootSpan, withActiveSpan, startInactiveSpan } from '@sentry/core';
4
+ import { startInactiveSpan, getRootSpan, withActiveSpan } from '@sentry/core';
5
5
  import { DEFAULT_COMPONENT_NAME, UI_SVELTE_INIT, UI_SVELTE_UPDATE } from './constants.js';
6
6
 
7
7
  const defaultTrackComponentOptions
@@ -21,11 +21,6 @@ const defaultTrackComponentOptions
21
21
  function trackComponent(options) {
22
22
  const mergedOptions = { ...defaultTrackComponentOptions, ...options };
23
23
 
24
- const transaction = getActiveTransaction();
25
- if (!transaction) {
26
- return;
27
- }
28
-
29
24
  const customComponentName = mergedOptions.componentName;
30
25
 
31
26
  // current_component.ctor.name is likely to give us the component's name automatically
@@ -34,7 +29,7 @@ function trackComponent(options) {
34
29
 
35
30
  let initSpan = undefined;
36
31
  if (mergedOptions.trackInit) {
37
- initSpan = recordInitSpan(transaction, componentName);
32
+ initSpan = recordInitSpan(componentName);
38
33
  }
39
34
 
40
35
  if (mergedOptions.trackUpdates) {
@@ -42,12 +37,12 @@ function trackComponent(options) {
42
37
  }
43
38
  }
44
39
 
45
- function recordInitSpan(transaction, componentName) {
46
- // eslint-disable-next-line deprecation/deprecation
47
- const initSpan = transaction.startChild({
40
+ function recordInitSpan(componentName) {
41
+ const initSpan = startInactiveSpan({
42
+ onlyIfParent: true,
48
43
  op: UI_SVELTE_INIT,
49
44
  name: componentName,
50
- origin: 'auto.ui.svelte',
45
+ attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.svelte' },
51
46
  });
52
47
 
53
48
  onMount(() => {
@@ -62,21 +57,25 @@ function recordUpdateSpans(componentName, initSpan) {
62
57
  beforeUpdate(() => {
63
58
  // We need to get the active transaction again because the initial one could
64
59
  // already be finished or there is currently no transaction going on.
65
- const transaction = getActiveTransaction();
66
- if (!transaction) {
60
+ const activeSpan = getActiveSpan();
61
+ if (!activeSpan) {
67
62
  return;
68
63
  }
69
64
 
70
65
  // If we are initializing the component when the update span is started, we start it as child
71
66
  // of the init span. Else, we start it as a child of the transaction.
72
67
  const parentSpan =
73
- initSpan && initSpan.isRecording() && getRootSpan(initSpan) === transaction ? initSpan : transaction;
68
+ initSpan && initSpan.isRecording() && getRootSpan(initSpan) === getRootSpan(activeSpan)
69
+ ? initSpan
70
+ : getRootSpan(activeSpan);
71
+
72
+ if (!parentSpan) return;
74
73
 
75
74
  updateSpan = withActiveSpan(parentSpan, () => {
76
75
  return startInactiveSpan({
77
76
  op: UI_SVELTE_UPDATE,
78
77
  name: componentName,
79
- origin: 'auto.ui.svelte',
78
+ attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.svelte' },
80
79
  });
81
80
  });
82
81
  });
@@ -90,10 +89,5 @@ function recordUpdateSpans(componentName, initSpan) {
90
89
  });
91
90
  }
92
91
 
93
- function getActiveTransaction() {
94
- // eslint-disable-next-line deprecation/deprecation
95
- return getCurrentScope().getTransaction();
96
- }
97
-
98
92
  export { trackComponent };
99
93
  //# sourceMappingURL=performance.js.map
@@ -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, 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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,EAAE;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;;;;"}
1
+ {"version":3,"file":"performance.js","sources":["../../src/performance.ts"],"sourcesContent":["import { SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, getActiveSpan } from '@sentry/browser';\nimport type { Span } 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 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(componentName);\n }\n\n if (mergedOptions.trackUpdates) {\n recordUpdateSpans(componentName, initSpan);\n }\n}\n\nfunction recordInitSpan(componentName: string): Span | undefined {\n const initSpan = startInactiveSpan({\n onlyIfParent: true,\n op: UI_SVELTE_INIT,\n name: componentName,\n attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_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 activeSpan = getActiveSpan();\n if (!activeSpan) {\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) === getRootSpan(activeSpan)\n ? initSpan\n : getRootSpan(activeSpan);\n\n if (!parentSpan) return;\n\n updateSpan = withActiveSpan(parentSpan, () => {\n return startInactiveSpan({\n op: UI_SVELTE_UPDATE,\n name: componentName,\n attributes: { [SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN]: 'auto.ui.svelte' },\n });\n });\n });\n\n afterUpdate(() => {\n if (!updateSpan) {\n return;\n }\n updateSpan.end();\n updateSpan = undefined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C,aAAa,EAAU,QAAQ,EAAe;AACzE,EAAE,IAAI,UAAU,CAAA;AAChB,EAAE,YAAY,CAAC,MAAM;AACrB;AACA;AACA,IAAI,MAAM,UAAA,GAAa,aAAa,EAAE,CAAA;AACtC,IAAI,IAAI,CAAC,UAAU,EAAE;AACrB,MAAM,OAAM;AACZ,KAAI;AACJ;AACA;AACA;AACA,IAAI,MAAM,UAAW;AACrB,MAAM,QAAS,IAAG,QAAQ,CAAC,WAAW,EAAC,IAAK,WAAW,CAAC,QAAQ,CAAA,KAAM,WAAW,CAAC,UAAU,CAAA;AAC5F,UAAU,QAAA;AACV,UAAU,WAAW,CAAC,UAAU,CAAC,CAAA;AACjC;AACA,IAAI,IAAI,CAAC,UAAU,EAAE,OAAM;AAC3B;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,UAAU,EAAE,EAAE,CAAC,gCAAgC,GAAG,kBAAkB;AAC5E,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;;;;"}
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@sentry/svelte",
3
- "version": "8.0.0-alpha.2",
3
+ "version": "8.0.0-alpha.3",
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.8"
10
+ "node": ">=14.18"
11
11
  },
12
12
  "files": [
13
13
  "cjs",
@@ -18,6 +18,19 @@
18
18
  "main": "cjs/index.js",
19
19
  "module": "esm/index.js",
20
20
  "types": "types/index.d.ts",
21
+ "exports": {
22
+ "./package.json": "./package.json",
23
+ ".": {
24
+ "import": {
25
+ "types": "./types/index.d.ts",
26
+ "default": "./esm/index.js"
27
+ },
28
+ "require": {
29
+ "types": "./types/index.d.ts",
30
+ "default": "./cjs/index.js"
31
+ }
32
+ }
33
+ },
21
34
  "typesVersions": {
22
35
  "<4.9": {
23
36
  "types/index.d.ts": [
@@ -29,10 +42,10 @@
29
42
  "access": "public"
30
43
  },
31
44
  "dependencies": {
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",
45
+ "@sentry/browser": "8.0.0-alpha.3",
46
+ "@sentry/core": "8.0.0-alpha.3",
47
+ "@sentry/types": "8.0.0-alpha.3",
48
+ "@sentry/utils": "8.0.0-alpha.3",
36
49
  "magic-string": "^0.30.0"
37
50
  },
38
51
  "peerDependencies": {
@@ -1 +1 @@
1
- {"version":3,"file":"performance.d.ts","sourceRoot":"","sources":["../../src/performance.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAWrD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAsBpE"}
1
+ {"version":3,"file":"performance.d.ts","sourceRoot":"","sources":["../../src/performance.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAWrD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAiBpE"}