Skip to content

Integrate Firebase Analytics (PP-5196) - #206

Draft
PoorBillyPilgrim wants to merge 2 commits into
mainfrom
feature/firebase-analytics
Draft

PoorBillyPilgrim wants to merge 2 commits into
mainfrom
feature/firebase-analytics

Conversation

@PoorBillyPilgrim

Copy link
Copy Markdown
Contributor

Description

Adds the Firebase Analytics SDK for capturing usage data.

  • New Firebase Analytics helpers (firebase.ts, useFirebaseAnalytics) provide asynchronous, non-blocking utilities for loading the Firebase Analytics SDK and logging custom events.
    • On first page load, firebase.init() kicks off loading the SDK asynchronously and queues events so that the app never has to wait for the SDK to load. A shared firebaseAnalytics Promise stores the SDK at module-level and makes it available to all the methods within firebase.ts.
  • Per-library usage is captured whenever events are logged from pages that are provided library data.
    • firebase.ts keeps track of the most recently visited library and adds library.id and library.slug as default event parameters and user properties on every logged event. useFirebaseAnalytics updates the SDK with the latest library whenever library data changes. Note: Pages that are unspecific to a library, like the multi-library home page, still log events even when no specific library data is available.
  • Custom page view events are sent from userFirebaseAnalytics whenever users navigate through the app. Any potential user credentials found on login-related URLs are stripped before any page views are logged. Locale is also added as a custom parameter.
  • Feature Flags: set PALACE_CPW_FEATURE_FIREBASE_ANALYTICS=true along with a valid FIREBASE_CONFIG JSON string to track usage stats using Firebase Analytics. It is off by default. While off, no attempts are made to load the Firebase Analytics SDK. Both flags are documented in the README for the repository.

Notes

  • Google Tag Manager remains as an alternative for those who would rather use Google Analytics to collect analytics.

Motivation and Context

The mobile apps currently capture usage data using Firebase Analytics. The web catalog will now be populating the Firebase console with its own data, allowing stakeholders to compare usage data easily.

Jira PP-5196

How Has This Been Tested?

  • Manually monitored event logs with Google's official Google Analytics Debugger browser extension in Chrome
  • New tests added ensure...
    • functionality is gated behind new feature flags
    • the library identifiers are updated and sent on every event
    • events are queued and logged whenever the SDK is made available
  • Tests and checks pass locally

Checklist:

  • I have updated the documentation accordingly.
  • All new and existing tests passed.

@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 36671977937

Coverage increased (+0.4%) to 27.371%

Details

  • Coverage increased (+0.4%) from the base build.
  • Patch coverage: 5 uncovered changes across 1 file (16 of 21 lines covered, 76.19%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
src/errors.ts 5 0 0.0%
Total (4 files) 21 16 76.19%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 2437
Covered Lines: 773
Line Coverage: 31.72%
Relevant Branches: 1717
Covered Branches: 364
Branch Coverage: 21.2%
Branches in Coverage %: Yes
Coverage Strength: 9.48 hits per line

💛 - Coveralls

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.

2 participants