Skip to content

Commit

Permalink
Merge pull request #718 from DataDog/buranmert/RUMM-1649-fix-webview-…
Browse files Browse the repository at this point in the history
…event-date

RUMM-1649 Fix: WebRUMEvent date offset in Ms
  • Loading branch information
buranmert authored Jan 14, 2022
2 parents 930723a + 9cf0651 commit 968f456
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ internal class DefaultWebRUMEventConsumer: WebRUMEventConsumer {

if let date = mutableEvent["date"] as? Int {
let viewID = (mutableEvent["view"] as? JSON)?["id"] as? String
let serverTimeOffsetInNs = getOffset(viewID: viewID)
let correctedDate = Int64(date) + serverTimeOffsetInNs
let serverTimeOffsetInMs = getOffsetInMs(viewID: viewID)
let correctedDate = Int64(date) + serverTimeOffsetInMs
mutableEvent["date"] = correctedDate
}

Expand Down Expand Up @@ -87,7 +87,7 @@ internal class DefaultWebRUMEventConsumer: WebRUMEventConsumer {
private typealias ViewIDOffsetPair = (viewID: String, offset: Offset)
private var viewIDOffsetPairs = [ViewIDOffsetPair]()

private func getOffset(viewID: String?) -> Offset {
private func getOffsetInMs(viewID: String?) -> Offset {
guard let viewID = viewID else {
return 0
}
Expand All @@ -97,7 +97,7 @@ internal class DefaultWebRUMEventConsumer: WebRUMEventConsumer {
if let found = found {
return found.offset
}
let offset = dateCorrector.currentCorrection.serverTimeOffset.toInt64Nanoseconds
let offset = dateCorrector.currentCorrection.serverTimeOffset.toInt64Milliseconds
viewIDOffsetPairs.insert((viewID: viewID, offset: offset), at: 0)
return offset
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class WebRUMEventConsumerTests: XCTestCase {
"session": ["plan": 1]
],
"application": ["id": mockContextProvider.context.rumApplicationID],
"date": 1_640_252_823_292 + 123.toInt64Nanoseconds,
"date": 1_640_252_823_292 + 123.toInt64Milliseconds,
"service": "shopist-web-ui",
"session": ["id": mockContextProvider.context.sessionID.toRUMDataFormat],
"view": [
Expand Down

0 comments on commit 968f456

Please sign in to comment.