Luna Lu | d1e8057 | 2019-06-05 20:58:16 | [diff] [blame] | 1 | # UseCounter Wiki |
| 2 | |
| 3 | UseCounter measures the usage of HTML and JavaScript features across all |
| 4 | channels and platforms in the wild. Feature usage is recorded per page load and |
| 5 | is anonymously aggregated. Note measurements only take place on HTTP/HTTPS |
| 6 | pages. Usages on new tab page, data URL, or file URL are not. Usages on |
| 7 | extensions is measured on a separate histogram. |
| 8 | |
| 9 | UseCounter data can be biased against scenarios where user metrics analysis is |
| 10 | not enabled (e.g., enterprises). However, UseCounter data is essential for |
| 11 | [web compat decision making](https://www.chromium.org/blink/platform-predictability/compat-tools) |
| 12 | and [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. |
| 13 | The results are publicly available on https://chromestatus.com/ and internally |
| 14 | (for Google employees) on [UMA dashboard](https://goto.google.com/uma-usecounter) |
| 15 | and [UKM dashboard](https://goto.google.com/ukm-usecounter) with more detailed |
| 16 | break-downs. |
| 17 | |
| 18 | |
| 19 | ## How to Add a UseCounter Feature |
| 20 | |
| 21 | UseCounter measures feature usage via UMA histogram and UKM. To add your |
| 22 | feature to UseCounter, simply: |
Wan-Teh Chang | a2185fc | 2021-02-04 22:38:20 | [diff] [blame] | 23 | + Add your feature to the |
Stephen McGruer | 2669ba3d | 2022-05-17 20:38:53 | [diff] [blame] | 24 | [blink::mojom::WebFeature enum](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom); |
Luna Lu | d1e8057 | 2019-06-05 20:58:16 | [diff] [blame] | 25 | + 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 Harrison | 642ada1 | 2023-03-14 14:10:51 | [diff] [blame] | 28 | * content::ContentBrowserClient::LogWebFeatureForCurrentPage() for browser side features. |
Luna Lu | d1e8057 | 2019-06-05 20:58:16 | [diff] [blame] | 29 | |
| 30 | Example: |
| 31 | ```c++ |
| 32 | enum WebFeature { |
| 33 | ... |
| 34 | kMyFeature = N, |
| 35 | ... |
| 36 | } |
| 37 | ``` |
| 38 | ``` |
| 39 | interface MyInterface { |
| 40 | ... |
| 41 | [MeasureAs=MyFeature] myIdlAttribute; |
| 42 | ... |
| 43 | } |
| 44 | ``` |
| 45 | OR |
| 46 | ```c++ |
| 47 | MyInterface::MyBlinkSideFunction() { |
| 48 | ... |
Wan-Teh Chang | a2185fc | 2021-02-04 22:38:20 | [diff] [blame] | 49 | UseCounter::Count(context, WebFeature::kMyFeature); |
Luna Lu | d1e8057 | 2019-06-05 20:58:16 | [diff] [blame] | 50 | ... |
| 51 | } |
| 52 | ``` |
| 53 | OR |
| 54 | ```c++ |
| 55 | MyBrowserSideFunction() { |
| 56 | ... |
Charlie Harrison | 642ada1 | 2023-03-14 14:10:51 | [diff] [blame] | 57 | GetContentClient()->browser()->LogWebFeatureForCurrentPage( |
Wan-Teh Chang | a2185fc | 2021-02-04 22:38:20 | [diff] [blame] | 58 | render_frame_host, blink::mojom::WebFeature::kMyFeature); |
Luna Lu | d1e8057 | 2019-06-05 20:58:16 | [diff] [blame] | 59 | ... |
| 60 | } |
| 61 | ``` |
| 62 | |
| 63 | Not all features collect URL-keyed metrics. To opt in your feature to UKM, |
| 64 | simply add your feature to |
Mason Freed | bef47320 | 2019-12-13 23:06:31 | [diff] [blame] | 65 | [UseCounterPageLoadMetricsObserver::GetAllowedUkmFeatures()](https://cs.chromium.org/chromium/src/components/page_load_metrics/browser/observers/use_counter/ukm_features.cc) |
Luna Lu | d1e8057 | 2019-06-05 20:58:16 | [diff] [blame] | 66 | and get approval from one of the privacy owners. |
| 67 | |
| 68 | You can quickly verify that your feature is added to UMA histograms and UKM by |
Wan-Teh Chang | 945a554 | 2021-02-05 14:57:50 | [diff] [blame] | 69 | checking chrome://histograms/Blink.UseCounter.Features and chrome://ukm in your |
| 70 | local build. |
Luna Lu | d1e8057 | 2019-06-05 20:58:16 | [diff] [blame] | 71 | |
| 72 | ## Analyze UseCounter Histogram Data |
| 73 | |
| 74 | ### Public Data on https://chromestatus.com |
| 75 | |
| 76 | Usage of JavaScript and HTML features is available |
| 77 | [here](https://chromestatus.com/metrics/feature/popularity). |
| 78 | Usage of CSS properties is available |
| 79 | [here](https://chromestatus.com/metrics/css/popularity). |
| 80 | |
| 81 | The data reflects features' daily usage (count of feature hits / count of total |
| 82 | page 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 Kaplow | b3f2df2 | 2023-09-21 20:52:37 | [diff] [blame^] | 88 | ### Internal UMA tools |
Luna Lu | d1e8057 | 2019-06-05 20:58:16 | [diff] [blame] | 89 | |
Robert Kaplow | b3f2df2 | 2023-09-21 20:52:37 | [diff] [blame^] | 90 | See (https://goto.google.com/uma-usecounter) for internal tooling. |
Luna Lu | d1e8057 | 2019-06-05 20:58:16 | [diff] [blame] | 91 | |
Robert Kaplow | b3f2df2 | 2023-09-21 20:52:37 | [diff] [blame^] | 92 | Some metrics of interest: |
Luna Lu | d1e8057 | 2019-06-05 20:58:16 | [diff] [blame] | 93 | + "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 Lu | d1e8057 | 2019-06-05 20:58:16 | [diff] [blame] | 99 | ### UseCounter Feature in HTTP Archive |
| 100 | |
| 101 | HTTP Archive crawls the top 10K sites on the web and records everything from |
| 102 | request and response headers. The data is available on Google BigQuery. |
| 103 | |
| 104 | You can find pages that trigger a particular UseCounter using the following |
| 105 | script: |
| 106 | |
| 107 | ```sql |
| 108 | SELECT |
| 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 |
| 114 | FROM [httparchive:blink_features.usage] |
| 115 | WHERE feature = 'MyFeature' |
| 116 | ORDER BY url_percentile DESC |
| 117 | ``` |
| 118 | OR |
| 119 | |
| 120 | ```sql |
| 121 | SELECT |
| 122 | url |
| 123 | FROM [httparchive:pages.yyyy_mm_dd_mobile] |
| 124 | WHERE |
| 125 | JSON_EXTRACT(payload, '$._blinkFeatureFirstUsed.Features.MyFeature') IS NOT |
| 126 | NULL |
| 127 | LIMIT 500 |
| 128 | ``` |
| 129 | |
| 130 | You can also find pages that trigger a particular CSS property (during parsing): |
| 131 | |
| 132 | ```sql |
| 133 | SELECT |
| 134 | url |
| 135 | FROM [httparchive:pages.yyyy_mm_dd_mobile] |
| 136 | WHERE |
| 137 | JSON_EXTRACT(payload, '$._blinkFeatureFirstUsed.CSSFeatures.MyCSSProperty') |
| 138 | IS NOT NULL |
| 139 | LIMIT 500 |
| 140 | ``` |
| 141 | |
| 142 | To find pages that trigger a UseCounter and sort by page rank: |
| 143 | |
| 144 | ```sql |
| 145 | SELECT |
| 146 | IFNULL(runs.rank, 1000000) AS rank, |
| 147 | har.url AS url, |
| 148 | FROM [httparchive:latest.pages_desktop] AS har |
| 149 | LEFT JOIN [httparchive:runs.latest_pages] AS runs |
| 150 | ON har.url = runs.url |
| 151 | WHERE |
| 152 | JSON_EXTRACT(payload, '$._blinkFeatureFirstUsed.Features.MyFeature') IS NOT |
| 153 | NULL |
| 154 | ORDER BY rank; |
| 155 | ``` |
| 156 | |
| 157 | |
| 158 | ### UMA Usage on Fraction of Users |
| 159 | You may also see the fraction of users that trigger your feature at lease once a |
| 160 | day on [UMA Usage dashboard](https://goto.google.com/uma-usecounter-peruser). |
| 161 | |
| 162 | |
| 163 | ## Analyze UseCounter UKM Data |
| 164 | For privacy concerns, UKM data is available for Google employees only. |
Sun Yueru | 4637eec | 2023-06-16 16:02:01 | [diff] [blame] | 165 | Please see [this internal |
| 166 | documentation](https://goto.google.com/ukm-blink-usecounter) for details. |