|
| 1 | +#standardSQL |
| 2 | +WITH raw_data AS ( |
| 3 | + SELECT |
| 4 | + date, |
| 5 | + page, |
| 6 | + -- 1. TECHNOLOGY FLAGS |
| 7 | + -- CSS Variables: Exclude NULL, {}, '{"summary":{}}', and 'null' string |
| 8 | + ( |
| 9 | + custom_metrics.css_variables IS NOT NULL |
| 10 | + AND TO_JSON_STRING(custom_metrics.css_variables) NOT IN ('{}', '{"summary":{}}', 'null') |
| 11 | + ) AS uses_css_vars, |
| 12 | + |
| 13 | + -- Tailwind: Check the array for the technology |
| 14 | + EXISTS( |
| 15 | + SELECT 1 FROM UNNEST(technologies) AS t WHERE t.technology = 'Tailwind CSS' |
| 16 | + ) AS uses_tailwind, |
| 17 | + |
| 18 | + -- Content String for Regex |
| 19 | + LOWER(TO_JSON_STRING(custom_metrics.css_variables)) AS vars_str |
| 20 | + FROM |
| 21 | + `httparchive.crawl.pages` |
| 22 | + WHERE |
| 23 | + client = 'mobile' |
| 24 | + AND is_root_page |
| 25 | + -- NO RANK FILTER (Analyze the entire long-tail of the web) |
| 26 | + |
| 27 | + -- Quarterly Dates |
| 28 | + AND date IN UNNEST([ |
| 29 | + DATE '2020-10-01', |
| 30 | + DATE '2021-01-01', DATE '2021-04-01', DATE '2021-07-01', DATE '2021-10-01', |
| 31 | + DATE '2022-01-01', DATE '2022-04-01', DATE '2022-07-01', DATE '2022-10-01', |
| 32 | + DATE '2023-01-01', DATE '2023-04-01', DATE '2023-07-01', DATE '2023-10-01', |
| 33 | + DATE '2024-01-01', DATE '2024-04-01', DATE '2024-07-01', DATE '2024-10-01', |
| 34 | + DATE '2025-01-01', DATE '2025-04-01', DATE '2025-07-01', DATE '2025-10-01' |
| 35 | + ]) |
| 36 | +), |
| 37 | + |
| 38 | +-- Pre-calculate heuristics |
| 39 | +flags AS ( |
| 40 | + SELECT |
| 41 | + date, |
| 42 | + page, |
| 43 | + uses_css_vars, |
| 44 | + uses_tailwind, |
| 45 | + |
| 46 | + -- HEURISTIC BOOLEANS (Only true if uses_css_vars is also true) |
| 47 | + (uses_css_vars AND REGEXP_CONTAINS(vars_str, r'"#6366f1"')) AS has_indigo_500, |
| 48 | + (uses_css_vars AND REGEXP_CONTAINS(vars_str, r'"(#6366f1|#8b5cf6|#a855f7)"')) AS has_ai_purples, |
| 49 | + (uses_css_vars AND REGEXP_CONTAINS(vars_str, r'inter')) AS has_inter, |
| 50 | + (uses_css_vars AND REGEXP_CONTAINS(vars_str, r'roboto')) AS has_roboto, |
| 51 | + (uses_css_vars AND REGEXP_CONTAINS(vars_str, r'system-ui')) AS has_system_ui, |
| 52 | + (uses_css_vars AND REGEXP_CONTAINS(vars_str, r'linear-gradient\(|radial-gradient\(')) AS has_gradient, |
| 53 | + (uses_css_vars AND REGEXP_CONTAINS(vars_str, r'"(2px|4px|6px|8px|12px|16px|0\.25rem|0\.5rem|0\.75rem|1rem|9999px)"')) AS has_radius, |
| 54 | + (uses_css_vars AND REGEXP_CONTAINS(vars_str, r'rgba\(|box-shadow')) AS has_shadow |
| 55 | + FROM |
| 56 | + raw_data |
| 57 | +) |
| 58 | + |
| 59 | +SELECT |
| 60 | + FORMAT_DATE('%Y-Q%Q', date) AS year_quarter, |
| 61 | + |
| 62 | + -- 1. CONTEXT (Denominators) |
| 63 | + COUNT(DISTINCT page) AS total_sites, |
| 64 | + COUNT(DISTINCT IF(uses_css_vars, page, NULL)) AS sites_using_vars, |
| 65 | + COUNT(DISTINCT IF(uses_tailwind, page, NULL)) AS sites_using_tailwind, |
| 66 | + |
| 67 | + ------------------------------------------------------------------------- |
| 68 | + -- 2. "AI PURPLE" SPECTRUM (Indigo/Violet/Purple 500) |
| 69 | + ------------------------------------------------------------------------- |
| 70 | + COUNT(DISTINCT IF(has_ai_purples, page, NULL)) AS cnt_ai_purples, |
| 71 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_ai_purples, page, NULL)), COUNT(DISTINCT page)) AS pct_all_ai_purples, |
| 72 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_ai_purples, page, NULL)), COUNT(DISTINCT IF(uses_css_vars, page, NULL))) AS pct_vars_ai_purples, |
| 73 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_ai_purples AND uses_tailwind, page, NULL)), COUNT(DISTINCT IF(uses_tailwind, page, NULL))) AS pct_tw_ai_purples, |
| 74 | + |
| 75 | + ------------------------------------------------------------------------- |
| 76 | + -- 3. SPECIFIC INDIGO 500 (#6366f1 Only) |
| 77 | + ------------------------------------------------------------------------- |
| 78 | + COUNT(DISTINCT IF(has_indigo_500, page, NULL)) AS cnt_indigo, |
| 79 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_indigo_500, page, NULL)), COUNT(DISTINCT page)) AS pct_all_indigo, |
| 80 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_indigo_500, page, NULL)), COUNT(DISTINCT IF(uses_css_vars, page, NULL))) AS pct_vars_indigo, |
| 81 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_indigo_500 AND uses_tailwind, page, NULL)), COUNT(DISTINCT IF(uses_tailwind, page, NULL))) AS pct_tw_indigo, |
| 82 | + |
| 83 | + ------------------------------------------------------------------------- |
| 84 | + -- 4. FONTS |
| 85 | + ------------------------------------------------------------------------- |
| 86 | + -- Inter |
| 87 | + COUNT(DISTINCT IF(has_inter, page, NULL)) AS cnt_inter, |
| 88 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_inter, page, NULL)), COUNT(DISTINCT page)) AS pct_all_inter, |
| 89 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_inter, page, NULL)), COUNT(DISTINCT IF(uses_css_vars, page, NULL))) AS pct_vars_inter, |
| 90 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_inter AND uses_tailwind, page, NULL)), COUNT(DISTINCT IF(uses_tailwind, page, NULL))) AS pct_tw_inter, |
| 91 | + |
| 92 | + -- Roboto |
| 93 | + COUNT(DISTINCT IF(has_roboto, page, NULL)) AS cnt_roboto, |
| 94 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_roboto, page, NULL)), COUNT(DISTINCT page)) AS pct_all_roboto, |
| 95 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_roboto, page, NULL)), COUNT(DISTINCT IF(uses_css_vars, page, NULL))) AS pct_vars_roboto, |
| 96 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_roboto AND uses_tailwind, page, NULL)), COUNT(DISTINCT IF(uses_tailwind, page, NULL))) AS pct_tw_roboto, |
| 97 | + |
| 98 | + -- System UI |
| 99 | + COUNT(DISTINCT IF(has_system_ui, page, NULL)) AS cnt_system, |
| 100 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_system_ui, page, NULL)), COUNT(DISTINCT page)) AS pct_all_system, |
| 101 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_system_ui, page, NULL)), COUNT(DISTINCT IF(uses_css_vars, page, NULL))) AS pct_vars_system, |
| 102 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_system_ui AND uses_tailwind, page, NULL)), COUNT(DISTINCT IF(uses_tailwind, page, NULL))) AS pct_tw_system, |
| 103 | + |
| 104 | + ------------------------------------------------------------------------- |
| 105 | + -- 5. UI ELEMENTS |
| 106 | + ------------------------------------------------------------------------- |
| 107 | + -- Gradients |
| 108 | + COUNT(DISTINCT IF(has_gradient, page, NULL)) AS cnt_gradient, |
| 109 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_gradient, page, NULL)), COUNT(DISTINCT page)) AS pct_all_gradient, |
| 110 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_gradient, page, NULL)), COUNT(DISTINCT IF(uses_css_vars, page, NULL))) AS pct_vars_gradient, |
| 111 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_gradient AND uses_tailwind, page, NULL)), COUNT(DISTINCT IF(uses_tailwind, page, NULL))) AS pct_tw_gradient, |
| 112 | + |
| 113 | + -- Radius |
| 114 | + COUNT(DISTINCT IF(has_radius, page, NULL)) AS cnt_radius, |
| 115 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_radius, page, NULL)), COUNT(DISTINCT page)) AS pct_all_radius, |
| 116 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_radius, page, NULL)), COUNT(DISTINCT IF(uses_css_vars, page, NULL))) AS pct_vars_radius, |
| 117 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_radius AND uses_tailwind, page, NULL)), COUNT(DISTINCT IF(uses_tailwind, page, NULL))) AS pct_tw_radius, |
| 118 | + |
| 119 | + -- Shadows |
| 120 | + COUNT(DISTINCT IF(has_shadow, page, NULL)) AS cnt_shadow, |
| 121 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_shadow, page, NULL)), COUNT(DISTINCT page)) AS pct_all_shadow, |
| 122 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_shadow, page, NULL)), COUNT(DISTINCT IF(uses_css_vars, page, NULL))) AS pct_vars_shadow, |
| 123 | + IEEE_DIVIDE(COUNT(DISTINCT IF(has_shadow AND uses_tailwind, page, NULL)), COUNT(DISTINCT IF(uses_tailwind, page, NULL))) AS pct_tw_shadow |
| 124 | + |
| 125 | +FROM |
| 126 | + flags |
| 127 | +GROUP BY |
| 128 | + year_quarter |
| 129 | +ORDER BY |
| 130 | + year_quarter; |
0 commit comments