Skip to content

Commit

Permalink
RUM-3588 CR feedback + rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
ncreated committed May 21, 2024
1 parent eb610b9 commit 99b72b8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ class CrashContextProviderTests: XCTestCase {
// MARK: - Helpers

private func DDAssert(crashContext: CrashContext, includes sdkContext: DatadogContext, file: StaticString = #filePath, line: UInt = #line) {
XCTAssertEqual(crashContext.appLaunchDate, sdkContext.launchTime?.launchDate, file: file, line: line)
XCTAssertEqual(crashContext.serverTimeOffset, sdkContext.serverTimeOffset, file: file, line: line)
XCTAssertEqual(crashContext.service, sdkContext.service, file: file, line: line)
XCTAssertEqual(crashContext.env, sdkContext.env, file: file, line: line)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,11 @@ extension CrashContextCoreProvider: FeatureMessageReceiver {
///
/// - Parameter context: The updated core context.
private func update(context: DatadogContext) {
queue.async {
queue.async { [weak self] in
guard let self = self else {
return
}

let crashContext = CrashContext(
context,
lastRUMViewEvent: self.viewEvent,
Expand All @@ -121,9 +125,9 @@ extension CrashContextCoreProvider: FeatureMessageReceiver {
}

private func updateRUMView(with baggage: FeatureBaggage, to core: DatadogCoreProtocol) {
queue.async { [weak core] in
queue.async { [weak core, weak self] in
do {
self.viewEvent = try baggage.decode(type: AnyCodable.self)
self?.viewEvent = try baggage.decode(type: AnyCodable.self)
} catch {
core?.telemetry
.error("Fails to decode RUM view event from Crash Reporting", error: error)
Expand All @@ -132,10 +136,10 @@ extension CrashContextCoreProvider: FeatureMessageReceiver {
}

private func resetRUMView(with baggage: FeatureBaggage, to core: DatadogCoreProtocol) {
queue.async { [weak core] in
queue.async { [weak core, weak self] in
do {
if try baggage.decode(type: Bool.self) {
self.viewEvent = nil
self?.viewEvent = nil
}
} catch {
core?.telemetry
Expand All @@ -145,9 +149,9 @@ extension CrashContextCoreProvider: FeatureMessageReceiver {
}

private func updateSessionState(with baggage: FeatureBaggage, to core: DatadogCoreProtocol) {
queue.async { [weak core] in
queue.async { [weak core, weak self] in
do {
self.sessionState = try baggage.decode(type: AnyCodable.self)
self?.sessionState = try baggage.decode(type: AnyCodable.self)
} catch {
core?.telemetry
.error("Fails to decode RUM session state from Crash Reporting", error: error)
Expand All @@ -156,9 +160,9 @@ extension CrashContextCoreProvider: FeatureMessageReceiver {
}

private func updateLogAttributes(with baggage: FeatureBaggage, to core: DatadogCoreProtocol) {
queue.async { [weak core] in
queue.async { [weak core, weak self] in
do {
self.logAttributes = try baggage.decode(type: AnyCodable.self)
self?.logAttributes = try baggage.decode(type: AnyCodable.self)
} catch {
core?.telemetry
.error("Fails to decode log attributes from Crash Reporting", error: error)
Expand All @@ -167,9 +171,9 @@ extension CrashContextCoreProvider: FeatureMessageReceiver {
}

private func updateRUMAttributes(with baggage: FeatureBaggage, to core: DatadogCoreProtocol) {
queue.async { [weak core] in
queue.async { [weak core, weak self] in
do {
self.rumAttributes = try baggage.decode(type: GlobalRUMAttributes.self)
self?.rumAttributes = try baggage.decode(type: GlobalRUMAttributes.self)
} catch {
core?.telemetry
.error("Fails to decode log attributes from Crash Reporting", error: error)
Expand Down

0 comments on commit 99b72b8

Please sign in to comment.