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
14 changes: 8 additions & 6 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
15E0A8ED240F2CB000F044E3 /* SentrySerialization.m in Sources */ = {isa = PBXBuildFile; fileRef = 15E0A8EC240F2CB000F044E3 /* SentrySerialization.m */; };
15E0A8F0240F638200F044E3 /* SentrySerializationNilTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 15E0A8EF240F638200F044E3 /* SentrySerializationNilTests.m */; };
15E0A8F22411A45A00F044E3 /* SentrySessionInternal.m in Sources */ = {isa = PBXBuildFile; fileRef = 15E0A8F12411A45A00F044E3 /* SentrySessionInternal.m */; };
33042A0D29DAF79A00C60085 /* SentryExtraContextProvider.m in Sources */ = {isa = PBXBuildFile; fileRef = 33042A0C29DAF79A00C60085 /* SentryExtraContextProvider.m */; };
33042A1729DC2C4300C60085 /* SentryExtraContextProviderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33042A1629DC2C4300C60085 /* SentryExtraContextProviderTests.swift */; };
33EB2A912C3412E4004FED3D /* SentryWithoutUIKit.h in Headers */ = {isa = PBXBuildFile; fileRef = 33EB2A8F2C3411AE004FED3D /* SentryWithoutUIKit.h */; settings = {ATTRIBUTES = (Public, ); }; };
33EB2A922C341300004FED3D /* Sentry.h in Headers */ = {isa = PBXBuildFile; fileRef = 63AA76931EB9C1C200D153DE /* Sentry.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -1113,6 +1112,8 @@
FAAB2F972E4D345800FE8B7E /* SentryUIDeviceWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAAB2F962E4D344F00FE8B7E /* SentryUIDeviceWrapper.swift */; };
FAAB30F32E4E8F2C00FE8B7E /* SentryInAppLogic.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAAB30F22E4E8F2C00FE8B7E /* SentryInAppLogic.swift */; };
FAAB95C02EA163590030A2DB /* SentryScopeObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAAB95BF2EA163590030A2DB /* SentryScopeObserver.swift */; };
FAAB95D82EA1E23F0030A2DB /* SentryExtraContextProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAAB95D22EA1E23A0030A2DB /* SentryExtraContextProvider.swift */; };
FAAB95DE2EA1EB470030A2DB /* SentryDeviceContextKeys.h in Headers */ = {isa = PBXBuildFile; fileRef = FAAB95DD2EA1EB470030A2DB /* SentryDeviceContextKeys.h */; };
FAB007362E9EF8D3001C806A /* SentryUIViewControllerPerformanceTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAB007302E9EF8CB001C806A /* SentryUIViewControllerPerformanceTracker.swift */; };
FAB007432E9F47E8001C806A /* SessionTracker.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAB007422E9F47E4001C806A /* SessionTracker.swift */; };
FAB007522E9FE2FF001C806A /* SentrySwizzleWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAB0074C2E9FE2FA001C806A /* SentrySwizzleWrapper.swift */; };
Expand Down Expand Up @@ -1314,8 +1315,6 @@
15E0A8EC240F2CB000F044E3 /* SentrySerialization.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentrySerialization.m; sourceTree = "<group>"; };
15E0A8EF240F638200F044E3 /* SentrySerializationNilTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentrySerializationNilTests.m; sourceTree = "<group>"; };
15E0A8F12411A45A00F044E3 /* SentrySessionInternal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentrySessionInternal.m; sourceTree = "<group>"; };
33042A0B29DAF5F400C60085 /* SentryExtraContextProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SentryExtraContextProvider.h; sourceTree = "<group>"; };
33042A0C29DAF79A00C60085 /* SentryExtraContextProvider.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryExtraContextProvider.m; sourceTree = "<group>"; };
33042A1629DC2C4300C60085 /* SentryExtraContextProviderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryExtraContextProviderTests.swift; sourceTree = "<group>"; };
33EB2A8F2C3411AE004FED3D /* SentryWithoutUIKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryWithoutUIKit.h; path = Public/SentryWithoutUIKit.h; sourceTree = "<group>"; };
51B15F7F2BE88D510026A2F2 /* URLSessionTaskHelperTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLSessionTaskHelperTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2478,6 +2477,8 @@
FAAB2F962E4D344F00FE8B7E /* SentryUIDeviceWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUIDeviceWrapper.swift; sourceTree = "<group>"; };
FAAB30F22E4E8F2C00FE8B7E /* SentryInAppLogic.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryInAppLogic.swift; sourceTree = "<group>"; };
FAAB95BF2EA163590030A2DB /* SentryScopeObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryScopeObserver.swift; sourceTree = "<group>"; };
FAAB95D22EA1E23A0030A2DB /* SentryExtraContextProvider.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryExtraContextProvider.swift; sourceTree = "<group>"; };
FAAB95DD2EA1EB470030A2DB /* SentryDeviceContextKeys.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryDeviceContextKeys.h; path = include/SentryDeviceContextKeys.h; sourceTree = "<group>"; };
FAB007302E9EF8CB001C806A /* SentryUIViewControllerPerformanceTracker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUIViewControllerPerformanceTracker.swift; sourceTree = "<group>"; };
FAB007422E9F47E4001C806A /* SessionTracker.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SessionTracker.swift; sourceTree = "<group>"; };
FAB0074C2E9FE2FA001C806A /* SentrySwizzleWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySwizzleWrapper.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2641,6 +2642,7 @@
621D9F2D2B9B030E003D94DE /* Helper */ = {
isa = PBXGroup;
children = (
FAAB95D22EA1E23A0030A2DB /* SentryExtraContextProvider.swift */,
FAB0074C2E9FE2FA001C806A /* SentrySwizzleWrapper.swift */,
D4F56C3C2E9CEFFB00D57DAB /* InfoPlist */,
F4E1E9802E8C2B150007B080 /* SentryDateUtil.swift */,
Expand Down Expand Up @@ -2971,8 +2973,6 @@
844EDC75294144DB00C86F34 /* SentrySystemWrapper.mm */,
FAB359972E05D7E90083D5E3 /* SentryEventSwiftHelper.h */,
FAB359992E05D8080083D5E3 /* SentryEventSwiftHelper.m */,
33042A0B29DAF5F400C60085 /* SentryExtraContextProvider.h */,
33042A0C29DAF79A00C60085 /* SentryExtraContextProvider.m */,
D8739D152BEEA33F007D2F66 /* SentryLevelHelper.h */,
D8739D162BEEA33F007D2F66 /* SentryLevelHelper.m */,
F452438B2DE65BC0003E8F50 /* SentryUseNSExceptionCallstackWrapper.h */,
Expand Down Expand Up @@ -3671,6 +3671,7 @@
7BE0DC35272AE7BF004FA8B7 /* SentryCrash */ = {
isa = PBXGroup;
children = (
FAAB95DD2EA1EB470030A2DB /* SentryDeviceContextKeys.h */,
7DC831082398283C0043DD9A /* SentryCrashIntegration.h */,
7DC831092398283C0043DD9A /* SentryCrashIntegration.m */,
7BCFBD6C2681D0A900BC27D8 /* SentryCrashScopeObserver.h */,
Expand Down Expand Up @@ -5103,6 +5104,7 @@
F49D419C2DEA30C300D9244E /* SentryCrashExceptionApplicationHelper.h in Headers */,
7BDEAA022632A4580001EA25 /* SentryOptions+Private.h in Headers */,
A8AFFCCD29069C3E00967CD7 /* SentryHttpStatusCodeRange.h in Headers */,
FAAB95DE2EA1EB470030A2DB /* SentryDeviceContextKeys.h in Headers */,
D83D079B2B7F9D1C00CC9674 /* SentryMsgPackSerializer.h in Headers */,
D84F833D2A1CC401005828E0 /* SentrySwiftAsyncIntegration.h in Headers */,
15E0A8EA240F2C9000F044E3 /* SentrySerialization.h in Headers */,
Expand Down Expand Up @@ -5783,7 +5785,6 @@
62C1AFAB2B7E10EA0038C5F7 /* SentrySpotlightTransport.m in Sources */,
7B5CAF7727F5A68C00ED0DB6 /* SentryNSURLRequestBuilder.m in Sources */,
639FCFA11EBC804600778193 /* SentryException.m in Sources */,
33042A0D29DAF79A00C60085 /* SentryExtraContextProvider.m in Sources */,
7BA61CAD247BAA0B00C130A8 /* SentryDebugImageProvider.m in Sources */,
63FE70E720DA4C1000CDBAE8 /* SentryCrashMonitor.c in Sources */,
84354E1229BF944900CDBB8B /* SentryProfileTimeseries.m in Sources */,
Expand Down Expand Up @@ -5889,6 +5890,7 @@
FA67DD0F2DDBD4EA00896B02 /* SentryViewControllerBreadcrumbTracking.swift in Sources */,
FA67DD102DDBD4EA00896B02 /* StringExtensions.swift in Sources */,
FA67DD112DDBD4EA00896B02 /* SentryANRType.swift in Sources */,
FAAB95D82EA1E23F0030A2DB /* SentryExtraContextProvider.swift in Sources */,
FA67DD122DDBD4EA00896B02 /* Locks.swift in Sources */,
62CB19252E77F8FD00AF5DA2 /* SentryDispatchSourceWrapper.swift in Sources */,
FA21F0B42E4A2A80008B4E5A /* SentryAppState.swift in Sources */,
Expand Down
1 change: 0 additions & 1 deletion Sources/Sentry/PrivateSentrySDKOnly.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#import "SentryClient.h"
#import "SentryDebugImageProvider+HybridSDKs.h"
#import "SentryDebugImageProvider.h"
#import "SentryExtraContextProvider.h"
#import "SentryHub+Private.h"
#import "SentryInstallation.h"
#import "SentryInternalDefines.h"
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#import "SentryDebugImageProvider+HybridSDKs.h"
#import "SentryDefaultThreadInspector.h"
#import "SentryDependencyContainer.h"
#import "SentryDeviceContextKeys.h"
#import "SentryDsn.h"
#import "SentryEvent+Private.h"
#import "SentryException.h"
#import "SentryExtraContextProvider.h"
#import "SentryHub+Private.h"
#import "SentryHub.h"
#import "SentryInstallation.h"
Expand Down
1 change: 0 additions & 1 deletion Sources/Sentry/SentryDependencyContainer.m
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#import "SentryANRTrackerV1.h"

#import "SentryDefaultThreadInspector.h"
#import "SentryExtraContextProvider.h"
#import "SentryInternalCDefines.h"
#import "SentryInternalDefines.h"
#import "SentryLogC.h"
Expand Down
30 changes: 0 additions & 30 deletions Sources/Sentry/SentryExtraContextProvider.h

This file was deleted.

92 changes: 0 additions & 92 deletions Sources/Sentry/SentryExtraContextProvider.m

This file was deleted.

3 changes: 0 additions & 3 deletions Sources/Sentry/include/SentryCrashIntegration.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ NS_ASSUME_NONNULL_BEGIN
@class SentryCrashWrapper;
@class SentryScope;

static NSString *const SentryDeviceContextFreeMemoryKey = @"free_memory";
static NSString *const SentryDeviceContextAppMemoryKey = @"app_memory";

@interface SentryCrashIntegration : SentryBaseIntegration

/**
Expand Down
2 changes: 2 additions & 0 deletions Sources/Sentry/include/SentryDeviceContextKeys.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
static NSString *const SentryDeviceContextFreeMemoryKey = @"free_memory";
static NSString *const SentryDeviceContextAppMemoryKey = @"app_memory";
1 change: 1 addition & 0 deletions Sources/Sentry/include/SentryPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#import "SentryDateUtils.h"
#import "SentryDefaultThreadInspector.h"
#import "SentryDependencyContainerSwiftHelper.h"
#import "SentryDeviceContextKeys.h"
#import "SentryEvent+Serialize.h"
#import "SentryFileIOTrackerHelper.h"
#import "SentryFileManagerHelper.h"
Expand Down
72 changes: 72 additions & 0 deletions Sources/Swift/Helper/SentryExtraContextProvider.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
@_implementationOnly import _SentryPrivate

@_spi(Private) @objc public final class SentryExtraContextProvider: NSObject {

private static let kSentryProcessInfoThermalStateNominal = "nominal"
private static let kSentryProcessInfoThermalStateFair = "fair"
private static let kSentryProcessInfoThermalStateSerious = "serious"
private static let kSentryProcessInfoThermalStateCritical = "critical"

private let crashWrapper: SentryCrashWrapper
private let processInfoWrapper: SentryProcessInfoSource

#if (os(iOS) || targetEnvironment(macCatalyst)) && !SENTRY_NO_UIKIT
private let deviceWrapper: SentryUIDeviceWrapper

@objc public init(crashWrapper: SentryCrashWrapper, processInfoWrapper: SentryProcessInfoSource, deviceWrapper: SentryUIDeviceWrapper) {
self.crashWrapper = crashWrapper
self.processInfoWrapper = processInfoWrapper
self.deviceWrapper = deviceWrapper
}
#else
@objc public init(crashWrapper: SentryCrashWrapper, processInfoWrapper: SentryProcessInfoSource) {
self.crashWrapper = crashWrapper
self.processInfoWrapper = processInfoWrapper
}
#endif

@objc public func getExtraContext() -> [String: Any] {
[
"device": getExtraDeviceContext(),
"app": getExtraAppContext()
]
}

private func getExtraDeviceContext() -> [String: Any] {
var extraDeviceContext: [String: Any] = [
SentryDeviceContextFreeMemoryKey: NSNumber(value: crashWrapper.freeMemorySize),
"processor_count": NSNumber(value: processInfoWrapper.processorCount)
]

let thermalState = processInfoWrapper.thermalState
switch thermalState {
case .nominal:
extraDeviceContext["thermal_state"] = Self.kSentryProcessInfoThermalStateNominal
case .fair:
extraDeviceContext["thermal_state"] = Self.kSentryProcessInfoThermalStateFair
case .serious:
extraDeviceContext["thermal_state"] = Self.kSentryProcessInfoThermalStateSerious
case .critical:
extraDeviceContext["thermal_state"] = Self.kSentryProcessInfoThermalStateCritical
default:
SentrySDKLog.warning("Unexpected thermal state enum value: \(thermalState)")
}

#if (os(iOS) || targetEnvironment(macCatalyst)) && !SENTRY_NO_UIKIT
if deviceWrapper.orientation != .unknown {
extraDeviceContext["orientation"]
= deviceWrapper.orientation.isPortrait ? "portrait" : "landscape"
}

if deviceWrapper.isBatteryMonitoringEnabled {
extraDeviceContext["charging"] = NSNumber(value: deviceWrapper.batteryState == .charging)
extraDeviceContext["battery_level"] = NSNumber(value: Int(deviceWrapper.batteryLevel * 100))
}
#endif
return extraDeviceContext
}

private func getExtraAppContext() -> [String: Any] {
[ SentryDeviceContextAppMemoryKey: NSNumber(value: self.crashWrapper.appMemorySize) ]
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@_spi(Private) import Sentry
@_spi(Private) import SentryTestUtils
import XCTest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Sentry
@_spi(Private) import Sentry

#if os(iOS) || targetEnvironment(macCatalyst)
class TestSentryUIDeviceWrapper: SentryUIDeviceWrapper {
Expand Down
1 change: 0 additions & 1 deletion Tests/SentryTests/SentryTests-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@
#import "SentryEnvelopeAttachmentHeader.h"
#import "SentryEnvelopeRateLimit.h"
#import "SentryEvent+Private.h"
#import "SentryExtraContextProvider.h"
#import "SentryFileIOTrackerHelper.h"
#import "SentryFileIOTrackingIntegration.h"
#import "SentryFileManager+Test.h"
Expand Down
Loading