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

Feature/add devtools viewer link to sheets #131

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

david-benson-fc
Copy link

@david-benson-fc david-benson-fc commented Jul 18, 2017

If files are uploaded to drive, then a link to chrome devtools timeline viewer which opens the given file is added to comment column of google sheets file.
Requires app authorisation.

This is a quick and dirty hack - am open to advice for improvements or how to write tests for it, or am happy for it to be considered a feature request.

Currently there is no way to connect a sheets entry and a file - files are identified by a unix timestamp which is not present in the sheet, and even if it were, cross-referencing would be tedious.
This provides a simple and expedient way of viewing the detail for any test that has had data uploaded.

@denar90
Copy link
Collaborator

denar90 commented Jul 18, 2017

Hi. Thanks for the contribution.
I have a concern about this one because it becomes unpredictable when data is submitted to sheets with or without timeline viewer link.
So in case
pwmetrics https://example.com --upload --submit will add column with link
and
pwmetrics https://example.com --submit will send data as it is right now
Right now I don't have any idea how to make it more predictable and obvious...

cc @paulirish @pedro93 , maybe @samccone
any ideas guys or you just ok with this behavior?

@@ -50,6 +51,12 @@ class Sheets {
results.forEach(data => {
const getTiming = (key: string) => data.timings.find(t => t.id === key).timing;
const dateObj = new Date(data.generatedTime);
let viewerUrl = '';

if(typeof data.fileName !== 'undefined' && typeof data.fileName !== 'undefined') {
Copy link
Contributor

Choose a reason for hiding this comment

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

if(data.fileName) {
  viewerUrl = VIEWER_URL_PREFIX + data.fileId;
}

Copy link
Author

Choose a reason for hiding this comment

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

Huh - just noticed one of those is supposed to be data.fileId, but that's the only one needed now - I originally intended to use both, but ditched the idea of using the file name as the link text.

I use typeof rather than a truthy check as it's won't choke on undefined.

Copy link
Contributor

Choose a reason for hiding this comment

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

So you don't need to be concerned of that because undefined is false when type checked in a boolean scenario.

`data.fileName` not used now (was considering making it the link text)
@david-benson-fc
Copy link
Author

@denar90 Ah good point - I hadn't considered a case where someone uploaded to drive with out submitting to sheets! Well spotted.

@david-benson-fc
Copy link
Author

@denar90 How's this?

cddb412

Copy link
Collaborator

@denar90 denar90 left a comment

Choose a reason for hiding this comment

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

I have this idea.
First I'd rather don't mix sheets with uploading to gdrive, it's a bit different modules.
What I think is extending MetricsResults interface with one more field which is viewerUrl. It will be optional.
So if upload flag is passed then condition where MetricsResults data and viewerUrl will be mixed should be somewhere here - https://github.com/paulirish/pwmetrics/blob/master/lib/index.ts#L201
Hense when appending results you will be able to do smth like data.viewerUrl
https://github.com/paulirish/pwmetrics/pull/131/files#diff-fe52226e90803c8fafc2594b79b63be5R73

One more thing. We should also mention about this feature in docs.

@DisasterMan78
Copy link

@denar90 That makes sense - it's certainly tidier. And yes, documentation is handy!

I've got some urgent work today, I'll take a look at this later.

(I've switched accounts btw - the comments before were from my work account on my previous contract)

DisasterMan78 pushed a commit to DisasterMan78/pwmetrics that referenced this pull request Aug 4, 2017
Strip out uneeded changes from prior commits on this branch.

Add `configIsSubmitAndUpload()` to lib/index.ts
Pass that fn to Sheets class.

Add null value `viwerUrl` to Metrics class return object to prevent undefined type errors in Sheets

paulirish#131
@DisasterMan78 DisasterMan78 force-pushed the feature/add_devtools_viewer_link_to_sheets branch from 22e2558 to 587c95e Compare August 4, 2017 15:45
DisasterMan78 pushed a commit to DisasterMan78/pwmetrics that referenced this pull request Aug 4, 2017
Strip out uneeded changes from prior commits on this branch.

Add `configIsSubmitAndUpload()` to lib/index.ts
Pass that fn to Sheets class.

Add null value `viwerUrl` to Metrics class return object to prevent undefined type errors in Sheets

paulirish#131
Strip out uneeded changes from prior commits on this branch.

Add `configIsSubmitAndUpload()` to lib/index.ts
Pass that fn to Sheets class.

Add null value `viwerUrl` to Metrics class return object to prevent undefined type errors in Sheets

Update readme.md

paulirish#131
@DisasterMan78 DisasterMan78 force-pushed the feature/add_devtools_viewer_link_to_sheets branch from 587c95e to a3bd4c7 Compare August 4, 2017 15:54
@DisasterMan78
Copy link

@denar90 Excuse the delay, life likes to interfere.

I've created a function configIsSubmitAndUpload() (bad name, am open to suggestions) in lib/index.ts, which can take advantage of your getTimelineViewerUrl() const (didn't spot that before!) but the Sheets class can't access it as it's out of scope. I don't want to be passing it in to Sheets, but that leaves me a little stuck.

I've just done it for now, but I don't like it much. Overall it's much more concise and tidy though.

Any suggestions?

Also, I haven't been able to properly check the viewer link as the viewer refuses to acknowledge it's authorised to access my drive account. Grr...

@denar90
Copy link
Collaborator

denar90 commented Sep 5, 2017

@DisasterMan78 sorry for so big delay. I'll take a look at it on the upcoming weekend.

@@ -96,7 +96,7 @@ class PWMetrics {
console.log(messages.getMessage('MEDIAN_RUN'));
this.displayOutput(results.median);
} else if (this.flags.submit) {
const sheets = new Sheets(this.sheets, this.clientSecret);
const sheets = new Sheets(this.sheets, this.clientSecret, this.configIsSubmitAndUpload);
Copy link
Collaborator

Choose a reason for hiding this comment

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

What if not pass function to the sheets but extend results.runs with viewerUrl like

const sheets = new Sheets(this.sheets, this.clientSecret, this.configIsSubmitAndUpload);
await sheets.appendResults(extendResultsToSubmit(results.runs));

....
//extendResultsToSubmit method
return results.map(data => {
  if (this.flags.submit && this.flags.upload) {
    data.viewerUrl = getTimelineViewerUrl(data.fileId);
  }
  return data;
});

in this case we can cut off some stuff
wdyt?

@DisasterMan78
Copy link

DisasterMan78 commented Dec 13, 2017

Quick update on this: This is still on my list to return to when I find the time, but if anyone would like to have a crack at it in the meantime, feel free.

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

Successfully merging this pull request may close these issues.

None yet

6 participants