@sentry/profiling-node 8.54.0 → 9.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +2 -3
  3. package/lib/cjs/index.js +45 -260
  4. package/lib/cjs/index.js.map +1 -1
  5. package/lib/esm/index.js +46 -255
  6. package/lib/esm/index.js.map +1 -1
  7. package/lib/esm/package.json +1 -1
  8. package/lib/types/integration.d.ts.map +1 -1
  9. package/lib/types/spanProfileUtils.d.ts.map +1 -1
  10. package/lib/types/utils.d.ts.map +1 -1
  11. package/package.json +13 -32
  12. package/binding.gyp +0 -20
  13. package/bindings/cpu_profiler.cc +0 -1226
  14. package/lib/sentry_cpu_profiler-darwin-arm64-108.node +0 -0
  15. package/lib/sentry_cpu_profiler-darwin-arm64-115.node +0 -0
  16. package/lib/sentry_cpu_profiler-darwin-arm64-127.node +0 -0
  17. package/lib/sentry_cpu_profiler-darwin-arm64-93.node +0 -0
  18. package/lib/sentry_cpu_profiler-darwin-x64-108.node +0 -0
  19. package/lib/sentry_cpu_profiler-darwin-x64-115.node +0 -0
  20. package/lib/sentry_cpu_profiler-darwin-x64-127.node +0 -0
  21. package/lib/sentry_cpu_profiler-darwin-x64-93.node +0 -0
  22. package/lib/sentry_cpu_profiler-linux-arm64-glibc-108.node +0 -0
  23. package/lib/sentry_cpu_profiler-linux-arm64-glibc-115.node +0 -0
  24. package/lib/sentry_cpu_profiler-linux-arm64-glibc-127.node +0 -0
  25. package/lib/sentry_cpu_profiler-linux-arm64-glibc-93.node +0 -0
  26. package/lib/sentry_cpu_profiler-linux-arm64-musl-108.node +0 -0
  27. package/lib/sentry_cpu_profiler-linux-arm64-musl-115.node +0 -0
  28. package/lib/sentry_cpu_profiler-linux-arm64-musl-127.node +0 -0
  29. package/lib/sentry_cpu_profiler-linux-arm64-musl-93.node +0 -0
  30. package/lib/sentry_cpu_profiler-linux-x64-glibc-108.node +0 -0
  31. package/lib/sentry_cpu_profiler-linux-x64-glibc-115.node +0 -0
  32. package/lib/sentry_cpu_profiler-linux-x64-glibc-127.node +0 -0
  33. package/lib/sentry_cpu_profiler-linux-x64-glibc-93.node +0 -0
  34. package/lib/sentry_cpu_profiler-linux-x64-musl-108.node +0 -0
  35. package/lib/sentry_cpu_profiler-linux-x64-musl-115.node +0 -0
  36. package/lib/sentry_cpu_profiler-linux-x64-musl-127.node +0 -0
  37. package/lib/sentry_cpu_profiler-linux-x64-musl-93.node +0 -0
  38. package/lib/sentry_cpu_profiler-win32-x64-108.node +0 -0
  39. package/lib/sentry_cpu_profiler-win32-x64-115.node +0 -0
  40. package/lib/sentry_cpu_profiler-win32-x64-127.node +0 -0
  41. package/lib/sentry_cpu_profiler-win32-x64-93.node +0 -0
  42. package/lib/types/cpu_profiler.d.ts +0 -16
  43. package/lib/types/cpu_profiler.d.ts.map +0 -1
  44. package/lib/types-ts3.8/cpu_profiler.d.ts +0 -16
  45. package/scripts/binaries.js +0 -27
  46. package/scripts/check-build.js +0 -56
  47. package/scripts/copy-target.js +0 -27
