Skip to content

Commit 11523b9

Browse files
committed
some adjustments
1 parent dd30aad commit 11523b9

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

packages/core/src/utils/baggage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function baggageHeaderToDynamicSamplingContext(
3333

3434
// Read all "sentry-" prefixed values out of the baggage object and put it onto a dynamic sampling context object.
3535
const dynamicSamplingContext = Object.entries(baggageObject).reduce<Record<string, string>>((acc, [key, value]) => {
36-
if (key.startsWith(SENTRY_BAGGAGE_KEY_PREFIX)) {
36+
if (key.match(SENTRY_BAGGAGE_KEY_PREFIX)) {
3737
const nonPrefixedKey = key.slice(SENTRY_BAGGAGE_KEY_PREFIX.length);
3838
acc[nonPrefixedKey] = value;
3939
}

packages/core/src/utils/envelope.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,11 @@ export function createAttachmentEnvelopeItem(attachment: Attachment): Attachment
204204
];
205205
}
206206

207+
type OverriddenItemType = Exclude<EnvelopeItemType, DataCategory>;
208+
207209
// Map of envelope item types to data categories where the category differs from the type.
208210
// Types that map to themselves (session, attachment, transaction, profile, feedback, span, metric) fall through.
209-
const DATA_CATEGORY_OVERRIDES: Partial<Record<string, DataCategory>> = {
211+
const DATA_CATEGORY_OVERRIDES: Record<OverriddenItemType, DataCategory> = {
210212
sessions: 'session',
211213
event: 'error',
212214
client_report: 'internal',
@@ -220,11 +222,15 @@ const DATA_CATEGORY_OVERRIDES: Partial<Record<string, DataCategory>> = {
220222
trace_metric: 'metric',
221223
};
222224

225+
function _isOverriddenType(type: EnvelopeItemType): type is OverriddenItemType {
226+
return type in DATA_CATEGORY_OVERRIDES;
227+
}
228+
223229
/**
224230
* Maps the type of an envelope item to a data category.
225231
*/
226232
export function envelopeItemTypeToDataCategory(type: EnvelopeItemType): DataCategory {
227-
return DATA_CATEGORY_OVERRIDES[type] || (type as DataCategory);
233+
return _isOverriddenType(type) ? DATA_CATEGORY_OVERRIDES[type] : type;
228234
}
229235

230236
/** Extracts the minimal SDK info from the metadata or an events */

packages/core/src/utils/object.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export function fill(source: { [key: string]: any }, name: string, replacementFa
5555
export function addNonEnumerableProperty(obj: object, name: string, value: unknown): void {
5656
try {
5757
Object.defineProperty(obj, name, {
58+
// enumerable: false, // the default, so we can save on bundle size by not explicitly setting it
5859
value,
5960
writable: true,
6061
configurable: true,

0 commit comments

Comments
 (0)