Skip to content

Commit b845030

Browse files
committed
use processEvent instead of beforeSendEvent
1 parent 918237e commit b845030

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

.size-limit.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ module.exports = [
4545
path: 'packages/browser/build/npm/esm/index.js',
4646
import: createImport('init', 'browserTracingIntegration', 'browserProfilingIntegration'),
4747
gzip: true,
48-
limit: '80 KB',
48+
limit: '48 KB',
4949
},
5050
{
5151
name: '@sentry/browser (incl. Tracing, Replay)',

packages/browser/src/profiling/integration.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ const INTEGRATION_NAME = 'BrowserProfiling';
2424
const _browserProfilingIntegration = (() => {
2525
return {
2626
name: INTEGRATION_NAME,
27-
// eslint-disable-next-line complexity
2827
setup(client) {
2928
const options = client.getOptions() as BrowserOptions;
3029

@@ -83,9 +82,6 @@ const _browserProfilingIntegration = (() => {
8382
}
8483
}, 0);
8584
}
86-
87-
// Adding client hook to attach profiles to transaction events before they are sent.
88-
client.on('beforeSendEvent', attachProfiledThreadToEvent);
8985
} else {
9086
// LEGACY PROFILING (v1)
9187
if (rootSpan && isAutomatedPageLoadSpan(rootSpan)) {
@@ -154,6 +150,9 @@ const _browserProfilingIntegration = (() => {
154150
});
155151
}
156152
},
153+
processEvent(event) {
154+
return attachProfiledThreadToEvent(event);
155+
},
157156
};
158157
}) satisfies IntegrationFn;
159158

packages/browser/src/profiling/utils.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -783,13 +783,13 @@ export function addProfileToGlobalCache(profile_id: string, profile: JSSelfProfi
783783
/**
784784
* Attaches the profiled thread information to the event's trace context.
785785
*/
786-
export function attachProfiledThreadToEvent(event: Event): void {
786+
export function attachProfiledThreadToEvent(event: Event): Event {
787787
if (!event?.contexts?.profile) {
788-
return;
788+
return event;
789789
}
790790

791791
if (!event.contexts) {
792-
return;
792+
return event;
793793
}
794794

795795
// @ts-expect-error the trace fallback value is wrong, though it should never happen
@@ -811,4 +811,6 @@ export function attachProfiledThreadToEvent(event: Event): void {
811811
['thread.name']: PROFILER_THREAD_NAME,
812812
};
813813
});
814+
815+
return event;
814816
}

0 commit comments

Comments
 (0)