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: add utm params to web.dev links #9555

Merged
merged 2 commits into from
Aug 14, 2019
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
4 changes: 2 additions & 2 deletions lighthouse-core/report/html/renderer/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ class DOM {
// Otherwise, append any links found.
const url = new URL(segment.linkHref);

const DEVELOPERS_GOOGLE_ORIGIN = 'https://developers.google.com';
if (url.origin === DEVELOPERS_GOOGLE_ORIGIN) {
const DOCS_ORIGINS = ['https://developers.google.com', 'https://web.dev'];
if (DOCS_ORIGINS.includes(url.origin)) {
url.searchParams.set('utm_source', 'lighthouse');
url.searchParams.set('utm_medium', this._lighthouseChannel);
}
Expand Down
9 changes: 8 additions & 1 deletion lighthouse-core/test/report/html/renderer/dom-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,14 @@ describe('DOM', () => {
assert.equal(result.innerHTML, '<a rel="noopener" target="_blank" href="https://developers.google.com/web/tools/lighthouse/audits/description?utm_source=lighthouse&amp;utm_medium=someChannel">Learn more</a>.');
});

it('doesn\'t append utm params to non https://developers.google.com origins', () => {
it('appends utm params to the URLs with https://web.dev origin', () => {
const text = '[Learn more](https://web.dev/tap-targets/).';

const result = dom.convertMarkdownLinkSnippets(text);
assert.equal(result.innerHTML, '<a rel="noopener" target="_blank" href="https://web.dev/tap-targets/?utm_source=lighthouse&amp;utm_medium=someChannel">Learn more</a>.');
Copy link
Member

Choose a reason for hiding this comment

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

utmMedium=someMedium?

Copy link
Member Author

Choose a reason for hiding this comment

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

we call it channel internally. we just expose it to GA through utm_medium but we're not gonna rename 'channel' to 'medium' so i think we keep it as is.

});

it('doesn\'t append utm params to other (non-docs) origins', () => {
const text = '[Learn more](https://example.com/info).';

const result = dom.convertMarkdownLinkSnippets(text);
Expand Down