Skip to content

Conversation

@tonybaroneee
Copy link

@tonybaroneee tonybaroneee commented Dec 8, 2025

image

@tonybaroneee tonybaroneee requested a review from a team as a code owner December 8, 2025 16:58
@changeset-bot
Copy link

changeset-bot bot commented Dec 8, 2025

⚠️ No Changeset found

Latest commit: e0606cc

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @tonybaroneee, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the telemetry session management to ensure that a client session ID is established proactively when the telemetry service is registered. This change centralizes the session creation logic, improves the predictability of session ID availability, and adds explicit logging for new session initiations. It also includes related test updates and a minor performance optimization in the React integration.

Highlights

  • Eager Session Creation: Telemetry session IDs are now created proactively when the registerTelemetry function is called, rather than waiting for the first error capture event.
  • Centralized Session Management: New helper functions, getSessionId and startNewSession, have been introduced to encapsulate the logic for retrieving and generating session IDs, including emitting a log entry upon new session creation.
  • Test Suite Enhancements: The test suite for the telemetry API has been updated to include dedicated tests for registerTelemetry() that verify the eager session creation and persistence behavior, and redundant tests have been removed.
  • React Component Optimization: The FirebaseTelemetry React component has been optimized to retrieve the telemetry instance only once within its useEffect hook, reducing redundant calls to getTelemetry.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the session creation logic for telemetry. Instead of creating a session lazily when the first error is captured, it now creates one eagerly when the telemetry service is initialized. This is a solid architectural improvement that allows for session tracking from the beginning of the application lifecycle. The implementation involves splitting the old getSessionId function into a getter and a new startNewSession function, and calling this new function during telemetry registration. The tests have been updated accordingly to reflect this new behavior. My review includes one suggestion to improve the robustness of the new session creation logic.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Dec 8, 2025

Size Report 1

Affected Products

  • @firebase/telemetry

    TypeBase (668485a)Merge (64d76b5)Diff
    browser8.80 kB9.29 kB+489 B (+5.6%)
    main8.74 kB8.61 kB-134 B (-1.5%)
    module8.80 kB9.29 kB+489 B (+5.6%)
  • firebase

    TypeBase (668485a)Merge (64d76b5)Diff
    firebase-telemetry.js88.2 kB88.5 kB+295 B (+0.3%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/0xcwAMqFmB.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Dec 8, 2025

Size Analysis Report 1

Affected Products

  • @firebase/telemetry

    • captureError

      Size

      TypeBase (668485a)Merge (64d76b5)Diff
      size5.29 kB5.55 kB+267 B (+5.1%)
      size-with-ext-deps64.7 kB64.9 kB+275 B (+0.4%)

      Dependency

      TypeBase (668485a)Merge (64d76b5)Diff
      functions

      captureError
      createLoggerProvider
      getAppVersion
      getSessionId
      isExportRetryable
      parseRetryAfterToMills
      registerTelemetry

      captureError
      createLoggerProvider
      getAppVersion
      getSessionId
      isExportRetryable
      parseRetryAfterToMills
      registerTelemetry
      startNewSession

      + startNewSession

    • flush

      Size

      TypeBase (668485a)Merge (64d76b5)Diff
      size4.28 kB4.95 kB+673 B (+15.7%)
      size-with-ext-deps63.0 kB64.3 kB+1.35 kB (+2.1%)

      Dependency

      TypeBase (668485a)Merge (64d76b5)Diff
      functions

      createLoggerProvider
      flush
      isExportRetryable
      parseRetryAfterToMills
      registerTelemetry

      createLoggerProvider
      flush
      getAppVersion
      getSessionId
      isExportRetryable
      parseRetryAfterToMills
      registerTelemetry
      startNewSession

      + getAppVersion
      + getSessionId
      + startNewSession

      variables

      LOG_ENTRY_ATTRIBUTE_KEYS
      TELEMETRY_TYPE
      name
      version

      AUTO_CONSTANTS
      LOG_ENTRY_ATTRIBUTE_KEYS
      TELEMETRY_SESSION_ID_KEY
      TELEMETRY_TYPE
      name
      version

      + AUTO_CONSTANTS
      + TELEMETRY_SESSION_ID_KEY

      External Dependency

      ModuleBase (668485a)Merge (64d76b5)Diff
      @opentelemetry/api-logs

      SeverityNumber

      + SeverityNumber

    • getTelemetry

      Size

      TypeBase (668485a)Merge (64d76b5)Diff
      size4.31 kB4.99 kB+673 B (+15.6%)
      size-with-ext-deps70.0 kB71.3 kB+1.35 kB (+1.9%)

      Dependency

      TypeBase (668485a)Merge (64d76b5)Diff
      functions

      createLoggerProvider
      getTelemetry
      isExportRetryable
      parseRetryAfterToMills
      registerTelemetry

      createLoggerProvider
      getAppVersion
      getSessionId
      getTelemetry
      isExportRetryable
      parseRetryAfterToMills
      registerTelemetry
      startNewSession

      + getAppVersion
      + getSessionId
      + startNewSession

      variables

      LOG_ENTRY_ATTRIBUTE_KEYS
      TELEMETRY_TYPE
      name
      version

      AUTO_CONSTANTS
      LOG_ENTRY_ATTRIBUTE_KEYS
      TELEMETRY_SESSION_ID_KEY
      TELEMETRY_TYPE
      name
      version

      + AUTO_CONSTANTS
      + TELEMETRY_SESSION_ID_KEY

      External Dependency

      ModuleBase (668485a)Merge (64d76b5)Diff
      @opentelemetry/api-logs

      SeverityNumber

      + SeverityNumber

    • nextOnRequestError

      Size

      TypeBase (668485a)Merge (64d76b5)Diff
      size5.66 kB5.92 kB+267 B (+4.7%)
      size-with-ext-deps72.0 kB72.3 kB+275 B (+0.4%)

      Dependency

      TypeBase (668485a)Merge (64d76b5)Diff
      functions

      captureError
      createLoggerProvider
      getAppVersion
      getSessionId
      getTelemetry
      isExportRetryable
      nextOnRequestError
      parseRetryAfterToMills
      registerTelemetry

      captureError
      createLoggerProvider
      getAppVersion
      getSessionId
      getTelemetry
      isExportRetryable
      nextOnRequestError
      parseRetryAfterToMills
      registerTelemetry
      startNewSession

      + startNewSession

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/oVYVgsKUWm.html

@tonybaroneee tonybaroneee merged commit 572afb5 into telemetry Dec 8, 2025
52 of 54 checks passed
@tonybaroneee tonybaroneee deleted the telemetry-new-session branch December 8, 2025 18:28
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.

3 participants