Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1867126 - automatic page load instrumentation #1835

Merged
merged 14 commits into from Dec 5, 2023

Conversation

rosahbruno
Copy link
Contributor

@rosahbruno rosahbruno commented Nov 23, 2023

Description

Configure auto instrumentation for page_load events.

Built-in page_load events can now be recorded in 2 ways

  1. Automatically via the enableAutoPageLoadEvents parameter in the Glean configuration object. Whenever this is set to true, page load events will be collected automatically whenever initialize is called.
  2. Manually via the @mozilla/glean/metrics object. We now expose pageLoad which is a function that a user can call at any time to record the same page load event that would have been collected automatically.

Automatic instrumentation

Glean.initialize("app-name", true, { enableAutoPageLoadEvents: true });

Example: https://debug-ping-preview.firebaseapp.com/pings/glean-from-website/9f6996dc-a336-46eb-8c93-a1278046ae10#L10

Manually call page_load

import GleanMetrics from "@mozilla/glean/metrics";

// ...

GleanMetrics.pageLoad({
  // Any of the values can be overwritten. If they are not overwritten,
  // the values pulled from the browser will be used.
  //
  // If `enableAutoPageLoadEvents` is true, then this call is a no-op.
  title: "Title Override"
});

Example: https://debug-ping-preview.firebaseapp.com/pings/glean-from-website/81fd045b-c8da-4229-8464-2860b054ece7#L10

Pull Request checklist

  • Quality: Make sure this PR builds and runs cleanly.
    • Inside the glean/ folder, run:
      • npm run test Runs all tests
      • npm run lint Runs all linters
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry to CHANGELOG.md or an explanation of why it does not need one
  • Documentation: This PR includes documentation changes, an explanation of why it does not need that or a follow-up bug has been filed to do that work

glean/package.json Outdated Show resolved Hide resolved
glean/src/core/built_in_events/index.ts Outdated Show resolved Hide resolved
glean/src/core/built_in_events/page_load.ts Outdated Show resolved Hide resolved
glean/src/metrics.yaml Outdated Show resolved Hide resolved
glean/src/core/built_in_events/index.ts Outdated Show resolved Hide resolved
glean/src/core/built_in_events/index.ts Outdated Show resolved Hide resolved
glean/src/core/built_in_events/index.ts Outdated Show resolved Hide resolved
@rosahbruno rosahbruno changed the title Glean built-in page_load events Bug 1867126 - automatic page load instrumentation Nov 28, 2023
@rosahbruno rosahbruno marked this pull request as ready for review November 29, 2023 20:55
@auto-assign auto-assign bot requested a review from travis79 November 29, 2023 20:55
@rosahbruno rosahbruno merged commit f4beced into mozilla:main Dec 5, 2023
6 checks passed
@rosahbruno rosahbruno deleted the page-loads branch December 5, 2023 13:50
@kirill-demtchouk
Copy link

Love this! ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants