Skip to content

Commit c2974f7

Browse files
bmeurerDevtools-frontend LUCI CQ
authored and
Devtools-frontend LUCI CQ
committed
Revert "Add docs traffic from DevTools must include utm_medium=referral."
This reverts commit 6e4e34a. Reason for revert: Analytics found a better solution that doesn't require adding the `utm_medium` tracking parameter to all outgoing links. Original change's description: > Add docs traffic from DevTools must include `utm_medium=referral`. > > This ensures that we also pass `utm_medium` correctly. > > Fixed: 416414182 > Bug: 402611137 > Change-Id: Id6945c55df97396072cbe3004c0e745e55f33be9 > Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6519593 > Reviewed-by: Kim-Anh Tran <kimanh@chromium.org> > Commit-Queue: Kim-Anh Tran <kimanh@chromium.org> > Auto-Submit: Benedikt Meurer <bmeurer@chromium.org> Bug: 402611137, 416414182 Change-Id: Ibf91bdf04fa4313e1172bbb1411188d21bbd02a4 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6549742 Reviewed-by: Kim-Anh Tran <kimanh@chromium.org> Commit-Queue: Benedikt Meurer <bmeurer@chromium.org> Auto-Submit: Benedikt Meurer <bmeurer@chromium.org> Commit-Queue: Kim-Anh Tran <kimanh@chromium.org>
1 parent f6eb456 commit c2974f7

File tree

2 files changed

+11
-52
lines changed

2 files changed

+11
-52
lines changed

front_end/ui/legacy/UIUtils.test.ts

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
// found in the LICENSE file.
44

55
import * as Host from '../../core/host/host.js';
6+
import * as Platform from '../../core/platform/platform.js';
67
import type * as Root from '../../core/root/root.js';
78
import {updateHostConfig} from '../../testing/EnvironmentHelpers.js';
89

910
import * as UI from './legacy.js';
1011

12+
const {urlString} = Platform.DevToolsPath;
13+
1114
describe('UIUtils', () => {
1215
describe('openInNewTab', () => {
1316
const {openInNewTab} = UI.UIUtils;
@@ -42,13 +45,7 @@ describe('UIUtils', () => {
4245

4346
openInNewTab(url);
4447

45-
sinon.assert.calledOnceWithMatch(stub, sinon.match(value => {
46-
try {
47-
return new URL(value).searchParams.get('utm_source') === 'unittests';
48-
} catch {
49-
return false;
50-
}
51-
}, 'doesn\'t have `utm_source=unittests` search parameter'));
48+
sinon.assert.calledOnceWithExactly(stub, urlString`${url}`);
5249
stub.restore();
5350
}
5451
});
@@ -67,13 +64,8 @@ describe('UIUtils', () => {
6764

6865
openInNewTab(url);
6966

70-
sinon.assert.calledOnceWithMatch(stub, sinon.match(value => {
71-
try {
72-
return new URL(value).searchParams.get('utm_source') === 'devtools';
73-
} catch {
74-
return false;
75-
}
76-
}, 'doesn\'t have `utm_source=devtools` search parameter'));
67+
sinon.assert.calledOnce(stub);
68+
assert.strictEqual(new URL(stub.args[0][0]).searchParams.get('utm_source'), 'devtools');
7769
stub.restore();
7870
}
7971
});
@@ -101,43 +93,13 @@ describe('UIUtils', () => {
10193

10294
openInNewTab(url);
10395

104-
sinon.assert.calledOnceWithMatch(stub, sinon.match(value => {
105-
try {
106-
return new URL(value).searchParams.get('utm_campaign') === channel;
107-
} catch {
108-
return false;
109-
}
110-
}, `doesn't have \`utm_campaign=${channel}\` search parameter`));
96+
sinon.assert.calledOnce(stub);
97+
assert.strictEqual(new URL(stub.args[0][0]).searchParams.get('utm_campaign'), channel);
11198
stub.restore();
11299
}
113100
}
114101
});
115102

116-
it('adds `utm_medium=referral` search parameter to Google documentation set links', () => {
117-
const URLs = [
118-
'http://developer.chrome.com/docs/devtools/workspaces/',
119-
'http://developers.google.com/learn/',
120-
'http://web.dev/',
121-
'https://developer.chrome.com/docs/devtools/',
122-
'https://developers.google.com/community/',
123-
'https://web.dev/baseline/',
124-
];
125-
for (const url of URLs) {
126-
const stub = sinon.stub(InspectorFrontendHostInstance, 'openInNewTab');
127-
128-
openInNewTab(url);
129-
130-
sinon.assert.calledOnceWithMatch(stub, sinon.match(value => {
131-
try {
132-
return new URL(value).searchParams.get('utm_medium') === 'referral';
133-
} catch {
134-
return false;
135-
}
136-
}, 'doesn\'t have `utm_medium=referral` search parameter'));
137-
stub.restore();
138-
}
139-
});
140-
141103
it('correctly preserves anchors', () => {
142104
updateHostConfig({channel: 'stable'});
143105
const stub = sinon.stub(InspectorFrontendHostInstance, 'openInNewTab');

front_end/ui/legacy/UIUtils.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,16 +1982,13 @@ export function measuredScrollbarWidth(document?: Document|null): number {
19821982
export function openInNewTab(url: URL|string): void {
19831983
url = new URL(`${url}`);
19841984
if (['developer.chrome.com', 'developers.google.com', 'web.dev'].includes(url.hostname)) {
1985+
if (!url.searchParams.has('utm_source')) {
1986+
url.searchParams.append('utm_source', 'devtools');
1987+
}
19851988
const {channel} = Root.Runtime.hostConfig;
19861989
if (!url.searchParams.has('utm_campaign') && typeof channel === 'string') {
19871990
url.searchParams.append('utm_campaign', channel);
19881991
}
1989-
if (!url.searchParams.has('utm_medium')) {
1990-
url.searchParams.append('utm_medium', 'referral');
1991-
}
1992-
if (!url.searchParams.has('utm_source')) {
1993-
url.searchParams.append('utm_source', 'devtools');
1994-
}
19951992
}
19961993
Host.InspectorFrontendHost.InspectorFrontendHostInstance.openInNewTab(Platform.DevToolsPath.urlString`${url}`);
19971994
}

0 commit comments

Comments
 (0)