Git Product home page Git Product logo

Comments (7)

rviscomi avatar rviscomi commented on August 24, 2024

What does the non-null response look like?

from legacy.httparchive.org.

tunetheweb avatar tunetheweb commented on August 24, 2024

I dunno how to select it - that's the problem. So just a greyed out box. But at least doesn't say Null

image

from legacy.httparchive.org.

tunetheweb avatar tunetheweb commented on August 24, 2024

FYI this is what the whole payload looks like:

image

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.

rviscomi avatar rviscomi commented on August 24, 2024

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.

tunetheweb avatar tunetheweb commented on August 24, 2024

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.

rviscomi avatar rviscomi commented on August 24, 2024

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.

tunetheweb avatar tunetheweb commented on August 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.