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)
}
For some domains, the chrome ux history api
chromeuxreport.googleapis.com/v1/records:queryHistoryRecordcould containNanvalues.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 float64The
Binstruct, used in the daily chrome ux api, does solve this by using a customUnmarshalJSON()method withgensupport.JSONFloat64.But in the
TimeseriesBinstruct is that step missing.Environment details
Steps to reproduce