[go: nahoru, domu]

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

misc: remove url hash to avoid gtm hang in treemap, viewer #15425

Merged
merged 2 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions treemap/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ <h1 class="treemap-placeholder__heading">Lighthouse Treemap</h1>
<script src="https://www.gstatic.com/firebasejs/4.1.2/firebase-auth.js"></script>
<script src="src/bundled.js"></script>

<script>
// b/298230436
window.__hash = window.location.hash;
window.location.hash = '';
</script>
Copy link
Member

Choose a reason for hiding this comment

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

Should this be above bundled.js and the other scripts?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It looks at both, so either way 🤷

<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-16X003MB7V"></script>
<script>
Expand Down
5 changes: 3 additions & 2 deletions treemap/app/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -929,8 +929,9 @@ async function main() {
const app = new LighthouseTreemap();
const queryParams = new URLSearchParams(window.location.search);
const gzip = queryParams.get('gzip') === '1';
const hashParams = location.hash ?
JSON.parse(TextEncoding.fromBase64(location.hash.substr(1), {gzip})) :
const hash = window.__hash ?? location.hash;
const hashParams = hash ?
JSON.parse(TextEncoding.fromBase64(hash.substr(1), {gzip})) :
{};
/** @type {Record<string, any>} */
const params = {
Expand Down
1 change: 1 addition & 0 deletions treemap/types/treemap.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ declare global {
interface Window {
logger: _Logger;
__treemapOptions?: LH.Treemap.Options;
__hash?: string;
ga: UniversalAnalytics.ga;
}

Expand Down
5 changes: 5 additions & 0 deletions viewer/app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ <h1 class="viewer-placeholder__heading">Lighthouse Report Viewer</h1>

<div id="lh-log"></div>

<script>
// b/298230436
window.__hash = window.location.hash;
window.location.hash = '';
</script>
<script src="src/bundled.js" type="module"></script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
Expand Down
5 changes: 3 additions & 2 deletions viewer/app/src/lighthouse-report-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,10 @@ export class LighthouseReportViewer {
const jsonurl = params.get('jsonurl');
const gzip = params.get('gzip') === '1';

if (location.hash) {
const hash = window.__hash ?? location.hash;
if (hash) {
try {
const hashParams = JSON.parse(TextEncoding.fromBase64(location.hash.substr(1), {gzip}));
const hashParams = JSON.parse(TextEncoding.fromBase64(hash.substr(1), {gzip}));
if (hashParams.lhr) {
this._replaceReportHtml(hashParams.lhr);
return Promise.resolve();
Expand Down
1 change: 1 addition & 0 deletions viewer/types/viewer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ declare global {
interface Window {
viewer: _LighthouseReportViewer;
ga: UniversalAnalytics.ga;
__hash?: string;

// Inserted by viewer build.
LH_CURRENT_VERSION: string;
Expand Down
Loading