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

Add protocols related metrics #816

Merged
merged 23 commits into from
Nov 11, 2020
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
45f4128
Prevent milestones events from being sent from iframes
gmetais Oct 9, 2020
366b210
Catch http and tls protocols versions from responses
gmetais Oct 9, 2020
9bc69fa
Merge with Prettier
gmetais Oct 9, 2020
409e960
Prettier
gmetais Nov 1, 2020
c4f60d0
HTTP and TLS protocols metrics
gmetais Nov 2, 2020
a7952d2
Merge branch 'devel' of https://github.com/macbre/phantomas into devel
gmetais Nov 2, 2020
51445f2
Merge branch 'devel' into protocols
gmetais Nov 2, 2020
ecb2252
Lint
gmetais Nov 2, 2020
91fe2a3
Merge branch 'devel' into protocols
macbre Nov 4, 2020
0f57dfd
Add viewport extension into metadata
gmetais Nov 5, 2020
a392d8d
Regenerate docs for the new protocols module
gmetais Nov 6, 2020
de2783d
Try to add an SSL certificate to nginx (not working)
gmetais Nov 6, 2020
67dbc8e
Add integration tests for the protocols module
gmetais Nov 6, 2020
4cb250a
Merge branch 'protocols' of https://github.com/gmetais/phantomas into…
gmetais Nov 6, 2020
0c725d3
Run Prettier
gmetais Nov 6, 2020
0cc995c
Merge branch 'devel' into protocols
macbre Nov 9, 2020
f580e36
Update test/nginx-docker-compose.yaml
macbre Nov 9, 2020
0ac6bf3
Merge branch 'devel' into protocols
macbre Nov 9, 2020
9638d95
Merge branch 'devel' into protocols
macbre Nov 9, 2020
c406ec2
test/integration-spec.yaml: fix assertions and ignoreSslErrors option
macbre Nov 9, 2020
b5043cf
Merge branch 'devel' into protocols
macbre Nov 9, 2020
383c1de
Merge branch 'devel' into protocols
macbre Nov 9, 2020
e32c31f
Merge branch 'devel' into protocols
macbre Nov 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/modules/navigationTiming/scope.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
(function (phantomas) {
// Prevent events from being sent from an iframe. Only from the main document.
if (window.parent !== window || window.location.href === "about:blank") {
return;
}

function emit(eventName) {
phantomas.log("Navigation Timing milestone: %s", eventName);
phantomas.emit("milestone", eventName); // @desc Page loading milestone has been reached: domInteractive, domReady and domComplete
Expand Down
6 changes: 6 additions & 0 deletions core/modules/requestsMonitor/requestsMonitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@ module.exports = function (phantomas) {
break;
}

// HTTP and TLS protocols version
entry.httpVersion = resp.protocol;
if (resp.securityDetails) {
entry.tlsVersion = resp.securityDetails.protocol;
}

// requests stats
if (!entry.isBase64) {
phantomas.incrMetric("requests");
Expand Down
39 changes: 38 additions & 1 deletion docs/metrics.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Modules and metrics
===================

This file describes all [`phantomas` modules](https://github.com/macbre/phantomas/tree/devel/modules) (34 of them) and 177 metrics that they emit.
This file describes all [`phantomas` modules](https://github.com/macbre/phantomas/tree/devel/modules) (35 of them) and 181 metrics that they emit.

When applicable, [offender](https://github.com/macbre/phantomas/issues/140) example is provided.

Expand Down Expand Up @@ -1023,6 +1023,43 @@ comma-separated list of HTTP status codes that main request followed through (co
Code taken from windowPerformance module


## [protocols](https://github.com/macbre/phantomas/tree/devel/modules/protocols/protocols.js)

> Checks versions of HTTP and TLS protocols

##### `mainDomainHttpProtocol`

HTTP protocol used by the main domain (string)

##### `mainDomainTlsProtocol`

TLS protocol used by the main domain (string)

##### `oldHttpProtocol`

number of domains using HTTP/1.0 or 1.1 (number, with offenders)

```json
{
"domain": "https://127.0.0.1:8889",
"httpVersion": "http/1.1",
"requests": 1
}
```

##### `oldTlsProtocol`

number of domains using TLS 1.1 or 1.2 (number, with offenders)

```json
{
"domain": "https://127.0.0.1:8889",
"tlsVersion": "TLS 1.1",
"beforeDomReady": true
}
```


## [redirects](https://github.com/macbre/phantomas/tree/devel/modules/redirects/redirects.js)

> Analyzes HTTP redirects
Expand Down
2 changes: 1 addition & 1 deletion extensions/viewport/viewport.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* Provides the --viewport option to set any device resolution and pixel density ratio.
* If the user sets a viewport size as well as a device option (--phone, --tablet, ...),
* we assume that he/she wants to overwrite the device values.
* we assume that he or she wants to overwrite the device values.
*
* Two syntaxes are supported:
* - 1200x800 will set a 1x pixel density ratio
Expand Down
3 changes: 2 additions & 1 deletion lib/metadata/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ function getModuleMetadata(moduleFile) {
}

// check if offenders are reported for this metric
if (content.indexOf("phantomas.addOffender('" + metricName + "'") > -1) {
let offenderRegex = new RegExp("phantomas.addOffender\\([\\n\\r\\s]*[\"']" + metricName + "[\"']");
if (content.search(offenderRegex) > -1) {
entry.offenders = true;
}

Expand Down
Loading