-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
core(config): specify lighthouse channel #7312
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! this turned out to be super clean with the bundling refactors! 🎉
I think this all seems good to me! I do worry a bit that someone out there was not treating lighthouseVersion
as a complete, parsable semantic version and doing version.split('.')
or something but I doubt they cared about the patch version component so we're good? 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks fine, just some minor questions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so one thing we didn't really talk about in #4663 is what happens as the LHR gets separated from its original source. Based on the conversation there, the primary purpose (for now) is to know where traffic is coming from when clicking links in the report, but what happens when you save an LHR json from DevTools or PSI and open it in viewer? Is it still useful information to know the original source, or should it be utm_medium=viewer
at that point? Especially if it's shared with multiple other people...none of them are touching the original source in that case.
@@ -3172,6 +3172,7 @@ | |||
"disableStorageReset": false, | |||
"disableDeviceEmulation": false, | |||
"emulatedFormFactor": "mobile", | |||
"channel": "cli", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should it also be in the top level of the LHR? Maybe inside environment
, next to benchmarkIndex
, etc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a benefit over using lhr.configSettings.channel
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a benefit over using lhr.configSettings.channel?
because it's not really a setting, but now it kind of is, so that's fine
clients/devtools-entry.js
Outdated
@@ -36,6 +36,7 @@ function getDefaultConfigForCategories(categoryIDs) { | |||
function runLighthouseInWorker(port, url, flags, categoryIDs) { | |||
// Default to 'info' logging level. | |||
flags.logLevel = flags.logLevel || 'info'; | |||
flags.channel = 'cdt'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have a good place to test any/all of these? It's going to be difficult to notice if something is accidentally falling back to the node default, but I don't know if we have a good place to check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a test case for the Chrome extension.
I think the original source is far more important for environment info than where they are currently looking at it. Maybe not the correct thing from utm medium perspective, but I think viewer is the only real case where there will be a mismatch and maybe viewer just overrides that with UI features or something? |
Any more feedback on this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really think I'm satisfied with the field just being freeform string, I'd prefer a enumerated type on ts and on the proto. I like the longer names, but personally I want them enumerated.
@exterkamp We allow CLI and node module consumers to pass in their own I feel it's similar on the Lightrider/proto side, but maybe we can put |
Hm, I might have missed this discussion (I don't see it in this PR?), but why do they get to pass their own channel? Wouldn't their channel be "cli" or "node-module"? Since that is the channel they were on? What's the use case for sending a custom run channel that we don't know about beforehand and have enumerated? |
I think it comes down to what the purpose of the field is. As helpful debug info after the fact, it makes sense to stick to just our "clients" (cli/node/devtools/extension/lr). That's the programmatic entry point, great. However, #4663 was about getting a sense of what lead users to our docs. In that case it makes some sense to have it open so we can distinguish between e.g. the cli and PSI and WPT, which are all very different user experience entry points. |
I've been convinced irl. sgtm! |
@exterkamp Should be good to merge now 🙂 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, inspired by your extension test, left some suggestions for the other channels (except devtools)
@@ -176,4 +179,8 @@ describe('Lighthouse chrome extension', function() { | |||
// this audit has regressed in the extension twice, so make sure it passes | |||
assert.ok(await extensionPage.$('#is-crawlable.lh-audit--pass'), 'did not pass is-crawlable'); | |||
}); | |||
|
|||
it('should specify the channel as extension', async () => { | |||
assert.equal(lhr.configSettings.channel, 'extension'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 👍
@@ -34,6 +34,7 @@ async function runLighthouseInLR(connection, url, flags, {lrDevice, categoryIDs, | |||
// disableStorageReset because it causes render server hang | |||
flags.disableStorageReset = true; | |||
flags.logLevel = flags.logLevel || 'info'; | |||
flags.channel = 'lr'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can assert this in lightrider-entry-test.js
@@ -146,6 +147,7 @@ function getFlags(manualArgv) { | |||
.default('port', 0) | |||
.default('hostname', 'localhost') | |||
.default('enable-error-reporting', undefined) // Undefined so prompted by default | |||
.default('channel', 'cli') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can assert this in 'runLighthouse completes a LH round trip'
in run-test.js
@@ -51,6 +51,7 @@ const defaultSettings = { | |||
disableStorageReset: false, | |||
disableDeviceEmulation: false, | |||
emulatedFormFactor: 'mobile', | |||
channel: 'node', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and can assert this in lighthouse-core/test/index-test.js
(basically just copy 'should return formatted LHR when given no categories'
and delete most of it :)
@@ -3172,6 +3172,7 @@ | |||
"disableStorageReset": false, | |||
"disableDeviceEmulation": false, | |||
"emulatedFormFactor": "mobile", | |||
"channel": "cli", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a benefit over using lhr.configSettings.channel?
because it's not really a setting, but now it kind of is, so that's fine
@brendankenny Thanks for those suggestions, added them now! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, last thing (jest over sinon), sorry, but otherwise LGTM!
@@ -56,5 +58,18 @@ describe('lightrider-entry', () => { | |||
assert.strictEqual(parsedResult.runtimeError.code, LHError.UNKNOWN_ERROR); | |||
assert.ok(parsedResult.runtimeError.message.includes(errorMsg)); | |||
}); | |||
|
|||
it('specifies the channel as lr', async () => { | |||
const runStub = sinon.stub(Runner, 'run'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you use jest mocks for this? I'm hoping we can drop sinon
since we currently only use it in one place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh +1 to using jest please :)
const runStub = Runner.run = jest.fn()
...
const config = runStub.mock.calls[0][1].config
I think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, somehow I felt I needed to use sinon in mocha tests 🙂
lighthouse-core/test/index-test.js
Outdated
@@ -132,6 +132,31 @@ describe('Module Tests', function() { | |||
}); | |||
}); | |||
|
|||
it('should specify the channel as node by default', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a big deal, but if making one last commit, could you make these async/await? no need to stick to the style of the file for that :)
thanks! |
After this feature is released we'll also need to update the PSI and web.dev clients to specify their channel configs. @paulirish is there somewhere we can file an issue to do this? |
@rviscomi interesting... :) right now PSI webapp, PSI API clients, and web.dev will be tagged as 'lr'. We don't have a straightforward way to distinguish between different PSI API consumers easily. How do you want to make use of this channel data? |
The web apps should include their channel in a UTM param appended to their learn more links so we can see where documentation visitors are coming from. |
The web front ends could change the setting in the lhr before generating the report. Pretty gross, though :/ web.dev and the PSI web interface do have their own analytics (I assume), which would allow teasing out those sources, at least. |
Yeah I assume we do have analytics on the tools themselves, this is just for the documentation on d.g.co to easily identify the LH channel that brought the user to the docs. |
Summary
Determine whether Lighthouse was run through the CLI, npm module, Chrome extension, Chrome DevTools, or Lightrider.
Is settings the right place to put this? Feels like it's similar to
locale
.Related Issues/PRs
Part of #4663