blob: 6b74125302b88efce81708fc734663031fbd0f00 [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:
23+ Add your feature to the blink::WebFeature enum;
24+ Usage can be measured via:
25 * MeasureAs=\<enum value\> in the feature's IDL definition; Or
26 * blink::UseCounter::Count() for blink side features; Or
27 * page_load_metrics::MetricsWebContentsObserver::RecordFeatureUsage()
28 for browser side features.
29
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 ...
49 UseCounter::Count(context, WebFeature::MyFeature);
50 ...
51 }
52```
53OR
54```c++
55 MyBrowserSideFunction() {
56 ...
57 page_load_metrics::MetricsWebContentObserver::RecordFeatureUsage(
58 render_frame_host, blink::mojom::WebFeature::MyFeature);
59 ...
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
69checking chrome://histograms/Blink.UseCounter.Features and chrome://ukm in your
70local build.
71
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
88### UMA Timeline with Formula
89
90Internally (sorry, Google employees only) you can query the usage of a feature
91with break-downs on platforms, channels, etc on the
92[UMA Timeline dashboard](https://goto.google.com/uma-usecounter).
93
94To create break-downs, select filters on the top of the dashboard, for example,
95"Platform", and set the `operation` to "split by". Note that you can also see
96data usage within Android Webview by setting a filter on "Platform".
97
98Select Metric:
99+ "Blink.UseCounter.Features" for HTML and JavaScript features.
100+ "Blink.UseCounter.CSSProperties" for CSS properties.
101+ "Blink.UseCounter.AnimatedCSSProperties" for animated CSS properties.
102+ "Blink.UseCounter.Extensions.Features" for HTML and JacaScript features on
103 extensions.
104
105In the metric panel, select "Formula" in the left-most drop-down. Then Click
106"ADD NEW FORMULA" with:
107```
108"MyFeature" / "PageVisits" * 100
109```
110
111This provides timeline data for your feature usage (per page load) with
112break-downs, which should more or less reflects the results on chromestatus.com.
113
114
115### UseCounter Feature in HTTP Archive
116
117HTTP Archive crawls the top 10K sites on the web and records everything from
118request and response headers. The data is available on Google BigQuery.
119
120You can find pages that trigger a particular UseCounter using the following
121script:
122
123```sql
124SELECT
125 DATE(yyyymmdd) AS date,
126 client AS platform,
127 num_url AS url_count,
128 pct_urls AS urls_percentile,
129 sample_urls AS url
130FROM [httparchive:blink_features.usage]
131WHERE feature = 'MyFeature'
132ORDER BY url_percentile DESC
133```
134OR
135
136```sql
137SELECT
138 url
139FROM [httparchive:pages.yyyy_mm_dd_mobile]
140WHERE
141 JSON_EXTRACT(payload, '$._blinkFeatureFirstUsed.Features.MyFeature') IS NOT
142 NULL
143LIMIT 500
144```
145
146You can also find pages that trigger a particular CSS property (during parsing):
147
148```sql
149SELECT
150 url
151FROM [httparchive:pages.yyyy_mm_dd_mobile]
152WHERE
153 JSON_EXTRACT(payload, '$._blinkFeatureFirstUsed.CSSFeatures.MyCSSProperty')
154 IS NOT NULL
155LIMIT 500
156```
157
158To find pages that trigger a UseCounter and sort by page rank:
159
160```sql
161SELECT
162 IFNULL(runs.rank, 1000000) AS rank,
163 har.url AS url,
164FROM [httparchive:latest.pages_desktop] AS har
165LEFT JOIN [httparchive:runs.latest_pages] AS runs
166 ON har.url = runs.url
167WHERE
168 JSON_EXTRACT(payload, '$._blinkFeatureFirstUsed.Features.MyFeature') IS NOT
169 NULL
170ORDER BY rank;
171```
172
173
174### UMA Usage on Fraction of Users
175You may also see the fraction of users that trigger your feature at lease once a
176day on [UMA Usage dashboard](https://goto.google.com/uma-usecounter-peruser).
177
178
179## Analyze UseCounter UKM Data
180For privacy concerns, UKM data is available for Google employees only.
181
182### UKM Dashboard
183UKM dashboard is accessible to Google employees only. Please see [this internal
184wiki](https://goto.google.com/usecounter-ukm-wiki) for details.