Skip to content

fix(messaging): wire Firelog delivery metrics flush (startLoggingService)#9916

Merged
zwu52 merged 8 commits intomainfrom
debug-bq
May 10, 2026
Merged

fix(messaging): wire Firelog delivery metrics flush (startLoggingService)#9916
zwu52 merged 8 commits intomainfrom
debug-bq

Conversation

@zwu52
Copy link
Copy Markdown
Member

@zwu52 zwu52 commented May 4, 2026

Intent

Ship a fix so FCM Web delivery metrics / Firelog logging actually runs after developers enable experimentalSetDeliveryMetricsExportedToBigQueryEnabled. Today stageLog only queues events in memory; startLoggingService was never started from production code, so _processQueue_dispatchLogEvents never fired and no POST to play.google.com/log occurred. This PR wires startLoggingService from stageLog and when enabling export, uses an immediate first flush (INITIAL_LOG_FLUSH_DELAY_MS = 0) for easier verification while keeping subsequent batches on LOG_INTERVAL_IN_MS after dispatch.


Summary

  • stageLog: call startLoggingService(messaging) after enqueueing (idempotent).
  • _setDeliveryMetricsExportedToBigQueryEnabled(..., true): call startLoggingService so the flush loop arms when users opt in.
  • startLoggingService: first _processQueue delay 0; _dispatchLogEvents still reschedules with LOG_INTERVAL_IN_MS (24h).

Root cause

startLoggingService had zero production call sites; only stageLog appended to logEvents, so Firelog fetch never ran.

b/503660323

@zwu52 zwu52 requested a review from a team as a code owner May 4, 2026 17:13
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 4, 2026

🦋 Changeset detected

Latest commit: a2c5f8b

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@firebase/messaging Patch
firebase Patch
@firebase/messaging-compat Patch

Not sure what this means? Click here to learn what changesets are.

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

Copy link
Copy Markdown
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 updates the messaging service to initiate the logging service immediately upon enabling delivery metrics or staging a log, while also reducing the initial flush delay to zero. Feedback highlights a logic issue where starting the service with an empty queue could cause a 24-hour delay for subsequent events. Additionally, there is a risk of data loss during asynchronous log dispatching and a recommendation to clear the log queue when metrics export is disabled to ensure data privacy and memory efficiency.

Comment thread packages/messaging/src/helpers/logToFirelog.ts Outdated
Comment thread packages/messaging/src/helpers/logToFirelog.ts
@zwu52 zwu52 requested review from a team as code owners May 4, 2026 17:18
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

Changeset File Check ✅

  • No modified packages are missing from the changeset file.
  • No changeset formatting errors detected.

@zwu52 zwu52 requested review from Doris-Ge and hsubox76 May 4, 2026 17:27
Doris-Ge

This comment was marked as outdated.

@zwu52 zwu52 requested a review from Doris-Ge May 5, 2026 17:05
Comment thread packages/messaging/src/helpers/logToFirelog.ts
Comment thread packages/messaging/src/helpers/logToFirelog.ts
Copy link
Copy Markdown

@Doris-Ge Doris-Ge left a comment

Choose a reason for hiding this comment

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

Is there any integration unit test we can add? For example, in the test, we set deliveryMetricsExportedToBigQueryEnabled to true, and then trigger onPush to verify that the logs are sent to FireLog. This test would help us catch the original bug that startLoggingService was not called anywhere.

@zwu52
Copy link
Copy Markdown
Member Author

zwu52 commented May 6, 2026

Is there any integration unit test we can add? For example, in the test, we set deliveryMetricsExportedToBigQueryEnabled to true, and then trigger onPush to verify that the logs are sent to FireLog. This test would help us catch the original bug that startLoggingService was not called anywhere.

added on in the sw test.

@zwu52 zwu52 requested a review from Doris-Ge May 6, 2026 20:46
Copy link
Copy Markdown

@Doris-Ge Doris-Ge left a comment

Choose a reason for hiding this comment

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

I can't find a way to mark a resolved comment as unresolved. But in case you didn't see it, I posted another comment under this thread:
#9916 (comment)

@Doris-Ge
Copy link
Copy Markdown

Doris-Ge commented May 6, 2026

I can't find a way to mark a resolved comment as unresolved. But in case you didn't see it, I posted another comment under this thread: #9916 (comment)

Looks like the link does not work as I expected. I meant this https://screenshot.googleplex.com/8au9ubxMhUaaAvg

Critique is definitely much better...

@zwu52
Copy link
Copy Markdown
Member Author

zwu52 commented May 6, 2026

I can't find a way to mark a resolved comment as unresolved. But in case you didn't see it, I posted another comment under this thread: #9916 (comment)

Looks like the link does not work as I expected. I meant this https://screenshot.googleplex.com/8au9ubxMhUaaAvg

Critique is definitely much better...

agreed. good catch. forgot to paste it after polishing with ai. added in the sw listener file where it is most approparte as the entrance point for looging

@zwu52 zwu52 requested a review from Doris-Ge May 6, 2026 22:54
Copy link
Copy Markdown
Contributor

@hsubox76 hsubox76 left a comment

Choose a reason for hiding this comment

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

LG - is there a reported Github issue we can link users to in the release notes, to show what problem has been fixed, or was the bug discovered elsewhere?

@zwu52 zwu52 merged commit a1a2455 into main May 10, 2026
34 checks passed
@zwu52 zwu52 deleted the debug-bq branch May 10, 2026 16:17
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