Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[main] fix startTime timestamp #2183

Merged
merged 3 commits into from
Oct 20, 2023
Merged

[main] fix startTime timestamp #2183

merged 3 commits into from
Oct 20, 2023

Conversation

siyuniu-ms
Copy link
Contributor

only modify the startTime for first page view telemetry

@siyuniu-ms siyuniu-ms added this to the 3.0.4 milestone Oct 19, 2023
} else {
// calculate the start time manually
let duration = ((customProperties || pageView.properties || {}).duration || 0);
pageView.startTime = new Date(new Date().getTime() - duration);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still needs to be done of ALL other cases, otherwise the reported "time" will be wrong.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise the Portal will show the wrong "startTime"

pageView.startTime = new Date(perf.timeOrigin + loadEventStart);
} else {
// calculate the start time manually
let duration = ((properties || pageView.properties || {}).duration || 0);
Copy link
Collaborator

@MSNev MSNev Oct 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at all of the "usages" of the sendPageViewInternal, it looks like (once we remove this from here), that we should do this duration update in the AngularPlugin.ts Line 602 (before the _pageTracking calls the _self.sendPageViewInternal so that the "time" is still shifted back by the duration otherwise the Portal will show the wrong "startTime"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe?? (testing required)
We can just keep something here like

if (isNullOrUndefined(pageView.startTime)) {
    // calculate the start time manually
    let duration = ((properties || pageView.properties || {}).duration || 0);
    if (duration) {
        pageView.startTime = new Date(new Date().getTime() - duration);
    }
}

So that if the previous code (like the line 602 above) doesn't specify any startTime then we keep "using" this default, this should also work for the subsequent page views, even with your code below for the if (!firstPageViewSent){

@siyuniu-ms
Copy link
Contributor Author

manual test time result:
first page view:
2023-10-20T00:15:01.881Z
page view performance time:
2023-10-20T00:15:04.612Z (this time is not adjusted with duration)

second page view triggered around 3 seconds after:
2023-10-20T00:15:04.888Z
third page view triggered around 4 seconds after:
2023-10-20T00:15:05.787Z

@siyuniu-ms siyuniu-ms marked this pull request as ready for review October 20, 2023 00:20
@siyuniu-ms siyuniu-ms merged commit d0f2a35 into main Oct 20, 2023
8 checks passed
@siyuniu-ms siyuniu-ms deleted the siyu/fixTime branch October 20, 2023 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants