Skip to content

fix: Replace performance.timeOrigin in favour of browserPerformanceTimeOrigin #3397

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

Merged
merged 3 commits into from
Apr 16, 2021

Conversation

dashed
Copy link
Member

@dashed dashed commented Apr 15, 2021

Use browserPerformanceTimeOrigin in favour of performance.timeOrigin when generating timestamps for the LCP and FID web vitals.

@dashed dashed requested review from rhcarvalho and a team April 15, 2021 15:03
@dashed dashed self-assigned this Apr 15, 2021
@dashed dashed requested a review from kamilogorek as a code owner April 15, 2021 15:03
@github-actions
Copy link
Contributor

github-actions bot commented Apr 15, 2021

size-limit report

Path Size
@sentry/browser - CDN Bundle (gzipped) 20.59 KB (-0.01% 🔽)
@sentry/browser - Webpack 21.45 KB (0%)
@sentry/react - Webpack 21.49 KB (0%)
@sentry/browser + @sentry/tracing - CDN Bundle (gzipped) 27.8 KB (-0.03% 🔽)

Copy link
Contributor

@rhcarvalho rhcarvalho left a comment

Choose a reason for hiding this comment

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

One suggestion for simplification and we should see less weird transaction durations :) Thanks @dashed ❤️

const startTime = msToSec(entry.startTime as number);
logger.log('[Measurements] Adding LCP');
this._measurements['lcp'] = { value: metric.value };
this._measurements['mark.lcp'] = { value: timeOrigin + startTime };
if (browserPerformanceTimeOrigin !== undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

browserPerformanceTimeOrigin should always exist when we can actually report LCP and FID.

I'd just replace performance.timeOrigin above with browserPerformanceTimeOrigin.

I see we use performance.timeOrigin directly in ember... maybe we change that too, cc @k-fish.

performance.measure && performance.getEntriesByName && performance.timeOrigin !== undefined;

const startTimestamp = (measure.startTime + performance.timeOrigin) / 1000;

Copy link
Member Author

Choose a reason for hiding this comment

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

@rhcarvalho typescript told me that browserPerformanceTimeOrigin could be undefined, but I'll coerce it as a number

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah typescript... it is only undefined if performance is also undefined.

@dashed dashed changed the title fix(webvitals): Use browserPerformanceTimeOrigin for web vitals timestamps fix: Replace performance.timeOrigin in favour of browserPerformanceTimeOrigin Apr 15, 2021
@dashed dashed requested a review from rhcarvalho April 15, 2021 15:30
@dashed dashed force-pushed the web-vitals-timeorigin branch from 830c67e to c016947 Compare April 15, 2021 15:31
Copy link
Contributor

@rhcarvalho rhcarvalho left a comment

Choose a reason for hiding this comment

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

Thanks @dashed

@dashed dashed merged commit 1c2cdc3 into master Apr 16, 2021
@dashed dashed deleted the web-vitals-timeorigin branch April 16, 2021 09:23
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.

2 participants