Skip to content

Commit f9b294d

Browse files
committed
ref: Envelope deserialization to Swift (#6186)
* ref: Envelope deserialization to Swift * PR feedback
1 parent 856fffe commit f9b294d

26 files changed

+288
-320
lines changed

Sentry.xcodeproj/project.pbxproj

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,6 @@
347347
7B05A61824A4D14A00EF211D /* SentrySessionGeneratorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B05A61724A4D14A00EF211D /* SentrySessionGeneratorTests.swift */; };
348348
7B08A3452924CF6C0059603A /* SentryMetricKitIntegration.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B08A3442924CF6C0059603A /* SentryMetricKitIntegration.h */; };
349349
7B08A3472924CF9C0059603A /* SentryMetricKitIntegration.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B08A3462924CF9C0059603A /* SentryMetricKitIntegration.m */; };
350-
7B0A54222521C21E00A71716 /* SentryFrameRemover.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B0A54212521C21E00A71716 /* SentryFrameRemover.h */; };
351-
7B0A54282521C22C00A71716 /* SentryFrameRemover.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B0A54272521C22C00A71716 /* SentryFrameRemover.m */; };
352350
7B0A542E2521C62400A71716 /* SentryFrameRemoverTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B0A542D2521C62400A71716 /* SentryFrameRemoverTests.swift */; };
353351
7B0A5452252311CE00A71716 /* SentryBreadcrumbTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B0A5451252311CE00A71716 /* SentryBreadcrumbTests.swift */; };
354352
7B0A54562523178700A71716 /* SentryScopeSwiftTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B0A54552523178700A71716 /* SentryScopeSwiftTests.swift */; };
@@ -1119,10 +1117,11 @@
11191117
FACEED132E3179A10007B4AC /* SentyOptionsInternal.m in Sources */ = {isa = PBXBuildFile; fileRef = FACEED122E3179A10007B4AC /* SentyOptionsInternal.m */; };
11201118
FAE2DAB82E1F317900262307 /* SentryProfilingSwiftHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = FAE2DAB72E1F317900262307 /* SentryProfilingSwiftHelpers.m */; };
11211119
FAE2DABA2E1F318900262307 /* SentryProfilingSwiftHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE2DAB92E1F318900262307 /* SentryProfilingSwiftHelpers.h */; };
1120+
FAE579CC2E7DE14900B710F9 /* SentryFrameRemover.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE579C62E7DE14400B710F9 /* SentryFrameRemover.swift */; };
11221121
FAE80C242E4695B40010A595 /* SentryEvent+Serialize.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE80C232E4695AE0010A595 /* SentryEvent+Serialize.h */; };
11231122
FAEC270E2DF3526000878871 /* SentryUserFeedback.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAEC270D2DF3526000878871 /* SentryUserFeedback.swift */; };
11241123
FAEC273D2DF3933A00878871 /* NSData+Unzip.m in Sources */ = {isa = PBXBuildFile; fileRef = FAEC273C2DF3933200878871 /* NSData+Unzip.m */; };
1125-
FAEEC0522E75E55F00E79CA9 /* DataDeserialization.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAEEC04C2E75E55A00E79CA9 /* DataDeserialization.swift */; };
1124+
FAEEC0522E75E55F00E79CA9 /* SentrySerializationSwift.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAEEC04C2E75E55A00E79CA9 /* SentrySerializationSwift.swift */; };
11261125
FAEFA12F2E4FAE1900C431D9 /* SentrySDKSettings.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAEFA1292E4FAE1700C431D9 /* SentrySDKSettings.swift */; };
11271126
FAF120182E70C08F006E1DA3 /* SentryEnvelopeHeaderHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = FAF120122E70C088006E1DA3 /* SentryEnvelopeHeaderHelper.h */; };
11281127
FAF1201A2E70C0EE006E1DA3 /* SentryEnvelopeHeaderHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = FAF120192E70C0EA006E1DA3 /* SentryEnvelopeHeaderHelper.m */; };
@@ -1599,8 +1598,6 @@
15991598
7B05A61724A4D14A00EF211D /* SentrySessionGeneratorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySessionGeneratorTests.swift; sourceTree = "<group>"; };
16001599
7B08A3442924CF6C0059603A /* SentryMetricKitIntegration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryMetricKitIntegration.h; path = include/SentryMetricKitIntegration.h; sourceTree = "<group>"; };
16011600
7B08A3462924CF9C0059603A /* SentryMetricKitIntegration.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryMetricKitIntegration.m; sourceTree = "<group>"; };
1602-
7B0A54212521C21E00A71716 /* SentryFrameRemover.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryFrameRemover.h; path = include/SentryFrameRemover.h; sourceTree = "<group>"; };
1603-
7B0A54272521C22C00A71716 /* SentryFrameRemover.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryFrameRemover.m; sourceTree = "<group>"; };
16041601
7B0A542D2521C62400A71716 /* SentryFrameRemoverTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryFrameRemoverTests.swift; sourceTree = "<group>"; };
16051602
7B0A5451252311CE00A71716 /* SentryBreadcrumbTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryBreadcrumbTests.swift; sourceTree = "<group>"; };
16061603
7B0A54552523178700A71716 /* SentryScopeSwiftTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryScopeSwiftTests.swift; sourceTree = "<group>"; };
@@ -2466,11 +2463,12 @@
24662463
FACEED122E3179A10007B4AC /* SentyOptionsInternal.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentyOptionsInternal.m; sourceTree = "<group>"; };
24672464
FAE2DAB72E1F317900262307 /* SentryProfilingSwiftHelpers.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryProfilingSwiftHelpers.m; sourceTree = "<group>"; };
24682465
FAE2DAB92E1F318900262307 /* SentryProfilingSwiftHelpers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryProfilingSwiftHelpers.h; path = Sources/Sentry/include/SentryProfilingSwiftHelpers.h; sourceTree = SOURCE_ROOT; };
2466+
FAE579C62E7DE14400B710F9 /* SentryFrameRemover.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryFrameRemover.swift; sourceTree = "<group>"; };
24692467
FAE80C232E4695AE0010A595 /* SentryEvent+Serialize.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "SentryEvent+Serialize.h"; path = "include/SentryEvent+Serialize.h"; sourceTree = "<group>"; };
24702468
FAEC270D2DF3526000878871 /* SentryUserFeedback.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUserFeedback.swift; sourceTree = "<group>"; };
24712469
FAEC273C2DF3933200878871 /* NSData+Unzip.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSData+Unzip.m"; sourceTree = "<group>"; };
24722470
FAEC273E2DF393E000878871 /* NSData+Unzip.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSData+Unzip.h"; sourceTree = "<group>"; };
2473-
FAEEC04C2E75E55A00E79CA9 /* DataDeserialization.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataDeserialization.swift; sourceTree = "<group>"; };
2471+
FAEEC04C2E75E55A00E79CA9 /* SentrySerializationSwift.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySerializationSwift.swift; sourceTree = "<group>"; };
24742472
FAEFA1292E4FAE1700C431D9 /* SentrySDKSettings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySDKSettings.swift; sourceTree = "<group>"; };
24752473
FAF120122E70C088006E1DA3 /* SentryEnvelopeHeaderHelper.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryEnvelopeHeaderHelper.h; path = include/SentryEnvelopeHeaderHelper.h; sourceTree = "<group>"; };
24762474
FAF120192E70C0EA006E1DA3 /* SentryEnvelopeHeaderHelper.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryEnvelopeHeaderHelper.m; sourceTree = "<group>"; };
@@ -2606,7 +2604,7 @@
26062604
isa = PBXGroup;
26072605
children = (
26082606
62CB19242E77F8FD00AF5DA2 /* SentryDispatchSourceWrapper.swift */,
2609-
FAEEC04C2E75E55A00E79CA9 /* DataDeserialization.swift */,
2607+
FAEEC04C2E75E55A00E79CA9 /* SentrySerializationSwift.swift */,
26102608
FA94E71B2E6F26BF00576666 /* SentrySerialization+ReplayRecording.swift */,
26112609
FA94E7232E6F32FA00576666 /* SentryEnvelopeItemType.swift */,
26122610
FA458CBD2E691A6E0061B13D /* SentryProcessInfo.swift */,
@@ -2841,8 +2839,6 @@
28412839
7BA61CC9247D128B00C130A8 /* SentryThreadInspector.m */,
28422840
7B7D872B2486480B00D2ECFF /* SentryStacktraceBuilder.h */,
28432841
7B7D872D2486482600D2ECFF /* SentryStacktraceBuilder.m */,
2844-
7B0A54212521C21E00A71716 /* SentryFrameRemover.h */,
2845-
7B0A54272521C22C00A71716 /* SentryFrameRemover.m */,
28462842
7B14089524878F090035403D /* SentryCrashStackEntryMapper.h */,
28472843
7B14089724878F950035403D /* SentryCrashStackEntryMapper.m */,
28482844
7B7D873124864BB900D2ECFF /* SentryCrashMachineContextWrapper.h */,
@@ -4753,6 +4749,7 @@
47534749
F4FE9E062E6248BB0014FED5 /* SentryCrash */ = {
47544750
isa = PBXGroup;
47554751
children = (
4752+
FAE579C62E7DE14400B710F9 /* SentryFrameRemover.swift */,
47564753
F4FE9E072E6248E40014FED5 /* SentryCrashWrapper.swift */,
47574754
);
47584755
path = SentryCrash;
@@ -4951,7 +4948,6 @@
49514948
63FE717D20DA4C1100CDBAE8 /* SentryCrashCachedData.h in Headers */,
49524949
03BCC38A27E1BF49003232C7 /* SentryTime.h in Headers */,
49534950
925824C22CB5897700C9B20B /* SentrySessionReplayIntegration-Hybrid.h in Headers */,
4954-
7B0A54222521C21E00A71716 /* SentryFrameRemover.h in Headers */,
49554951
63FE70CD20DA4C1000CDBAE8 /* SentryCrashDoctor.h in Headers */,
49564952
7B6438AA26A70F24000D0F65 /* UIViewController+Sentry.h in Headers */,
49574953
33EB2A912C3412E4004FED3D /* SentryWithoutUIKit.h in Headers */,
@@ -5583,7 +5579,7 @@
55835579
FA90FAA82E06614E008CAAE8 /* SentryExtraPackages.swift in Sources */,
55845580
7BD86ED1264A7CF6005439DB /* SentryAppStartMeasurement.m in Sources */,
55855581
7DC27EC723997EB7006998B5 /* SentryAutoBreadcrumbTrackingIntegration.m in Sources */,
5586-
FAEEC0522E75E55F00E79CA9 /* DataDeserialization.swift in Sources */,
5582+
FAEEC0522E75E55F00E79CA9 /* SentrySerializationSwift.swift in Sources */,
55875583
D84D2CDF2C2BF9370011AF8A /* SentryReplayType.swift in Sources */,
55885584
63FE717B20DA4C1100CDBAE8 /* SentryCrashReport.c in Sources */,
55895585
D8F67B222BEAB6CC00C9197B /* SentryRRWebEvent.swift in Sources */,
@@ -5691,6 +5687,7 @@
56915687
63FE711D20DA4C1000CDBAE8 /* SentryCrashCPU_arm64.c in Sources */,
56925688
844EDC77294144DB00C86F34 /* SentrySystemWrapper.mm in Sources */,
56935689
D451ED5F2D92ECDE00C9BEA8 /* SentryReplayFrame.swift in Sources */,
5690+
FAE579CC2E7DE14900B710F9 /* SentryFrameRemover.swift in Sources */,
56945691
FA94E71C2E6F26C500576666 /* SentrySerialization+ReplayRecording.swift in Sources */,
56955692
D49480D72DC23FE300A3B6E9 /* SentrySessionReplayDelegate.swift in Sources */,
56965693
FA67DCC12DDBD4C800896B02 /* SentrySDKLog+Configure.swift in Sources */,
@@ -5755,7 +5752,6 @@
57555752
63FE70D520DA4C1000CDBAE8 /* SentryCrashMonitor_NSException.m in Sources */,
57565753
62F70E952D423BCD00634054 /* SentryMechanismCodable.swift in Sources */,
57575754
0AAE201E28ED9B9400D0CD80 /* SentryReachability.m in Sources */,
5758-
7B0A54282521C22C00A71716 /* SentryFrameRemover.m in Sources */,
57595755
6283085F2D50AA8C00EAEF77 /* SentryMessage.swift in Sources */,
57605756
7BC63F0A28081288009D9E37 /* SentrySwizzleWrapper.m in Sources */,
57615757
6276350C2D59FACC00F7CEF6 /* SentryEventDecoder.swift in Sources */,

Sources/Sentry/PrivateSentrySDKOnly.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ + (void)captureEnvelope:(SentryEnvelope *)envelope
5050

5151
+ (nullable SentryEnvelope *)envelopeWithData:(NSData *)data
5252
{
53-
return [SentrySerialization envelopeWithData:data];
53+
return [SentrySerializationSwift envelopeWithData:data];
5454
}
5555

5656
#if !SDK_V9

Sources/Sentry/Public/SentryEnvelopeItemHeader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ SENTRY_NO_INIT
3131

3232
- (instancetype)initWithType:(NSString *)type
3333
length:(NSUInteger)length
34-
contentType:(NSString *)contentType
34+
contentType:(NSString *_Nullable)contentType
3535
itemCount:(NSNumber *)itemCount;
3636

3737
/**

Sources/Sentry/SentryAttachment.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ - (instancetype)initWithPath:(NSString *)path
8888
}
8989

9090
SentryAttachmentType
91-
typeForSentryAttachmentName(NSString *name)
91+
typeForSentryAttachmentName(NSString *_Nullable name)
9292
{
9393
if ([name isEqualToString:kSentryAttachmentTypeNameViewHierarchy]) {
9494
return kSentryAttachmentTypeViewHierarchy;

Sources/Sentry/SentryFileManager.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -974,7 +974,7 @@ - (nullable SentrySession *)readSession:(NSString *)sessionFilePath
974974
return nil;
975975
}
976976
}
977-
SentrySession *currentSession = [DataDeserialization sessionWithData:currentData];
977+
SentrySession *currentSession = [SentrySerializationSwift sessionWithData:currentData];
978978
if (nil == currentSession) {
979979
SENTRY_LOG_ERROR(
980980
@"Data stored in session: '%@' was not parsed as session.", sessionFilePath);
@@ -993,7 +993,7 @@ - (SentryAppState *_Nullable)readAppStateFrom:(NSString *)path
993993
SENTRY_LOG_WARN(@"No app state data found at %@", path);
994994
return nil;
995995
}
996-
return [DataDeserialization appStateWithData:currentData];
996+
return [SentrySerializationSwift appStateWithData:currentData];
997997
}
998998

999999
- (void)deleteAppStateFrom:(NSString *)path
@@ -1073,7 +1073,7 @@ - (void)handleEnvelopesLimit
10731073
[envelopePathsCopy removeObjectAtIndex:i];
10741074

10751075
NSData *envelopeData = [[NSFileManager defaultManager] contentsAtPath:envelopeFilePath];
1076-
SentryEnvelope *envelope = [SentrySerialization envelopeWithData:envelopeData];
1076+
SentryEnvelope *envelope = [SentrySerializationSwift envelopeWithData:envelopeData];
10771077

10781078
BOOL didMigrateSessionInit =
10791079
[SentryMigrateSessionInit migrateSessionInit:envelope

Sources/Sentry/SentryFrameRemover.m

Lines changed: 0 additions & 23 deletions
This file was deleted.

Sources/Sentry/SentryHttpTransport.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ - (void)sendAllCachedEnvelopes
339339

340340
envelopeFilePath = envelopeFileContents.path;
341341

342-
envelope = [SentrySerialization envelopeWithData:envelopeFileContents.contents];
342+
envelope = [SentrySerializationSwift envelopeWithData:envelopeFileContents.contents];
343343
if (nil == envelope) {
344344
SENTRY_LOG_DEBUG(@"Envelope contained no deserializable data.");
345345
[self deleteEnvelopeAndSendNext:envelopeFilePath];

Sources/Sentry/SentryMigrateSessionInit.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ + (BOOL)migrateSessionInit:(nullable SentryEnvelope *)envelope
2424
@"Could not migrate session init, because the envelope item has no data.");
2525
continue;
2626
}
27-
SentrySession *session = [DataDeserialization sessionWithData:data];
27+
SentrySession *session = [SentrySerializationSwift sessionWithData:data];
2828
if (nil != session && [session.flagInit boolValue]) {
2929
BOOL didSetInitFlag =
3030
[self setInitFlagOnNextEnvelopeWithSameSessionId:session
@@ -56,7 +56,7 @@ + (BOOL)setInitFlagOnNextEnvelopeWithSameSessionId:(SentrySession *)session
5656
continue;
5757
}
5858

59-
SentryEnvelope *envelope = [SentrySerialization envelopeWithData:envelopeData];
59+
SentryEnvelope *envelope = [SentrySerializationSwift envelopeWithData:envelopeData];
6060

6161
if (nil != envelope) {
6262
BOOL didSetInitFlag = [self setInitFlagIfContainsSameSessionId:session.sessionId
@@ -84,7 +84,7 @@ + (BOOL)setInitFlagIfContainsSameSessionId:(NSUUID *)sessionId
8484
@"Could not migrate session init, because the envelope item has no data.");
8585
continue;
8686
}
87-
SentrySession *localSession = [DataDeserialization sessionWithData:data];
87+
SentrySession *localSession = [SentrySerializationSwift sessionWithData:data];
8888

8989
if (nil != localSession && [localSession.sessionId isEqual:sessionId]) {
9090
[localSession setFlagInit];

0 commit comments

Comments
 (0)