-
-
Notifications
You must be signed in to change notification settings - Fork 214
Expand file tree
/
Copy pathsourcemaps.sql
More file actions
44 lines (39 loc) · 1.01 KB
/
Copy pathsourcemaps.sql
File metadata and controls
44 lines (39 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#standardSQL
# Number of pages with publicly available sourcemaps
CREATE TEMPORARY FUNCTION getSourceMaps(payload STRING)
RETURNS STRUCT<hasSourceMaps BOOL, isPublic BOOL>
LANGUAGE js AS '''
try {
const $ = JSON.parse(payload);
const javascript = JSON.parse($._javascript);
if (javascript && javascript.sourceMaps) {
const { sourceMaps } = javascript;
return ({
hasSourceMaps: Boolean(sourceMaps.count),
isPublic: Boolean(Object.keys(sourceMaps.ext).length)
});
}
return {};
} catch (e) {
return {};
}
''';
SELECT
client,
COUNTIF(sourcemaps.hasSourceMaps = true) AS has_sourcemaps,
COUNTIF(sourcemaps.isPublic = true) AS has_public_sourcemaps,
COUNT(0) AS total_pages,
COUNTIF(sourcemaps.hasSourceMaps = true) / COUNT(0) AS pct_has_sourcemaps,
COUNTIF(sourcemaps.isPublic = true) / COUNT(0) AS pct_has_public_sourcemaps
FROM (
SELECT
client,
page,
getSourceMaps(payload) AS sourcemaps
FROM
`httparchive.all.pages`
WHERE
date = '2024-06-01'
)
GROUP BY
client