Skip to content

Commit 2b7a00f

Browse files
authored
fix(core): Export new transport methods (#4778)
- Export types and methods for new transports in core package - Add logic for cleaning up event and adding SDK details to `createEventEnvelope`. This is duplicating code, but considering we are going to refactor this in v7, we can take the temporary bundle size hit.
1 parent c80152d commit 2b7a00f

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

packages/core/src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ export { BackendClass, BaseBackend } from './basebackend';
2929
export { eventToSentryRequest, sessionToSentryRequest } from './request';
3030
export { initAndBind, ClientClass } from './sdk';
3131
export { NoopTransport } from './transports/noop';
32+
export {
33+
BaseTransportOptions,
34+
createTransport,
35+
NewTransport,
36+
TransportMakeRequestResponse,
37+
TransportRequest,
38+
} from './transports/base';
3239
export { SDK_VERSION } from './version';
3340

3441
import * as Integrations from './integrations';

packages/core/src/request.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,35 @@ export function createEventEnvelope(event: Event, api: APIDetails): EventEnvelop
8282
const { transactionSampling } = event.sdkProcessingMetadata || {};
8383
const { method: samplingMethod, rate: sampleRate } = transactionSampling || {};
8484

85+
// TODO: Below is a temporary hack in order to debug a serialization error - see
86+
// https://github.com/getsentry/sentry-javascript/issues/2809,
87+
// https://github.com/getsentry/sentry-javascript/pull/4425, and
88+
// https://github.com/getsentry/sentry-javascript/pull/4574.
89+
//
90+
// TL; DR: even though we normalize all events (which should prevent this), something is causing `JSON.stringify` to
91+
// throw a circular reference error.
92+
//
93+
// When it's time to remove it:
94+
// 1. Delete everything between here and where the request object `req` is created, EXCEPT the line deleting
95+
// `sdkProcessingMetadata`
96+
// 2. Restore the original version of the request body, which is commented out
97+
// 3. Search for either of the PR URLs above and pull out the companion hacks in the browser playwright tests and the
98+
// baseClient tests in this package
99+
enhanceEventWithSdkInfo(event, api.metadata.sdk);
100+
event.tags = event.tags || {};
101+
event.extra = event.extra || {};
102+
103+
// In theory, all events should be marked as having gone through normalization and so
104+
// we should never set this tag/extra data
105+
if (!(event.sdkProcessingMetadata && event.sdkProcessingMetadata.baseClientNormalized)) {
106+
event.tags.skippedNormalization = true;
107+
event.extra.normalizeDepth = event.sdkProcessingMetadata ? event.sdkProcessingMetadata.normalizeDepth : 'unset';
108+
}
109+
110+
// prevent this data from being sent to sentry
111+
// TODO: This is NOT part of the hack - DO NOT DELETE
112+
delete event.sdkProcessingMetadata;
113+
85114
const envelopeHeaders = {
86115
event_id: event.event_id as string,
87116
sent_at: new Date().toISOString(),

0 commit comments

Comments
 (0)