弃用报告

社区组报告草案,

本版本:
https://wicg.github.io/deprecation-reporting/
版本历史:
https://github.com/WICG/deprecation-reporting/commits/gh-pages
编辑:
(Google Inc.)
参与方式:
提交议题 (查看已开放议题)

摘要

本文档定义了通过使用 Reporting API 向网站所有者报告弃用特性使用情况的机制。

本文档状态

本规范由 Web Platform Incubator Community Group 发布。 这不是 W3C 标准,也不在 W3C 标准轨道上。 请注意,根据 W3C Community Contributor License Agreement (CLA),有有限的选择退出权以及其它条件。 了解更多 W3C Community and Business Groups 信息。

1. 介绍

[引言内容待补充]

1.1. 示例

Example, Inc. 希望跟踪用户在其网站上使用即将在未来浏览器版本中移除的 Web API 的时间。它可以通过发送以下 header 来定义一个默认报告端点,将弃用报告发送至该地址:
Reporting-Endpoints: default="https://example.com/reports"

2. 弃用报告

弃用报告表示已使用了某个浏览器 API 或特性,该特性预计将在未来浏览器更新中停止工作。

弃用报告是一种报告类型。

弃用报告报告类型为 "deprecation"。

弃用报告ReportingObserver可见。

[Exposed=(Window,Worker)]
interface DeprecationReportBody : ReportBody {
  [Default] object toJSON();
  readonly attribute DOMString id;
  readonly attribute object? anticipatedRemoval;
  readonly attribute DOMString message;
  readonly attribute DOMString? sourceFile;
  readonly attribute unsigned long? lineNumber;
  readonly attribute unsigned long? columnNumber;
};

弃用报告body,在 JavaScript 中由 DeprecationReportBody 表示,包含以下字段:

注意: 弃用报告始终发送到名为 default端点;目前无法更改此行为。如果你希望接收其它类型的报告但不需要弃用报告,请为其它报告选择不同的端点名称。

3. 报告示例

    POST /reports HTTP/1.1
    Host: example.com
    ...
    Content-Type: application/reports+json

    [{
      "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 已弃用,将在 Chrome 97(约2020年1月)移除",
        "sourceFile": "https://example.com/index.js",
        "lineNumber": 1234,
        "columnNumber": 42
      }
    }]
}

4. 安全注意事项

关于带外报告的安全注意事项,详见 Reporting API §8 安全注意事项

本节剩余部分专门讨论弃用报告的安全注意事项。

5. 隐私注意事项

关于带外报告的隐私注意事项,详见 Reporting API §9 隐私注意事项

本节剩余部分专门讨论弃用报告的隐私注意事项。

索引

本规范定义的术语

引用定义的术语

参考文献

规范性引用

[ECMASCRIPT]
ECMAScript 语言规范. 链接: https://tc39.es/ecma262/
[REPORTING-1]
Douglas Creager 等. Reporting API. 2018年9月25日. WD. 链接: https://www.w3.org/TR/reporting-1/
[WebIDL]
Boris Zbarsky. Web IDL. 2016年12月15日. ED. 链接: https://heycam.github.io/webidl/

IDL 索引

[Exposed=(Window,Worker)]
interface DeprecationReportBody : ReportBody {
  [Default] object toJSON();
  readonly attribute DOMString id;
  readonly attribute object? anticipatedRemoval;
  readonly attribute DOMString message;
  readonly attribute DOMString? sourceFile;
  readonly attribute unsigned long? lineNumber;
  readonly attribute unsigned long? columnNumber;
};