Skip to content

Conversation

@kevmo314
Copy link
Collaborator

Summary

  • Fixed Firebase Analytics warning that appears when using the package in Node.js environments
  • Analytics now checks if the environment supports it before initialization

Changes

  • Added isSupported() check from Firebase Analytics to detect environment compatibility
  • Created safeLogEvent() helper function that gracefully handles analytics in all environments
  • Analytics initialization is now deferred and cached to avoid repeated checks

Test plan

  • Node.js import works without analytics warning
  • Browser environment still receives analytics events
  • Package builds successfully with existing Rollup configuration

Fixes the warning:

@firebase/analytics: Analytics: Firebase Analytics is not supported in this environment. 
Wrap initialization of analytics in analytics.isSupported() to prevent initialization in unsupported environments.

🤖 Generated with Claude Code

@kevmo314 kevmo314 force-pushed the fix/firebase-analytics-warning branch from bc303b9 to edc1ab1 Compare August 15, 2025 14:27
@github-actions
Copy link

github-actions bot commented Aug 15, 2025

Visit the preview URL for this PR (updated for commit 2a92868):

(expires Fri, 22 Aug 2025 14:37:33 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 97736d8937dc1c35fa9cd85e09c8e5539fc44d09

@kevmo314 kevmo314 force-pushed the fix/firebase-analytics-warning branch from edc1ab1 to 370c248 Compare August 15, 2025 14:28
…warnings

- Add isSupported() check before initializing Firebase Analytics
- Create safeLogEvent helper that handles analytics gracefully in all environments
- Prevents "Analytics not supported in this environment" warnings in Node.js

This allows the package to work seamlessly in both browser and Node.js
environments without throwing analytics-related warnings.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
@kevmo314 kevmo314 force-pushed the fix/firebase-analytics-warning branch from 370c248 to 30056ee Compare August 15, 2025 14:29
@kevmo314 kevmo314 merged commit 8c7f87c into main Aug 15, 2025
2 checks passed
@kevmo314 kevmo314 deleted the fix/firebase-analytics-warning branch August 15, 2025 14:51
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