package/lib/esm/index.js CHANGED
@@ -1,16 +1,8 @@
1
- import { _nullishCoalesce, _optionalChain, _optionalChainDelete } from '@sentry/core';
2
- import { logger, GLOBAL_OBJ, parseSemver, forEachEnvelopeItem, createEnvelope, getDebugImagesForResources, uuid4, dsnToString, spanIsSampled, spanToJSON, LRUMap, defineIntegration, consoleSandbox, getRootSpan, getIsolationScope, getCurrentScope, getGlobalScope } from '@sentry/core';
3
- import { createRequire } from 'node:module';
4
- import { platform as platform$1, arch as arch$1 } from 'node:os';
5
- import { dirname, join, resolve } from 'node:path';
6
- import { versions, env } from 'node:process';
7
- import { pathToFileURL, fileURLToPath } from 'node:url';
8
- import { threadId } from 'node:worker_threads';
9
- import { familySync } from 'detect-libc';
10
- import { getAbi } from 'node-abi';
1
+ import { CpuProfilerBindings } from '@sentry-internal/node-cpu-profiler';
2
+ import { parseSemver, logger, forEachEnvelopeItem, createEnvelope, getDebugImagesForResources, uuid4, dsnToString, spanIsSampled, spanToJSON, LRUMap, defineIntegration, consoleSandbox, getRootSpan, getIsolationScope, getCurrentScope, getGlobalScope } from '@sentry/core';
11
3
  import * as os from 'os';
12
- import { versions as versions$1, env as env$1 } from 'process';
13
- import { threadId as threadId$1, isMainThread } from 'worker_threads';
4
+ import { versions, env } from 'process';
5
+ import { threadId, isMainThread } from 'worker_threads';
14
6
 
15
7
  /**
16
8
  * 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.
@@ -19,225 +11,22 @@ import { threadId as threadId$1, isMainThread } from 'worker_threads';
19
11
  */
20
12
  const DEBUG_BUILD = (typeof __SENTRY_DEBUG__ === 'undefined' || __SENTRY_DEBUG__);
21
13
 
