-
Notifications
You must be signed in to change notification settings - Fork 1.2k
ChromeUX History API doesn't support NaN values #1970
Copy link
Copy link
Closed
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
For some domains, the chrome ux history api chromeuxreport.googleapis.com/v1/records:queryHistoryRecord could contain Nan values.
For example:
{
"record": {
"key": {
"origin": "https://nordbeton.shop"
},
"metrics": {
"cumulative_layout_shift": {
"histogramTimeseries": [
{
"start": "0.00",
"end": "0.10",
"densities": [
"NaN",
"NaN",
"NaN",
0.953582763671875,
0.94488525390625,
0.93817138671875,The api client does not support that and returns an error: json: cannot unmarshal string into Go struct field TimeseriesBin.record.metrics.histogramTimeseries.densities of type float64
The Bin struct, used in the daily chrome ux api, does solve this by using a custom UnmarshalJSON() method with gensupport.JSONFloat64.
But in the TimeseriesBin struct is that step missing.
Environment details
- Programming language: Golang
- OS: MacOS
- Language runtime version: go1.20.3 darwin/amd64
- Package version: v0.120.0
Steps to reproduce
package main
import (
"context"
"fmt"
"google.golang.org/api/chromeuxreport/v1"
"google.golang.org/api/option"
)
func main() {
s, err := chromeuxreport.NewService(
context.Background(),
option.WithAPIKey("API-KEY"))
if err != nil {
panic(err)
}
req := &chromeuxreport.QueryHistoryRequest{
Origin: "https://nordbeton.shop",
}
res, err := s.Records.QueryHistoryRecord(req).Do()
if err != nil {
// returns
// json: cannot unmarshal string into Go struct field TimeseriesBin.record.metrics.histogramTimeseries.densities of type float64
panic(err)
}
fmt.Println(res)
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.