diff --git a/CHANGELOG.md b/CHANGELOG.md index 367fc19477..888dec0b82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -56,6 +56,7 @@ This version adds a dependency on Swift. - Bump minimum Xcode version to 13 (#2483) - Rename `SentryOptions.enableOutOfMemoryTracking` to `SentryOptions.enableWatchdogTerminationTracking` (#2499) - Remove the automatic `viewAppearing` span for UIViewController APM (#2511) +- Remove the permission context for events (#2529) ## 8.0.0-beta.4 diff --git a/Sentry.xcodeproj/project.pbxproj b/Sentry.xcodeproj/project.pbxproj index fcb49c46b9..d7f1811180 100644 --- a/Sentry.xcodeproj/project.pbxproj +++ b/Sentry.xcodeproj/project.pbxproj @@ -38,7 +38,6 @@ 03F84D3827DD4191008FE43F /* SentryBacktrace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 03F84D3127DD4191008FE43F /* SentryBacktrace.cpp */; }; 03F9D37C2819A65C00602916 /* SentryProfilerTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = 03F9D37B2819A65C00602916 /* SentryProfilerTests.mm */; }; 0A1B497328E597DD00D7BFA3 /* TestLogOutput.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A1B497228E597DD00D7BFA3 /* TestLogOutput.swift */; }; - 0A2690B72885C2E000E4432D /* TestSentryPermissionsObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0AABE2EF2885C2120057ED69 /* TestSentryPermissionsObserver.swift */; }; 0A283E79291A67E000EF4126 /* SentryUIDeviceWrapperTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A283E78291A67E000EF4126 /* SentryUIDeviceWrapperTests.swift */; }; 0A2D7BBA29152CBF008727AF /* SentryWatchdogTerminationsScopeObserverTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A2D7BB929152CBF008727AF /* SentryWatchdogTerminationsScopeObserverTests.swift */; }; 0A2D8D5B289815C0008720F6 /* SentryBaseIntegration.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A2D8D5A289815C0008720F6 /* SentryBaseIntegration.m */; }; @@ -54,7 +53,6 @@ 0A6EEADD28A657970076B469 /* UIViewRecursiveDescriptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6EEADC28A657970076B469 /* UIViewRecursiveDescriptionTests.swift */; }; 0A80E433291017C300095219 /* SentryWatchdogTerminationScopeObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A80E432291017C300095219 /* SentryWatchdogTerminationScopeObserver.m */; }; 0A80E435291017D500095219 /* SentryWatchdogTerminationScopeObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A80E434291017D500095219 /* SentryWatchdogTerminationScopeObserver.h */; }; - 0A8F0A392886CC70000B15F6 /* SentryPermissionsObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = 0AABE2EE288592750057ED69 /* SentryPermissionsObserver.h */; }; 0A94158228F6C4C2006A5DD1 /* SentryAppStateManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A94158128F6C4C2006A5DD1 /* SentryAppStateManagerTests.swift */; }; 0A9415BA28F96CAC006A5DD1 /* TestSentryReachability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A9415B928F96CAC006A5DD1 /* TestSentryReachability.swift */; }; 0A9BF4E228A114940068D266 /* SentryViewHierarchyIntegration.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A9BF4E128A114940068D266 /* SentryViewHierarchyIntegration.m */; }; @@ -62,7 +60,6 @@ 0A9BF4E928A125390068D266 /* TestSentryViewHierarchy.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A9BF4E628A123270068D266 /* TestSentryViewHierarchy.swift */; }; 0A9BF4EB28A127120068D266 /* SentryViewHierarchyIntegrationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A9BF4EA28A127120068D266 /* SentryViewHierarchyIntegrationTests.swift */; }; 0A9E917128DC7E7000FB4182 /* SentryInternalDefines.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A9E917028DC7E7000FB4182 /* SentryInternalDefines.h */; }; - 0AABE2ED2885924A0057ED69 /* SentryPermissionsObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AABE2EC2885924A0057ED69 /* SentryPermissionsObserver.m */; }; 0AAE201E28ED9B9400D0CD80 /* SentryReachability.m in Sources */ = {isa = PBXBuildFile; fileRef = 0AAE201D28ED9B9400D0CD80 /* SentryReachability.m */; }; 0AAE202128ED9BCC00D0CD80 /* SentryReachability.h in Headers */ = {isa = PBXBuildFile; fileRef = 0AAE202028ED9BCC00D0CD80 /* SentryReachability.h */; }; 0ACBA10128A6406400D711F7 /* UIView+Sentry.m in Sources */ = {isa = PBXBuildFile; fileRef = 0ACBA10028A6406400D711F7 /* UIView+Sentry.m */; }; @@ -816,9 +813,6 @@ 0A9BF4E628A123270068D266 /* TestSentryViewHierarchy.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestSentryViewHierarchy.swift; sourceTree = ""; }; 0A9BF4EA28A127120068D266 /* SentryViewHierarchyIntegrationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryViewHierarchyIntegrationTests.swift; sourceTree = ""; }; 0A9E917028DC7E7000FB4182 /* SentryInternalDefines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryInternalDefines.h; path = include/SentryInternalDefines.h; sourceTree = ""; }; - 0AABE2EC2885924A0057ED69 /* SentryPermissionsObserver.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryPermissionsObserver.m; sourceTree = ""; }; - 0AABE2EE288592750057ED69 /* SentryPermissionsObserver.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryPermissionsObserver.h; path = include/SentryPermissionsObserver.h; sourceTree = ""; }; - 0AABE2EF2885C2120057ED69 /* TestSentryPermissionsObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestSentryPermissionsObserver.swift; sourceTree = ""; }; 0AAE201D28ED9B9400D0CD80 /* SentryReachability.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryReachability.m; sourceTree = ""; }; 0AAE202028ED9BCC00D0CD80 /* SentryReachability.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryReachability.h; path = include/SentryReachability.h; sourceTree = ""; }; 0ACBA10028A6406400D711F7 /* UIView+Sentry.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "UIView+Sentry.m"; sourceTree = ""; }; @@ -1830,8 +1824,6 @@ 7B7D873524864C9D00D2ECFF /* SentryCrashDefaultMachineContextWrapper.m */, 7B7A30C524B48321005A4C6E /* SentryCrashWrapper.h */, 7B7A30C724B48389005A4C6E /* SentryCrashWrapper.m */, - 0AABE2EE288592750057ED69 /* SentryPermissionsObserver.h */, - 0AABE2EC2885924A0057ED69 /* SentryPermissionsObserver.m */, 0ADC33ED28D9BB890078D980 /* SentryUIDeviceWrapper.h */, 0ADC33EB28D9BB780078D980 /* SentryUIDeviceWrapper.m */, ); @@ -2296,7 +2288,6 @@ 0A283E78291A67E000EF4126 /* SentryUIDeviceWrapperTests.swift */, 7BED3574266F7BC600EAA70D /* TestSentryCrashWrapper.h */, 7BED3575266F7BFF00EAA70D /* TestSentryCrashWrapper.m */, - 0AABE2EF2885C2120057ED69 /* TestSentryPermissionsObserver.swift */, 0ADC33EF28D9BE690078D980 /* TestSentryUIDeviceWrapper.swift */, 7B984A9E28E572AF001F4BEE /* CrashReportWriter.swift */, ); @@ -3117,7 +3108,6 @@ 03F84D1E27DD414C008FE43F /* SentryBacktrace.hpp in Headers */, 63AA76991EB9C1C200D153DE /* SentryDefines.h in Headers */, 0A4EDEA928D3461B00FA67CB /* SentryPerformanceTracker+Private.h in Headers */, - 0A8F0A392886CC70000B15F6 /* SentryPermissionsObserver.h in Headers */, 7B2A70DB27D607CF008B0D15 /* SentryThreadWrapper.h in Headers */, 8EAE980B261E9F530073B6B3 /* SentryPerformanceTracker.h in Headers */, 63FE718520DA4C1100CDBAE8 /* SentryCrashC.h in Headers */, @@ -3663,7 +3653,6 @@ 0ACBA10128A6406400D711F7 /* UIView+Sentry.m in Sources */, 639FCF991EBC7B9700778193 /* SentryEvent.m in Sources */, 632F43521F581D5400A18A36 /* SentryCrashExceptionApplication.m in Sources */, - 0AABE2ED2885924A0057ED69 /* SentryPermissionsObserver.m in Sources */, 7B77BE3727EC8460003C9020 /* SentryDiscardReasonMapper.m in Sources */, 63FE712520DA4C1000CDBAE8 /* SentryCrashSignalInfo.c in Sources */, 63FE70F320DA4C1000CDBAE8 /* SentryCrashMonitor_Signal.c in Sources */, @@ -3807,7 +3796,6 @@ 7BA0C04C28056556003E0326 /* SentryTransportAdapterTests.swift in Sources */, 7BE0DC29272A9E1C004FA8B7 /* SentryBreadcrumbTrackerTests.swift in Sources */, 63FE722520DA66EC00CDBAE8 /* SentryCrashFileUtils_Tests.m in Sources */, - 0A2690B72885C2E000E4432D /* TestSentryPermissionsObserver.swift in Sources */, 7BFC16BA2524D4AF00FF6266 /* SentryMessage+Equality.m in Sources */, 7B4260342630315C00B36EDD /* SampleError.swift in Sources */, D855B3E827D652AF00BCED76 /* SentryCoreDataTrackingIntegrationTest.swift in Sources */, diff --git a/Sources/Sentry/Public/SentryDefines.h b/Sources/Sentry/Public/SentryDefines.h index 6e1d16c4aa..ec8e709c39 100644 --- a/Sources/Sentry/Public/SentryDefines.h +++ b/Sources/Sentry/Public/SentryDefines.h @@ -111,16 +111,6 @@ typedef NS_ENUM(NSUInteger, SentryLevel) { kSentryLevelFatal = 5 }; -/** - * Permission status - */ -typedef NS_ENUM(NSInteger, SentryPermissionStatus) { - kSentryPermissionStatusUnknown = 0, - kSentryPermissionStatusGranted, - kSentryPermissionStatusPartial, - kSentryPermissionStatusDenied -}; - /** * Static internal helper to convert enum to string */ diff --git a/Sources/Sentry/SentryClient.m b/Sources/Sentry/SentryClient.m index ef2eef5cb2..a01bd8896e 100644 --- a/Sources/Sentry/SentryClient.m +++ b/Sources/Sentry/SentryClient.m @@ -30,7 +30,6 @@ #import "SentryMeta.h" #import "SentryNSError.h" #import "SentryOptions+Private.h" -#import "SentryPermissionsObserver.h" #import "SentrySDK+Private.h" #import "SentryScope+Private.h" #import "SentryStacktraceBuilder.h" @@ -59,7 +58,6 @@ @property (nonatomic, strong) SentryDebugImageProvider *debugImageProvider; @property (nonatomic, strong) id random; @property (nonatomic, strong) SentryCrashWrapper *crashWrapper; -@property (nonatomic, strong) SentryPermissionsObserver *permissionsObserver; @property (nonatomic, strong) SentryUIDeviceWrapper *deviceWrapper; @property (nonatomic, strong) NSLocale *locale; @property (nonatomic, strong) NSTimeZone *timezone; @@ -89,33 +87,11 @@ - (nullable instancetype)initWithOptions:(SentryOptions *)options SENTRY_LOG_ERROR(@"Cannot init filesystem."); return nil; } - return [self initWithOptions:options - permissionsObserver:[[SentryPermissionsObserver alloc] init] - fileManager:fileManager]; -} - -- (nullable instancetype)initWithOptions:(SentryOptions *)options - permissionsObserver:(SentryPermissionsObserver *)permissionsObserver - dispatchQueue:(SentryDispatchQueueWrapper *)dispatchQueue -{ - NSError *error; - SentryFileManager *fileManager = - [[SentryFileManager alloc] initWithOptions:options - andCurrentDateProvider:[SentryDefaultCurrentDateProvider sharedInstance] - dispatchQueueWrapper:dispatchQueue - error:&error]; - if (error != nil) { - SENTRY_LOG_ERROR(@"Cannot init filesystem."); - return nil; - } - return [self initWithOptions:options - permissionsObserver:permissionsObserver - fileManager:fileManager]; + return [self initWithOptions:options fileManager:fileManager]; } /** Internal constructor for testing purposes. */ - (instancetype)initWithOptions:(SentryOptions *)options - permissionsObserver:(SentryPermissionsObserver *)permissionsObserver fileManager:(SentryFileManager *)fileManager { id transport = [SentryTransportFactory initTransport:options @@ -144,7 +120,6 @@ - (instancetype)initWithOptions:(SentryOptions *)options threadInspector:threadInspector random:[SentryDependencyContainer sharedInstance].random crashWrapper:[SentryCrashWrapper sharedInstance] - permissionsObserver:permissionsObserver deviceWrapper:deviceWrapper locale:[NSLocale autoupdatingCurrentLocale] timezone:[NSCalendar autoupdatingCurrentCalendar].timeZone]; @@ -156,7 +131,6 @@ - (instancetype)initWithOptions:(SentryOptions *)options threadInspector:(SentryThreadInspector *)threadInspector random:(id)random crashWrapper:(SentryCrashWrapper *)crashWrapper - permissionsObserver:(SentryPermissionsObserver *)permissionsObserver deviceWrapper:(SentryUIDeviceWrapper *)deviceWrapper locale:(NSLocale *)locale timezone:(NSTimeZone *)timezone @@ -169,7 +143,6 @@ - (instancetype)initWithOptions:(SentryOptions *)options self.threadInspector = threadInspector; self.random = random; self.crashWrapper = crashWrapper; - self.permissionsObserver = permissionsObserver; self.debugImageProvider = [SentryDependencyContainer sharedInstance].debugImageProvider; self.locale = locale; self.timezone = timezone; @@ -583,7 +556,6 @@ - (SentryEvent *_Nullable)prepareEvent:(SentryEvent *)event // at the time of this event, but not for crashes as the current data isn't guaranteed to be // the same as when the app crashed. [self applyExtraDeviceContextToEvent:event]; - [self applyPermissionsToEvent:event]; [self applyCultureContextToEvent:event]; } @@ -741,46 +713,6 @@ - (BOOL)isWatchdogTermination:(SentryEvent *)event isCrashEvent:(BOOL)isCrashEve [exception.mechanism.type isEqualToString:SentryWatchdogTerminationMechanismType]; } -- (void)applyPermissionsToEvent:(SentryEvent *)event -{ - [self modifyContext:event - key:@"app" - block:^(NSMutableDictionary *app) { - app[@"permissions"] = @ { - @"push_notifications" : - [self stringForPermissionStatus:self.permissionsObserver - .pushPermissionStatus], - @"location_access" : - [self stringForPermissionStatus:self.permissionsObserver - .locationPermissionStatus], - @"photo_library" : - [self stringForPermissionStatus:self.permissionsObserver - .photoLibraryPermissionStatus], - }; - }]; -} - -- (NSString *)stringForPermissionStatus:(SentryPermissionStatus)status -{ - switch (status) { - case kSentryPermissionStatusUnknown: - return @"unknown"; - break; - - case kSentryPermissionStatusGranted: - return @"granted"; - break; - - case kSentryPermissionStatusPartial: - return @"partial"; - break; - - case kSentryPermissionStatusDenied: - return @"not_granted"; - break; - } -} - - (void)applyCultureContextToEvent:(SentryEvent *)event { [self modifyContext:event diff --git a/Sources/Sentry/SentryPermissionsObserver.m b/Sources/Sentry/SentryPermissionsObserver.m deleted file mode 100644 index 017bbaedc8..0000000000 --- a/Sources/Sentry/SentryPermissionsObserver.m +++ /dev/null @@ -1,153 +0,0 @@ -#import "SentryPermissionsObserver.h" -#import -#import - -#if SENTRY_HAS_UIKIT -# import -# import -#endif - -NS_ASSUME_NONNULL_BEGIN - -@interface -SentryPermissionsObserver () -@property (nonatomic, strong) CLLocationManager *locationManager; -@end - -@implementation SentryPermissionsObserver - -- (instancetype)init -{ - self = [super init]; - if (self) { - // Don't start observing when we're in tests - if (NSBundle.mainBundle.bundleIdentifier != nil - && ![NSBundle.mainBundle.bundleIdentifier isEqual:@"com.apple.dt.xctest.tool"]) { - [self startObserving]; - } - } - return self; -} - -- (void)startObserving -{ - // Set initial values - [self refreshPermissions]; - [self setLocationPermissionFromStatus:[CLLocationManager authorizationStatus]]; - - // Listen for location permission updates - self.locationManager = [[CLLocationManager alloc] init]; - self.locationManager.delegate = self; - -#if SENTRY_HAS_UIKIT - // For most permissions there is no API for to be notified of changes (delegate, completion - // handler). Instead we refresh the values when the application comes back to the foreground. - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(refreshPermissions) - name:UIApplicationDidBecomeActiveNotification - object:nil]; -#endif -} - -- (void)refreshPermissions -{ -#if SENTRY_HAS_UIKIT - [self setPhotoLibraryPermissionFromStatus:PHPhotoLibrary.authorizationStatus]; - - [[UNUserNotificationCenter currentNotificationCenter] - getNotificationSettingsWithCompletionHandler:^(UNNotificationSettings *settings) { - [self setPushPermissionFromStatus:settings.authorizationStatus]; - }]; -#endif -} - -#if SENTRY_HAS_UIKIT -- (void)setPhotoLibraryPermissionFromStatus:(PHAuthorizationStatus)status -{ - switch (status) { - case PHAuthorizationStatusNotDetermined: - self.photoLibraryPermissionStatus = kSentryPermissionStatusUnknown; - break; - - case PHAuthorizationStatusDenied: - case PHAuthorizationStatusRestricted: - self.photoLibraryPermissionStatus = kSentryPermissionStatusDenied; - break; - - case PHAuthorizationStatusLimited: - self.photoLibraryPermissionStatus = kSentryPermissionStatusPartial; - break; - - case PHAuthorizationStatusAuthorized: - self.photoLibraryPermissionStatus = kSentryPermissionStatusGranted; - break; - } -} - -- (void)setPushPermissionFromStatus:(UNAuthorizationStatus)status -{ - switch (status) { - case UNAuthorizationStatusNotDetermined: - self.pushPermissionStatus = kSentryPermissionStatusUnknown; - break; - - case UNAuthorizationStatusDenied: - self.pushPermissionStatus = kSentryPermissionStatusDenied; - break; - - case UNAuthorizationStatusAuthorized: - self.pushPermissionStatus = kSentryPermissionStatusGranted; - break; - - case UNAuthorizationStatusProvisional: - self.pushPermissionStatus = kSentryPermissionStatusPartial; - break; - -# if TARGET_OS_IOS - case UNAuthorizationStatusEphemeral: - self.pushPermissionStatus = kSentryPermissionStatusPartial; - break; -# endif - } -} -#endif - -- (void)setLocationPermissionFromStatus:(CLAuthorizationStatus)status -{ - switch (status) { - case kCLAuthorizationStatusNotDetermined: - self.locationPermissionStatus = kSentryPermissionStatusUnknown; - break; - - case kCLAuthorizationStatusDenied: - case kCLAuthorizationStatusRestricted: - self.locationPermissionStatus = kSentryPermissionStatusDenied; - break; - - case kCLAuthorizationStatusAuthorizedAlways: - self.locationPermissionStatus = kSentryPermissionStatusGranted; - break; - -#if !TARGET_OS_OSX - case kCLAuthorizationStatusAuthorizedWhenInUse: - self.locationPermissionStatus = kSentryPermissionStatusPartial; - break; -#endif - } -} - -- (void)locationManager:(CLLocationManager *)manager - didChangeAuthorizationStatus:(CLAuthorizationStatus)status -{ - [self setLocationPermissionFromStatus:status]; -} - -- (void)locationManagerDidChangeAuthorization:(CLLocationManager *)manager -{ - CLAuthorizationStatus locationStatus = [CLLocationManager authorizationStatus]; - [self setLocationPermissionFromStatus:locationStatus]; -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/Sources/Sentry/include/SentryPermissionsObserver.h b/Sources/Sentry/include/SentryPermissionsObserver.h deleted file mode 100644 index 747067ea35..0000000000 --- a/Sources/Sentry/include/SentryPermissionsObserver.h +++ /dev/null @@ -1,24 +0,0 @@ -#import "SentryDefines.h" -#import - -NS_ASSUME_NONNULL_BEGIN - -@interface SentryPermissionsObserver : NSObject - -/* - * We want as many permissions as possible, - * but we had to remove the media permission because it was preventing some developers from - * publishing their apps. Apple was requiring developers to include NSAppleMusicUsageDescription in - * their plist files, even when they don't use this feature. More info at - * https://github.com/getsentry/sentry-cocoa/issues/2065 - */ - -@property (nonatomic) SentryPermissionStatus pushPermissionStatus; -@property (nonatomic) SentryPermissionStatus locationPermissionStatus; -@property (nonatomic) SentryPermissionStatus photoLibraryPermissionStatus; - -- (void)startObserving; - -@end - -NS_ASSUME_NONNULL_END diff --git a/Tests/SentryTests/SentryClient+TestInit.h b/Tests/SentryTests/SentryClient+TestInit.h index 8e9eb69137..35664de83c 100644 --- a/Tests/SentryTests/SentryClient+TestInit.h +++ b/Tests/SentryTests/SentryClient+TestInit.h @@ -1,4 +1,3 @@ -#import "SentryPermissionsObserver.h" #import "SentryRandom.h" #import "SentryTransport.h" #import @@ -13,12 +12,7 @@ SentryClient () - (_Nullable instancetype)initWithOptions:(SentryOptions *)options dispatchQueue:(SentryDispatchQueueWrapper *)dispatchQueue; -- (nullable instancetype)initWithOptions:(SentryOptions *)options - permissionsObserver:(SentryPermissionsObserver *)permissionsObserver - dispatchQueue:(SentryDispatchQueueWrapper *)dispatchQueue; - - (_Nullable instancetype)initWithOptions:(SentryOptions *)options - permissionsObserver:(SentryPermissionsObserver *)permissionsObserver fileManager:(SentryFileManager *)fileManager; - (instancetype)initWithOptions:(SentryOptions *)options @@ -27,7 +21,6 @@ SentryClient () threadInspector:(SentryThreadInspector *)threadInspector random:(id)random crashWrapper:(SentryCrashWrapper *)crashWrapper - permissionsObserver:(SentryPermissionsObserver *)permissionsObserver deviceWrapper:(SentryUIDeviceWrapper *)deviceWrapper locale:(NSLocale *)locale timezone:(NSTimeZone *)timezone; diff --git a/Tests/SentryTests/SentryClientTests.swift b/Tests/SentryTests/SentryClientTests.swift index 02851bcf55..57857cf6f6 100644 --- a/Tests/SentryTests/SentryClientTests.swift +++ b/Tests/SentryTests/SentryClientTests.swift @@ -28,7 +28,6 @@ class SentryClientTest: XCTestCase { let trace = SentryTracer(transactionContext: TransactionContext(name: "SomeTransaction", operation: "SomeOperation"), hub: nil) let transaction: Transaction let crashWrapper = TestSentryCrashWrapper.sharedInstance() - let permissionsObserver = TestSentryPermissionsObserver() let deviceWrapper = TestSentryUIDeviceWrapper() let locale = Locale(identifier: "en_US") let timezone = TimeZone(identifier: "Europe/Vienna")! @@ -75,7 +74,6 @@ class SentryClientTest: XCTestCase { threadInspector: threadInspector, random: random, crashWrapper: crashWrapper, - permissionsObserver: permissionsObserver, deviceWrapper: deviceWrapper, locale: locale, timezone: timezone @@ -647,22 +645,6 @@ class SentryClientTest: XCTestCase { #endif } - func testCaptureEvent_AddCurrentPermissions() { - fixture.permissionsObserver.internalLocationPermissionStatus = SentryPermissionStatus.granted - fixture.permissionsObserver.internalPushPermissionStatus = SentryPermissionStatus.granted - fixture.permissionsObserver.internalMediaLibraryPermissionStatus = SentryPermissionStatus.denied - fixture.permissionsObserver.internalPhotoLibraryPermissionStatus = SentryPermissionStatus.partial - - fixture.getSut().capture(event: TestData.event) - - assertLastSentEvent { actual in - let permissions = actual.context?["app"]?["permissions"] as? [String: String] - XCTAssertEqual(permissions?["push_notifications"], "granted") - XCTAssertEqual(permissions?["location_access"], "granted") - XCTAssertEqual(permissions?["photo_library"], "partial") - } - } - func testCaptureEvent_AddCurrentCulture() { fixture.getSut().capture(event: TestData.event) @@ -1109,7 +1091,7 @@ class SentryClientTest: XCTestCase { let options = Options() options.dsn = SentryClientTest.dsn - let client = SentryClient(options: options, permissionsObserver: TestSentryPermissionsObserver(), dispatchQueue: TestSentryDispatchQueueWrapper()) + let client = SentryClient(options: options, dispatchQueue: TestSentryDispatchQueueWrapper()) XCTAssertNil(client) diff --git a/Tests/SentryTests/SentryCrash/TestSentryPermissionsObserver.swift b/Tests/SentryTests/SentryCrash/TestSentryPermissionsObserver.swift deleted file mode 100644 index 3dfada9c79..0000000000 --- a/Tests/SentryTests/SentryCrash/TestSentryPermissionsObserver.swift +++ /dev/null @@ -1,33 +0,0 @@ -import Sentry - -class TestSentryPermissionsObserver: SentryPermissionsObserver { - var internalPushPermissionStatus = SentryPermissionStatus.unknown - var internalLocationPermissionStatus = SentryPermissionStatus.unknown - var internalMediaLibraryPermissionStatus = SentryPermissionStatus.unknown - var internalPhotoLibraryPermissionStatus = SentryPermissionStatus.unknown - - override func startObserving() { - // noop - } - - override var pushPermissionStatus: SentryPermissionStatus { - get { - return internalPushPermissionStatus - } - set {} - } - - override var locationPermissionStatus: SentryPermissionStatus { - get { - return internalLocationPermissionStatus - } - set {} - } - - override var photoLibraryPermissionStatus: SentryPermissionStatus { - get { - return internalPhotoLibraryPermissionStatus - } - set {} - } -} diff --git a/Tests/SentryTests/TestClient.swift b/Tests/SentryTests/TestClient.swift index 1ca29705b2..7df8d27157 100644 --- a/Tests/SentryTests/TestClient.swift +++ b/Tests/SentryTests/TestClient.swift @@ -2,16 +2,16 @@ import Foundation class TestClient: SentryClient { override init?(options: Options) { - super.init(options: options, permissionsObserver: TestSentryPermissionsObserver(), fileManager: try! TestFileManager(options: options)) + super.init(options: options, fileManager: try! TestFileManager(options: options)) } - init?(options: Options, fileManager: SentryFileManager) { - super.init(options: options, permissionsObserver: TestSentryPermissionsObserver(), fileManager: fileManager) + override init?(options: Options, fileManager: SentryFileManager) { + super.init(options: options, fileManager: fileManager) } // Without this override we get a fatal error: use of unimplemented initializer // see https://stackoverflow.com/questions/28187261/ios-swift-fatal-error-use-of-unimplemented-initializer-init - override init(options: Options, transportAdapter: SentryTransportAdapter, fileManager: SentryFileManager, threadInspector: SentryThreadInspector, random: SentryRandomProtocol, crashWrapper: SentryCrashWrapper, permissionsObserver: SentryPermissionsObserver, deviceWrapper: SentryUIDeviceWrapper, locale: Locale, timezone: TimeZone) { + override init(options: Options, transportAdapter: SentryTransportAdapter, fileManager: SentryFileManager, threadInspector: SentryThreadInspector, random: SentryRandomProtocol, crashWrapper: SentryCrashWrapper, deviceWrapper: SentryUIDeviceWrapper, locale: Locale, timezone: TimeZone) { super.init( options: options, transportAdapter: transportAdapter, @@ -19,7 +19,6 @@ class TestClient: SentryClient { threadInspector: threadInspector, random: random, crashWrapper: crashWrapper, - permissionsObserver: permissionsObserver, deviceWrapper: deviceWrapper, locale: locale, timezone: timezone diff --git a/develop-docs/README.md b/develop-docs/README.md index b858b1b02c..ea43b92bd5 100644 --- a/develop-docs/README.md +++ b/develop-docs/README.md @@ -151,7 +151,7 @@ We don't mind breaking changes in SentryPrivate, because this is not meant to be ### Writing breadcrumbs to disk in the main thread -Date November 15, 2022 +Date: November 15, 2022 Contributors: @kevinrenskers, @brustolin and @philipphofmann For the benefit of OOM crashes, we write breadcrumbs to disk; see https://github.com/getsentry/sentry-cocoa/pull/2347. We have decided to do this in the main thread to ensure we're not missing out on any breadcrumbs. It's mainly the last breadcrumb(s) that are important to figure out what is causing an OOM. And since we're only appending to an open file stream, the overhead is acceptable compared to the benefit of having accurate breadcrumbs. @@ -167,3 +167,9 @@ with Carthage, which was the default for Xcode 11 and below, because the platform-specific framework bundles only works with Xcode 12. Carthage has encouraged its users [to use XCFrameworks](https://github.com/Carthage/Carthage/tree/a91d086ceaffef65c4a4a761108f3f32c519940c#getting-started) since version 0.37.0, released in January 2021. Therefore, it's acceptable to use XCFrameworks for Carthage users. + +## Remove the permissions feature + +Date: December 14, 2022 + +We [removed](https://github.com/getsentry/sentry-cocoa/pull/2529) the permissions feature that we added in [7.24.0](https://github.com/getsentry/sentry-cocoa/releases/tag/7.24.0). Multiple people reported getting denied in app review because of permission access without the corresponding Info.plist entry: see [#2528](https://github.com/getsentry/sentry-cocoa/issues/2528) and [2065](https://github.com/getsentry/sentry-cocoa/issues/2065).