-
-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Copies 2021 queries and updates dates to 2022 * Update sql/2022/mobile-web/README.md Co-authored-by: Rick Viscomi <[email protected]> * Add back resources to readme Co-authored-by: Rick Viscomi <[email protected]>
- Loading branch information
1 parent
54fc1fe
commit 3cae569
Showing
25 changed files
with
787 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# standardSQL | ||
# Usage of client hint directives | ||
CREATE TEMPORARY FUNCTION getClientHints(headers STRING) | ||
RETURNS ARRAY<STRING> LANGUAGE js AS """ | ||
try { | ||
const header_name = 'Accept-CH'; | ||
const parsed_headers = JSON.parse(headers); | ||
const matching_headers = parsed_headers.filter(h => h.name.toLowerCase() == header_name.toLowerCase()); | ||
if (matching_headers.length <= 0) { | ||
return []; | ||
} | ||
const unique_directives = new Set(); | ||
for (const header of matching_headers) { | ||
const directives = header.value.split(/\\s*,\\s*/); | ||
for (const directive of directives) { | ||
unique_directives.add(directive.toLowerCase()); | ||
} | ||
} | ||
return Array.from(unique_directives); | ||
} catch (e) { | ||
return []; | ||
} | ||
"""; | ||
|
||
SELECT | ||
client, | ||
total_pages, | ||
SUM(COUNT(DISTINCT page)) OVER (PARTITION BY client) AS total_pages_using_ch, | ||
|
||
ch_directive, | ||
COUNT(0) AS total_pages_using, | ||
COUNT(0) / total_pages AS pct_pages, | ||
COUNT(0) / SUM(COUNT(DISTINCT page)) OVER (PARTITION BY client) AS pct_ch_pages_using | ||
FROM ( | ||
SELECT | ||
page, | ||
client, | ||
ch_directive | ||
FROM | ||
`httparchive.almanac.requests`, | ||
UNNEST(getClientHints(JSON_EXTRACT(payload, '$.response.headers'))) AS ch_directive | ||
WHERE | ||
date = '2022-06-01' AND | ||
firstHtml | ||
) | ||
LEFT JOIN ( | ||
SELECT | ||
_TABLE_SUFFIX AS client, | ||
COUNT(0) AS total_pages | ||
FROM | ||
`httparchive.pages.2022_06_01_*` | ||
GROUP BY _TABLE_SUFFIX | ||
) | ||
USING (client) | ||
GROUP BY | ||
client, | ||
ch_directive, | ||
total_pages | ||
ORDER BY | ||
pct_pages DESC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#standardSQL | ||
# % mobile pages with sufficient text color contrast with its background | ||
SELECT | ||
COUNTIF(color_contrast_score IS NOT NULL) AS total_applicable, | ||
COUNTIF(CAST(color_contrast_score AS NUMERIC) = 1) AS total_sufficient, | ||
COUNTIF(CAST(color_contrast_score AS NUMERIC) = 1) / COUNTIF(color_contrast_score IS NOT NULL) AS pct_in_applicable | ||
FROM ( | ||
SELECT | ||
JSON_EXTRACT_SCALAR(report, '$.audits.color-contrast.score') AS color_contrast_score | ||
FROM | ||
`httparchive.lighthouse.2022_06_01_mobile` | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#standardSQL | ||
# pages with perfect scores on the properly sized images audit | ||
SELECT | ||
COUNTIF(properly_sized_images_score IS NOT NULL) AS total_applicable, | ||
COUNTIF(properly_sized_images_score = 1) AS total_with_properly_sized_images, | ||
COUNTIF(properly_sized_images_score = 1) / COUNTIF(properly_sized_images_score IS NOT NULL) AS pct_with_properly_sized_images | ||
FROM ( | ||
SELECT | ||
SAFE_CAST(JSON_EXTRACT_SCALAR(report, '$.audits.uses-responsive-images.score') AS NUMERIC) AS properly_sized_images_score | ||
FROM | ||
`httparchive.lighthouse.2022_06_01_mobile` | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#standardSQL | ||
# Usage of Credential Manager | ||
SELECT DISTINCT | ||
client, | ||
feature, | ||
num_urls AS freq, | ||
total_urls AS total, | ||
pct_urls AS pct | ||
FROM | ||
`httparchive.blink_features.usage` | ||
WHERE | ||
yyyymmdd = '20220601' AND | ||
feature = 'CredentialManagerGet' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#standardSQL | ||
# Ecommerce pages using type=search inputs | ||
CREATE TEMPORARY FUNCTION getSearchInputStats(payload STRING) | ||
RETURNS STRUCT<has_inputs BOOLEAN, has_search_inputs BOOLEAN> LANGUAGE js AS ''' | ||
try { | ||
const almanac = JSON.parse(payload); | ||
const search_node_index = almanac.input_elements.nodes.findIndex((node) => { | ||
return node.type.toLowerCase() === 'search'; | ||
}); | ||
return { | ||
has_inputs: almanac.input_elements.total > 0, | ||
has_search_inputs: search_node_index >= 0, | ||
}; | ||
} catch (e) { | ||
return { | ||
has_inputs: false, | ||
has_search_inputs: false, | ||
}; | ||
} | ||
'''; | ||
|
||
SELECT | ||
client, | ||
COUNT(0) AS total_pages, | ||
COUNTIF(search_input_stats.has_inputs) AS pages_with_inputs, | ||
COUNTIF(search_input_stats.has_search_inputs) AS pages_with_search_inputs, | ||
|
||
COUNTIF(search_input_stats.has_search_inputs) / COUNT(0) AS pct_pages_with_search_inputs, | ||
COUNTIF(search_input_stats.has_search_inputs) / COUNTIF(search_input_stats.has_inputs) AS pct_input_pages_with_search_inputs | ||
FROM ( | ||
SELECT | ||
_TABLE_SUFFIX AS client, | ||
getSearchInputStats(JSON_EXTRACT_SCALAR(payload, '$._almanac')) AS search_input_stats, | ||
url | ||
FROM | ||
`httparchive.pages.2022_06_01_*` | ||
) | ||
JOIN ( | ||
SELECT | ||
_TABLE_SUFFIX AS client, | ||
url | ||
FROM | ||
`httparchive.technologies.2022_06_01_*` | ||
WHERE | ||
category = 'Ecommerce' | ||
) | ||
USING (client, url) | ||
GROUP BY | ||
client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#standardSQL | ||
# Usage of native lazy loading | ||
CREATE TEMPORARY FUNCTION usesLoadingLazy(payload STRING) | ||
RETURNS BOOLEAN LANGUAGE js AS ''' | ||
try { | ||
const almanac = JSON.parse(payload); | ||
let found = false; | ||
for (const node of almanac.images.imgs.nodes) { | ||
if (node.loading === "lazy") { | ||
found = true; | ||
break; | ||
} | ||
} | ||
return found; | ||
} catch (e) { | ||
return false; | ||
} | ||
'''; | ||
SELECT | ||
client, | ||
COUNTIF(total_img > 0) AS pages_with_images, | ||
|
||
COUNTIF(uses_loading_lazy) AS pages_using_loading_attribute, | ||
COUNTIF(uses_loading_lazy) / COUNTIF(total_img > 0) AS pct_pages_using_loading_attribute | ||
FROM ( | ||
SELECT | ||
_TABLE_SUFFIX AS client, | ||
SAFE_CAST(JSON_EXTRACT_SCALAR(JSON_EXTRACT_SCALAR(payload, '$._almanac'), '$.images.imgs.total') AS INT64) AS total_img, | ||
usesLoadingLazy(JSON_EXTRACT_SCALAR(payload, '$._almanac')) AS uses_loading_lazy | ||
FROM | ||
`httparchive.pages.2022_06_01_*` | ||
) | ||
GROUP BY | ||
client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#standardSQL | ||
# Percentage of websites receiving more traffic from mobile than desktop. Tablet is excluded since it does not fit well in either category | ||
|
||
WITH base AS ( | ||
SELECT | ||
date, | ||
origin, | ||
rank, | ||
|
||
desktopDensity, | ||
phoneDensity | ||
FROM | ||
`chrome-ux-report.materialized.metrics_summary` | ||
WHERE | ||
date IN ('2022-06-01') | ||
) | ||
|
||
SELECT | ||
date, | ||
CASE | ||
WHEN rank_grouping = 10000000 THEN 'all' | ||
ELSE CAST(rank_grouping AS STRING) | ||
END AS ranking, | ||
|
||
COUNT(DISTINCT origin) AS total_origins, | ||
|
||
COUNT(DISTINCT IF(desktopDensity = phoneDensity, origin, NULL)) AS total_equal, | ||
COUNT(DISTINCT IF(desktopDensity < phoneDensity, origin, NULL)) AS total_more_mobile, | ||
COUNT(DISTINCT IF(desktopDensity > phoneDensity, origin, NULL)) AS total_more_desktop, | ||
|
||
SAFE_DIVIDE(COUNT(DISTINCT IF(desktopDensity = phoneDensity, origin, NULL)), COUNT(DISTINCT origin)) AS perc_equal, | ||
SAFE_DIVIDE(COUNT(DISTINCT IF(desktopDensity < phoneDensity, origin, NULL)), COUNT(DISTINCT origin)) AS perc_more_mobile, | ||
SAFE_DIVIDE(COUNT(DISTINCT IF(desktopDensity > phoneDensity, origin, NULL)), COUNT(DISTINCT origin)) AS perc_more_desktop | ||
FROM | ||
base, | ||
UNNEST([1000, 10000, 100000, 1000000, 10000000]) AS rank_grouping | ||
WHERE | ||
rank <= rank_grouping | ||
GROUP BY | ||
date, | ||
rank_grouping | ||
ORDER BY | ||
rank_grouping |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#standardSQL | ||
# Distribution of traffic coming from mobile devices | ||
SELECT | ||
percentile, | ||
APPROX_QUANTILES(phoneDensity, 1000)[OFFSET(percentile * 10)] AS pct_traffic_from_mobile | ||
FROM | ||
`chrome-ux-report.materialized.device_summary`, | ||
UNNEST(GENERATE_ARRAY(1, 100)) AS percentile | ||
WHERE | ||
date = '2022-06-01' AND | ||
device = 'phone' | ||
GROUP BY | ||
percentile | ||
ORDER BY | ||
percentile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#standardSQL | ||
# Most used technologies - mobile only | ||
SELECT | ||
total_pages, | ||
|
||
category, | ||
app, | ||
COUNT(0) AS pages_with_app, | ||
COUNT(0) / total_pages AS pct_pages_with_app | ||
FROM | ||
`httparchive.technologies.2022_06_01_mobile` | ||
CROSS JOIN ( | ||
SELECT | ||
COUNT(0) AS total_pages | ||
FROM | ||
`httparchive.summary_pages.2022_06_01_mobile` | ||
) | ||
GROUP BY | ||
total_pages, | ||
category, | ||
app | ||
ORDER BY | ||
pct_pages_with_app DESC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#standardSQL | ||
# Most used technologies by domain rank - mobile only | ||
SELECT | ||
rank_grouping, | ||
total_in_rank, | ||
|
||
category, | ||
app, | ||
COUNT(0) AS pages_with_app, | ||
COUNT(0) / total_in_rank AS pct_pages_with_app | ||
FROM ( | ||
SELECT | ||
app, | ||
category, | ||
url | ||
FROM | ||
`httparchive.technologies.2022_06_01_mobile` | ||
) | ||
LEFT OUTER JOIN ( | ||
SELECT | ||
url, | ||
rank_grouping | ||
FROM | ||
`httparchive.summary_pages.2022_06_01_mobile`, | ||
UNNEST([1000, 10000, 100000, 1000000, 10000000]) AS rank_grouping | ||
WHERE | ||
rank <= rank_grouping | ||
) USING (url) | ||
JOIN ( | ||
SELECT | ||
rank_grouping, | ||
COUNT(0) AS total_in_rank | ||
FROM | ||
`httparchive.summary_pages.2022_06_01_mobile`, | ||
UNNEST([1000, 10000, 100000, 1000000, 10000000]) AS rank_grouping | ||
WHERE | ||
rank <= rank_grouping | ||
GROUP BY | ||
rank_grouping | ||
) USING (rank_grouping) | ||
GROUP BY | ||
rank_grouping, | ||
total_in_rank, | ||
category, | ||
app | ||
ORDER BY | ||
app, | ||
rank_grouping |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#standardSQL | ||
# Usage of Navigator.deviceMemory | ||
SELECT | ||
client, | ||
feature, | ||
num_urls AS freq, | ||
total_urls AS total, | ||
pct_urls AS pct | ||
FROM | ||
`httparchive.blink_features.usage` | ||
WHERE | ||
yyyymmdd = '20220601' AND | ||
feature = 'NavigatorDeviceMemory' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#standardSQL | ||
# Usage of NetworkInformation.effectiveType | ||
SELECT | ||
client, | ||
feature, | ||
num_urls AS freq, | ||
total_urls AS total, | ||
pct_urls AS pct | ||
FROM | ||
`httparchive.blink_features.usage` | ||
WHERE | ||
yyyymmdd = '20220601' AND | ||
feature = 'NetInfoEffectiveType' |
Oops, something went wrong.