22
- const stdlib = familySync();
23
- const platform = process.env['BUILD_PLATFORM'] || platform$1();
24
- const arch = process.env['BUILD_ARCH'] || arch$1();
25
- const abi = getAbi(versions.node, 'node');
26
- const identifier = [platform, arch, stdlib, abi].filter(c => c !== undefined && c !== null).join('-');
27
-
28
- /**
29
- * Imports cpp bindings based on the current platform and architecture.
30
- */
31
- // eslint-disable-next-line complexity
32
- function importCppBindingsModule() {
33
- // We need to work around using import.meta.url directly with import.meta.url because jest complains about it.
34
- const importMetaUrl =
35
- typeof import.meta.url !== 'undefined'
36
- ? // This case is always hit when the SDK is built
37
- import.meta.url
38
- : // This case is hit when the tests are run
39
- pathToFileURL(__filename).href;
40
-
41
- const createdRequire = createRequire(importMetaUrl);
42
- const esmCompatibleDirname = dirname(fileURLToPath(importMetaUrl));
43
-
44
- // If a binary path is specified, use that.
45
- if (env['SENTRY_PROFILER_BINARY_PATH']) {
46
- const envPath = env['SENTRY_PROFILER_BINARY_PATH'];
47
- return createdRequire(envPath);
48
- }
49
-
50
- // If a user specifies a different binary dir, they are in control of the binaries being moved there
51
- if (env['SENTRY_PROFILER_BINARY_DIR']) {
52
- const binaryPath = join(resolve(env['SENTRY_PROFILER_BINARY_DIR']), `sentry_cpu_profiler-${identifier}`);
53
- return createdRequire(`${binaryPath}.node`);
54
- }
55
-
56
- // We need the fallthrough so that in the end, we can fallback to the dynamic require.
57
- // This is for cases where precompiled binaries were not provided, but may have been compiled from source.
58
- if (platform === 'darwin') {
59
- if (arch === 'x64') {
60
- if (abi === '93') {
61
- return createdRequire('../sentry_cpu_profiler-darwin-x64-93.node');
62
- }
63
- if (abi === '108') {
64
- return createdRequire('../sentry_cpu_profiler-darwin-x64-108.node');
65
- }
66
- if (abi === '115') {
67
- return createdRequire('../sentry_cpu_profiler-darwin-x64-115.node');
68
- }
69
- if (abi === '127') {
70
- return createdRequire('../sentry_cpu_profiler-darwin-x64-127.node');
71
- }
72
- }
73
-
74
- if (arch === 'arm64') {
75
- if (abi === '93') {
76
- return createdRequire('../sentry_cpu_profiler-darwin-arm64-93.node');
77
- }
78
- if (abi === '108') {
79
- return createdRequire('../sentry_cpu_profiler-darwin-arm64-108.node');
80
- }
81
- if (abi === '115') {
82
- return createdRequire('../sentry_cpu_profiler-darwin-arm64-115.node');
83
- }
84
- if (abi === '127') {
85
- return createdRequire('../sentry_cpu_profiler-darwin-arm64-127.node');
86
- }
87
- }
88
- }
89
-
90
- if (platform === 'win32') {
91
- if (arch === 'x64') {
92
- if (abi === '93') {
93
- return createdRequire('../sentry_cpu_profiler-win32-x64-93.node');
94
- }
95
- if (abi === '108') {
96
- return createdRequire('../sentry_cpu_profiler-win32-x64-108.node');
97
- }
98
- if (abi === '115') {
99
- return createdRequire('../sentry_cpu_profiler-win32-x64-115.node');
100
- }
101
- if (abi === '127') {
102
- return createdRequire('../sentry_cpu_profiler-win32-x64-127.node');
103
- }
104
- }
105
- }
106
-
107
- if (platform === 'linux') {
108
- if (arch === 'x64') {
109
- if (stdlib === 'musl') {
110
- if (abi === '93') {
111
- return createdRequire('../sentry_cpu_profiler-linux-x64-musl-93.node');
112
- }
113
- if (abi === '108') {
114
- return createdRequire('../sentry_cpu_profiler-linux-x64-musl-108.node');
115
- }
116
- if (abi === '115') {
117
- return createdRequire('../sentry_cpu_profiler-linux-x64-musl-115.node');
118
- }
119
- if (abi === '127') {
120
- return createdRequire('../sentry_cpu_profiler-linux-x64-musl-127.node');
121
- }
122
- }
123
- if (stdlib === 'glibc') {
124
- if (abi === '93') {
125
- return createdRequire('../sentry_cpu_profiler-linux-x64-glibc-93.node');
126
- }
127
- if (abi === '108') {
128
- return createdRequire('../sentry_cpu_profiler-linux-x64-glibc-108.node');
129
- }
130
- if (abi === '115') {
131
- return createdRequire('../sentry_cpu_profiler-linux-x64-glibc-115.node');
132
- }
133
- if (abi === '127') {
134
- return createdRequire('../sentry_cpu_profiler-linux-x64-glibc-127.node');
135
- }
136
- }
137
- }
138
- if (arch === 'arm64') {
139
- if (stdlib === 'musl') {
140
- if (abi === '93') {
141
- return createdRequire('../sentry_cpu_profiler-linux-arm64-musl-93.node');
142
- }
143
- if (abi === '108') {
144
- return createdRequire('../sentry_cpu_profiler-linux-arm64-musl-108.node');
145
- }
146
- if (abi === '115') {
147
- return createdRequire('../sentry_cpu_profiler-linux-arm64-musl-115.node');
148
- }
149
- if (abi === '127') {
150
- return createdRequire('../sentry_cpu_profiler-linux-arm64-musl-127.node');
151
- }
152
- }
153
-
154
- if (stdlib === 'glibc') {
155
- if (abi === '93') {
156
- return createdRequire('../sentry_cpu_profiler-linux-arm64-glibc-93.node');
157
- }
158
- if (abi === '108') {
159
- return createdRequire('../sentry_cpu_profiler-linux-arm64-glibc-108.node');
160
- }
161
- if (abi === '115') {
162
- return createdRequire('../sentry_cpu_profiler-linux-arm64-glibc-115.node');
163
- }
164
- if (abi === '127') {
165
- return createdRequire('../sentry_cpu_profiler-linux-arm64-glibc-127.node');
166
- }
167
- }
168
- }
169
- }
170
-
171
- const built_from_source_path = resolve(esmCompatibleDirname, '..', `sentry_cpu_profiler-${identifier}`);
172
- return createdRequire(`${built_from_source_path}.node`);
173
- }
174
-
175
- const PrivateCpuProfilerBindings = importCppBindingsModule();
176
-
177
- class Bindings {
178
- startProfiling(name) {
179
- if (!PrivateCpuProfilerBindings) {
180
- DEBUG_BUILD && logger.log('[Profiling] Bindings not loaded, ignoring call to startProfiling.');
181
- return;
182
- }
183
-
184
- if (typeof PrivateCpuProfilerBindings.startProfiling !== 'function') {
185
- DEBUG_BUILD &&
186
- logger.log('[Profiling] Native startProfiling function is not available, ignoring call to startProfiling.');
187
- return;
188
- }
189
-
190
- return PrivateCpuProfilerBindings.startProfiling(name);
191
- }
192
-
193
- stopProfiling(
194
- name,
195
- format,
196
- ) {
197
- if (!PrivateCpuProfilerBindings) {
198
- DEBUG_BUILD &&
199
- logger.log('[Profiling] Bindings not loaded or profile was never started, ignoring call to stopProfiling.');
200
- return null;
201
- }
202
-
203
- if (typeof PrivateCpuProfilerBindings.stopProfiling !== 'function') {
204
- DEBUG_BUILD &&
205
- logger.log('[Profiling] Native stopProfiling function is not available, ignoring call to stopProfiling.');
206
- return null;
207
- }
208
-
209
- return PrivateCpuProfilerBindings.stopProfiling(
210
- name,
211
- format ,
212
- threadId,
213
- !!GLOBAL_OBJ._sentryDebugIds,
214
- );
215
- }
216
- }
217
-
218
- const CpuProfilerBindings = new Bindings();
219
-
220
14
  const NODE_VERSION = parseSemver(process.versions.node) ;
