Skip to content

Log events - #2397

Open
mertbagt wants to merge 14 commits into
codeforboston:mainfrom
mertbagt:logEvents
Open

mertbagt wants to merge 14 commits into
codeforboston:mainfrom
mertbagt:logEvents

Conversation

@mertbagt

@mertbagt mertbagt commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds the testimony_submitted Firebase Analytics event, logged when testimony is successfully published.

Part of Add Firebase Analytics Events #2333 (does not close it).

Changes

  • Added a trackEvent helper in firebase.ts. It reuses the existing getAnalytics() setup, so it only sends in production builds on supported browsers, and failures never affect the user's action.
  • publishTestimonyAndProceed now logs testimony_submitted after a successful publish, with parameters:
    • type: bill or ballot_question
    • target: the bill ID or ballot question ID
    • isEdit: true when republishing existing testimony, so reports can separate new testimony from edits. This goes beyond the issue; happy to remove it or count only first publishes if preferred.
  • Cosign and conference testimony drafts are skipped by a guard, to avoid logging them with the wrong type.

Follow Up PRs

  • testimony_submitted for conference committee and cosign testimony
  • the sign_up event

Known issues

One catch for testing

getAnalytics() returns null unless NODE_ENV === "production", so in yarn dev no events are sent at all. That's deliberate (it keeps dev traffic out of the real data), but it means you can't see your events locally the normal way. Two options:

  1. Quick check: temporarily add a console.log(name, params) inside trackEvent before the getAnalytics() call to confirm the right event and parameters fire at the right moments. Remove it before the PR.
  2. Real check: run a production build locally (next build then next start, or whatever the repo's equivalent scripts are) and use Firebase DebugView with the Chrome Google Analytics Debugger extension. Without the repo's NEXT_PUBLIC_FIREBASE_CONFIG set, it uses the dev config's measurement ID (G-R81R1WLMXY), so you'd need access to that dev project's console to see the events there.

I used 1st option in this PR but making this note for posterity

Testing

Verified locally with a temporary console log (since removed): new bill publish, edit and republish (isEdit: true), ballot question publish, and a forced failure (offline), where no event fired. To test ballot questions, I temporarily set the development ballot questions feature flag to true locally (reverted, not part of this PR). I did not verify delivery to Google Analytics, because analytics is disabled outside production builds. A maintainer may want to confirm in DebugView after merge. Also note that isEdit and type must be registered as custom dimensions in Google Analytics to appear in reports. (see Extra Deploy Steps)

IMdy-Ow01gCA4_webp_animated_original_aspect_ratio

Extra Deploy Steps

  • After deploy: As covered earlier, custom parameters only show up in GA reports after someone registers them under Custom Definitions, which the issue says @mvictor55 handles for the Key Events side.

@vercel

vercel Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
maple-dev Ready Ready Preview Nov 30, 2026 6:36pm UTC

Request Review

This branch was successfully deployed

1 active deployment
Preview – maple-dev — cb9b3080 Deployed Nov 30, 2026 by vercel[bot]
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.

1 participant