Skip to content

Latest commit

 

History

History
34 lines (24 loc) · 862 Bytes

File metadata and controls

34 lines (24 loc) · 862 Bytes
title useSetCurrentScreenMutation

Set the current screen name via gtag config.

This hook wraps a deprecated Firebase API. Prefer [`useLogEventMutation`](/react/analytics/hooks/useLogEventMutation) with `eventName: "screen_view"` for new code.

Usage

import { getAnalytics } from "firebase/analytics";
import { useSetCurrentScreenMutation } from "@tanstack-query-firebase/react/analytics";

const analytics = getAnalytics(app);
const { mutate: setScreen } = useSetCurrentScreenMutation(analytics);

setScreen({ screenName: "Home" });

Recommended alternative

import { useLogEventMutation } from "@tanstack-query-firebase/react/analytics";

const { mutate: logAnalyticsEvent } = useLogEventMutation(analytics);

logAnalyticsEvent({
  eventName: "screen_view",
  eventParams: { firebase_screen: "Home" },
});