Skip to content

Commit 4a7a005

Browse files
authored
ref: Convert global event processor swift (#6221)
1 parent a024df0 commit 4a7a005

File tree

9 files changed

+35
-78
lines changed

9 files changed

+35
-78
lines changed

Sentry.xcodeproj/project.pbxproj

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,7 @@
589589
7D0FCFB22379B915004DD83A /* SentryHub.h in Headers */ = {isa = PBXBuildFile; fileRef = 7D0FCFB02379B915004DD83A /* SentryHub.h */; settings = {ATTRIBUTES = (Public, ); }; };
590590
7D5C441C237C2E1F00DAB0A3 /* SentryHub.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D5C4419237C2E1F00DAB0A3 /* SentryHub.m */; };
591591
7D65260E237F649E00113EA2 /* SentryScope.m in Sources */ = {isa = PBXBuildFile; fileRef = 7D65260B237F649E00113EA2 /* SentryScope.m */; };
592-
7D7F0A5F23DF3D2C00A4629C /* SentryGlobalEventProcessor.h in Headers */ = {isa = PBXBuildFile; fileRef = 7D7F0A5E23DF3D2C00A4629C /* SentryGlobalEventProcessor.h */; };
593592
7D9B07A023D1E89900C5FC8E /* SentryMeta.h in Headers */ = {isa = PBXBuildFile; fileRef = 7D9B079F23D1E89800C5FC8E /* SentryMeta.h */; };
594-
7DAC589123D8B2E0001CF26B /* SentryGlobalEventProcessor.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DAC588E23D8B2E0001CF26B /* SentryGlobalEventProcessor.m */; };
595593
7DB3A687238EA75E00A2D442 /* SentryHttpTransport.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DB3A684238EA75E00A2D442 /* SentryHttpTransport.m */; };
596594
7DC27EC523997EB7006998B5 /* SentryAutoBreadcrumbTrackingIntegration.h in Headers */ = {isa = PBXBuildFile; fileRef = 7DC27EC323997EB7006998B5 /* SentryAutoBreadcrumbTrackingIntegration.h */; };
597595
7DC27EC723997EB7006998B5 /* SentryAutoBreadcrumbTrackingIntegration.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DC27EC423997EB7006998B5 /* SentryAutoBreadcrumbTrackingIntegration.m */; };
@@ -1113,6 +1111,7 @@
11131111
FAE2DAB82E1F317900262307 /* SentryProfilingSwiftHelpers.m in Sources */ = {isa = PBXBuildFile; fileRef = FAE2DAB72E1F317900262307 /* SentryProfilingSwiftHelpers.m */; };
11141112
FAE2DABA2E1F318900262307 /* SentryProfilingSwiftHelpers.h in Headers */ = {isa = PBXBuildFile; fileRef = FAE2DAB92E1F318900262307 /* SentryProfilingSwiftHelpers.h */; };
11151113
FAE5798D2E7D9D4C00B710F9 /* SentrySysctl.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE579872E7D9D4900B710F9 /* SentrySysctl.swift */; };
1114+
FAE579BA2E7DBE9900B710F9 /* SentryGlobalEventProcessor.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE579B42E7DBE9400B710F9 /* SentryGlobalEventProcessor.swift */; };
11161115
FAE579C22E7DDDE700B710F9 /* SentryThreadWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE579BC2E7DDDE400B710F9 /* SentryThreadWrapper.swift */; };
11171116
FAE579842E7CF21800B710F9 /* SentryMigrateSessionInit.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE5797E2E7CF21300B710F9 /* SentryMigrateSessionInit.swift */; };
11181117
FAE579CC2E7DE14900B710F9 /* SentryFrameRemover.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAE579C62E7DE14400B710F9 /* SentryFrameRemover.swift */; };
@@ -1871,11 +1870,9 @@
18711870
7D0FCFB02379B915004DD83A /* SentryHub.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryHub.h; path = Public/SentryHub.h; sourceTree = "<group>"; };
18721871
7D5C4419237C2E1F00DAB0A3 /* SentryHub.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentryHub.m; sourceTree = "<group>"; };
18731872
7D65260B237F649E00113EA2 /* SentryScope.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryScope.m; sourceTree = "<group>"; };
1874-
7D7F0A5E23DF3D2C00A4629C /* SentryGlobalEventProcessor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryGlobalEventProcessor.h; path = include/SentryGlobalEventProcessor.h; sourceTree = "<group>"; };
18751873
7D826E3E2390840E00EED93D /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = "<group>"; };
18761874
7D826E3F2390840E00EED93D /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
18771875
7D9B079F23D1E89800C5FC8E /* SentryMeta.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryMeta.h; path = include/SentryMeta.h; sourceTree = "<group>"; };
1878-
7DAC588E23D8B2E0001CF26B /* SentryGlobalEventProcessor.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryGlobalEventProcessor.m; sourceTree = "<group>"; };
18791876
7DB3A684238EA75E00A2D442 /* SentryHttpTransport.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryHttpTransport.m; sourceTree = "<group>"; };
18801877
7DC27E9823995F97006998B5 /* Sentry.modulemap */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.module-map"; name = Sentry.modulemap; path = ../Resources/Sentry.modulemap; sourceTree = "<group>"; };
18811878
7DC27EC323997EB7006998B5 /* SentryAutoBreadcrumbTrackingIntegration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryAutoBreadcrumbTrackingIntegration.h; path = include/SentryAutoBreadcrumbTrackingIntegration.h; sourceTree = "<group>"; };
@@ -2458,6 +2455,7 @@
24582455
FAE2DAB92E1F318900262307 /* SentryProfilingSwiftHelpers.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryProfilingSwiftHelpers.h; path = Sources/Sentry/include/SentryProfilingSwiftHelpers.h; sourceTree = SOURCE_ROOT; };
24592456
FAE5797E2E7CF21300B710F9 /* SentryMigrateSessionInit.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryMigrateSessionInit.swift; sourceTree = "<group>"; };
24602457
FAE579872E7D9D4900B710F9 /* SentrySysctl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySysctl.swift; sourceTree = "<group>"; };
2458+
FAE579B42E7DBE9400B710F9 /* SentryGlobalEventProcessor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryGlobalEventProcessor.swift; sourceTree = "<group>"; };
24612459
FAE579BC2E7DDDE400B710F9 /* SentryThreadWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryThreadWrapper.swift; sourceTree = "<group>"; };
24622460
FAE579C62E7DE14400B710F9 /* SentryFrameRemover.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryFrameRemover.swift; sourceTree = "<group>"; };
24632461
FAE80C232E4695AE0010A595 /* SentryEvent+Serialize.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "SentryEvent+Serialize.h"; path = "include/SentryEvent+Serialize.h"; sourceTree = "<group>"; };
@@ -2881,8 +2879,6 @@
28812879
D85596EF280580BE0041FF8B /* Screenshot */,
28822880
0A9BF4E028A114690068D266 /* ViewHierarchy */,
28832881
D80CD8D52B752FD9002F710B /* SessionReplay */,
2884-
7D7F0A5E23DF3D2C00A4629C /* SentryGlobalEventProcessor.h */,
2885-
7DAC588E23D8B2E0001CF26B /* SentryGlobalEventProcessor.m */,
28862882
FA034AC72DD3DB4900FE3107 /* SentryIntegrationProtocol.h */,
28872883
7BA235622600B61200E12865 /* SentryInternalNotificationNames.h */,
28882884
0A2D8D5C289815EB008720F6 /* SentryBaseIntegration.h */,
@@ -4686,6 +4682,7 @@
46864682
D8CAC02D2BA0663E00E38F34 /* Integrations */ = {
46874683
isa = PBXGroup;
46884684
children = (
4685+
FAE579B42E7DBE9400B710F9 /* SentryGlobalEventProcessor.swift */,
46894686
D49064862DFAE1B700555785 /* Screenshot */,
46904687
D8739CF72BECFF92007D2F66 /* Performance */,
46914688
D8CAC02C2BA0663E00E38F34 /* SessionReplay */,
@@ -4948,7 +4945,6 @@
49484945
639FCFAC1EBC811400778193 /* SentryUser.h in Headers */,
49494946
F44858132E03579D0013E63B /* SentryCrashDynamicLinker+Test.h in Headers */,
49504947
D8CB74192947285A00A5F964 /* SentryEnvelopeItemHeader.h in Headers */,
4951-
7D7F0A5F23DF3D2C00A4629C /* SentryGlobalEventProcessor.h in Headers */,
49524948
D867063D27C3BC2400048851 /* SentryCoreDataTrackingIntegration.h in Headers */,
49534949
0A2D8D5D289815EB008720F6 /* SentryBaseIntegration.h in Headers */,
49544950
84AC61D629F75A98009EEF61 /* SentryDispatchFactory.h in Headers */,
@@ -5850,6 +5846,7 @@
58505846
84AF45A729A7FFA500FBB177 /* SentryProfiledTracerConcurrency.mm in Sources */,
58515847
7DC8310C2398283C0043DD9A /* SentryCrashIntegration.m in Sources */,
58525848
D45CE9752E5F454E00BFEDB2 /* SentryScreenshotSource.swift in Sources */,
5849+
FAE579BA2E7DBE9900B710F9 /* SentryGlobalEventProcessor.swift in Sources */,
58535850
03F84D3227DD4191008FE43F /* SentryProfiler.mm in Sources */,
58545851
635B3F391EBC6E2500A6176D /* SentryAsynchronousOperation.m in Sources */,
58555852
63FE717520DA4C1100CDBAE8 /* SentryCrash.m in Sources */,
@@ -5899,7 +5896,6 @@
58995896
7B42C48227E08F4B009B58C2 /* SentryDependencyContainer.m in Sources */,
59005897
639FCFAD1EBC811400778193 /* SentryUser.m in Sources */,
59015898
FA94E7242E6F339400576666 /* SentryEnvelopeItemType.swift in Sources */,
5902-
7DAC589123D8B2E0001CF26B /* SentryGlobalEventProcessor.m in Sources */,
59035899
7BBD189E244EC8D200427C76 /* SentryRetryAfterHeaderParser.m in Sources */,
59045900
F41362152E1C568400B84443 /* SentryScopePersistentStore+Context.swift in Sources */,
59055901
F46DA6C32E1DBCA000DF6E3B /* SentryScopePersistentStore+Helper.swift in Sources */,

SentryTestUtils/SentryTestUtils-ObjC-BridgingHeader.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#import "SentryDependencyContainer.h"
3636
#import "SentryDispatchFactory.h"
3737
#import "SentryFileManager+Test.h"
38-
#import "SentryGlobalEventProcessor.h"
3938
#import "SentryHub+Private.h"
4039
#import "SentryHub+Test.h"
4140
#import "SentryLogC.h"

Sources/Sentry/SentryClient.m

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#import "SentryException.h"
1313
#import "SentryExtraContextProvider.h"
1414
#import "SentryFileManager.h"
15-
#import "SentryGlobalEventProcessor.h"
1615
#import "SentryHub+Private.h"
1716
#import "SentryHub.h"
1817
#import "SentryInstallation.h"
@@ -945,14 +944,10 @@ - (SentryEvent *_Nullable)callEventProcessors:(SentryEvent *)event
945944
SentryGlobalEventProcessor *globalEventProcessor
946945
= SentryDependencyContainer.sharedInstance.globalEventProcessor;
947946

948-
SentryEvent *newEvent = event;
949-
for (SentryEventProcessor processor in globalEventProcessor.processors) {
950-
newEvent = processor(newEvent);
951-
if (newEvent == nil) {
952-
SENTRY_LOG_DEBUG(@"SentryScope callEventProcessors: An event processor decided to "
953-
@"remove this event.");
954-
break;
955-
}
947+
SentryEvent *newEvent = [globalEventProcessor reportAll:event];
948+
if (newEvent == nil) {
949+
SENTRY_LOG_DEBUG(@"SentryScope callEventProcessors: An event processor decided to "
950+
@"remove this event.");
956951
}
957952
return newEvent;
958953
}

Sources/Sentry/SentryDependencyContainer.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#import <SentryDebugImageProvider+HybridSDKs.h>
2020
#import <SentryDefaultRateLimits.h>
2121
#import <SentryDependencyContainer.h>
22-
#import <SentryGlobalEventProcessor.h>
2322
#import <SentryHttpDateParser.h>
2423
#import <SentryPerformanceTracker.h>
2524
#import <SentryRateLimitParser.h>

Sources/Sentry/SentryGlobalEventProcessor.m

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

Sources/Sentry/SentrySessionReplayIntegration.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
# import "SentryDisplayLinkWrapper.h"
1010
# import "SentryEvent+Private.h"
1111
# import "SentryFileManager.h"
12-
# import "SentryGlobalEventProcessor.h"
1312
# import "SentryHub+Private.h"
1413
# import "SentryLogC.h"
1514
# import "SentryOptions.h"

Sources/Sentry/include/SentryGlobalEventProcessor.h

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
@_spi(Private) public typealias SentryEventProcessor = (Event) -> Event?
2+
3+
@_spi(Private) @objc public final class SentryGlobalEventProcessor: NSObject {
4+
5+
var processors = [SentryEventProcessor]()
6+
7+
@objc(addEventProcessor:) public func add(_ newProcessor: @escaping SentryEventProcessor) {
8+
processors.append(newProcessor)
9+
}
10+
11+
/// Only for testing
12+
func removeAllProcessors() {
13+
self.processors.removeAll()
14+
}
15+
16+
@objc @discardableResult public func reportAll(_ event: Event) -> Event? {
17+
var mutableEvent = event
18+
for processor in processors {
19+
if let newEvent = processor(mutableEvent) {
20+
mutableEvent = newEvent
21+
} else {
22+
return nil
23+
}
24+
}
25+
return mutableEvent
26+
}
27+
}

Tests/SentryTests/SentryTests-Bridging-Header.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@
124124
#import "SentryFormatter.h"
125125
#import "SentryFrame.h"
126126
#import "SentryFramesTrackingIntegration.h"
127-
#import "SentryGlobalEventProcessor.h"
128127
#import "SentryHttpDateParser.h"
129128
#import "SentryHttpStatusCodeRange+Private.h"
130129
#import "SentryHttpTransport.h"

0 commit comments

Comments
 (0)