Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9cfe4c7
add TextEncoder and TextDecoder to jsdom test environment
lobsterkatie Aug 18, 2021
37b4944
add TransactionMetadata to DebugMeta type
lobsterkatie Aug 18, 2021
2ec4722
add segment to user type
lobsterkatie Aug 18, 2021
f9ba96c
add TraceHeaders and SpanContext.getTraceHeaders() to types
lobsterkatie Aug 18, 2021
bbf472d
add base64 string functions
lobsterkatie Aug 18, 2021
9474a4e
fix circular dependency
lobsterkatie Aug 19, 2021
6728b26
move setting default environment to SDK initialization rather than ev…
lobsterkatie Aug 18, 2021
0af6717
remove unused traceHeaders function
lobsterkatie Aug 18, 2021
5e57193
polyfill Object.fromEntries for tracing tests
lobsterkatie Aug 18, 2021
5d53567
s/TRACEPARENT_REGEXP/SENTRY_TRACE_REGEX
lobsterkatie Aug 18, 2021
2a50338
s/extractTraceparentData/extractSentrytraceData
lobsterkatie Aug 18, 2021
54ac0d6
s/traceparent/sentrytrace in various spots
lobsterkatie Aug 19, 2021
58eeda9
add functions for computing tracestate and combined tracing headers
lobsterkatie Aug 19, 2021
a758e16
add tracestate header to outgoing requests
lobsterkatie Aug 19, 2021
a007a83
deprecate toTraceparent
lobsterkatie Aug 19, 2021
1a4336e
add extractTracestateData() function
lobsterkatie Aug 19, 2021
fcb41b3
make transactions accept metadata in their incoming transaction context
lobsterkatie Aug 19, 2021
f0f7ed6
propagate incoming tracestate headers
lobsterkatie Aug 19, 2021
9ab5a8f
extract and propagate tracestate data from <meta> tags
lobsterkatie Aug 19, 2021
08d9ba4
add missing tracestate when capturing transaction, if necessary
lobsterkatie Aug 19, 2021
5c6070e
only deal with envelope header data if we're using an envelope
lobsterkatie Aug 19, 2021
50819b6
add tracestate to envelope header
lobsterkatie Aug 19, 2021
756e855
clean up comments
lobsterkatie Aug 19, 2021
a0b5caf
add http header tests
lobsterkatie Aug 19, 2021
f1a0dbf
random cleanup
lobsterkatie Aug 19, 2021
6415a5a
don't stringify event data until the end
lobsterkatie Aug 19, 2021
15a2e85
rework and add request tests
lobsterkatie Aug 19, 2021
dd76840
remove redundant string test, add browser test for non-base64 string
lobsterkatie Aug 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
only deal with envelope header data if we're using an envelope
  • Loading branch information
lobsterkatie committed Aug 23, 2021
commit 5c6070e0245402c6dc2955aeb220f372d80a0193
33 changes: 19 additions & 14 deletions packages/core/src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,6 @@ export function eventToSentryRequest(event: Event, api: API): SentryRequest {
const eventType = event.type || 'event';
const useEnvelope = eventType === 'transaction' || api.forceEnvelope();

const { transactionSampling, ...metadata } = event.debug_meta || {};
const { method: samplingMethod, rate: sampleRate } = transactionSampling || {};
if (Object.keys(metadata).length === 0) {
delete event.debug_meta;
} else {
event.debug_meta = metadata;
}

const req: SentryRequest = {
body: JSON.stringify(sdkInfo ? enhanceEventWithSdkInfo(event, api.metadata.sdk) : event),
type: eventType,
Expand All @@ -75,18 +67,23 @@ export function eventToSentryRequest(event: Event, api: API): SentryRequest {
// deserialization. Instead, we only implement a minimal subset of the spec to
// serialize events inline here.
if (useEnvelope) {
// Extract header information from event
const { transactionSampling, ...metadata } = event.debug_meta || {};
if (Object.keys(metadata).length === 0) {
delete event.debug_meta;
} else {
event.debug_meta = metadata;
}

const envelopeHeaders = JSON.stringify({
event_id: event.event_id,
sent_at: new Date().toISOString(),
...(sdkInfo && { sdk: sdkInfo }),
...(api.forceEnvelope() && { dsn: api.getDsn().toString() }),
});
const itemHeaders = JSON.stringify({
type: eventType,

// TODO: Right now, sampleRate may or may not be defined (it won't be in the cases of inheritance and
// explicitly-set sampling decisions). Are we good with that?
sample_rates: [{ id: samplingMethod, rate: sampleRate }],
const itemHeaderEntries: { [key: string]: unknown } = {
type: eventType,

// The content-type is assumed to be 'application/json' and not part of
// the current spec for transaction items, so we don't bloat the request
Expand All @@ -101,7 +98,15 @@ export function eventToSentryRequest(event: Event, api: API): SentryRequest {
// size and to reduce request body size.
//
// length: new TextEncoder().encode(req.body).length,
});
};

if (eventType === 'transaction') {
// TODO: Right now, `sampleRate` will be undefined in the cases of inheritance and explicitly-set sampling decisions.
itemHeaderEntries.sample_rates = [{ id: transactionSampling?.method, rate: transactionSampling?.rate }];
}

const itemHeaders = JSON.stringify(itemHeaderEntries);

// The trailing newline is optional. We intentionally don't send it to avoid
// sending unnecessary bytes.
//
Expand Down