@sentry/browser 9.8.0 → 9.10.0

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.
Files changed (42) hide show
  1. package/build/npm/cjs/client.js +0 -3
  2. package/build/npm/cjs/client.js.map +1 -1
  3. package/build/npm/cjs/diagnose-sdk.js +46 -0
  4. package/build/npm/cjs/diagnose-sdk.js.map +1 -0
  5. package/build/npm/cjs/index.js +4 -0
  6. package/build/npm/cjs/index.js.map +1 -1
  7. package/build/npm/cjs/log.js +267 -0
  8. package/build/npm/cjs/log.js.map +1 -0
  9. package/build/npm/cjs/tracing/browserTracingIntegration.js +20 -0
  10. package/build/npm/cjs/tracing/browserTracingIntegration.js.map +1 -1
  11. package/build/npm/cjs/tracing/previousTrace.js +107 -0
  12. package/build/npm/cjs/tracing/previousTrace.js.map +1 -0
  13. package/build/npm/esm/client.js +1 -4
  14. package/build/npm/esm/client.js.map +1 -1
  15. package/build/npm/esm/diagnose-sdk.js +44 -0
  16. package/build/npm/esm/diagnose-sdk.js.map +1 -0
  17. package/build/npm/esm/index.js +3 -0
  18. package/build/npm/esm/index.js.map +1 -1
  19. package/build/npm/esm/log.js +260 -0
  20. package/build/npm/esm/log.js.map +1 -0
  21. package/build/npm/esm/package.json +1 -1
  22. package/build/npm/esm/tracing/browserTracingIntegration.js +21 -1
  23. package/build/npm/esm/tracing/browserTracingIntegration.js.map +1 -1
  24. package/build/npm/esm/tracing/previousTrace.js +101 -0
  25. package/build/npm/esm/tracing/previousTrace.js.map +1 -0
  26. package/build/npm/types/client.d.ts.map +1 -1
  27. package/build/npm/types/diagnose-sdk.d.ts +11 -0
  28. package/build/npm/types/diagnose-sdk.d.ts.map +1 -0
  29. package/build/npm/types/index.d.ts +3 -0
  30. package/build/npm/types/index.d.ts.map +1 -1
  31. package/build/npm/types/log.d.ts +169 -0
  32. package/build/npm/types/log.d.ts.map +1 -0
  33. package/build/npm/types/tracing/browserTracingIntegration.d.ts +22 -0
  34. package/build/npm/types/tracing/browserTracingIntegration.d.ts.map +1 -1
  35. package/build/npm/types/tracing/previousTrace.d.ts +31 -0
  36. package/build/npm/types/tracing/previousTrace.d.ts.map +1 -0
  37. package/build/npm/types-ts3.8/diagnose-sdk.d.ts +11 -0
  38. package/build/npm/types-ts3.8/index.d.ts +3 -0
  39. package/build/npm/types-ts3.8/log.d.ts +169 -0
  40. package/build/npm/types-ts3.8/tracing/browserTracingIntegration.d.ts +22 -0
  41. package/build/npm/types-ts3.8/tracing/previousTrace.d.ts +31 -0
  42. package/package.json +7 -7
