@sentry/profiling-node 8.10.0 → 8.11.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 (153) hide show
  1. package/bindings/cpu_profiler.cc +5 -3
  2. package/lib/cjs/index.js +2 -662
  3. package/lib/cjs/index.js.map +1 -1
  4. package/lib/esm/index.js +2 -662
  5. package/lib/esm/index.js.map +1 -1
  6. package/lib/sentry_cpu_profiler-darwin-arm64-108.node +0 -0
  7. package/lib/sentry_cpu_profiler-darwin-arm64-115.node +0 -0
  8. package/lib/sentry_cpu_profiler-darwin-arm64-127.node +0 -0
  9. package/lib/sentry_cpu_profiler-darwin-arm64-93.node +0 -0
  10. package/lib/sentry_cpu_profiler-darwin-x64-108.node +0 -0
  11. package/lib/sentry_cpu_profiler-darwin-x64-115.node +0 -0
  12. package/lib/sentry_cpu_profiler-darwin-x64-127.node +0 -0
  13. package/lib/sentry_cpu_profiler-darwin-x64-93.node +0 -0
  14. package/lib/sentry_cpu_profiler-linux-arm64-glibc-108.node +0 -0
  15. package/lib/sentry_cpu_profiler-linux-arm64-glibc-115.node +0 -0
  16. package/lib/sentry_cpu_profiler-linux-arm64-glibc-127.node +0 -0
  17. package/lib/sentry_cpu_profiler-linux-arm64-glibc-93.node +0 -0
  18. package/lib/sentry_cpu_profiler-linux-arm64-musl-108.node +0 -0
  19. package/lib/sentry_cpu_profiler-linux-arm64-musl-115.node +0 -0
  20. package/lib/sentry_cpu_profiler-linux-arm64-musl-127.node +0 -0
  21. package/lib/sentry_cpu_profiler-linux-arm64-musl-93.node +0 -0
  22. package/lib/sentry_cpu_profiler-linux-x64-glibc-108.node +0 -0
  23. package/lib/sentry_cpu_profiler-linux-x64-glibc-115.node +0 -0
  24. package/lib/sentry_cpu_profiler-linux-x64-glibc-127.node +0 -0
  25. package/lib/sentry_cpu_profiler-linux-x64-glibc-93.node +0 -0
  26. package/lib/sentry_cpu_profiler-linux-x64-musl-108.node +0 -0
  27. package/lib/sentry_cpu_profiler-linux-x64-musl-115.node +0 -0
  28. package/lib/sentry_cpu_profiler-linux-x64-musl-127.node +0 -0
  29. package/lib/sentry_cpu_profiler-linux-x64-musl-93.node +0 -0
  30. package/lib/sentry_cpu_profiler-win32-x64-108.node +0 -0
  31. package/lib/sentry_cpu_profiler-win32-x64-115.node +0 -0
  32. package/lib/sentry_cpu_profiler-win32-x64-127.node +0 -0
  33. package/lib/sentry_cpu_profiler-win32-x64-93.node +0 -0
  34. package/lib/types/cpu_profiler.d.ts.map +1 -0
  35. package/lib/types/debug-build.d.ts.map +1 -0
  36. package/lib/types/index.d.ts.map +1 -0
  37. package/lib/types/integration.d.ts.map +1 -0
  38. package/lib/types/nodeVersion.d.ts.map +1 -0
  39. package/lib/types/spanProfileUtils.d.ts.map +1 -0
  40. package/lib/types/types.d.ts.map +1 -0
  41. package/lib/types/utils.d.ts.map +1 -0
  42. package/package.json +5 -5
  43. package/lib/types/core/src/asyncContext/index.d.ts +0 -14
  44. package/lib/types/core/src/asyncContext/index.d.ts.map +0 -1
  45. package/lib/types/core/src/asyncContext/stackStrategy.d.ts +0 -52
  46. package/lib/types/core/src/asyncContext/stackStrategy.d.ts.map +0 -1
  47. package/lib/types/core/src/asyncContext/types.d.ts +0 -47
  48. package/lib/types/core/src/asyncContext/types.d.ts.map +0 -1
  49. package/lib/types/core/src/carrier.d.ts +0 -37
  50. package/lib/types/core/src/carrier.d.ts.map +0 -1
  51. package/lib/types/core/src/constants.d.ts +0 -2
  52. package/lib/types/core/src/constants.d.ts.map +0 -1
  53. package/lib/types/core/src/currentScopes.d.ts +0 -55
  54. package/lib/types/core/src/currentScopes.d.ts.map +0 -1
  55. package/lib/types/core/src/debug-build.d.ts.map +0 -1
  56. package/lib/types/core/src/defaultScopes.d.ts +0 -6
  57. package/lib/types/core/src/defaultScopes.d.ts.map +0 -1
  58. package/lib/types/core/src/envelope.d.ts +0 -15
  59. package/lib/types/core/src/envelope.d.ts.map +0 -1
  60. package/lib/types/core/src/metrics/constants.d.ts +0 -19
  61. package/lib/types/core/src/metrics/constants.d.ts.map +0 -1
  62. package/lib/types/core/src/metrics/metric-summary.d.ts +0 -13
  63. package/lib/types/core/src/metrics/metric-summary.d.ts.map +0 -1
  64. package/lib/types/core/src/metrics/types.d.ts +0 -5
  65. package/lib/types/core/src/metrics/types.d.ts.map +0 -1
  66. package/lib/types/core/src/scope.d.ts +0 -211
  67. package/lib/types/core/src/scope.d.ts.map +0 -1
  68. package/lib/types/core/src/semanticAttributes.d.ts +0 -33
  69. package/lib/types/core/src/semanticAttributes.d.ts.map +0 -1
  70. package/lib/types/core/src/session.d.ts +0 -35
  71. package/lib/types/core/src/session.d.ts.map +0 -1
  72. package/lib/types/core/src/tracing/dynamicSamplingContext.d.ts +0 -24
  73. package/lib/types/core/src/tracing/dynamicSamplingContext.d.ts.map +0 -1
  74. package/lib/types/core/src/tracing/logSpans.d.ts +0 -10
  75. package/lib/types/core/src/tracing/logSpans.d.ts.map +0 -1
  76. package/lib/types/core/src/tracing/measurement.d.ts +0 -10
  77. package/lib/types/core/src/tracing/measurement.d.ts.map +0 -1
  78. package/lib/types/core/src/tracing/sampling.d.ts +0 -9
  79. package/lib/types/core/src/tracing/sampling.d.ts.map +0 -1
  80. package/lib/types/core/src/tracing/sentryNonRecordingSpan.d.ts +0 -26
  81. package/lib/types/core/src/tracing/sentryNonRecordingSpan.d.ts.map +0 -1
  82. package/lib/types/core/src/tracing/sentrySpan.d.ts +0 -86
  83. package/lib/types/core/src/tracing/sentrySpan.d.ts.map +0 -1
  84. package/lib/types/core/src/tracing/spanstatus.d.ts +0 -17
  85. package/lib/types/core/src/tracing/spanstatus.d.ts.map +0 -1
  86. package/lib/types/core/src/tracing/trace.d.ts +0 -76
  87. package/lib/types/core/src/tracing/trace.d.ts.map +0 -1
  88. package/lib/types/core/src/tracing/utils.d.ts +0 -13
  89. package/lib/types/core/src/tracing/utils.d.ts.map +0 -1
  90. package/lib/types/core/src/utils/handleCallbackErrors.d.ts +0 -13
  91. package/lib/types/core/src/utils/handleCallbackErrors.d.ts.map +0 -1
  92. package/lib/types/core/src/utils/hasTracingEnabled.d.ts +0 -8
  93. package/lib/types/core/src/utils/hasTracingEnabled.d.ts.map +0 -1
  94. package/lib/types/core/src/utils/parseSampleRate.d.ts +0 -9
  95. package/lib/types/core/src/utils/parseSampleRate.d.ts.map +0 -1
  96. package/lib/types/core/src/utils/spanOnScope.d.ts +0 -17
  97. package/lib/types/core/src/utils/spanOnScope.d.ts.map +0 -1
  98. package/lib/types/core/src/utils/spanUtils.d.ts +0 -74
  99. package/lib/types/core/src/utils/spanUtils.d.ts.map +0 -1
  100. package/lib/types/profiling-node/src/cpu_profiler.d.ts.map +0 -1
  101. package/lib/types/profiling-node/src/debug-build.d.ts +0 -7
  102. package/lib/types/profiling-node/src/debug-build.d.ts.map +0 -1
  103. package/lib/types/profiling-node/src/index.d.ts.map +0 -1
  104. package/lib/types/profiling-node/src/integration.d.ts.map +0 -1
  105. package/lib/types/profiling-node/src/nodeVersion.d.ts.map +0 -1
  106. package/lib/types/profiling-node/src/spanProfileUtils.d.ts.map +0 -1
  107. package/lib/types/profiling-node/src/types.d.ts.map +0 -1
  108. package/lib/types/profiling-node/src/utils.d.ts.map +0 -1
  109. package/lib/types-ts3.8/core/src/asyncContext/index.d.ts +0 -14
  110. package/lib/types-ts3.8/core/src/asyncContext/stackStrategy.d.ts +0 -52
  111. package/lib/types-ts3.8/core/src/asyncContext/types.d.ts +0 -47
  112. package/lib/types-ts3.8/core/src/carrier.d.ts +0 -37
  113. package/lib/types-ts3.8/core/src/constants.d.ts +0 -2
  114. package/lib/types-ts3.8/core/src/currentScopes.d.ts +0 -55
  115. package/lib/types-ts3.8/core/src/defaultScopes.d.ts +0 -6
  116. package/lib/types-ts3.8/core/src/envelope.d.ts +0 -18
  117. package/lib/types-ts3.8/core/src/metrics/constants.d.ts +0 -19
  118. package/lib/types-ts3.8/core/src/metrics/metric-summary.d.ts +0 -13
  119. package/lib/types-ts3.8/core/src/metrics/types.d.ts +0 -5
  120. package/lib/types-ts3.8/core/src/scope.d.ts +0 -211
  121. package/lib/types-ts3.8/core/src/semanticAttributes.d.ts +0 -33
  122. package/lib/types-ts3.8/core/src/session.d.ts +0 -35
  123. package/lib/types-ts3.8/core/src/tracing/dynamicSamplingContext.d.ts +0 -24
  124. package/lib/types-ts3.8/core/src/tracing/logSpans.d.ts +0 -10
  125. package/lib/types-ts3.8/core/src/tracing/measurement.d.ts +0 -10
  126. package/lib/types-ts3.8/core/src/tracing/sampling.d.ts +0 -12
  127. package/lib/types-ts3.8/core/src/tracing/sentryNonRecordingSpan.d.ts +0 -26
  128. package/lib/types-ts3.8/core/src/tracing/sentrySpan.d.ts +0 -86
  129. package/lib/types-ts3.8/core/src/tracing/spanstatus.d.ts +0 -17
  130. package/lib/types-ts3.8/core/src/tracing/trace.d.ts +0 -76
  131. package/lib/types-ts3.8/core/src/tracing/utils.d.ts +0 -13
  132. package/lib/types-ts3.8/core/src/utils/handleCallbackErrors.d.ts +0 -13
  133. package/lib/types-ts3.8/core/src/utils/hasTracingEnabled.d.ts +0 -8
  134. package/lib/types-ts3.8/core/src/utils/parseSampleRate.d.ts +0 -9
  135. package/lib/types-ts3.8/core/src/utils/spanOnScope.d.ts +0 -17
  136. package/lib/types-ts3.8/core/src/utils/spanUtils.d.ts +0 -74
  137. package/lib/types-ts3.8/profiling-node/src/debug-build.d.ts +0 -7
  138. /package/lib/types/{profiling-node/src/cpu_profiler.d.ts → cpu_profiler.d.ts} +0 -0
  139. /package/lib/types/{core/src/debug-build.d.ts → debug-build.d.ts} +0 -0
  140. /package/lib/types/{profiling-node/src/index.d.ts → index.d.ts} +0 -0
  141. /package/lib/types/{profiling-node/src/integration.d.ts → integration.d.ts} +0 -0
  142. /package/lib/types/{profiling-node/src/nodeVersion.d.ts → nodeVersion.d.ts} +0 -0
  143. /package/lib/types/{profiling-node/src/spanProfileUtils.d.ts → spanProfileUtils.d.ts} +0 -0
  144. /package/lib/types/{profiling-node/src/types.d.ts → types.d.ts} +0 -0
  145. /package/lib/types/{profiling-node/src/utils.d.ts → utils.d.ts} +0 -0
  146. /package/lib/types-ts3.8/{profiling-node/src/cpu_profiler.d.ts → cpu_profiler.d.ts} +0 -0
  147. /package/lib/types-ts3.8/{core/src/debug-build.d.ts → debug-build.d.ts} +0 -0
  148. /package/lib/types-ts3.8/{profiling-node/src/index.d.ts → index.d.ts} +0 -0
  149. /package/lib/types-ts3.8/{profiling-node/src/integration.d.ts → integration.d.ts} +0 -0
  150. /package/lib/types-ts3.8/{profiling-node/src/nodeVersion.d.ts → nodeVersion.d.ts} +0 -0
  151. /package/lib/types-ts3.8/{profiling-node/src/spanProfileUtils.d.ts → spanProfileUtils.d.ts} +0 -0
  152. /package/lib/types-ts3.8/{profiling-node/src/types.d.ts → types.d.ts} +0 -0
  153. /package/lib/types-ts3.8/{profiling-node/src/utils.d.ts → utils.d.ts} +0 -0
