From 8386d9644f2def7fb7948d9d53d12da4a0a1503b Mon Sep 17 00:00:00 2001 From: Alexander Pantiukhov Date: Thu, 4 Dec 2025 16:17:05 +0100 Subject: [PATCH 1/4] feat(metrics): A fix for metrics --- packages/core/src/js/index.ts | 3 ++- packages/core/src/js/wrapper.ts | 7 +++---- samples/react-native/src/Screens/ErrorsScreen.tsx | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/core/src/js/index.ts b/packages/core/src/js/index.ts index d43df01c5f..6d251cad10 100644 --- a/packages/core/src/js/index.ts +++ b/packages/core/src/js/index.ts @@ -13,6 +13,7 @@ export type { UserFeedback, ErrorEvent, TransactionEvent, + Metric, } from '@sentry/core'; export { @@ -46,7 +47,6 @@ export { setCurrentClient, addEventProcessor, lastEventId, - metrics, } from '@sentry/core'; export { @@ -63,6 +63,7 @@ export { consoleLoggingIntegration, featureFlagsIntegration, type FeatureFlagsIntegration, + metrics, } from '@sentry/browser'; export * from './integrations/exports'; diff --git a/packages/core/src/js/wrapper.ts b/packages/core/src/js/wrapper.ts index 3ac01e6498..7752e2fe96 100644 --- a/packages/core/src/js/wrapper.ts +++ b/packages/core/src/js/wrapper.ts @@ -182,17 +182,16 @@ export const NATIVE: SentryNativeWrapper = { for (const rawItem of envelopeItems) { const [itemHeader, itemPayload] = this._processItem(rawItem); - let bytesContentType: string; + let bytesContentType: string = + typeof itemHeader.content_type === 'string' ? itemHeader.content_type : 'application/octet-stream'; let bytesPayload: number[] | Uint8Array | undefined; + if (typeof itemPayload === 'string') { bytesContentType = 'text/plain'; bytesPayload = encodeUTF8(itemPayload); } else if (itemPayload instanceof Uint8Array) { - bytesContentType = - typeof itemHeader.content_type === 'string' ? itemHeader.content_type : 'application/octet-stream'; bytesPayload = itemPayload; } else { - bytesContentType = 'application/vnd.sentry.items.log+json'; bytesPayload = encodeUTF8(JSON.stringify(itemPayload)); if (!hardCrashed) { hardCrashed = isHardCrash(itemPayload); diff --git a/samples/react-native/src/Screens/ErrorsScreen.tsx b/samples/react-native/src/Screens/ErrorsScreen.tsx index 62682038a3..a03022a351 100644 --- a/samples/react-native/src/Screens/ErrorsScreen.tsx +++ b/samples/react-native/src/Screens/ErrorsScreen.tsx @@ -127,9 +127,9 @@ const ErrorsScreen = (_props: Props) => { }} />