Comments (7)
What does the non-null response look like?
from legacy.httparchive.org.
I dunno how to select it - that's the problem. So just a greyed out box. But at least doesn't say Null
from legacy.httparchive.org.
FYI this is what the whole payload
looks like:
So you can see the other custom metrics are basically strings, but the pwa
one is a full JSON object (as are the _event-names
and _initiators
). You'd think that would make it EASIER to select but struggling to get it working.
from legacy.httparchive.org.
The type of _pwa.serviceWorkers
is a JSON object, so I think JSON_EXTRACT_SCALAR
is expected to return null values. JSON_EXTRACT_ARRAY
seems to be WAI because there are no integer indices.
Something like this works to extract a few sample objects:
SELECT
JSON_EXTRACT(payload, "$._pwa.serviceWorkers") AS pwa
FROM
`httparchive.pages.2021_06_01_desktop`
WHERE
JSON_EXTRACT(payload, "$._pwa.serviceWorkers") != "[]"
LIMIT
10
I think a complex custom metric like this would require a UDF to iterate through the response object. For example:
CREATE TEMP FUNCTION GET_SERVICE_WORKERS(pwa STRING) RETURNS ARRAY<STRING> LANGUAGE js AS '''
var $ = JSON.parse(pwa);
return Object.keys($.serviceWorkers);
''';
SELECT
GET_SERVICE_WORKERS(JSON_EXTRACT(payload, '$._pwa')) AS ServiceWorkers
FROM
`httparchive.pages.2021_06_01_desktop`
WHERE
url = 'https://www.naranja.com/'
This returns https://www.naranja.com/sw.js
.
from legacy.httparchive.org.
Cheers for the pointers. Will play with it some more. Agree will need a UDF for most queries but started on a simple one that was looking at another table, and wanted to restrict to PWAs (i.e has a SW and a Manifest) so thought UDF was overkill. You’re middle might work for that. Or maybe a simple UDF is the way to go.
So we think we should do JSON objects for future customs metrics rather than Strings that need to be parsed? It probably is easier but just need to think about it slightly differently.
from legacy.httparchive.org.
I think because the object keys are the variables that makes a UDF necessary.
IIRC we used string format for custom metrics in the past because it made debugging easier on WPT. @pmeenan has since improved the way JSON-based custom metrics are rendered in the UI so that gave us a good reason to use more semantic types rather than nesting JSON in JSON.
That said, I do have some regrets about introducing inconsistencies between custom metrics. Ideally we could convert the stringified custom metrics back to their object-based format, but that would require updating old queries.
from legacy.httparchive.org.
Ok. As long as it was intentional that’s cool. Will figure it out with your pointers and say your Fugu one again. Will close this.
from legacy.httparchive.org.
Related Issues (20)
- Legacy website explorer limited to July 2018 HOT 2
- Crawlid 558 missing from stats HOT 3
- Legacy Website Reports are Missing Historical Data HOT 3
- Update FAQs HOT 1
- Video summary needs updating HOT 3
- Data from 2018-12-15 contains duplicate tests for some sites HOT 4
- Data from 2019-01-01 contains unknown crawls HOT 13
- Calculation of reqTotal incorrect for many sites for 2019-03-01 data HOT 1
- Legacy website not reachable HOT 4
- stats download for November is empty HOT 5
- A11Y metrics bugs HOT 3
- wpt_bodies meta description and robots gathering is invalid as the selector used is case sensitive HOT 1
- Create documentation file listing the contents of each custom metrics file
- Add a shorter timeout for fetches in custom metrics HOT 13
- Better script element custom metrics
- Create new scripts to detect importScripts() and usage of SW methods inside pwa.js HOT 1
- Add nativeSource to a11y custom metric
- Improve avif detection
- Improve a11y metric for captioned tables HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from legacy.httparchive.org.