package/lib/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { _nullishCoalesce, _optionalChain, _optionalChainDelete } from '@sentry/utils';
2
- import { spanIsSampled, spanToJSON, defineIntegration, getRootSpan, getCurrentScope, getIsolationScope } from '@sentry/core';
3
- import { timestampInSeconds, uuid4, addNonEnumerableProperty, generatePropagationContext, isPlainObject, dateTimestampInSeconds, logger, getGlobalSingleton, GLOBAL_OBJ, parseSemver, forEachEnvelopeItem, createEnvelope, dsnToString, LRUMap } from '@sentry/utils';
2
+ import { spanIsSampled, spanToJSON, defineIntegration, getRootSpan, getCurrentScope, getIsolationScope, getGlobalScope } from '@sentry/core';
3
+ import { logger, GLOBAL_OBJ, parseSemver, forEachEnvelopeItem, createEnvelope, uuid4, dsnToString, LRUMap } from '@sentry/utils';
4
4
  import { platform as platform$1, arch as arch$1 } from 'node:os';
5
5
  import { resolve, join } from 'node:path';
6
6
  import { versions, env } from 'node:process';
@@ -19,666 +19,6 @@ import cjsModule from 'node:module';
19
19
  const __filename = cjsUrl.fileURLToPath(import.meta.url);
