Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,6 @@
7B96572226830D2400C66E25 /* SentryScopeSyncC.c in Sources */ = {isa = PBXBuildFile; fileRef = 7B96572126830D2400C66E25 /* SentryScopeSyncC.c */; };
7B965728268321CD00C66E25 /* SentryCrashScopeObserverTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B965727268321CD00C66E25 /* SentryCrashScopeObserverTests.swift */; };
7B984A9F28E572AF001F4BEE /* CrashReport.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B984A9E28E572AF001F4BEE /* CrashReport.swift */; };
7B98D7CB25FB64EC00C5A389 /* SentryWatchdogTerminationTrackingIntegration.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B98D7CA25FB64EC00C5A389 /* SentryWatchdogTerminationTrackingIntegration.h */; };
7B98D7CF25FB650F00C5A389 /* SentryWatchdogTerminationTrackingIntegration.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B98D7CE25FB650F00C5A389 /* SentryWatchdogTerminationTrackingIntegration.m */; };
7B98D7E025FB73B900C5A389 /* SentryWatchdogTerminationTrackerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B98D7DF25FB73B900C5A389 /* SentryWatchdogTerminationTrackerTests.swift */; };
7B98D7EC25FB7C4900C5A389 /* SentryAppStateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B98D7EB25FB7C4900C5A389 /* SentryAppStateTests.swift */; };
7BA0C04628055F8E003E0326 /* SentryTransportAdapter.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BA0C04528055F8E003E0326 /* SentryTransportAdapter.h */; };
Expand Down Expand Up @@ -983,6 +981,7 @@
F429D3AA2E8562EF00DBF387 /* RateLimitParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = F429D3A82E8562EF00DBF387 /* RateLimitParser.swift */; };
F43CC2F22F0C45CC005996DF /* SentryWatchdogTerminationLogic.swift in Sources */ = {isa = PBXBuildFile; fileRef = F43CC2F02F0C45CC005996DF /* SentryWatchdogTerminationLogic.swift */; };
F43CC2F32F0C45CC005996DF /* SentryWatchdogTerminationTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = F43CC2F12F0C45CC005996DF /* SentryWatchdogTerminationTracker.swift */; };
F43CC3012F0C4F06005996DF /* SentryWatchdogTerminationTrackingIntegration.swift in Sources */ = {isa = PBXBuildFile; fileRef = F43CC3002F0C4F06005996DF /* SentryWatchdogTerminationTrackingIntegration.swift */; };
F443DB272E09BE8C009A9045 /* LoadValidatorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F443DB262E09BE8C009A9045 /* LoadValidatorTests.swift */; };
F44544012EDF5A6200EFE964 /* SentryAutoSessionTrackingIntegration.swift in Sources */ = {isa = PBXBuildFile; fileRef = F44544002EDF5A5C00EFE964 /* SentryAutoSessionTrackingIntegration.swift */; };
F44858132E03579D0013E63B /* SentryCrashDynamicLinker+Test.h in Headers */ = {isa = PBXBuildFile; fileRef = F44858122E0357940013E63B /* SentryCrashDynamicLinker+Test.h */; };
Expand Down Expand Up @@ -1758,8 +1757,6 @@
7B965727268321CD00C66E25 /* SentryCrashScopeObserverTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryCrashScopeObserverTests.swift; sourceTree = "<group>"; };
7B9660B12783500E0014A767 /* ThreadSanitizer.sup */ = {isa = PBXFileReference; lastKnownFileType = text; path = ThreadSanitizer.sup; sourceTree = "<group>"; };
7B984A9E28E572AF001F4BEE /* CrashReport.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CrashReport.swift; sourceTree = "<group>"; };
7B98D7CA25FB64EC00C5A389 /* SentryWatchdogTerminationTrackingIntegration.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryWatchdogTerminationTrackingIntegration.h; path = include/SentryWatchdogTerminationTrackingIntegration.h; sourceTree = "<group>"; };
7B98D7CE25FB650F00C5A389 /* SentryWatchdogTerminationTrackingIntegration.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryWatchdogTerminationTrackingIntegration.m; sourceTree = "<group>"; };
7B98D7DF25FB73B900C5A389 /* SentryWatchdogTerminationTrackerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryWatchdogTerminationTrackerTests.swift; sourceTree = "<group>"; };
7B98D7EB25FB7C4900C5A389 /* SentryAppStateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryAppStateTests.swift; sourceTree = "<group>"; };
7BA0C04528055F8E003E0326 /* SentryTransportAdapter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryTransportAdapter.h; path = include/SentryTransportAdapter.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2385,6 +2382,7 @@
F429D3A82E8562EF00DBF387 /* RateLimitParser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RateLimitParser.swift; sourceTree = "<group>"; };
F43CC2F02F0C45CC005996DF /* SentryWatchdogTerminationLogic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryWatchdogTerminationLogic.swift; sourceTree = "<group>"; };
F43CC2F12F0C45CC005996DF /* SentryWatchdogTerminationTracker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryWatchdogTerminationTracker.swift; sourceTree = "<group>"; };
F43CC3002F0C4F06005996DF /* SentryWatchdogTerminationTrackingIntegration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryWatchdogTerminationTrackingIntegration.swift; sourceTree = "<group>"; };
F443DB262E09BE8C009A9045 /* LoadValidatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoadValidatorTests.swift; sourceTree = "<group>"; };
F44544002EDF5A5C00EFE964 /* SentryAutoSessionTrackingIntegration.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryAutoSessionTrackingIntegration.swift; sourceTree = "<group>"; };
F44858122E0357940013E63B /* SentryCrashDynamicLinker+Test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SentryCrashDynamicLinker+Test.h"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3712,8 +3710,6 @@
7BE0DC34272AE78C004FA8B7 /* WatchdogTerminations */ = {
isa = PBXGroup;
children = (
7B98D7CA25FB64EC00C5A389 /* SentryWatchdogTerminationTrackingIntegration.h */,
7B98D7CE25FB650F00C5A389 /* SentryWatchdogTerminationTrackingIntegration.m */,
D452FC512DDB4AF100AFF56F /* Processors */,
);
name = WatchdogTerminations;
Expand Down Expand Up @@ -4300,6 +4296,7 @@
D452FCBC2DDB6FA800AFF56F /* WatchdogTerminations */ = {
isa = PBXGroup;
children = (
F43CC3002F0C4F06005996DF /* SentryWatchdogTerminationTrackingIntegration.swift */,
F485947D2F11A0610035B6EE /* SentryWatchdogTerminationConstants.swift */,
F43CC2F02F0C45CC005996DF /* SentryWatchdogTerminationLogic.swift */,
F43CC2F12F0C45CC005996DF /* SentryWatchdogTerminationTracker.swift */,
Expand Down Expand Up @@ -5399,7 +5396,6 @@
8E5D38E3261D4B57000D363D /* SentryPerformanceTrackingIntegration.h in Headers */,
63FE70F920DA4C1000CDBAE8 /* SentryCrashMonitor.h in Headers */,
D8BD2E6829361A0F00D96C6A /* PrivatesHeader.h in Headers */,
7B98D7CB25FB64EC00C5A389 /* SentryWatchdogTerminationTrackingIntegration.h in Headers */,
63FE710920DA4C1000CDBAE8 /* SentryCrashFileUtils.h in Headers */,
D865892F29D6ECA7000BE151 /* SentryCrashBinaryImageCache.h in Headers */,
6344DDB41EC309E000D9160D /* SentryCrashReportSink.h in Headers */,
Expand Down Expand Up @@ -5892,6 +5888,7 @@
A8F17B342902870300990B25 /* SentryHttpStatusCodeRange.m in Sources */,
62C97D3A2CC64E6B00DDA204 /* SentryUncaughtNSExceptions.m in Sources */,
D4599F892E98F4750045BB95 /* SentryInfoPlistKey.swift in Sources */,
F43CC3012F0C4F06005996DF /* SentryWatchdogTerminationTrackingIntegration.swift in Sources */,
03F84D3727DD4191008FE43F /* SentrySamplingProfiler.cpp in Sources */,
8453421628BE8A9500C22EEC /* SentrySpanStatus.m in Sources */,
6292585B2DAFA5F70049388F /* SentryCrashCxaThrowSwapper.c in Sources */,
Expand Down Expand Up @@ -6189,7 +6186,6 @@
D452FC592DDB4B1700AFF56F /* SentryWatchdogTerminationBreadcrumbProcessor.m in Sources */,
FAE2DAB82E1F317900262307 /* SentryProfilingSwiftHelpers.m in Sources */,
8EA1ED0B2668F8C400E62B98 /* SentryUIViewControllerSwizzling.m in Sources */,
7B98D7CF25FB650F00C5A389 /* SentryWatchdogTerminationTrackingIntegration.m in Sources */,
8E5D38DD261D4A3E000D363D /* SentryPerformanceTrackingIntegration.m in Sources */,
7B4E23C2251A2C2B00060D68 /* SentryCrashIntegrationSessionHandler.m in Sources */,
9286059729A5098900F96038 /* SentryGeo.m in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryCrashIntegration.m
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ - (void)configureScope

[SentryDependencyContainer.sharedInstance.crashReporter setUserInfo:userInfo];

[outerScope addObserver:self.scopeObserver];
[outerScope addScopeObserver:self.scopeObserver];
}];

[NSNotificationCenter.defaultCenter addObserver:self
Expand Down
2 changes: 0 additions & 2 deletions Sources/Sentry/SentrySDKInternal.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
# import "SentryPerformanceTrackingIntegration.h"
# import "SentryUIEventTrackingIntegration.h"
# import "SentryViewHierarchyIntegration.h"
# import "SentryWatchdogTerminationTrackingIntegration.h"
#endif // SENTRY_HAS_UIKIT

#if TARGET_OS_OSX
Expand Down Expand Up @@ -514,7 +513,6 @@ + (void)endSession
[SentryAppStartTrackingIntegration class], [SentryFramesTrackingIntegration class],
[SentryPerformanceTrackingIntegration class], [SentryUIEventTrackingIntegration class],
[SentryViewHierarchyIntegration class],
[SentryWatchdogTerminationTrackingIntegration class],
#endif // SENTRY_HAS_UIKIT
[SentryAutoBreadcrumbTrackingIntegration class], [SentryCoreDataTrackingIntegration class],
[SentryFileIOTrackingIntegration class], nil];
Expand Down
33 changes: 30 additions & 3 deletions Sources/Sentry/SentryScope.m
Original file line number Diff line number Diff line change
Expand Up @@ -678,9 +678,36 @@ - (SentryEvent *__nullable)applyToEvent:(SentryEvent *_Nullable)event
return event;
}

- (void)addObserver:(id<SentryScopeObserver>)observer
{
[self.observers addObject:observer];
- (void)addScopeObserver:(id)observer
{
// Validate if the observer conforms because the API doesn't require
// observers to conform anymore due to the protocol being written in Swift
// but protocol forwarded in ObjC
// Additionaly, conformsToProtocol:@protocol(SentryScopeObserver) seems to fail
// because the conformance is declared in a Category, so runtime checks fail.
// So we use check for all SentryScopeObserver functions AND an assertion to get alerts on tests
// As a compile check if any of these selectors cease to exist, this should fail to build.
// Once this class is converted to Swift, we shouldn't need this anymore

BOOL conformsToScopeObserver = [observer respondsToSelector:@selector(setTraceContext:)] &&
[observer respondsToSelector:@selector(setUser:)] &&
[observer respondsToSelector:@selector(setTags:)] &&
[observer respondsToSelector:@selector(setExtras:)] &&
[observer respondsToSelector:@selector(setContext:)] &&
[observer respondsToSelector:@selector(setDist:)] &&
[observer respondsToSelector:@selector(setEnvironment:)] &&
[observer respondsToSelector:@selector(setFingerprint:)] &&
[observer respondsToSelector:@selector(setLevel:)] &&
[observer respondsToSelector:@selector(setFingerprint:)] &&
[observer respondsToSelector:@selector(setAttributes:)] &&
[observer respondsToSelector:@selector(addSerializedBreadcrumb:)] &&
[observer respondsToSelector:@selector(clearBreadcrumbs)] &&
[observer respondsToSelector:@selector(clear)];
SENTRY_ASSERT(conformsToScopeObserver,
@"Observer must be an instance conforming to SentryScopeObserver protocol")
if (conformsToScopeObserver) {
[self.observers addObject:observer];
}
}

- (NSDictionary *)buildTraceContext:(nullable id<SentrySpan>)span
Expand Down
132 changes: 0 additions & 132 deletions Sources/Sentry/SentryWatchdogTerminationTrackingIntegration.m

This file was deleted.

2 changes: 0 additions & 2 deletions Sources/Sentry/include/SentryScope+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (atomic, strong) NSMutableDictionary<NSString *, NSString *> *tagDictionary;

- (void)addObserver:(id<SentryScopeObserver>)observer;

- (nullable SentryEvent *)applyToEvent:(SentryEvent *_Nullable)event
maxBreadcrumb:(NSUInteger)maxBreadcrumbs
NS_SWIFT_NAME(applyTo(event:maxBreadcrumbs:));
Expand Down
7 changes: 7 additions & 0 deletions Sources/Sentry/include/SentryScope+PrivateSwift.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ static NSString *const SENTRY_CONTEXT_APP_KEY = @"app";

- (NSDictionary<NSString *, id> *_Nullable)getContextForKey:(NSString *)key;

/**
* Adds a scope observer. The observer will be notified of scope changes.
* The observer should conform to SentryScopeObserver protocol, but the type is id
* because Swift-defined protocols don't work correctly with Objective-C's id<Protocol> syntax.
*/
- (void)addScopeObserver:(id)observer NS_SWIFT_NAME(add(_:));

@end

NS_ASSUME_NONNULL_END

This file was deleted.

4 changes: 4 additions & 0 deletions Sources/Swift/Core/Integrations/Integrations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ private struct AnyIntegration {
.init(SentryMetricsIntegration.self)
]

#if (os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) || os(visionOS)) && !SENTRY_NO_UIKIT
integrations.append(.init(SentryWatchdogTerminationTrackingIntegration.self))
#endif

#if os(iOS) && !SENTRY_NO_UIKIT
integrations.append(.init(UserFeedbackIntegration.self))
#endif
Expand Down
Loading
Loading