React Native Firebase Analytics window.document.getElementsByTagName Problem

I want to connect firebase analytics to my react native project, but when I write this code in my app,

import {initializeApp} from 'firebase/app'
import {getAnalytics} from 'firebase/analytics';

const firebaseConfig = {

.
.
.

};

const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);

i am facing this error in my terminal

Possible Unhandled Promise Rejection (id: 0): TypeError: undefined is
not an object (evaluating ‘window.document.getElementsByTagName’)