目次
- Crash/Deprecation/Intervention Reporting
- Crash Reporting
- Deprecation Reporting
- Intervention Reporting
ブラウザがWebページを表示する際に発生したエラーを、任意のエンドポイントにレポートさせる「Reporting API」という仕様があります。今回紹介する機能もchromeでいくつか実際に使用できます。
例えば、以前紹介した Deprecation Reporting もこの仕様によって定義されていました。
asnokaze.hatenablog.com
他にもTLS証明書エラーや名前解決エラーといった、ネットワークエラーを通知するNetwork Error Loggingといった仕様もReporting APIを利用しています。
asnokaze.hatenablog.com
Crash/Deprecation/Intervention Reporting
今までCrash/Deprecation/Interventionという3つのエラータイプが、「Reporting API」のドキュメントで定義されていましたが、議論の結果それぞれ独立したドキュメントに分離されることになりました。
背景は以下を参照
discourse.wicg.io
分離されたドキュメントはそれぞれ下記のとおりです。
- https://wicg.github.io/crash-reporting/
- https://wicg.github.io/deprecation-reporting/
- https://wicg.github.io/intervention-reporting/
レスポンスヘッダで下記のように設定することで、そのドメインでエラーなどが発生した場合に、指定したエンドポイントにレポートが送信されます。
Report-To: { "group": "default",
"max_age": 10886400,
"endpoints": [
{ "url": "https://example.com/reports", "priority": 1 },
{ "url": "https://backup.com/reports", "priority": 2 }
] }前述のブログでも紹介しましたが、改めてそれぞれ簡単に紹介ようかとおもいます。
Crash Reporting
サイトを閲覧したブラウザがクラッシュした際に、サイト所有者に通知する機能。
下記のデータがPOSTされます
[{
"type": "crash",
"age": 42,
"url": "https://example.com/",
"user_agent": "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0",
"body": {
"reason": "oom"
}
}]reasonは現状下記の2つが定義されています
- oom: メモリ不足
- unresponsive: 反応がない
Deprecation Reporting
サイトを閲覧したブラウザがdeprecatedな機能(JavaScript API)を利用していた場合に、サイト所有者に通知する機能。
例えば、「Application Cache API」や「window.webkitStorageInfo」といったものをChromeで使ってるとDeprecation Reportingが飛びます
下記のデータがPOSTされます
[{
"type": "deprecation",
"age": 32,
"url": "https://example.com/",
"user_agent": "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0",
"body": {
"id": "websql",
"anticipatedRemoval": "2020-01-01",
"message": "WebSQL is deprecated and will be removed in Chrome 97 around January 2020",
"sourceFile": "https://example.com/index.js",
"lineNumber": 1234,
"columnNumber": 42
}
}]
}
Intervention Reporting
サイトを閲覧したブラウザがJavaScriptを実行した際など、セキュリティなどの理由によって動作が変更されたりブロックされた場合に、サイト所有者に通知する機能。
下記のデータがPOSTされます
[{
"type": "intervention",
"age": 27,
"url": "https://example.com/",
"user_agent": "Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0",
"body": {
"id": "audio-no-gesture",
"message": "A request to play audio was blocked because it was not triggered by user activation (such as a click).",
"sourceFile": "https://example.com/index.js",
"lineNumber": 1234,
"columnNumber": 42
}
}]
}