221
15
  const NODE_MAJOR = NODE_VERSION.major;
222
16
 
223
- function _nullishCoalesce$1(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }function _optionalChain$1(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
224
17
  // We require the file because if we import it, it will be included in the bundle.
225
18
  // I guess tsc does not check file contents when it's imported.
226
- const PROFILER_THREAD_ID_STRING = String(threadId$1);
19
+ const PROFILER_THREAD_ID_STRING = String(threadId);
227
20
  const PROFILER_THREAD_NAME = isMainThread ? 'main' : 'worker';
228
21
  const FORMAT_VERSION = '1';
229
22
  const CONTINUOUS_FORMAT_VERSION = '2';
230
23
 
231
- // Os machine was backported to 16.18, but this was not reflected in the types
232
- // @ts-expect-error ignore missing
233
- const machine = typeof os.machine === 'function' ? os.machine() : os.arch();
234
-
235
24
  // Machine properties (eval only once)
236
25
  const PLATFORM = os.platform();
237
26
  const RELEASE = os.release();
238
27
  const VERSION = os.version();
239
28
  const TYPE = os.type();
240
- const MODEL = machine;
29
+ const MODEL = os.machine();
241
30
  const ARCH = os.arch();
242
31
 
243
32
  /**
@@ -289,12 +78,12 @@ function createProfilingEvent(client, profile, event) {
289
78
  }
290
79
 
291
80
  return createProfilePayload(client, profile, {
292
- release: _nullishCoalesce$1(event.release, () => ( '')),
293
- environment: _nullishCoalesce$1(event.environment, () => ( '')),
294
- event_id: _nullishCoalesce$1(event.event_id, () => ( '')),
295
- transaction: _nullishCoalesce$1(event.transaction, () => ( '')),
81
+ release: event.release ?? '',
82
+ environment: event.environment ?? '',
83
+ event_id: event.event_id ?? '',
84
+ transaction: event.transaction ?? '',
296
85
  start_timestamp: event.start_timestamp ? event.start_timestamp * 1000 : Date.now(),
297
- trace_id: _nullishCoalesce$1(_optionalChain$1([event, 'access', _ => _.contexts, 'optionalAccess', _2 => _2['trace'], 'optionalAccess', _3 => _3['trace_id']]), () => ( '')),
86
+ trace_id: event.contexts?.trace?.trace_id ?? '',
298
87
  profile_id: profile.profile_id,
299
88
  });
300
89
  }
@@ -323,7 +112,7 @@ function createProfilePayload(
323
112
  // Log a warning if the profile has an invalid traceId (should be uuidv4).
324
113
  // All profiles and transactions are rejected if this is the case and we want to
325
114
  // warn users that this is happening if they enable debug flag
326
- if (trace_id && trace_id.length !== 32) {
115
+ if (trace_id?.length !== 32) {
327
116
  DEBUG_BUILD && logger.log(`[Profiling] Invalid traceId: ${trace_id} on profiled event`);
328
117
  }
329
118
 
@@ -339,7 +128,7 @@ function createProfilePayload(
339
128
  measurements: cpuProfile.measurements,
340
129
  runtime: {
341
130
  name: 'node',
342
- version: versions$1.node || '',
131
+ version: versions.node || '',
343
132
  },
344
133
  os: {
345
134
  name: PLATFORM,
@@ -347,7 +136,7 @@ function createProfilePayload(
347
136
  build_number: VERSION,
348
137
  },
349
138
  device: {
350
- locale: env$1['LC_ALL'] || env$1['LC_MESSAGES'] || env$1['LANG'] || env$1['LANGUAGE'] || '',
139
+ locale: env['LC_ALL'] || env['LC_MESSAGES'] || env['LANG'] || env['LANGUAGE'] || '',
351
140
  model: MODEL,
352
141
  manufacturer: TYPE,
353
142
  architecture: ARCH,
@@ -391,7 +180,7 @@ function createProfileChunkPayload(
391
180
  // Log a warning if the profile has an invalid traceId (should be uuidv4).
392
181
  // All profiles and transactions are rejected if this is the case and we want to
393
182
  // warn users that this is happening if they enable debug flag
394
- if (trace_id && trace_id.length !== 32) {
183
+ if (trace_id?.length !== 32) {
395
184
  DEBUG_BUILD && logger.log(`[Profiling] Invalid traceId: ${trace_id} on profiled event`);
396
185
  }
397
186
 
@@ -400,8 +189,8 @@ function createProfileChunkPayload(
400
189
  const profile = {
401
190
  chunk_id: chunk_id,
402
191
  client_sdk: {
403
- name: _nullishCoalesce$1(_optionalChain$1([sdk, 'optionalAccess', _4 => _4.name]), () => ( 'sentry.javascript.node')),
404
- version: _nullishCoalesce$1(_optionalChain$1([sdk, 'optionalAccess', _5 => _5.version]), () => ( '0.0.0')),
192
+ name: sdk?.name ?? 'sentry.javascript.node',
193
+ version: sdk?.version ?? '0.0.0',
405
194
  },
406
195
  profiler_id: profiler_id,
407
196
  platform: 'node',
@@ -433,9 +222,9 @@ function createProfilingChunkEvent(
433
222
  }
434
223
 
435
224
  return createProfileChunkPayload(client, profile, {
436
- release: _nullishCoalesce$1(options.release, () => ( '')),
437
- environment: _nullishCoalesce$1(options.environment, () => ( '')),
438
- trace_id: _nullishCoalesce$1(identifiers.trace_id, () => ( '')),
225
+ release: options.release ?? '',
226
+ environment: options.environment ?? '',
227
+ trace_id: identifiers.trace_id ?? '',
439
228
  chunk_id: identifiers.chunk_id,
440
229
  profiler_id: identifiers.profiler_id,
441
230
  sdk,
@@ -545,18 +334,17 @@ function findProfiledTransactionsFromEnvelope(envelope) {
545
334
 
546
335
  // First item is the type, so we can skip it, everything else is an event
547
336
  for (let j = 1; j < item.length; j++) {
548
- const event = item[j];
337
+ const event = item[j] ;
549
338
 
550
339
  if (!event) {
551
340
  // Shouldn't happen, but lets be safe
552
341
  continue;
553
342
  }
554
343
 
555
- // @ts-expect-error profile_id is not part of the metadata type
556
- const profile_id = _optionalChain$1([(event.contexts ), 'optionalAccess', _6 => _6['profile'], 'optionalAccess', _7 => _7['profile_id']]);
344
+ const profile_id = event.contexts?.profile?.profile_id;
557
345
 
558
346
  if (event && profile_id) {
559
- events.push(item[j] );
347
+ events.push(event);
560
348
  }
561
349
  }
562
350
  });
@@ -607,7 +395,7 @@ function makeProfileChunkEnvelope(
607
395
  function applyDebugMetadata(client, resource_paths) {
608
396
  const options = client.getOptions();
609
397
 
610
- if (!options || !options.stackParser) {
398
+ if (!options?.stackParser) {
611
399
  return [];
612
400
  }
613
401
 
@@ -656,10 +444,6 @@ function maybeProfileSpan(
656
444
  profilesSampleRate = profilesSampler({
657
445
  name: spanName,
658
446
  attributes: data,
659
- transactionContext: {
660
- name: spanName,
661
- parentSampled,
662
- },
663
447
  parentSampled,
664
448
  ...customSamplingContext,
665
449
  });
@@ -738,11 +522,14 @@ function stopSpanProfile(span, profile_id) {
738
522
  return profile;
739
523
  }
740
524
 
741
- var ProfileFormat;(function (ProfileFormat) {
525
+ var ProfileFormat; (function (ProfileFormat) {
742
526
  const THREAD = 0; ProfileFormat[ProfileFormat["THREAD"] = THREAD] = "THREAD";
743
527
  const CHUNK = 1; ProfileFormat[ProfileFormat["CHUNK"] = CHUNK] = "CHUNK";
744
528
  })(ProfileFormat || (ProfileFormat = {}));
745
529
 
530
+ /* eslint-disable max-lines */
531
+
532
+
746
533
  const CHUNK_INTERVAL_MS = 5000;
747
534
  const PROFILE_MAP = new LRUMap(50);
748
535
  const PROFILE_TIMEOUTS = {};
@@ -775,8 +562,7 @@ function setupAutomatedSpanProfiling(client) {
775
562
  const options = client.getOptions();
776
563
  // Not intended for external use, hence missing types, but we want to profile a couple of things at Sentry that
777
564
  // currently exceed the default timeout set by the SDKs.
778
- const maxProfileDurationMs =
779
- (options._experiments && options._experiments['maxProfileDurationMs']) || MAX_PROFILE_DURATION_MS;
565
+ const maxProfileDurationMs = options._experiments?.maxProfileDurationMs || MAX_PROFILE_DURATION_MS;
780
566
 
781
567
  if (PROFILE_TIMEOUTS[profile_id]) {
782
568
  global.clearTimeout(PROFILE_TIMEOUTS[profile_id]);
@@ -834,8 +620,8 @@ function setupAutomatedSpanProfiling(client) {
834
620
  const profilesToAddToEnvelope = [];
835
621
 
836
622
  for (const profiledTransaction of profiledTransactionEvents) {
837
- const profileContext = _optionalChain([profiledTransaction, 'access', _ => _.contexts, 'optionalAccess', _2 => _2['profile']]);
838
- const profile_id = _optionalChain([profileContext, 'optionalAccess', _3 => _3['profile_id']]);
623
+ const profileContext = profiledTransaction.contexts?.profile;
624
+ const profile_id = profileContext?.profile_id;
839
625
 
840
626
  if (!profile_id) {
841
627
  throw new TypeError('[Profiling] cannot find profile for a transaction without a profile context');
@@ -843,7 +629,7 @@ function setupAutomatedSpanProfiling(client) {
843
629
 
844
630
  // Remove the profile from the transaction context before sending, relay will take care of the rest.
845
631
  if (profileContext) {
846
- _optionalChainDelete([profiledTransaction, 'access', _4 => _4.contexts, 'optionalAccess', _5 => delete _5['profile']]);
632
+ delete profiledTransaction.contexts?.profile;
847
633
  }
848
634
 
849
635
  const cpuProfile = takeFromProfileQueue(profile_id);
@@ -861,6 +647,11 @@ function setupAutomatedSpanProfiling(client) {
861
647
  client.emit('preprocessEvent', profile, {
862
648
  event_id: profiledTransaction.event_id,
863
649
  });
650
+
651
+ // @ts-expect-error profile does not inherit from Event
652
+ client.emit('postprocessEvent', profile, {
653
+ event_id: profiledTransaction.event_id,
654
+ });
864
655
  }
865
656
 
866
657
  addProfilesToEnvelope(envelope, profilesToAddToEnvelope);
@@ -943,7 +734,7 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
943
734
  * Stops profiling of the current chunks and flushes the profile to Sentry
944
735
  */
945
736
  _chunkStop() {
946
- if (_optionalChain([this, 'access', _6 => _6._chunkData, 'optionalAccess', _7 => _7.timer])) {
737
+ if (this._chunkData?.timer) {
947
738
  global.clearTimeout(this._chunkData.timer);
948
739
  this._chunkData.timer = undefined;
949
740
  DEBUG_BUILD && logger.log(`[Profiling] Stopping profiling chunk: ${this._chunkData.id}`);
@@ -953,9 +744,9 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
953
744
  logger.log('[Profiling] Failed to collect profile, sentry client was never attached to the profiler.');
954
745
  return;
955
746
  }
956
- if (!_optionalChain([this, 'access', _8 => _8._chunkData, 'optionalAccess', _9 => _9.id])) {
747
+ if (!this._chunkData?.id) {
957
748
  DEBUG_BUILD &&
958
- logger.log(`[Profiling] Failed to collect profile for: ${_optionalChain([this, 'access', _10 => _10._chunkData, 'optionalAccess', _11 => _11.id])}, the chunk_id is missing.`);
749
+ logger.log(`[Profiling] Failed to collect profile for: ${this._chunkData?.id}, the chunk_id is missing.`);
959
750
  return;
960
751
  }
961
752
 
@@ -979,7 +770,7 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
979
770
  this._client,
980
771
  this._client.getOptions(),
981
772
  profile,
982
- _optionalChain([this, 'access', _12 => _12._client, 'access', _13 => _13.getSdkMetadata, 'call', _14 => _14(), 'optionalAccess', _15 => _15.sdk]),
773
+ this._client.getSdkMetadata()?.sdk,
983
774
  {
984
775
  chunk_id: this._chunkData.id,
985
776
  trace_id: this._chunkData.startTraceID,
@@ -1022,7 +813,7 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
1022
813
  const metadata = this._client.getSdkMetadata();
1023
814
  const tunnel = this._client.getOptions().tunnel;
1024
815
 
1025
- const envelope = makeProfileChunkEnvelope(chunk, _optionalChain([metadata, 'optionalAccess', _16 => _16.sdk]), tunnel, dsn);
816
+ const envelope = makeProfileChunkEnvelope(chunk, metadata?.sdk, tunnel, dsn);
1026
817
  transport.send(envelope).then(null, reason => {
1027
818
  DEBUG_BUILD && logger.error('Error while sending profile chunk envelope:', reason);
1028
819
  });
@@ -1103,7 +894,7 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
1103
894
  * Assigns thread_id and thread name context to a profiled event.
1104
895
  */
1105
896
  _assignThreadIdContext(event) {
1106
- if (!_optionalChain([event, 'optionalAccess', _17 => _17['contexts'], 'optionalAccess', _18 => _18['profile']])) {
897
+ if (!event?.contexts?.profile) {
1107
898
  return;
1108
899
  }
1109
900
 
@@ -1113,10 +904,10 @@ class ContinuousProfiler {constructor() { ContinuousProfiler.prototype.__init.ca
1113
904
 
1114
905
  // @ts-expect-error the trace fallback value is wrong, though it should never happen
1115
906
  // and in case it does, we dont want to override whatever was passed initially.
1116
- event.contexts['trace'] = {
1117
- ...(_nullishCoalesce(_optionalChain([event, 'access', _19 => _19.contexts, 'optionalAccess', _20 => _20['trace']]), () => ( {}))),
907
+ event.contexts.trace = {
908
+ ...(event.contexts?.trace ?? {}),
1118
909
  data: {
1119
- ...(_nullishCoalesce(_optionalChain([event, 'access', _21 => _21.contexts, 'optionalAccess', _22 => _22['trace'], 'optionalAccess', _23 => _23['data']]), () => ( {}))),
910
+ ...(event.contexts?.trace?.data ?? {}),
1120
911
  ['thread.id']: PROFILER_THREAD_ID_STRING,
1121
912
  ['thread.name']: PROFILER_THREAD_NAME,
1122
913
  },