-
-
Notifications
You must be signed in to change notification settings - Fork 17
Description
Describe the bug
I am encountering an issue with ReactGA.initialize in my project using ROLLDOWN-VITE v7.1.19. The initialize method from ReactGA (which is the Google Analytics 4 integration library) is not working, and I am seeing the following error:
Uncaught TypeError: ReactGA.initialize is not a function at main.tsx:15:11
Steps to Reproduce:
- Install
ROLLDOWN-VITE v7.1.19. - Install and configure
react-ga4(Google Analytics 4). - Try initializing
ReactGAin yourmain.tsx(or similar entry file). - Observe that the
initializemethod does not work and causes the error mentioned above.
Expected Behavior:
ReactGA.initialize should work as expected, allowing Google Analytics 4 to be initialized and track user interactions.
Actual Behavior:
The error message Uncaught TypeError: ReactGA.initialize is not a function is thrown in the console.
Code Snippet:
import React from 'react'
import ReactDOM from 'react-dom/client'
import { Provider } from 'react-redux'
import ReactGA from 'react-ga4'
import App from './app/App'
import './index.css'
import globalStore from './configs/store'
import 'react-datepicker/dist/react-datepicker.css'
const GA_TRACKING_ID = import.meta.env.APP_GA_ID
// Initialize Google Analytics 4
if (GA_TRACKING_ID) {
ReactGA.initialize(GA_TRACKING_ID as string, {
gtagOptions: {
send_page_view: false
},
gaOptions: {
send_page_view: false
}
})
}
ReactDOM.createRoot(document.getElementById('root')!).render(
<React.StrictMode>
<Provider store={globalStore}>
<App />
</Provider>
</React.StrictMode>
)Possible Solution:
It seems that the ReactGA library may have updated its API or initialization process, and the initialize method might have been deprecated or changed. If that is the case, could the documentation or integration instructions be updated accordingly?
Environment:
- ROLLDOWN-VITE version: v7.1.19
- ReactGA version: 2.1.0
- Node.js version: v22.14.0
- Browser: Chrome
Steps to reproduce
No response
System Info
System:
OS: macOS 15.1.1
CPU: (8) arm64 Apple M1
Memory: 120.61 MB / 8.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.14.0 - /Users/dbodindin/.nvm/versions/node/v22.14.0/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 10.9.2 - /Users/dbodindin/.nvm/versions/node/v22.14.0/bin/npm
Browsers:
Chrome: 141.0.7390.108
Edge: 141.0.3537.71
Safari: 18.1.1
npmPackages:
@vitejs/plugin-react-swc: ^3.5.0 => 3.11.0
rolldown-vite: ^7.1.5 => 7.1.19
vite: ^5.0.8 => 5.4.21 Used Package Manager
npm
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs and the Rolldown-related guide.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.