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

report(third party): filter out third party urls #6351

Merged
merged 53 commits into from
Apr 30, 2019
Merged

Conversation

wardpeet
Copy link
Collaborator

@wardpeet wardpeet commented Oct 21, 2018

Summary

Hides 3th party urls from our tables when the checkbox is marked. This do not changes scores, just hides it in the UI.

A request is marked as third party when the TLD + 1 can not be found in the url.
pageTLDPlusOne = new URL(this.json.finalUrl).origin.split('.').slice(-2).join('.');

Demo:
http://wardpeet-filestorage.surge.sh/lh-store/pr-6351/report.html

Related Issues/PRs

#4516

need upgraded jsdom:
#6411

@wardpeet wardpeet requested a review from paulirish as a code owner October 21, 2018 17:56
@wardpeet wardpeet changed the title report(third party): filter out third party urls report(third party): filter out third party urls (WIP) Oct 21, 2018
@wardpeet
Copy link
Collaborator Author

I still need to add a global checkbox to select/unselect all checkboxes. We might also want to show a label on marked elements like @hwikyounglee suggested.

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

nice!! slick solution to the even background colors too :)

Two sticking points I still see I think we'll need to wrestle with:

  • Skipping this in certain audits (like preconnect to 3rd party origins, it doesn't make any sense to hide the list of 100% third party origins, image aspect ratios audit also doesn't have any connection to the origin of the resource)

  • Super obviously marking that there's information in the table that's missing when filtered. I still kinda like the idea of inserting a summary placeholder row to further indicate that there's information in the table that's being hidden, but open to other ideas of course if @hwikyounglee has some awesome tricks hidden up her sleeve for us :)

@hwikyounglee
Copy link

hwikyounglee commented Oct 24, 2018

3p-show

Taking all things out of my sleeve, hmm, not much hidden! But made up a few things now. Open for suggestions.

  1. Probably okay without background color
  2. Probably we could see how the locally scoped checkboxes are used, and reassess a need of a global checkbox.
  3. Just to make the checkboxes look noticeable, I'm wondering if we might try the checkbox 'checked' and the label it as 'Show' instead of 'Filter-out/hide'.

@wardpeet
Copy link
Collaborator Author

  1. I think it would be nice to have local scoped checkboxes and a global one? Or maybe the global one is over rated.
  2. We could check it by default and rephrase into Show 3th party resources. I don't really have an opinion on this.

@wardpeet wardpeet force-pushed the feat/report-3p branch 2 times, most recently from 22ef255 to c4d9b64 Compare October 26, 2018 22:58
@wardpeet wardpeet changed the title report(third party): filter out third party urls (WIP) report(third party): filter out third party urls Oct 29, 2018
@wardpeet
Copy link
Collaborator Author

I'm having an issue with the tests because the initFeatures is ran on the report template which does not contain the strings. I could combine the files with a string replace but other errors occur so not sure what to do here? I'm thinking of moving the report-ui-feature-test.js to end to end tests with puppeteer WDYT?

@brendankenny
Copy link
Member

there's definitely value in having it be a unit test.

the report template which does not contain the strings

Which strings do you mean? The travis failure doesn't give much of a clue

@wardpeet
Copy link
Collaborator Author

wardpeet commented Oct 31, 2018

https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/report/html/reporttemplate.html is used in the report features test which means there are no tags to clone.
Templates are stored in https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/report/html/templates.html. It would make sense to replace the %%LIGHTHOUSE_TEMPLATES%% with the templates but somehow it didn't work. I could figure out why that didn't work

@brendankenny
Copy link
Member

brendankenny commented Oct 31, 2018

It would make sense to replace the %%LIGHTHOUSE_TEMPLATES%% with the templates but somehow it didn't work.

ah, I see. I thought maybe you were talking about the i18n strings and was worried :)

build-viewer.js does literally just htmlSrc = htmlSrc.replace(/%%LIGHTHOUSE_TEMPLATES%%/, htmlReportAssets.REPORT_TEMPLATES);, so it should work in theory...

@wardpeet
Copy link
Collaborator Author

@brendankenny fixed the issue by changing const container = reportUIFeatures._dom._document.body into const container = reportUIFeatures._dom._document.querySelector('main'); as it's getting cleared by the renderReport function.

Please let me know what is left to move forward.

@brendankenny
Copy link
Member

brendankenny commented Apr 27, 2019

No rendering tests, though!

:)

(sorry)

@connorjclark
Copy link
Collaborator

connorjclark commented Apr 29, 2019

image
highlighted is 3P, lol. I think there is nothing that can be done about this?

EDIT: oh, btw I audited "www.nyt.com" which redirects to "www.nytimes.com". I guess this is WAI.

@connorjclark
Copy link
Collaborator

No rendering tests, though!

:)

(sorry)

done. caught a bug :)

continue;
}
const datasetUrl = urlItem.dataset.url || '';
const isThirdParty = Util.getRootDomain(datasetUrl) !== rootDomain;
Copy link
Collaborator

Choose a reason for hiding this comment

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

@wardpeet this ok?

@vercel vercel bot temporarily deployed to staging April 29, 2019 19:27 Inactive
Copy link
Member

@brendankenny brendankenny left a comment

Choose a reason for hiding this comment

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

LGTM!

over to you, @paulirish

Copy link
Member

@paulirish paulirish left a comment

Choose a reason for hiding this comment

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

image

@brendankenny
Copy link
Member

🎊 🎊 🎊

@paulirish
Copy link
Member

paulirish commented Apr 30, 2019 via email

@wardpeet
Copy link
Collaborator Author

@hoten thanks for getting this out the door! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants