Skip to content

Commit

Permalink
docs: add insights
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Apr 28, 2020
1 parent d93878c commit b5d6adc
Show file tree
Hide file tree
Showing 5 changed files with 289 additions and 49 deletions.
48 changes: 0 additions & 48 deletions src/pages/docs/api/parameters/insights.md

This file was deleted.

48 changes: 48 additions & 0 deletions src/pages/docs/api/parameters/insights/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: 'insights'
---

Type: <TypeContainer><Type children='<boolean>'/> | <Type children='<object>'/></TypeContainer><br/>
Default: <Type children='false'/>

It gets web perfomance metrics over the target URL.

<MultiCodeEditor languages={{
Shell: `microlink-api https://vercel.com&insights`,
'Node.js': `const mql = require('@microlink/mql')
module.exports = async () => {
const { status, data, response } = await mql('https://vercel.com', {
insights: true
})
console.log(status, data)
}
`
}}
/>

When you enabled it, a new `insights` field will be present into the data response payload. These field contain two subfields:

- `technologies`: A list of web technologies identified powered by [Wappalyzer](https://www.wappalyzer.com/).
- `lighthouse`: A full metrics report powered by [Lighthouse](https://developers.google.com/web/tools/lighthouse).

Both fields are enabled by default. They can be disabled programmatically in order to speed up the response time.

<MultiCodeEditor languages={{
Shell: `microlink-api https://vercel.com&insights.technologies=false`,
'Node.js': `const mql = require('@microlink/mql')
module.exports = async () => {
const { status, data, response } = await mql('https://vercel.com', {
insights: {
lighthouse: true,
technologies: false
}
})
console.log(status, data)
}
`
}}
/>

<Figcaption children='Enabling insights but only the lighthouse report' />
95 changes: 95 additions & 0 deletions src/pages/docs/api/parameters/insights/lighthouse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
title: 'lighthouse'
---

Type: <TypeContainer><Type children="boolean"/> | <Type children="object"/></TypeContainer><br/>
Default: <Type children='true'/>

<Iframe
src="https://lighthouse.microlink.io/?url=http%3A%2F%2Fapi.microlink.io%2F%3Furl%3Dhttps%3A%2F%2Fmicrolink.io%26insights%26embed%3Dinsights.lighthouse"
/>

It returns a full web perfomance metrics report powered by [Lighthouse](https://developers.google.com/web/tools/lighthouse).

<MultiCodeEditor languages={{
Shell: `microlink-api https://microlink.io&insights.lighthouse=true`,
'Node.js': `const mql = require('@microlink/mql')
module.exports = async () => {
const { status, data, response } = await mql('https://microlink.io', {
insights: {
lighthouse: true
}
})
console.log(status, data)
}
`
}}
/>

By default, the report is serialized to JSON. In this way, you can use [lighthouse.microlink.io](https://lighthouse.microlink.io) for visualizing your perfomance report.

<Link icon={false} href="https://lighthouse.microlink.io">
<Image src="https://i.imgur.com/xeC7nZk.png"/>
</Link>

The default configuration is known as [lighthouse:default](https://github.com/GoogleChrome/lighthouse/blob/master/docs/configuration.md):

```json
{
"output": "json",
"device": "desktop",
"onlyCategories": [
"perfomance",
"best-practices",
"accessibility",
"seo"
]
}
```

It's the same configuration used by Google Chrome when you perform an audit from the Developers Tools. You can extend it, for example, targeting `mobile`:

<MultiCodeEditor languages={{
Shell: `microlink-api https://microlink.io&insights.lighthouse.device=mobile`,
'Node.js': `const mql = require('@microlink/mql')
module.exports = async () => {
const { status, data, response } = await mql('https://microlink.io', {
insights: {
lighthouse: {
device: 'mobile'
}
}
})
console.log(status, data)
}
`
}}
/>

The most common [lighthouse configuration](https://github.com/GoogleChrome/lighthouse/blob/master/docs/configuration.md) parameters are:

<H2 titleize={false}>output</H2>

Type: <TypeContainer><Type children="string"/></TypeContainer><br/>
Default: <Type children='json'/><br/>
Values: <TypeContainer><Type children="'json'"/> | <Type children="'csv'"/> | <Type children="'html'"/></TypeContainer>

The type of report output to be produced.

<H2 titleize={false}>device</H2>

Type: <TypeContainer><Type children="string"/></TypeContainer><br/>
Default: <Type children='desktop'/><br/>
values: <TypeContainer><Type children="'desktop'"/> | <Type children="'mobile'"/> | <Type children="'none'"/></TypeContainer><br/>

How emulation (useragent, device screen metrics, touch) should be applied. 'none' indicates Lighthouse should leave the host browser as-is.

<H2 titleize={false}>onlyCategories</H2>

Type: <TypeContainer><Type children="string[]"/></TypeContainer><br/>
Default: <Type children="['performance', 'best-practices', 'accessibility', 'seo']"/><br/>
values: <TypeContainer><Type children="'perfomance'"/> | <Type children="'best-practices'"/> | <Type children="'accessibility'"/> | <Type children="'pwa'"/> | <Type children="'seo'"/></TypeContainer><br/>

Includes only the specified categories in the final report
135 changes: 135 additions & 0 deletions src/pages/docs/api/parameters/insights/technologies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
---
title: 'technologies'
---

Type: <TypeContainer><Type children='<boolean>'/></TypeContainer><br/>
Default: <Type children='true'/>

It identifies technology behind the target URL powered by [Wappalyzer](https://www.wappalyzer.com).

<MultiCodeEditor languages={{
Shell: `microlink-api https://microlink.io&insights.technologies=true`,
'Node.js': `const mql = require('@microlink/mql')
module.exports = async () => {
const { status, data, response } = await mql('https://microlink.io', {
insights: {
technologies: true
}
})
console.log(status, data)
}
`
}}
/>

A detected technology is defined by:

- `name` (e.g., <Type children="'CloudFlare'"/>)<br/>
The normalized name of the techonlogy.
- `confidence` (e.g., <Type children="100"/>)<br/>
How sure technology is present on the site, scoring from <Type children="0"/> to <Type children="100"/>.
- `logo` (e.g., <Type children="'https://www.wappalyzer.com/images/icons/CloudFlare.svg'"/>)<br/>
The technology logo as URL.
- `logo` (e.g., <Type children="'http://www.cloudflare.com'"/>)<br/>
The main website of the technology.
- `categories` (e.g., <Type children="['PaaS', 'CDN']"/>)<br/>
A list of keywords identified with similar technologies.

The output can contain one or more technologies detected.

```json
{
"status": "success",
"data": {
"insights": {
"technologies": [
{
"name": "CloudFlare",
"confidence": 100,
"logo": "https://www.wappalyzer.com/images/icons/CloudFlare.svg",
"url": "http://www.cloudflare.com",
"categories": [
"CDN"
]
},
{
"name": "Gatsby",
"confidence": 100,
"logo": "https://www.wappalyzer.com/images/icons/Gatsby.svg",
"url": "https://www.gatsbyjs.org/",
"categories": [
"Static site generator",
"JavaScript frameworks"
]
},
{
"name": "Google Analytics",
"confidence": 100,
"logo": "https://www.wappalyzer.com/images/icons/Google%20Analytics.svg",
"url": "http://google.com/analytics",
"categories": [
"Analytics"
]
},
{
"name": "Now",
"confidence": 100,
"logo": "https://www.wappalyzer.com/images/icons/zeit.svg",
"url": "https://zeit.co/now",
"categories": [
"Web servers"
]
},
{
"name": "Polyfill",
"confidence": 100,
"logo": "https://www.wappalyzer.com/images/icons/polyfill.svg",
"url": "https://polyfill.io",
"categories": [
"JavaScript libraries"
]
},
{
"name": "React",
"confidence": 100,
"logo": "https://www.wappalyzer.com/images/icons/React.png",
"url": "https://reactjs.org",
"categories": [
"JavaScript frameworks"
]
},
{
"name": "Segment",
"confidence": 100,
"logo": "https://www.wappalyzer.com/images/icons/Segment.png",
"url": "https://segment.com",
"categories": [
"Analytics"
]
},
{
"name": "Stripe",
"confidence": 100,
"logo": "https://www.wappalyzer.com/images/icons/Stripe.png",
"url": "http://stripe.com",
"categories": [
"Payment processors"
]
},
{
"name": "webpack",
"confidence": 0,
"logo": "https://www.wappalyzer.com/images/icons/webpack.svg",
"url": "https://webpack.js.org/",
"categories": [
"Miscellaneous"
]
}
]
}
}
}
```

<Figcaption>An example of techonologies detected over microlink.io.</Figcaption>
12 changes: 11 additions & 1 deletion src/templates/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,17 @@ const ROUTES_API = [
},
{
name: 'insights',
href: '/docs/api/parameters/insights'
href: '/docs/api/parameters/insights',
posts: [
{
name: 'lighthouse',
href: '/docs/api/parameters/insights/lighthouse'
},
{
name: 'technologies',
href: '/docs/api/parameters/insights/technologies'
}
]
},
{
name: 'javascript',
Expand Down

0 comments on commit b5d6adc

Please sign in to comment.