User analytics for Google Antigravity IDE
# Analytics Implementation for Google Antigravity
Master analytics tracking in Google Antigravity IDE.
## Analytics Provider
```typescript
"use client";
import { useEffect } from "react";
import { usePathname } from "next/navigation";
export function AnalyticsProvider({ children }: { children: ReactNode }) {
const pathname = usePathname();
useEffect(() => {
if (window.analytics) {
window.analytics.page(pathname);
}
}, [pathname]);
return <>{children}</>;
}
export function useAnalytics() {
const track = (event: string, properties?: Record<string, unknown>) => {
if (window.analytics) {
window.analytics.track(event, properties);
}
};
const identify = (userId: string, traits?: Record<string, unknown>) => {
if (window.analytics) {
window.analytics.identify(userId, traits);
}
};
return { track, identify };
}
```
## Event Tracking
```typescript
function SignupForm() {
const { track } = useAnalytics();
const handleSubmit = async (data: FormData) => {
track("Signup Started", { method: "email" });
try {
await signup(data);
track("Signup Completed");
} catch (error) {
track("Signup Failed", { error: error.message });
}
};
return <form onSubmit={handleSubmit}>...</form>;
}
```
## Best Practices
1. **Consistent naming** - Use event naming conventions
2. **Respect privacy** - Honor DNT and consent
Google Antigravity IDE provides analytics scaffolding.This Analytics prompt is ideal for developers working on:
By using this prompt, you can save hours of manual coding and ensure best practices are followed from the start. It's particularly valuable for teams looking to maintain consistency across their analytics implementations.
Yes! All prompts on Antigravity AI Directory are free to use for both personal and commercial projects. No attribution required, though it's always appreciated.
This prompt works excellently with Claude, ChatGPT, Cursor, GitHub Copilot, and other modern AI coding assistants. For best results, use models with large context windows.
You can modify the prompt by adding specific requirements, constraints, or preferences. For Analytics projects, consider mentioning your framework version, coding style, and any specific libraries you're using.