@@ -0,0 +1,169 @@
1
+ import { Log, ParameterizedString } from '@sentry/core';
2
+ /**
3
+ * @summary Capture a log with the `trace` level. Requires `_experiments.enableLogs` to be enabled.
4
+ *
5
+ * @param message - The message to log.
6
+ * @param attributes - Arbitrary structured data that stores information about the log - e.g., { userId: 100, route: '/dashboard' }.
7
+ *
8
+ * @example
9
+ *
10
+ * ```
11
+ * Sentry.logger.trace('User clicked submit button', {
12
+ * buttonId: 'submit-form',
13
+ * formId: 'user-profile',
14
+ * timestamp: Date.now()
15
+ * });
16
+ * ```
17
+ *
18
+ * @example With template strings
19
+ *
20
+ * ```
21
+ * Sentry.logger.trace(Sentry.logger.fmt`User ${user} navigated to ${page}`, {
22
+ * userId: '123',
23
+ * sessionId: 'abc-xyz'
24
+ * });
25
+ * ```
26
+ */
27
+ export declare function trace(message: ParameterizedString, attributes?: Log['attributes']): void;
28
+ /**
29
+ * @summary Capture a log with the `debug` level. Requires `_experiments.enableLogs` to be enabled.
30
+ *
31
+ * @param message - The message to log.
32
+ * @param attributes - Arbitrary structured data that stores information about the log - e.g., { component: 'Header', state: 'loading' }.
33
+ *
34
+ * @example
35
+ *
36
+ * ```
37
+ * Sentry.logger.debug('Component mounted', {
38
+ * component: 'UserProfile',
39
+ * props: { userId: 123 },
40
+ * renderTime: 150
41
+ * });
42
+ * ```
43
+ *
44
+ * @example With template strings
45
+ *
46
+ * ```
47
+ * Sentry.logger.debug(Sentry.logger.fmt`API request to ${endpoint} failed`, {
48
+ * statusCode: 404,
49
+ * requestId: 'req-123',
50
+ * duration: 250
51
+ * });
52
+ * ```
53
+ */
54
+ export declare function debug(message: ParameterizedString, attributes?: Log['attributes']): void;
55
+ /**
56
+ * @summary Capture a log with the `info` level. Requires `_experiments.enableLogs` to be enabled.
57
+ *
58
+ * @param message - The message to log.
59
+ * @param attributes - Arbitrary structured data that stores information about the log - e.g., { feature: 'checkout', status: 'completed' }.
60
+ *
61
+ * @example
62
+ *
63
+ * ```
64
+ * Sentry.logger.info('User completed checkout', {
65
+ * orderId: 'order-123',
66
+ * amount: 99.99,
67
+ * paymentMethod: 'credit_card'
68
+ * });
69
+ * ```
70
+ *
71
+ * @example With template strings
72
+ *
73
+ * ```
74
+ * Sentry.logger.info(Sentry.logger.fmt`User ${user} updated profile picture`, {
75
+ * userId: 'user-123',
76
+ * imageSize: '2.5MB',
77
+ * timestamp: Date.now()
78
+ * });
79
+ * ```
80
+ */
81
+ export declare function info(message: ParameterizedString, attributes?: Log['attributes']): void;
82
+ /**
83
+ * @summary Capture a log with the `warn` level. Requires `_experiments.enableLogs` to be enabled.
84
+ *
85
+ * @param message - The message to log.
86
+ * @param attributes - Arbitrary structured data that stores information about the log - e.g., { browser: 'Chrome', version: '91.0' }.
87
+ *
88
+ * @example
89
+ *
90
+ * ```
91
+ * Sentry.logger.warn('Browser compatibility issue detected', {
92
+ * browser: 'Safari',
93
+ * version: '14.0',
94
+ * feature: 'WebRTC',
95
+ * fallback: 'enabled'
96
+ * });
97
+ * ```
98
+ *
99
+ * @example With template strings
100
+ *
101
+ * ```
102
+ * Sentry.logger.warn(Sentry.logger.fmt`API endpoint ${endpoint} is deprecated`, {
103
+ * recommendedEndpoint: '/api/v2/users',
104
+ * sunsetDate: '2024-12-31',
105
+ * clientVersion: '1.2.3'
106
+ * });
107
+ * ```
108
+ */
109
+ export declare function warn(message: ParameterizedString, attributes?: Log['attributes']): void;
110
+ /**
111
+ * @summary Capture a log with the `error` level. Requires `_experiments.enableLogs` to be enabled.
112
+ *
113
+ * @param message - The message to log.
114
+ * @param attributes - Arbitrary structured data that stores information about the log - e.g., { error: 'NetworkError', url: '/api/data' }.
115
+ *
116
+ * @example
117
+ *
118
+ * ```
119
+ * Sentry.logger.error('Failed to load user data', {
120
+ * error: 'NetworkError',
121
+ * url: '/api/users/123',
122
+ * statusCode: 500,
123
+ * retryCount: 3
124
+ * });
125
+ * ```
126
+ *
127
+ * @example With template strings
128
+ *
129
+ * ```
130
+ * Sentry.logger.error(Sentry.logger.fmt`Payment processing failed for order ${orderId}`, {
131
+ * error: 'InsufficientFunds',
132
+ * amount: 100.00,
133
+ * currency: 'USD',
134
+ * userId: 'user-456'
135
+ * });
136
+ * ```
137
+ */
138
+ export declare function error(message: ParameterizedString, attributes?: Log['attributes']): void;
139
+ /**
140
+ * @summary Capture a log with the `fatal` level. Requires `_experiments.enableLogs` to be enabled.
141
+ *
142
+ * @param message - The message to log.
143
+ * @param attributes - Arbitrary structured data that stores information about the log - e.g., { appState: 'corrupted', sessionId: 'abc-123' }.
144
+ *
145
+ * @example
146
+ *
147
+ * ```
148
+ * Sentry.logger.fatal('Application state corrupted', {
149
+ * lastKnownState: 'authenticated',
150
+ * sessionId: 'session-123',
151
+ * timestamp: Date.now(),
152
+ * recoveryAttempted: true
153
+ * });
154
+ * ```
155
+ *
156
+ * @example With template strings
157
+ *
158
+ * ```
159
+ * Sentry.logger.fatal(Sentry.logger.fmt`Critical system failure in ${service}`, {
160
+ * service: 'payment-processor',
161
+ * errorCode: 'CRITICAL_FAILURE',
162
+ * affectedUsers: 150,
163
+ * timestamp: Date.now()
164
+ * });
165
+ * ```
166
+ */
167
+ export declare function fatal(message: ParameterizedString, attributes?: Log['attributes']): void;
168
+ export { fmt } from '@sentry/core';
169
+ //# sourceMappingURL=log.d.ts.map
@@ -86,6 +86,28 @@ export interface BrowserTracingOptions {
86
86
  * Default: true
87
87
  */
88
88
  enableHTTPTimings: boolean;
89
+ /**
90
+ * Link the currently started trace to a previous trace (e.g. a prior pageload, navigation or
91
+ * manually started span). When enabled, this option will allow you to navigate between traces
92
+ * in the Sentry UI.
93
+ *
94
+ * You can set this option to the following values:
95
+ *
96
+ * - `'in-memory'`: The previous trace data will be stored in memory.
97
+ * This is useful for single-page applications and enabled by default.
98
+ *
99
+ * - `'session-storage'`: The previous trace data will be stored in the `sessionStorage`.
100
+ * This is useful for multi-page applications or static sites but it means that the
101
+ * Sentry SDK writes to the browser's `sessionStorage`.
102
+ *
103
+ * - `'off'`: The previous trace data will not be stored or linked.
104
+ *
105
+ * Note that your `tracesSampleRate` or `tracesSampler` config significantly influences
106
+ * how often traces will be linked.
107
+ *
108
+ * @default 'in-memory' - see explanation above
109
+ */
110
+ linkPreviousTrace: 'in-memory' | 'session-storage' | 'off';
89
111
  /**
90
112
  * _experiments allows the user to send options to define how this integration works.
91
113
  *
@@ -0,0 +1,31 @@
1
+ import { Span } from '@sentry/core';
2
+ import { SpanContextData } from '@sentry/core';
3
+ export interface PreviousTraceInfo {
4
+ /**
5
+ * Span context of the previous trace's local root span
6
+ */
7
+ spanContext: SpanContextData;
8
+ /**
9
+ * Timestamp in seconds when the previous trace was started
10
+ */
11
+ startTimestamp: number;
12
+ }
13
+ export declare const PREVIOUS_TRACE_MAX_DURATION = 3600;
14
+ export declare const PREVIOUS_TRACE_KEY = "sentry_previous_trace";
15
+ /**
16
+ * Adds a previous_trace span link to the passed span if the passed
17
+ * previousTraceInfo is still valid.
18
+ *
19
+ * @returns the updated previous trace info (based on the current span/trace) to
20
+ * be used on the next call
21
+ */
22
+ export declare function addPreviousTraceSpanLink(previousTraceInfo: PreviousTraceInfo | undefined, span: Span): PreviousTraceInfo;
23
+ /**
24
+ * Stores @param previousTraceInfo in sessionStorage.
25
+ */
26
+ export declare function storePreviousTraceInSessionStorage(previousTraceInfo: PreviousTraceInfo): void;
27
+ /**
28
+ * Retrieves the previous trace from sessionStorage if available.
29
+ */
30
+ export declare function getPreviousTraceFromSessionStorage(): PreviousTraceInfo | undefined;
31
+ //# sourceMappingURL=previousTrace.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/browser",
3
- "version": "9.8.0",
3
+ "version": "9.10.0",
4
4
  "description": "Official Sentry SDK for browsers",
5
5
  "repository": "git://github.com/getsentry/sentry-javascript.git",
6
6
  "homepage": "https://github.com/getsentry/sentry-javascript/tree/master/packages/browser",
@@ -39,14 +39,14 @@
39
39
  "access": "public"
40
40
  },
41
41
  "dependencies": {
42
- "@sentry-internal/browser-utils": "9.8.0",
43
- "@sentry-internal/feedback": "9.8.0",
44
- "@sentry-internal/replay": "9.8.0",
45
- "@sentry-internal/replay-canvas": "9.8.0",
46
- "@sentry/core": "9.8.0"
42
+ "@sentry-internal/browser-utils": "9.10.0",
43
+ "@sentry-internal/feedback": "9.10.0",
44
+ "@sentry-internal/replay": "9.10.0",
45
+ "@sentry-internal/replay-canvas": "9.10.0",
46
+ "@sentry/core": "9.10.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@sentry-internal/integration-shims": "9.8.0",
49
+ "@sentry-internal/integration-shims": "9.10.0",
50
50
  "fake-indexeddb": "^4.0.1"
51
51
  },
52
52
  "scripts": {