diff --git a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m index a5aa18533a..b33cbdecc9 100644 --- a/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m +++ b/packages/core/RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryTests.m @@ -94,20 +94,16 @@ - (void)prepareNativeFrameMocksWithLocalSymbolication:(BOOL)debug OCMStub([sentryBinaryImageCacheMock imageByAddress:[@456 unsignedLongLongValue]]) .andReturn(sentryBinaryImageInfoMockTwo); - NSDictionary *serializedDebugImage = @{ - @"uuid" : @"mockuuid", - @"debug_id" : @"mockdebugid", - @"type" : @"macho", - @"image_addr" : @"0x000000000001b669", - }; - id sentryDebugImageMock = OCMClassMock([SentryDebugMeta class]); - OCMStub([sentryDebugImageMock serialize]).andReturn(serializedDebugImage); + SentryDebugMeta *sentryDebugImage = [[SentryDebugMeta alloc] init]; + sentryDebugImage.debugID = @"mockdebugid"; + sentryDebugImage.type = @"macho"; + sentryDebugImage.imageAddress = @"0x000000000001b669"; id sentryDebugImageProviderMock = OCMClassMock([SentryDebugImageProvider class]); OCMStub( [sentryDebugImageProviderMock getDebugImagesForImageAddressesFromCache:[NSSet setWithObject:@"0x000000000001b669"]]) - .andReturn(@[ sentryDebugImageMock ]); + .andReturn(@[ sentryDebugImage ]); OCMStub([sentryDependencyContainerMock debugImageProvider]) .andReturn(sentryDebugImageProviderMock); @@ -123,7 +119,6 @@ - (void)testFetchNativeStackFramesByInstructionsServerSymbolication NSDictionary *expected = @{ @"debugMetaImages" : @[ @{ - @"uuid" : @"mockuuid", @"debug_id" : @"mockdebugid", @"type" : @"macho", @"image_addr" : @"0x000000000001b669", diff --git a/packages/core/ios/RNSentry+fetchNativeStack.m b/packages/core/ios/RNSentry+fetchNativeStack.m index 6e67f563df..cede3bf30e 100644 --- a/packages/core/ios/RNSentry+fetchNativeStack.m +++ b/packages/core/ios/RNSentry+fetchNativeStack.m @@ -2,6 +2,7 @@ #import "RNSentryBreadcrumb.h" #import "RNSentryHexFormatter.h" #import "RNSentryId.h" +#import "RNSentrySwiftBridge.h" #import "SentrySDKWrapper.h" @import Sentry; @@ -75,7 +76,7 @@ - (NSDictionary *)fetchNativeStackFramesBy:(NSArray *)instructionsAd getDebugImagesForImageAddressesFromCache:imagesAddrToRetrieveDebugMetaImages]; for (SentryDebugMeta *debugImage in debugMetaImages) { - [serializedDebugMetaImages addObject:[debugImage serialize]]; + [serializedDebugMetaImages addObject:[RNSentryInternal serializeDebugMeta:debugImage]]; } return @{ diff --git a/packages/core/ios/RNSentry.mm b/packages/core/ios/RNSentry.mm index 56398156d9..0e11ece5ae 100644 --- a/packages/core/ios/RNSentry.mm +++ b/packages/core/ios/RNSentry.mm @@ -444,7 +444,7 @@ - (void)handleShakeDetected [SentrySDKWrapper configureScope:^(SentryScope *_Nonnull scope) { // Serialize to get contexts dictionary - NSDictionary *serializedScope = [scope serialize]; + NSDictionary *serializedScope = [RNSentryInternalWrapper serializeScope:scope]; NSDictionary *allContexts = serializedScope[@"context"]; // It's singular here, annoyingly NSMutableDictionary *contexts = [NSMutableDictionary new]; @@ -496,7 +496,7 @@ - (void)handleShakeDetected } __block NSMutableDictionary *serializedScope; [SentrySDKWrapper configureScope:^(SentryScope *_Nonnull scope) { - serializedScope = [[scope serialize] mutableCopy]; + serializedScope = [[RNSentryInternalWrapper serializeScope:scope] mutableCopy]; NSDictionary *user = [serializedScope valueForKey:@"user"]; if (user == nil) { diff --git a/packages/core/ios/RNSentryInternalWrapper.h b/packages/core/ios/RNSentryInternalWrapper.h index a05121c3d8..9bb94c3c82 100644 --- a/packages/core/ios/RNSentryInternalWrapper.h +++ b/packages/core/ios/RNSentryInternalWrapper.h @@ -2,6 +2,7 @@ @class SentryEnvelope; @class SentryId; +@class SentryScope; NS_ASSUME_NONNULL_BEGIN @@ -40,6 +41,10 @@ NS_ASSUME_NONNULL_BEGIN @property (class, readonly) BOOL isFramesTrackingRunning; +// MARK: - Serialization + ++ (NSDictionary *)serializeScope:(SentryScope *)scope; + // MARK: - Envelopes + (nullable SentryEnvelope *)envelopeFromData:(nullable NSData *)data; diff --git a/packages/core/ios/RNSentryInternalWrapper.m b/packages/core/ios/RNSentryInternalWrapper.m index 0ffde0639d..d1b40c0714 100644 --- a/packages/core/ios/RNSentryInternalWrapper.m +++ b/packages/core/ios/RNSentryInternalWrapper.m @@ -44,6 +44,13 @@ + (BOOL)isFramesTrackingRunning return RNSentryInternal.isFramesTrackingRunning; } +// MARK: - Serialization + ++ (NSDictionary *)serializeScope:(SentryScope *)scope +{ + return [RNSentryInternal serializeScope:scope]; +} + // MARK: - Envelopes + (SentryEnvelope *)envelopeFromData:(NSData *)data diff --git a/packages/core/ios/Swift/RNSentryInternal.swift b/packages/core/ios/Swift/RNSentryInternal.swift index 51a0fc4f4d..f8a4750321 100644 --- a/packages/core/ios/Swift/RNSentryInternal.swift +++ b/packages/core/ios/Swift/RNSentryInternal.swift @@ -95,6 +95,16 @@ import Foundation // stub on macOS/watchOS. #endif + // MARK: - Serialization + + @_spi(Private) @objc public static func serializeScope(_ scope: Scope) -> [String: Any] { + SentrySDK.internal.serializer.serialize(scope: scope) + } + + @_spi(Private) @objc public static func serializeDebugMeta(_ debugMeta: DebugMeta) -> [String: Any] { + SentrySDK.internal.serializer.serialize(debugMeta: debugMeta) + } + // MARK: - Envelope // Accepts `Data?` (nil-safe) rather than `Data` so the ObjC bridge boundary