Skip to content
Merged

Add SPI #5307

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
2 changes: 1 addition & 1 deletion SentryTestUtils/ClearTestState.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
@testable import Sentry
@_spi(Private) @testable import Sentry

public func clearTestState() {
TestCleanup.clearTestState()
Expand Down
2 changes: 1 addition & 1 deletion SentryTestUtils/SentryLogExtensions.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Foundation
@testable import Sentry
@_spi(Private) @testable import Sentry

extension SentryLog {
public static func setTestDefaultLogLevel() {
Expand Down
6 changes: 3 additions & 3 deletions SentryTestUtils/TestHub.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import _SentryPrivate
import Foundation
@testable import Sentry
@_spi(Private) @testable import Sentry

public class TestHub: SentryHub {

Expand Down Expand Up @@ -51,8 +51,8 @@ public class TestHub: SentryHub {
}

public var onReplayCapture: (() -> Void)?
public var capturedReplayRecordingVideo = Invocations<(replay: SentryReplayEvent, recording: SentryReplayRecording, video: URL)>()
public override func capture(_ replayEvent: SentryReplayEvent, replayRecording: SentryReplayRecording, video videoURL: URL) {
@_spi(Private) public var capturedReplayRecordingVideo = Invocations<(replay: SentryReplayEvent, recording: SentryReplayRecording, video: URL)>()
@_spi(Private) public override func capture(_ replayEvent: SentryReplayEvent, replayRecording: SentryReplayRecording, video videoURL: URL) {
capturedReplayRecordingVideo.record((replayEvent, replayRecording, videoURL))
onReplayCapture?()
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/Swift/Core/Helper/Log/SentryLevel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@
}

@objcMembers
class SentryLevelHelper: NSObject {
static func nameForLevel(_ level: SentryLevel) -> String {
@_spi(Private) public class SentryLevelHelper: NSObject {
public static func nameForLevel(_ level: SentryLevel) -> String {

Check warning on line 40 in Sources/Swift/Core/Helper/Log/SentryLevel.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Core/Helper/Log/SentryLevel.swift#L40

Added line #L40 was not covered by tests
return level.description
}

static func levelForName(_ name: String) -> SentryLevel {
public static func levelForName(_ name: String) -> SentryLevel {

Check warning on line 44 in Sources/Swift/Core/Helper/Log/SentryLevel.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Core/Helper/Log/SentryLevel.swift#L44

Added line #L44 was not covered by tests
.fromName(name)
}
}
10 changes: 5 additions & 5 deletions Sources/Swift/Core/Helper/SentryCurrentDateProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@
}

@objcMembers
class SentryDefaultCurrentDateProvider: NSObject, SentryCurrentDateProvider {
func date() -> Date {
@_spi(Private) public class SentryDefaultCurrentDateProvider: NSObject, SentryCurrentDateProvider {
public func date() -> Date {
return Date()
}

func timezoneOffset() -> Int {
public func timezoneOffset() -> Int {

Check warning on line 21 in Sources/Swift/Core/Helper/SentryCurrentDateProvider.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Core/Helper/SentryCurrentDateProvider.swift#L21

Added line #L21 was not covered by tests
return TimeZone.current.secondsFromGMT()
}

/**
* Returns the absolute timestamp, which has no defined reference point or unit
* as it is platform dependent.
*/
func systemTime() -> UInt64 {
public func systemTime() -> UInt64 {
Self.getAbsoluteTime()
}

func systemUptime() -> TimeInterval {
ProcessInfo.processInfo.systemUptime
}

static func getAbsoluteTime() -> UInt64 {
public static func getAbsoluteTime() -> UInt64 {
clock_gettime_nsec_np(CLOCK_UPTIME_RAW)
}
}
8 changes: 4 additions & 4 deletions Sources/Swift/Core/Helper/SentryFileContents.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Foundation

@objcMembers
class SentryFileContents: NSObject {
@_spi(Private) public class SentryFileContents: NSObject {

let path: String
let contents: Data
public let path: String
public let contents: Data

init(path: String, contents: Data) {
public init(path: String, contents: Data) {

Check warning on line 9 in Sources/Swift/Core/Helper/SentryFileContents.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Core/Helper/SentryFileContents.swift#L9

Added line #L9 was not covered by tests
self.path = path
self.contents = contents
}
Expand Down
28 changes: 14 additions & 14 deletions Sources/Swift/Core/MetricKit/SentryMXCallStackTree.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
* JSON specification of MXCallStackTree can be found here https://developer.apple.com/documentation/metrickit/mxcallstacktree/3552293-jsonrepresentation
*/
@objcMembers
class SentryMXCallStackTree: NSObject, Codable {
@_spi(Private) public class SentryMXCallStackTree: NSObject, Codable {

let callStacks: [SentryMXCallStack]
let callStackPerThread: Bool
public let callStacks: [SentryMXCallStack]
public let callStackPerThread: Bool

init(callStacks: [SentryMXCallStack], callStackPerThread: Bool) {
self.callStacks = callStacks
Expand All @@ -21,11 +21,11 @@
}

@objcMembers
class SentryMXCallStack: NSObject, Codable {
var threadAttributed: Bool?
var callStackRootFrames: [SentryMXFrame]
@_spi(Private) public class SentryMXCallStack: NSObject, Codable {
public var threadAttributed: Bool?
public var callStackRootFrames: [SentryMXFrame]

var flattenedRootFrames: [SentryMXFrame] {
public var flattenedRootFrames: [SentryMXFrame] {

Check warning on line 28 in Sources/Swift/Core/MetricKit/SentryMXCallStackTree.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Core/MetricKit/SentryMXCallStackTree.swift#L28

Added line #L28 was not covered by tests
return callStackRootFrames.flatMap { [$0] + $0.frames }
}

Expand All @@ -36,14 +36,14 @@
}

@objcMembers
class SentryMXFrame: NSObject, Codable {
var binaryUUID: UUID
var offsetIntoBinaryTextSegment: Int
var binaryName: String?
var address: UInt64
var subFrames: [SentryMXFrame]?
@_spi(Private) public class SentryMXFrame: NSObject, Codable {
public var binaryUUID: UUID
public var offsetIntoBinaryTextSegment: Int
public var binaryName: String?
public var address: UInt64
public var subFrames: [SentryMXFrame]?

var sampleCount: Int?
public var sampleCount: Int?

init(binaryUUID: UUID, offsetIntoBinaryTextSegment: Int, sampleCount: Int? = nil, binaryName: String? = nil, address: UInt64, subFrames: [SentryMXFrame]?) {
self.binaryUUID = binaryUUID
Expand Down
10 changes: 5 additions & 5 deletions Sources/Swift/Core/MetricKit/SentryMXManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@objc protocol SentryMXManagerDelegate {
@objc @_spi(Private) public protocol SentryMXManagerDelegate {

func didReceiveCrashDiagnostic(_ diagnostic: MXCrashDiagnostic, callStackTree: SentryMXCallStackTree, timeStampBegin: Date, timeStampEnd: Date)

Expand All @@ -26,7 +26,7 @@
@available(iOS 15.0, macOS 12.0, macCatalyst 15.0, *)
@available(tvOS, unavailable)
@available(watchOS, unavailable)
@objcMembers class SentryMXManager: NSObject, MXMetricManagerSubscriber {
@objcMembers @_spi(Private) public class SentryMXManager: NSObject, MXMetricManagerSubscriber {

let disableCrashDiagnostics: Bool

Expand All @@ -36,17 +36,17 @@

weak var delegate: SentryMXManagerDelegate?

func receiveReports() {
public func receiveReports() {

Check warning on line 39 in Sources/Swift/Core/MetricKit/SentryMXManager.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Core/MetricKit/SentryMXManager.swift#L39

Added line #L39 was not covered by tests
let shared = MXMetricManager.shared
shared.add(self)
}

func pauseReports() {
public func pauseReports() {

Check warning on line 44 in Sources/Swift/Core/MetricKit/SentryMXManager.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Core/MetricKit/SentryMXManager.swift#L44

Added line #L44 was not covered by tests
let shared = MXMetricManager.shared
shared.remove(self)
}

func didReceive(_ payloads: [MXDiagnosticPayload]) {
public func didReceive(_ payloads: [MXDiagnosticPayload]) {

Check warning on line 49 in Sources/Swift/Core/MetricKit/SentryMXManager.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Core/MetricKit/SentryMXManager.swift#L49

Added line #L49 was not covered by tests
func actOn(callStackTree: MXCallStackTree, action: (SentryMXCallStackTree) -> Void) {
guard let callStackTree = try? SentryMXCallStackTree.from(data: callStackTree.jsonRepresentation()) else {
return
Expand Down
8 changes: 4 additions & 4 deletions Sources/Swift/Core/SwiftDescriptor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
#endif

@objc
class SwiftDescriptor: NSObject {
@_spi(Private) public class SwiftDescriptor: NSObject {

@objc
static func getObjectClassName(_ object: AnyObject) -> String {
public static func getObjectClassName(_ object: AnyObject) -> String {

Check warning on line 11 in Sources/Swift/Core/SwiftDescriptor.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Core/SwiftDescriptor.swift#L11

Added line #L11 was not covered by tests
return String(describing: type(of: object))
}

/// UIViewControllers aren't available on watchOS
#if canImport(UIKit) && !os(watchOS) && !SENTRY_NO_UIKIT
@objc
static func getViewControllerClassName(_ object: UIViewController) -> String {
public static func getViewControllerClassName(_ object: UIViewController) -> String {

Check warning on line 18 in Sources/Swift/Core/SwiftDescriptor.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Core/SwiftDescriptor.swift#L18

Added line #L18 was not covered by tests
if let object = object as? SentryUIViewControllerDescriptor {
return object.sentryName
}
Expand All @@ -24,7 +24,7 @@
#endif

@objc
static func getSwiftErrorDescription(_ error: Error) -> String? {
public static func getSwiftErrorDescription(_ error: Error) -> String? {

Check warning on line 27 in Sources/Swift/Core/SwiftDescriptor.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Core/SwiftDescriptor.swift#L27

Added line #L27 was not covered by tests
return String(describing: error)
}
}
4 changes: 2 additions & 2 deletions Sources/Swift/Core/Tools/HTTPHeaderSanitizer.swift
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Foundation

@objcMembers
class HTTPHeaderSanitizer: NSObject {
static func sanitizeHeaders(_ headers: [String: String]) -> [String: String] {
@_spi(Private) public class HTTPHeaderSanitizer: NSObject {
public static func sanitizeHeaders(_ headers: [String: String]) -> [String: String] {

Check warning on line 5 in Sources/Swift/Core/Tools/HTTPHeaderSanitizer.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Core/Tools/HTTPHeaderSanitizer.swift#L5

Added line #L5 was not covered by tests
let _securityHeaders = Set([
"X-FORWARDED-FOR", "AUTHORIZATION", "COOKIE", "SET-COOKIE", "X-API-KEY", "X-REAL-IP",
"REMOTE-ADDR", "FORWARDED", "PROXY-AUTHORIZATION", "X-CSRF-TOKEN", "X-CSRFTOKEN",
Expand Down
6 changes: 3 additions & 3 deletions Sources/Swift/Core/Tools/SentryLog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/// and the thread sanitizer would surface these race conditions. We accept these race conditions for
/// the log messages in the tests over adding locking for all log messages.
@objc
class SentryLog: NSObject {
@_spi(Private) public class SentryLog: NSObject {

static private(set) var isDebug = true
static private(set) var diagnosticLevel = SentryLevel.error
Expand All @@ -29,7 +29,7 @@
}

@objc
static func log(message: String, andLevel level: SentryLevel) {
public static func log(message: String, andLevel level: SentryLevel) {

Check warning on line 32 in Sources/Swift/Core/Tools/SentryLog.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Core/Tools/SentryLog.swift#L32

Added line #L32 was not covered by tests
guard willLog(atLevel: level) else { return }

// We use the timeIntervalSinceReferenceDate because date format is
Expand All @@ -45,7 +45,7 @@
* @c NO if not.
*/
@objc
static func willLog(atLevel level: SentryLevel) -> Bool {
public static func willLog(atLevel level: SentryLevel) -> Bool {
if level == .none {
return false
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Swift/Core/Tools/URLSessionTaskHelper.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Foundation

@objcMembers
class URLSessionTaskHelper: NSObject {
@_spi(Private) public class URLSessionTaskHelper: NSObject {

static func getGraphQLOperationName(from task: URLSessionTask?) -> String? {
public static func getGraphQLOperationName(from task: URLSessionTask?) -> String? {

Check warning on line 6 in Sources/Swift/Core/Tools/URLSessionTaskHelper.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Core/Tools/URLSessionTaskHelper.swift#L6

Added line #L6 was not covered by tests
guard let task = task else { return nil }
guard task.originalRequest?.value(forHTTPHeaderField: "Content-Type") == "application/json" else { return nil }
guard let requestBody = task.originalRequest?.httpBody else { return nil }
Expand Down
12 changes: 6 additions & 6 deletions Sources/Swift/Core/Tools/UrlSanitized.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import Foundation

@objcMembers
class UrlSanitized: NSObject {
@_spi(Private) public class UrlSanitized: NSObject {
static let SENSITIVE_DATA_SUBSTITUTE = "[Filtered]"
private var components: URLComponents?

var query: String? { components?.query }
var queryItems: [URLQueryItem]? { components?.queryItems }
var fragment: String? { components?.fragment }
public var query: String? { components?.query }
public var queryItems: [URLQueryItem]? { components?.queryItems }
public var fragment: String? { components?.fragment }

Check warning on line 10 in Sources/Swift/Core/Tools/UrlSanitized.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Core/Tools/UrlSanitized.swift#L8-L10

Added lines #L8 - L10 were not covered by tests

init(URL url: URL) {
public init(URL url: URL) {

Check warning on line 12 in Sources/Swift/Core/Tools/UrlSanitized.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Core/Tools/UrlSanitized.swift#L12

Added line #L12 was not covered by tests
components = URLComponents(url: url, resolvingAgainstBaseURL: false)

if components?.user != nil {
Expand All @@ -21,7 +21,7 @@
}
}

var sanitizedUrl: String? {
public var sanitizedUrl: String? {

Check warning on line 24 in Sources/Swift/Core/Tools/UrlSanitized.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Core/Tools/UrlSanitized.swift#L24

Added line #L24 was not covered by tests
guard var result = self.components?.string else { return nil }
if let end = result.firstIndex(of: "?") ?? result.firstIndex(of: "#") {
result = String(result[result.startIndex..<end])
Expand Down
4 changes: 2 additions & 2 deletions Sources/Swift/Helper/SentryEnabledFeaturesBuilder.swift
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import Foundation

@objcMembers class SentryEnabledFeaturesBuilder: NSObject {
@objcMembers @_spi(Private) public class SentryEnabledFeaturesBuilder: NSObject {

// swiftlint:disable cyclomatic_complexity function_body_length
static func getEnabledFeatures(options: Options?) -> [String] {
public static func getEnabledFeatures(options: Options?) -> [String] {

Check warning on line 6 in Sources/Swift/Helper/SentryEnabledFeaturesBuilder.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Helper/SentryEnabledFeaturesBuilder.swift#L6

Added line #L6 was not covered by tests
guard let options = options else {
return []
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,27 @@
import Foundation

@objcMembers
class SentryReplayEvent: Event {
@_spi(Private) public class SentryReplayEvent: Event {

// Start time of the replay segment
let replayStartTimestamp: Date
public let replayStartTimestamp: Date

// The Type of the replay
let replayType: SentryReplayType
public let replayType: SentryReplayType

/**
* Number of the segment in the replay.
* This is an incremental number
*/
let segmentId: Int
public let segmentId: Int

/**
* This will be used to store the name of the screens
* that appear during the duration of the replay segment.
*/
var urls: [String]?
init(eventId: SentryId, replayStartTimestamp: Date, replayType: SentryReplayType, segmentId: Int) {
public var urls: [String]?

public init(eventId: SentryId, replayStartTimestamp: Date, replayType: SentryReplayType, segmentId: Int) {

Check warning on line 25 in Sources/Swift/Integrations/SessionReplay/SentryReplayEvent.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/SessionReplay/SentryReplayEvent.swift#L25

Added line #L25 was not covered by tests
self.replayStartTimestamp = replayStartTimestamp
self.replayType = replayType
self.segmentId = segmentId
Expand All @@ -36,7 +36,7 @@
fatalError("init() has not been implemented")
}

override func serialize() -> [String: Any] {
public override func serialize() -> [String: Any] {

Check warning on line 39 in Sources/Swift/Integrations/SessionReplay/SentryReplayEvent.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/SessionReplay/SentryReplayEvent.swift#L39

Added line #L39 was not covered by tests
var result = super.serialize()
result["urls"] = urls
result["replay_start_timestamp"] = replayStartTimestamp.timeIntervalSince1970
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

@objcMembers
class SentryReplayRecording: NSObject {
@_spi(Private) public class SentryReplayRecording: NSObject {

static let SentryReplayEncoding = "h264"
static let SentryReplayContainer = "mp4"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

@objc
enum SentryReplayType: Int {
@_spi(Private) public enum SentryReplayType: Int {
case session
case buffer
}
Expand All @@ -18,7 +18,7 @@
// Implementing the CustomStringConvertible protocol to provide a string representation of the enum values.
// This method will be called by the Swift runtime when converting the enum to a string, i.e. in String interpolations.
extension SentryReplayType: CustomStringConvertible {
var description: String {
public var description: String {

Check warning on line 21 in Sources/Swift/Integrations/SessionReplay/SentryReplayType.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Integrations/SessionReplay/SentryReplayType.swift#L21

Added line #L21 was not covered by tests
return toString()
}
}
2 changes: 1 addition & 1 deletion Sources/Swift/Protocol/Codable/SentryEventDecoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

@objcMembers
public class SentryEventDecoder: NSObject {
static func decodeEvent(jsonData: Data) -> Event? {
@_spi(Private) public static func decodeEvent(jsonData: Data) -> Event? {

Check warning on line 5 in Sources/Swift/Protocol/Codable/SentryEventDecoder.swift

View check run for this annotation

Codecov / codecov/patch

Sources/Swift/Protocol/Codable/SentryEventDecoder.swift#L5

Added line #L5 was not covered by tests
return decodeFromJSONData(jsonData: jsonData) as SentryEventDecodable?
}
}
Loading
Loading