Private
appPrivate
pingPrivate
userPrivate
chooseClears currently persisted data for a given lifetime.
The lifetime to clear.
Optional
ping: stringThe ping to clear data from. When omitted, data from all pings will be cleared.
Counts the number of stored metrics with an id starting with a specific identifier.
the metric Lifetime
.
the ping storage to search in.
the type of the metric.
the metric identifier.
the number of stored metrics with their id starting with the given identifier.
Private
getHelper function to validate and get a specific lifetime data related to a ping from the underlying storage.
If invalid data is encountered it will be deleted and won't be part of the final ping payload.
The ping we want to get the data from
The lifetime of the data we want to retrieve
The ping payload found for the given parameters or an empty object in case no data was found or the data that was found, was invalid.
Gets and validates the persisted payload of a given metric in a given ping.
If the persisted value is invalid for the metric we are attempting to retrieve, the persisted value is deleted and `undefined is returned.
This behaviour is not consistent with what the Glean SDK does, but this is on purpose. On the Glean SDK we panic when we can't serialize the persisted value, that is because this is an extremely unlikely situation for that environment.
Since Glean.js will run on the browser, it is easy for consumers / developers to mess with the storage which makes this sort of errors plausible. That is why we choose to not panic and simply delete the corrupted data here.
Note: This is not a strong guard against consumers / developers messing with the storage on their own. Currently Glean.js does not include mechanisms to reliably prevent that.
@param ping The ping from which we want to retrieve the given metric.
@param metric An object containing the information about the metric to retrieve.
@returns The payload persisted for the given metric,
undefined
in case the metric has not been recorded yet or the found values in invalid.
Gets all of the persisted metrics related to a given ping.
The name of the ping to retrieve.
Whether or not to clear the ping lifetime metrics retrieved.
An object containing all the metrics recorded to the given ping,
undefined
in case the ping doesn't contain any recorded metrics.
Checks if anything was stored for the provided metric.
the metric Lifetime
.
the ping storage to search in.
the type of the metric.
the metric identifier.
true
if the metric was found (regardless of the validity of the
stored data), false
otherwise.
Private
processRecords a given value to a given metric. Will overwrite in case there is already a value in there.
The metric to record to.
The value we want to record to the given metric.
Generated using TypeDoc
The metrics database is an abstraction layer on top of the underlying storage.
Metric data is saved to the database in the following format:
{ "pingName": { "metricType (i.e. boolean)": { "metricIdentifier": metricPayload } } }
We have one store in this format for each lifetime: user, ping and application.