20
20
  const __dirname = cjsPath.dirname(__filename);
21
21
  const require = cjsModule.createRequire(import.meta.url);
22
- /**
23
- * Updates a session object with the properties passed in the context.
24
- *
25
- * Note that this function mutates the passed object and returns void.
26
- * (Had to do this instead of returning a new and updated session because closing and sending a session
27
- * makes an update to the session after it was passed to the sending logic.
28
- * @see BaseClient.captureSession )
29
- *
30
- * @param session the `Session` to update
31
- * @param context the `SessionContext` holding the properties that should be updated in @param session
32
- */
33
- // eslint-disable-next-line complexity
34
- function updateSession(session, context = {}) {
35
- if (context.user) {
36
- if (!session.ipAddress && context.user.ip_address) {
37
- session.ipAddress = context.user.ip_address;
38
- }
39
-
40
- if (!session.did && !context.did) {
41
- session.did = context.user.id || context.user.email || context.user.username;
42
- }
43
- }
44
-
45
- session.timestamp = context.timestamp || timestampInSeconds();
46
-
47
- if (context.abnormal_mechanism) {
48
- session.abnormal_mechanism = context.abnormal_mechanism;
49
- }
50
-
51
- if (context.ignoreDuration) {
52
- session.ignoreDuration = context.ignoreDuration;
53
- }
54
- if (context.sid) {
55
- // Good enough uuid validation. — Kamil
56
- session.sid = context.sid.length === 32 ? context.sid : uuid4();
57
- }
58
- if (context.init !== undefined) {
59
- session.init = context.init;
60
- }
61
- if (!session.did && context.did) {
62
- session.did = `${context.did}`;
63
- }
64
- if (typeof context.started === 'number') {
65
- session.started = context.started;
66
- }
67
- if (session.ignoreDuration) {
68
- session.duration = undefined;
69
- } else if (typeof context.duration === 'number') {
70
- session.duration = context.duration;
71
- } else {
72
- const duration = session.timestamp - session.started;
73
- session.duration = duration >= 0 ? duration : 0;
74
- }
75
- if (context.release) {
76
- session.release = context.release;
77
- }
78
- if (context.environment) {
79
- session.environment = context.environment;
80
- }
81
- if (!session.ipAddress && context.ipAddress) {
82
- session.ipAddress = context.ipAddress;
83
- }
84
- if (!session.userAgent && context.userAgent) {
85
- session.userAgent = context.userAgent;
86
- }
87
- if (typeof context.errors === 'number') {
88
- session.errors = context.errors;
89
- }
90
- if (context.status) {
91
- session.status = context.status;
92
- }
93
- }
94
-
95
- const SCOPE_SPAN_FIELD = '_sentrySpan';
96
-
97
- /**
98
- * Set the active span for a given scope.
99
- * NOTE: This should NOT be used directly, but is only used internally by the trace methods.
100
- */
101
- function _setSpanForScope(scope, span) {
102
- if (span) {
103
- addNonEnumerableProperty(scope , SCOPE_SPAN_FIELD, span);
104
- } else {
105
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
106
- delete (scope )[SCOPE_SPAN_FIELD];
107
- }
108
- }
109
-
110
- /**
111
- * Get the active span for a given scope.
112
- * NOTE: This should NOT be used directly, but is only used internally by the trace methods.
113
- */
114
- function _getSpanForScope(scope) {
115
- return scope[SCOPE_SPAN_FIELD];
116
- }
117
-
118
- /**
119
- * Default value for maximum number of breadcrumbs added to an event.
120
- */
121
- const DEFAULT_MAX_BREADCRUMBS = 100;
122
-
123
- /**
124
- * Holds additional event information.
125
- */
126
- class ScopeClass {
127
- /** Flag if notifying is happening. */
128
-
129
- /** Callback for client to receive scope changes. */
130
-
131
- /** Callback list that will be called during event processing. */
132
-
133
- /** Array of breadcrumbs. */
134
-
135
- /** User */
136
-
137
- /** Tags */
138
-
139
- /** Extra */
140
-
141
- /** Contexts */
142
-
143
- /** Attachments */
144
-
145
- /** Propagation Context for distributed tracing */
146
-
147
- /**
148
- * A place to stash data which is needed at some point in the SDK's event processing pipeline but which shouldn't get
149
- * sent to Sentry
150
- */
151
-
152
- /** Fingerprint */
153
-
154
- /** Severity */
155
-
156
- /**
157
- * Transaction Name
158
- *
159
- * IMPORTANT: The transaction name on the scope has nothing to do with root spans/transaction objects.
160
- * It's purpose is to assign a transaction to the scope that's added to non-transaction events.
161
- */
162
-
163
- /** Session */
164
-
165
- /** Request Mode Session Status */
166
-
167
- /** The client on this scope */
168
-
169
- /** Contains the last event id of a captured event. */
170
-
171
- // NOTE: Any field which gets added here should get added not only to the constructor but also to the `clone` method.
172
-
173
- constructor() {
174
- this._notifyingListeners = false;
175
- this._scopeListeners = [];
176
- this._eventProcessors = [];
177
- this._breadcrumbs = [];
178
- this._attachments = [];
179
- this._user = {};
180
- this._tags = {};
181
- this._extra = {};
182
- this._contexts = {};
183
- this._sdkProcessingMetadata = {};
184
- this._propagationContext = generatePropagationContext();
185
- }
186
-
187
- /**
188
- * @inheritDoc
189
- */
190
- clone() {
191
- const newScope = new ScopeClass();
192
- newScope._breadcrumbs = [...this._breadcrumbs];
193
- newScope._tags = { ...this._tags };
194
- newScope._extra = { ...this._extra };
195
- newScope._contexts = { ...this._contexts };
196
- newScope._user = this._user;
197
- newScope._level = this._level;
198
- newScope._session = this._session;
199
- newScope._transactionName = this._transactionName;
200
- newScope._fingerprint = this._fingerprint;
201
- newScope._eventProcessors = [...this._eventProcessors];
202
- newScope._requestSession = this._requestSession;
203
- newScope._attachments = [...this._attachments];
204
- newScope._sdkProcessingMetadata = { ...this._sdkProcessingMetadata };
205
- newScope._propagationContext = { ...this._propagationContext };
206
- newScope._client = this._client;
207
- newScope._lastEventId = this._lastEventId;
208
-
209
- _setSpanForScope(newScope, _getSpanForScope(this));
210
-
211
- return newScope;
212
- }
213
-
214
- /**
215
- * @inheritDoc
216
- */
217
- setClient(client) {
218
- this._client = client;
219
- }
220
-
221
- /**
222
- * @inheritDoc
223
- */
224
- setLastEventId(lastEventId) {
225
- this._lastEventId = lastEventId;
226
- }
227
-
228
- /**
229
- * @inheritDoc
230
- */
231
- getClient() {
232
- return this._client ;
233
- }
234
-
235
- /**
236
- * @inheritDoc
237
- */
238
- lastEventId() {
239
- return this._lastEventId;
240
- }
241
-
242
- /**
243
- * @inheritDoc
244
- */
245
- addScopeListener(callback) {
246
- this._scopeListeners.push(callback);
247
- }
248
-
249
- /**
250
- * @inheritDoc
251
- */
252
- addEventProcessor(callback) {
253
- this._eventProcessors.push(callback);
254
- return this;
255
- }
256
-
257
- /**
258
- * @inheritDoc
259
- */
260
- setUser(user) {
261
- // If null is passed we want to unset everything, but still define keys,
262
- // so that later down in the pipeline any existing values are cleared.
263
- this._user = user || {
264
- email: undefined,
265
- id: undefined,
266
- ip_address: undefined,
267
- username: undefined,
268
- };
269
-
270
- if (this._session) {
271
- updateSession(this._session, { user });
272
- }
273
-
274
- this._notifyScopeListeners();
275
- return this;
276
- }
277
-
278
- /**
279
- * @inheritDoc
280
- */
281
- getUser() {
282
- return this._user;
283
- }
284
-
285
- /**
286
- * @inheritDoc
287
- */
288
- getRequestSession() {
289
- return this._requestSession;
290
- }
291
-
292
- /**
293
- * @inheritDoc
294
- */
295
- setRequestSession(requestSession) {
296
- this._requestSession = requestSession;
297
- return this;
298
- }
299
-
300
- /**
301
- * @inheritDoc
302
- */
303
- setTags(tags) {
304
- this._tags = {
305
- ...this._tags,
306
- ...tags,
307
- };
308
- this._notifyScopeListeners();
309
- return this;
310
- }
311
-
312
- /**
313
- * @inheritDoc
314
- */
315
- setTag(key, value) {
316
- this._tags = { ...this._tags, [key]: value };
317
- this._notifyScopeListeners();
318
- return this;
319
- }
320
-
321
- /**
322
- * @inheritDoc
323
- */
324
- setExtras(extras) {
325
- this._extra = {
326
- ...this._extra,
327
- ...extras,
328
- };
329
- this._notifyScopeListeners();
330
- return this;
331
- }
332
-
333
- /**
334
- * @inheritDoc
335
- */
336
- setExtra(key, extra) {
337
- this._extra = { ...this._extra, [key]: extra };
338
- this._notifyScopeListeners();
339
- return this;
340
- }
341
-
342
- /**
343
- * @inheritDoc
344
- */
345
- setFingerprint(fingerprint) {
346
- this._fingerprint = fingerprint;
347
- this._notifyScopeListeners();
348
- return this;
349
- }
350
-
351
- /**
352
- * @inheritDoc
353
- */
354
- setLevel(level) {
355
- this._level = level;
356
- this._notifyScopeListeners();
357
- return this;
358
- }
359
-
360
- /**
361
- * @inheritDoc
362
- */
363
- setTransactionName(name) {
364
- this._transactionName = name;
365
- this._notifyScopeListeners();
366
- return this;
367
- }
368
-
369
- /**
370
- * @inheritDoc
371
- */
372
- setContext(key, context) {
373
- if (context === null) {
374
- // eslint-disable-next-line @typescript-eslint/no-dynamic-delete
375
- delete this._contexts[key];
376
- } else {
377
- this._contexts[key] = context;
378
- }
379
-
380
- this._notifyScopeListeners();
381
- return this;
382
- }
383
-
384
- /**
385
- * @inheritDoc
386
- */
387
- setSession(session) {
388
- if (!session) {
389
- delete this._session;
390
- } else {
391
- this._session = session;
392
- }
393
- this._notifyScopeListeners();
394
- return this;
395
- }
396
-
397
- /**
398
- * @inheritDoc
399
- */
400
- getSession() {
401
- return this._session;
402
- }
403
-
404
- /**
405
- * @inheritDoc
406
- */
407
- update(captureContext) {
408
- if (!captureContext) {
409
- return this;
410
- }
411
-
412
- const scopeToMerge = typeof captureContext === 'function' ? captureContext(this) : captureContext;
413
-
414
- const [scopeInstance, requestSession] =
415
- scopeToMerge instanceof Scope
416
- ? [scopeToMerge.getScopeData(), scopeToMerge.getRequestSession()]
417
- : isPlainObject(scopeToMerge)
418
- ? [captureContext , (captureContext ).requestSession]
419
- : [];
420
-
421
- const { tags, extra, user, contexts, level, fingerprint = [], propagationContext } = scopeInstance || {};
422
-
423
- this._tags = { ...this._tags, ...tags };
424
- this._extra = { ...this._extra, ...extra };
425
- this._contexts = { ...this._contexts, ...contexts };
426
-
427
- if (user && Object.keys(user).length) {
428
- this._user = user;
429
- }
430
-
431
- if (level) {
432
- this._level = level;
433
- }
434
-
435
- if (fingerprint.length) {
436
- this._fingerprint = fingerprint;
437
- }
438
-
439
- if (propagationContext) {
440
- this._propagationContext = propagationContext;
441
- }
442
-
443
- if (requestSession) {
444
- this._requestSession = requestSession;
445
- }
446
-
447
- return this;
448
- }
449
-
450
- /**
451
- * @inheritDoc
452
- */
453
- clear() {
454
- // client is not cleared here on purpose!
455
- this._breadcrumbs = [];
456
- this._tags = {};
457
- this._extra = {};
458
- this._user = {};
459
- this._contexts = {};
460
- this._level = undefined;
461
- this._transactionName = undefined;
462
- this._fingerprint = undefined;
463
- this._requestSession = undefined;
464
- this._session = undefined;
465
- _setSpanForScope(this, undefined);
466
- this._attachments = [];
467
- this._propagationContext = generatePropagationContext();
468
-
469
- this._notifyScopeListeners();
470
- return this;
471
- }
472
-
473
- /**
474
- * @inheritDoc
475
- */
476
- addBreadcrumb(breadcrumb, maxBreadcrumbs) {
477
- const maxCrumbs = typeof maxBreadcrumbs === 'number' ? maxBreadcrumbs : DEFAULT_MAX_BREADCRUMBS;
478
-
479
- // No data has been changed, so don't notify scope listeners
480
- if (maxCrumbs <= 0) {
481
- return this;
482
- }
483
-
484
- const mergedBreadcrumb = {
485
- timestamp: dateTimestampInSeconds(),
486
- ...breadcrumb,
487
- };
488
-
489
- const breadcrumbs = this._breadcrumbs;
490
- breadcrumbs.push(mergedBreadcrumb);
491
- this._breadcrumbs = breadcrumbs.length > maxCrumbs ? breadcrumbs.slice(-maxCrumbs) : breadcrumbs;
492
-
493
- this._notifyScopeListeners();
494
-
495
- return this;
496
- }
497
-
498
- /**
499
- * @inheritDoc
500
- */
501
- getLastBreadcrumb() {
502
- return this._breadcrumbs[this._breadcrumbs.length - 1];
503
- }
504
-
505
- /**
506
- * @inheritDoc
507
- */
508
- clearBreadcrumbs() {
509
- this._breadcrumbs = [];
510
- this._notifyScopeListeners();
511
- return this;
512
- }
513
-
514
- /**
515
- * @inheritDoc
516
- */
517
- addAttachment(attachment) {
518
- this._attachments.push(attachment);
519
- return this;
520
- }
521
-
522
- /**
523
- * @inheritDoc
524
- */
525
- clearAttachments() {
526
- this._attachments = [];
527
- return this;
528
- }
529
-
530
- /** @inheritDoc */
531
- getScopeData() {
532
- return {
533
- breadcrumbs: this._breadcrumbs,
534
- attachments: this._attachments,
535
- contexts: this._contexts,
536
- tags: this._tags,
537
- extra: this._extra,
538
- user: this._user,
539
- level: this._level,
540
- fingerprint: this._fingerprint || [],
541
- eventProcessors: this._eventProcessors,
542
- propagationContext: this._propagationContext,
543
- sdkProcessingMetadata: this._sdkProcessingMetadata,
544
- transactionName: this._transactionName,
545
- span: _getSpanForScope(this),
546
- };
547
- }
548
-
549
- /**
550
- * @inheritDoc
551
- */
552
- setSDKProcessingMetadata(newData) {
553
- this._sdkProcessingMetadata = { ...this._sdkProcessingMetadata, ...newData };
554
-
555
- return this;
556
- }
557
-
558
- /**
559
- * @inheritDoc
560
- */
561
- setPropagationContext(context) {
562
- this._propagationContext = context;
563
- return this;
564
- }
565
-
566
- /**
567
- * @inheritDoc
568
- */
569
- getPropagationContext() {
570
- return this._propagationContext;
571
- }
572
-
573
- /**
574
- * @inheritDoc
575
- */
576
- captureException(exception, hint) {
577
- const eventId = hint && hint.event_id ? hint.event_id : uuid4();
578
-
579
- if (!this._client) {
580
- logger.warn('No client configured on scope - will not capture exception!');
581
- return eventId;
582
- }
583
-
584
- const syntheticException = new Error('Sentry syntheticException');
585
-
586
- this._client.captureException(
587
- exception,
588
- {
589
- originalException: exception,
590
- syntheticException,
591
- ...hint,
592
- event_id: eventId,
593
- },
594
- this,
595
- );
596
-
597
- return eventId;
598
- }
599
-
600
- /**
601
- * @inheritDoc
602
- */
603
- captureMessage(message, level, hint) {
604
- const eventId = hint && hint.event_id ? hint.event_id : uuid4();
605
-
606
- if (!this._client) {
607
- logger.warn('No client configured on scope - will not capture message!');
608
- return eventId;
609
- }
610
-
611
- const syntheticException = new Error(message);
612
-
613
- this._client.captureMessage(
614
- message,
615
- level,
616
- {
617
- originalException: message,
618
- syntheticException,
619
- ...hint,
620
- event_id: eventId,
621
- },
622
- this,
623
- );
624
-
625
- return eventId;
626
- }
627
-
628
- /**
629
- * @inheritDoc
630
- */
631
- captureEvent(event, hint) {
632
- const eventId = hint && hint.event_id ? hint.event_id : uuid4();
633
-
634
- if (!this._client) {
635
- logger.warn('No client configured on scope - will not capture event!');
636
- return eventId;
637
- }
638
-
639
- this._client.captureEvent(event, { ...hint, event_id: eventId }, this);
640
-
641
- return eventId;
642
- }
643
-
644
- /**
645
- * This will be called on every set call.
646
- */
647
- _notifyScopeListeners() {
648
- // We need this check for this._notifyingListeners to be able to work on scope during updates
649
- // If this check is not here we'll produce endless recursion when something is done with the scope
650
- // during the callback.
651
- if (!this._notifyingListeners) {
652
- this._notifyingListeners = true;
653
- this._scopeListeners.forEach(callback => {
654
- callback(this);
655
- });
656
- this._notifyingListeners = false;
657
- }
658
- }
659
- }
660
-
661
- // NOTE: By exporting this here as const & type, instead of doing `export class`,
662
- // We can get the correct class when importing from `@sentry/core`, but the original type (from `@sentry/types`)
663
- // This is helpful for interop, e.g. when doing `import type { Scope } from '@sentry/node';` (which re-exports this)
664
-
665
- /**
666
- * Holds additional event information.
667
- */
668
- const Scope = ScopeClass;
669
-
670
- /**
671
- * Holds additional event information.
672
- */
673
-
674
- /**
675
- * Get the global scope.
676
- * This scope is applied to _all_ events.
677
- */
678
- function getGlobalScope() {
679
- return getGlobalSingleton('globalScope', () => new Scope());
680
- }
681
-
682
22
  /**
683
23
  * This serves as a build time flag that will be true by default, but false in non-debug builds or if users replace `__SENTRY_DEBUG__` in their generated code.
684
24
  *