in glean/src/core/glean_metrics.ts [74:111]
export function pageLoad(overrides?: PageLoadParams) {
// Cannot record an event if Glean has not been initialized.
if (!Context.initialized) {
log(
LOG_TAG,
"Attempted to record a page load event before Glean was initialized. This is a no-op.",
LoggingLevel.Warn
);
return;
}
// Rotate the page_id for each page_load event.
metrics.pageId.generateAndSet();
// Each key defaults to the override. If no override is provided, we fall
// back to the default value IF the `window` or the `document` objects
// are available.
//
// If neither of those are available, then we default to a value that shows
// that no value is available.
metrics.pageLoad.record({
url:
overrides?.url ?? (typeof window !== "undefined"
? window.location.href
: "URL_NOT_PROVIDED_OR_AVAILABLE"
),
referrer:
overrides?.referrer ?? (typeof document !== "undefined"
? document.referrer
: "REFERRER_NOT_PROVIDED_OR_AVAILABLE"
),
title:
overrides?.title ?? (typeof document !== "undefined"
? document.title
: "TITLE_NOT_PROVIDED_OR_AVAILABLE"
),
});
}