Skip to content

Commit

Permalink
Merge pull request #1938 from DataDog/jward/RUM-5155-fileId-over-file…
Browse files Browse the repository at this point in the history
…path

feat: Replace use of #filePath with #fileID
  • Loading branch information
fuzzybinary authored Jul 3, 2024
2 parents dc33648 + eed20be commit 33cf1b9
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Unreleased

- [IMPROVEMENT] Use `#fileID` over `#filePath` as the default argument in errors. See [#1938][]
- [FEATURE] Add support for Watchdog Terminations tracking in RUM. See [#1917][] [#1911][] [#1912][] [#1889][]
- [IMPROVEMENT] Allow disabling app hang monitoring in ObjC API. See [#1908][]
- [IMPROVEMENT] Update RUM and Telemetry models with KMP source. See [#1925][]
Expand Down Expand Up @@ -698,6 +699,7 @@ Release `2.0` introduces breaking changes. Follow the [Migration Guide](MIGRATIO
[#1912]: https://github.com/DataDog/dd-sdk-ios/pull/1912
[#1889]: https://github.com/DataDog/dd-sdk-ios/pull/1889
[#1925]: https://github.com/DataDog/dd-sdk-ios/pull/1925
[#1938]: https://github.com/DataDog/dd-sdk-ios/pull/1938
[@00fa9a]: https://github.com/00FA9A
[@britton-earnin]: https://github.com/Britton-Earnin
[@hengyu]: https://github.com/Hengyu
Expand Down
4 changes: 2 additions & 2 deletions DatadogRUM/Sources/RUMMonitorProtocol+Convenience.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,15 +77,15 @@ public extension RUMMonitorProtocol {
/// - stack: stack trace of the error. No specific format is required. If not specified, it will be inferred from `file` and `line`.
/// - source: the origin of the error.
/// - attributes: custom attributes to attach to this error.
/// - file: the file in which the error occurred (the default is the `#filePath` of the caller).
/// - file: the file in which the error occurred (the default is the `#fileID` of the caller).
/// - line: the line number on which the error occurred (the default is the `#line` of the caller).
func addError(
message: String,
type: String? = nil,
stack: String? = nil,
source: RUMErrorSource = .custom,
attributes: [AttributeKey: AttributeValue] = [:],
file: StaticString? = #filePath,
file: StaticString? = #fileID,
line: UInt? = #line
) {
addError(
Expand Down
2 changes: 1 addition & 1 deletion DatadogRUM/Sources/RUMMonitorProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public protocol RUMMonitorProtocol: AnyObject {
/// - stack: stack trace of the error. No specific format is required. If not specified, it will be inferred from `file` and `line`.
/// - source: the origin of the error.
/// - attributes: custom attributes to attach to this error.
/// - file: the file in which the error occurred (the default is the `#filePath` of the caller).
/// - file: the file in which the error occurred (the default is the `#fileID` of the caller).
/// - line: the line number on which the error occurred (the default is the `#line` of the caller).
func addError(
message: String,
Expand Down
2 changes: 1 addition & 1 deletion DatadogRUM/Tests/DDTAssertValidRUMUUID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import Foundation
import TestUtilities

func DDTAssertValidRUMUUID(_ uuid: @autoclosure () throws -> String?, _ message: @autoclosure () -> String = "", file: StaticString = #filePath, line: UInt = #line) {
func DDTAssertValidRUMUUID(_ uuid: @autoclosure () throws -> String?, _ message: @autoclosure () -> String = "", file: StaticString = #fileID, line: UInt = #line) {
_DDEvaluateAssertion(message: message(), file: file, line: line) {
try _DDTAssertValidRUMUUID(uuid())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class RUMInstrumentationTests: XCTestCase {
}
}

internal func DDAssertActiveSwizzlings(_ expectedSwizzledSelectors: [String], file: StaticString = #filePath, line: UInt = #line) {
internal func DDAssertActiveSwizzlings(_ expectedSwizzledSelectors: [String], file: StaticString = #fileID, line: UInt = #line) {
_DDEvaluateAssertion(message: "Only \(expectedSwizzledSelectors) swizzlings should be active", file: file, line: line) {
let actual = Swizzling.methods.map { "\(method_getName($0))" }.sorted()
let expected = expectedSwizzledSelectors.sorted()
Expand Down
12 changes: 6 additions & 6 deletions TestUtilities/Helpers/DDAssert.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,19 +148,19 @@ private func _DDAssertJSONEqual<T, U>(_ expression1: @autoclosure () throws -> T
}
}

public func DDAssertJSONEqual(_ expression1: @autoclosure () throws -> Any, _ expression2: @autoclosure () throws -> Any, _ message: @autoclosure () -> String = "", file: StaticString = #filePath, line: UInt = #line) {
public func DDAssertJSONEqual(_ expression1: @autoclosure () throws -> Any, _ expression2: @autoclosure () throws -> Any, _ message: @autoclosure () -> String = "", file: StaticString = #fileID, line: UInt = #line) {
_DDEvaluateAssertion(message: message(), file: file, line: line) {
try _DDAssertJSONEqual(AnyCodable(expression1()), AnyCodable(expression2()))
}
}

public func DDAssertJSONEqual<T, U>(_ expression1: @autoclosure () throws -> T, _ expression2: @autoclosure () throws -> U, _ message: @autoclosure () -> String = "", file: StaticString = #filePath, line: UInt = #line) where T: Encodable, U: Encodable {
public func DDAssertJSONEqual<T, U>(_ expression1: @autoclosure () throws -> T, _ expression2: @autoclosure () throws -> U, _ message: @autoclosure () -> String = "", file: StaticString = #fileID, line: UInt = #line) where T: Encodable, U: Encodable {
_DDEvaluateAssertion(message: message(), file: file, line: line) {
try _DDAssertJSONEqual(expression1(), expression2())
}
}

public func DDAssertJSONNotEqual<T, U>(_ expression1: @autoclosure () throws -> T, _ expression2: @autoclosure () throws -> U, _ message: @autoclosure () -> String = "", file: StaticString = #filePath, line: UInt = #line) where T: Encodable, U: Encodable {
public func DDAssertJSONNotEqual<T, U>(_ expression1: @autoclosure () throws -> T, _ expression2: @autoclosure () throws -> U, _ message: @autoclosure () -> String = "", file: StaticString = #fileID, line: UInt = #line) where T: Encodable, U: Encodable {
_DDEvaluateAssertion(message: message(), file: file, line: line) {
do {
try _DDAssertJSONEqual(expression1(), expression2())
Expand Down Expand Up @@ -198,13 +198,13 @@ private func _DDAssertDictionariesEqual(_ expression1: @autoclosure () throws ->
}
}

public func DDAssertDictionariesEqual(_ expression1: @autoclosure () throws -> [String: Any], _ expression2: @autoclosure () throws -> [String: Any], _ message: @autoclosure () -> String = "", file: StaticString = #filePath, line: UInt = #line) {
public func DDAssertDictionariesEqual(_ expression1: @autoclosure () throws -> [String: Any], _ expression2: @autoclosure () throws -> [String: Any], _ message: @autoclosure () -> String = "", file: StaticString = #fileID, line: UInt = #line) {
_DDEvaluateAssertion(message: message(), file: file, line: line) {
try _DDAssertDictionariesEqual(expression1(), expression2())
}
}

public func DDAssertDictionariesNotEqual(_ expression1: @autoclosure () throws -> [String: Any], _ expression2: @autoclosure () throws -> [String: Any], _ message: @autoclosure () -> String = "", file: StaticString = #filePath, line: UInt = #line) {
public func DDAssertDictionariesNotEqual(_ expression1: @autoclosure () throws -> [String: Any], _ expression2: @autoclosure () throws -> [String: Any], _ message: @autoclosure () -> String = "", file: StaticString = #fileID, line: UInt = #line) {
_DDEvaluateAssertion(message: message(), file: file, line: line) {
do {
try _DDAssertDictionariesEqual(expression1(), expression2())
Expand All @@ -216,7 +216,7 @@ public func DDAssertDictionariesNotEqual(_ expression1: @autoclosure () throws -
}
}

public func DDAssertThrowsError<T, E: Error>(_ expression: @autoclosure () throws -> T, _ message: @autoclosure () -> String = "", file: StaticString = #filePath, line: UInt = #line, _ errorHandler: (_ error: E) -> Void = { _ in }) {
public func DDAssertThrowsError<T, E: Error>(_ expression: @autoclosure () throws -> T, _ message: @autoclosure () -> String = "", file: StaticString = #fileID, line: UInt = #line, _ errorHandler: (_ error: E) -> Void = { _ in }) {
_DDEvaluateAssertion(message: message(), file: file, line: line) {
do {
let result = try expression()
Expand Down

0 comments on commit 33cf1b9

Please sign in to comment.