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

New debug view #141 #362

Merged
merged 35 commits into from
Mar 29, 2018
Merged

New debug view #141 #362

merged 35 commits into from
Mar 29, 2018

Conversation

abovedave
Copy link
Contributor

@abovedave abovedave commented Mar 20, 2018

screen shot 2018-03-20 at 18 34 35

New debug view for #141

  • Changes config setting allowJsonView to allowDebugView
  • Replaces ?json=true with ?debug=json
  • Shows the Web and Node.js version

?debug

Shows the page data object, template and the output (prior to any postProcessors)

?debug=data

Shows the page data object

?debug=page

Shows the data used to the construct the page internally to Web

  • Name
  • Key
  • hostKey
  • Template (e.g., index.dust)
  • resolvedTemplate (full path on disk)
  • ContentType
  • Datasources
  • requiredDatasources
  • Events
  • globalEvents
  • preloadedEvents
  • Settings
  • postProcessors
  • globalPostProcessors
  • passFilters (boolean)
  • passHeaders (boolean)
  • Routes

?debug=ds

Shows all the datasources attached to the page, including

  • Schema
  • Full endpoint URL
  • endpointEvents
  • filterEvents
  • requestParams
  • chained status

?debug=result

Shows the rendered template next to the output with postProcessors applied (if applicable)

?debug=stats

The data that used to be attached to the page data, with the addition of extra information e.g.,

seconds	:	0
nanoseconds	:	79435440
milliseconds	:	79.43544
startTime	:	1521572339526
endTime	:	1521572339605
time	:	0.079
  • Auth timer
  • Request timer (post, get etc)
  • Load data timet
  • Preload data timer
  • Datasources timer

And some new additions:

  • Total time to render output
  • Size of data payload
  • Size of rendered output (before any gzip/br compression)

?debug=route

Shows the list of routes and the current page pathname. The active route is highlighted and the user can change the pathname to see their proposed input matches any of this pages routes.

?debug=headers

Shows the request and response headers. The response headers are made from a new http call to the page so is not the full picture (e.g., http doesn’t send any accept-encoding headers)

?debug=json

What used to be ?json=true ie., the raw page data JSON.

Changing of default page data

  • Added new url object which includes stuff from the native Node.js url.parse()
  • pathname becomes url.pathname
  • host becomes url.host
  • title becomes page.name
  • Removed stats which appeared when debug mode enabled
  • checkValue becomes a more useful timestamp which is UNIX miliseconds (new Date().getTime())

Misc changes

@abovedave abovedave changed the title 🚧[Do not merge] New debug view #141 🚧New debug view #141 Mar 21, 2018
@abovedave abovedave changed the title 🚧New debug view #141 New debug view #141 Mar 21, 2018
@jimlambie
Copy link
Contributor

@abovedave I like it! the datasource view (and anywhere datasources are listed) should include both the original endpoint as specified in the schema, and the actual endpoint fired

@jimlambie
Copy link
Contributor

@abovedave this changes globalEvents to be run as part of the request lifecycle, rather than as preload, right?

@abovedave
Copy link
Contributor Author

Yes, this guy 👉 #258

} catch (e) {
console.log('RouteValidator Load Error:', datasource.name, req.url)
console.log(e)
var results = data
Copy link
Contributor

Choose a reason for hiding this comment

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

use const?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

could just change the next line to if (data.results && data.results.length > 0) {?

Copy link
Contributor

Choose a reason for hiding this comment

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

agreed!

this.data = {}

this.templateName =
this.page.hostKey +
this.page.template.slice(0, this.page.template.indexOf('.'))

this.templateEngineSettings = this.page.settings.engine || {}
Copy link
Contributor

Choose a reason for hiding this comment

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

this is likely a breaking change, is it documented as such?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

// Send the templated page
const templateData = Object.assign({}, this.data, {
host: this.page.hostKey
})

this.template
.render(templateData, {
keepWhitespace: this.page.keepWhitespace
Copy link
Contributor

Choose a reason for hiding this comment

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

this is the breaking change, I mean 🥇

config.get('allowJsonView') &&
urlData.query.json &&
urlData.query.json.toString() === 'true'
// allow debug view using ?debug=
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we keep json=true for backwards compatibility, translating it to debug=json?

@jimlambie jimlambie merged commit 29977b8 into develop Mar 29, 2018
@jimlambie jimlambie deleted the feature/debug-view branch March 29, 2018 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants