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

fix: better handle TTFB from BFCache #221

Merged
merged 1 commit into from
Feb 21, 2023

Conversation

SuperOleg39
Copy link
Contributor

No description provided.

src/observe.ts Outdated
// @ts-ignore
report.value = report.value - report.entries[0].requestStart;
report.value = report.entries[0] ? report.value - report.entries[0].requestStart : report.value;
Copy link
Owner

Choose a reason for hiding this comment

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

I feel like we should just take a step forward and not report it completely.

Otherwise, it will increase the score for "good" pages. And I have a feeling people will not read the docs, and forget to skip the 0 value.

Copy link
Owner

Choose a reason for hiding this comment

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

Actually never mind, let me read this convo first. GoogleChrome/web-vitals#313

Copy link
Owner

Choose a reason for hiding this comment

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

@SuperOleg39 I read the discussion, which btw, thank you @tunetheweb for taking the time to respond with so many insights.

I was not aware of this definition "CrUX measured "TTFB"", that's brilliant.

ttfb

As Perfume.js aims to be used for capturing data similar to "CrUX", let's follow that standard.

@SuperOleg39 would you mind taking care of adjusting TTFB to "CrUX" standard, adding the tests and updating the README please.

As this is a breaking changes, this means we are going to cut v9 with this fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated onTTFB handle, will try to add some tests later, need to think about realization)

README.md Outdated
@@ -118,7 +118,10 @@ const perfume = new Perfume({
myAnalyticsTool.track('storageEstimate', data);
break;
case 'TTFB':
myAnalyticsTool.track('timeToFirstByte', { duration: data });
// Zero value mean than page restored from Back-Forward Cache, and you can ignore it before reporting
if (data > 0) {
Copy link
Owner

Choose a reason for hiding this comment

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

I feel like this check should be part of Perfume at this point, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure about it - because of we are reported navigation type now, and 0 is not a problem when you will filter values by navigation type..

Copy link
Owner

@Zizzamia Zizzamia Feb 14, 2023

Choose a reason for hiding this comment

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

I don't follow, what do you mean? If people should ignore 0, why reporting those values?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just don't have an answer, is 0 values a problem or not, and users must decide it or perfume.js internally

Because web-vitals still report this values with navigationType: 'back-forward-cache'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe ignoring 0 is a really useful default behaviour

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point) Will rework soon

Choose a reason for hiding this comment

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

Zero value may mean it's 0, or it's not set (Safari reports zero for cross-origin redirect for example).

For this uncertainty reason we choose NOT to emit 0 TTFBs at all. Technically we could do it for bfcache restores (as it's by definition not a redirect and really is known to be zero), and we debated that, but in the end decided to not emit there either for consistency.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but in the end decided to not emit there either for consistency

Don't fully understand this case - in fact, web-vitals sends 0 value in callback. Or I miss something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sent fix where ignore zero

Choose a reason for hiding this comment

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

As of this change we don't "report" a 0 TTFB: https://github.com/GoogleChrome/web-vitals/pull/281/files (see also the comments in that PR).

@Zizzamia Zizzamia merged commit f846326 into Zizzamia:master Feb 21, 2023
@Zizzamia
Copy link
Owner

Nice! Thank you @SuperOleg39
I am going to cut the new release in a couple of days, as soon as @Cdub-9 publish is next PR on the new User Journey perf feature.

@SuperOleg39
Copy link
Contributor Author

@Zizzamia Hello! Sorry, is this fix was released?

@Zizzamia
Copy link
Owner

Zizzamia commented Jul 7, 2023

Ciao @SuperOleg39 it should under the v9 RC, v9.0.0-rc.3.

I asked @lkuangPR also to help me out cut the official v9 release, as we are doing some cleanup before the official cut.

Give a try to v9.0.0-rc.3, and let me know how it is.

@lkuangPR can you please start working on updating the CHANGELOG with all the latest changes we are doing. This can help as well our contributors to get a sense on what's going on.

@SuperOleg39
Copy link
Contributor Author

Ciao @SuperOleg39 it should under the v9 RC, v9.0.0-rc.3.

Thanks for the answer!

RC looks little bit too risky for production(

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.

3 participants