blob: 055b2b814b526d5bb74a6f145264b578e4304904 [file] [log] [blame] [view]
Luna Lud1e80572019-06-05 20:58:161# UseCounter Wiki
2
3UseCounter measures the usage of HTML and JavaScript features across all
4channels and platforms in the wild. Feature usage is recorded per page load and
5is anonymously aggregated. Note measurements only take place on HTTP/HTTPS
6pages. Usages on new tab page, data URL, or file URL are not. Usages on
7extensions is measured on a separate histogram.
8
9UseCounter data can be biased against scenarios where user metrics analysis is
10not enabled (e.g., enterprises). However, UseCounter data is essential for
11[web compat decision making](https://www.chromium.org/blink/platform-predictability/compat-tools)
12and [the blink process for breaking changes](https://sites.google.com/a/chromium.org/dev/blink/removing-features), as it reflects the real Chrome usage with a wide fraction of coverage.
13The results are publicly available on https://chromestatus.com/ and internally
14(for Google employees) on [UMA dashboard](https://goto.google.com/uma-usecounter)
15and [UKM dashboard](https://goto.google.com/ukm-usecounter) with more detailed
16break-downs.
17
18
19## How to Add a UseCounter Feature
20
21UseCounter measures feature usage via UMA histogram and UKM. To add your
22feature to UseCounter, simply:
Wan-Teh Changa2185fc2021-02-04 22:38:2023+ Add your feature to the
Stephen McGruer2669ba3d2022-05-17 20:38:5324 [blink::mojom::WebFeature enum](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom);
Luna Lud1e80572019-06-05 20:58:1625+ Usage can be measured via:
26 * MeasureAs=\<enum value\> in the feature's IDL definition; Or
27 * blink::UseCounter::Count() for blink side features; Or
Charlie Harrison642ada12023-03-14 14:10:5128 * content::ContentBrowserClient::LogWebFeatureForCurrentPage() for browser side features.
Luna Lud1e80572019-06-05 20:58:1629
30Example:
31```c++
32enum WebFeature {
33 ...
34 kMyFeature = N,
35 ...
36}
37```
38```
39interface MyInterface {
40 ...
41 [MeasureAs=MyFeature] myIdlAttribute;
42 ...
43}
44```
45OR
46```c++
47 MyInterface::MyBlinkSideFunction() {
48 ...
Wan-Teh Changa2185fc2021-02-04 22:38:2049 UseCounter::Count(context, WebFeature::kMyFeature);
Luna Lud1e80572019-06-05 20:58:1650 ...
51 }
52```
53OR
54```c++
55 MyBrowserSideFunction() {
56 ...
Charlie Harrison642ada12023-03-14 14:10:5157 GetContentClient()->browser()->LogWebFeatureForCurrentPage(
Wan-Teh Changa2185fc2021-02-04 22:38:2058 render_frame_host, blink::mojom::WebFeature::kMyFeature);
Luna Lud1e80572019-06-05 20:58:1659 ...
60 }
61```
62
63Not all features collect URL-keyed metrics. To opt in your feature to UKM,
64simply add your feature to
Mason Freedbef473202019-12-13 23:06:3165[UseCounterPageLoadMetricsObserver::GetAllowedUkmFeatures()](https://cs.chromium.org/chromium/src/components/page_load_metrics/browser/observers/use_counter/ukm_features.cc)
Luna Lud1e80572019-06-05 20:58:1666and get approval from one of the privacy owners.
67
68You can quickly verify that your feature is added to UMA histograms and UKM by
Wan-Teh Chang945a5542021-02-05 14:57:5069checking chrome://histograms/Blink.UseCounter.Features and chrome://ukm in your
70local build.
Luna Lud1e80572019-06-05 20:58:1671
72## Analyze UseCounter Histogram Data
73
74### Public Data on https://chromestatus.com
75
76Usage of JavaScript and HTML features is available
77[here](https://chromestatus.com/metrics/feature/popularity).
78Usage of CSS properties is available
79[here](https://chromestatus.com/metrics/css/popularity).
80
81The data reflects features' daily usage (count of feature hits / count of total
82page visits):
83+ On all platforms: Android, Windows, Mac, ChromeOS, and Linux.
84+ On "official" channels: stable, beta, and dev.
85+ For the most dominant milestone.
86
87
Robert Kaplowb3f2df22023-09-21 20:52:3788### Internal UMA tools
Luna Lud1e80572019-06-05 20:58:1689
Robert Kaplowb3f2df22023-09-21 20:52:3790See (https://goto.google.com/uma-usecounter) for internal tooling.
Luna Lud1e80572019-06-05 20:58:1691
Robert Kaplowb3f2df22023-09-21 20:52:3792Some metrics of interest:
Luna Lud1e80572019-06-05 20:58:1693+ "Blink.UseCounter.Features" for HTML and JavaScript features.
94+ "Blink.UseCounter.CSSProperties" for CSS properties.
95+ "Blink.UseCounter.AnimatedCSSProperties" for animated CSS properties.
96+ "Blink.UseCounter.Extensions.Features" for HTML and JacaScript features on
97 extensions.
98
Luna Lud1e80572019-06-05 20:58:1699### UseCounter Feature in HTTP Archive
100
101HTTP Archive crawls the top 10K sites on the web and records everything from
102request and response headers. The data is available on Google BigQuery.
103
104You can find pages that trigger a particular UseCounter using the following
105script:
106
107```sql
108SELECT
109 DATE(yyyymmdd) AS date,
110 client AS platform,
111 num_url AS url_count,
112 pct_urls AS urls_percentile,
113 sample_urls AS url
114FROM [httparchive:blink_features.usage]
115WHERE feature = 'MyFeature'
116ORDER BY url_percentile DESC
117```
118OR
119
120```sql
121SELECT
122 url
123FROM [httparchive:pages.yyyy_mm_dd_mobile]
124WHERE
125 JSON_EXTRACT(payload, '$._blinkFeatureFirstUsed.Features.MyFeature') IS NOT
126 NULL
127LIMIT 500
128```
129
130You can also find pages that trigger a particular CSS property (during parsing):
131
132```sql
133SELECT
134 url
135FROM [httparchive:pages.yyyy_mm_dd_mobile]
136WHERE
137 JSON_EXTRACT(payload, '$._blinkFeatureFirstUsed.CSSFeatures.MyCSSProperty')
138 IS NOT NULL
139LIMIT 500
140```
141
142To find pages that trigger a UseCounter and sort by page rank:
143
144```sql
145SELECT
146 IFNULL(runs.rank, 1000000) AS rank,
147 har.url AS url,
148FROM [httparchive:latest.pages_desktop] AS har
149LEFT JOIN [httparchive:runs.latest_pages] AS runs
150 ON har.url = runs.url
151WHERE
152 JSON_EXTRACT(payload, '$._blinkFeatureFirstUsed.Features.MyFeature') IS NOT
153 NULL
154ORDER BY rank;
155```
156
157
158### UMA Usage on Fraction of Users
159You may also see the fraction of users that trigger your feature at lease once a
160day on [UMA Usage dashboard](https://goto.google.com/uma-usecounter-peruser).
161
162
163## Analyze UseCounter UKM Data
164For privacy concerns, UKM data is available for Google employees only.
Sun Yueru4637eec2023-06-16 16:02:01165Please see [this internal
166documentation](https://goto.google.com/ukm-blink-usecounter) for details.