mirror of
https://github.com/lucasrcsantana/story-generator.git
synced 2025-12-16 21:37:51 +00:00
fix: Retirando tracking do Rudderstack do localhost
Some checks are pending
Docker Build and Push / build (push) Waiting to run
Some checks are pending
Docker Build and Push / build (push) Waiting to run
This commit is contained in:
parent
bb85c83c5b
commit
c2bcfe1e3f
@ -2,23 +2,49 @@ import { analytics } from '../lib/analytics';
|
||||
import { UserTraits } from '../types/analytics';
|
||||
|
||||
export function useRudderstack() {
|
||||
const isDevelopment = process.env.NODE_ENV === 'development';
|
||||
const isLocalhost = typeof window !== 'undefined' &&
|
||||
(window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1');
|
||||
|
||||
const shouldTrack = !isDevelopment && !isLocalhost;
|
||||
|
||||
const track = (eventName: string, properties?: Record<string, unknown>) => {
|
||||
if (!shouldTrack) {
|
||||
console.log('Evento não rastreado em desenvolvimento:', eventName, properties);
|
||||
return;
|
||||
}
|
||||
analytics.track(eventName, properties);
|
||||
};
|
||||
|
||||
const page = (name?: string, properties?: Record<string, unknown>) => {
|
||||
if (!shouldTrack) {
|
||||
console.log('Página não rastreada em desenvolvimento:', name, properties);
|
||||
return;
|
||||
}
|
||||
analytics.page(name, properties);
|
||||
};
|
||||
|
||||
const identify = (userId: string, traits?: UserTraits) => {
|
||||
if (!shouldTrack) {
|
||||
console.log('Usuário não identificado em desenvolvimento:', userId, traits);
|
||||
return;
|
||||
}
|
||||
analytics.identify({ id: userId, user_metadata: traits } as any);
|
||||
};
|
||||
|
||||
const group = (groupId: string, traits?: Record<string, unknown>) => {
|
||||
if (!shouldTrack) {
|
||||
console.log('Grupo não rastreado em desenvolvimento:', groupId, traits);
|
||||
return;
|
||||
}
|
||||
analytics.group(groupId, traits);
|
||||
};
|
||||
|
||||
const reset = () => {
|
||||
if (!shouldTrack) {
|
||||
console.log('Reset não executado em desenvolvimento');
|
||||
return;
|
||||
}
|
||||
analytics.reset();
|
||||
};
|
||||
|
||||
@ -27,6 +53,6 @@ export function useRudderstack() {
|
||||
page,
|
||||
identify,
|
||||
group,
|
||||
reset,
|
||||
reset
|
||||
};
|
||||
}
|
||||
@ -54,6 +54,21 @@ export function StudentDashboardLayout() {
|
||||
{!isCollapsed && <span>Minhas Histórias</span>}
|
||||
</NavLink>
|
||||
|
||||
<NavLink
|
||||
to="/aluno/redacoes"
|
||||
onClick={handleNavigation}
|
||||
className={({ isActive }) =>
|
||||
`flex items-center gap-2 px-4 py-2 rounded-lg text-sm ${
|
||||
isActive
|
||||
? 'bg-purple-50 text-purple-700'
|
||||
: 'text-gray-600 hover:bg-gray-50'
|
||||
}`
|
||||
}
|
||||
>
|
||||
<PenTool className="h-5 w-5" />
|
||||
{!isCollapsed && <span>Redações</span>}
|
||||
</NavLink>
|
||||
|
||||
<NavLink
|
||||
to="/aluno/painel"
|
||||
end
|
||||
@ -70,21 +85,6 @@ export function StudentDashboardLayout() {
|
||||
{!isCollapsed && <span>Painel</span>}
|
||||
</NavLink>
|
||||
|
||||
<NavLink
|
||||
to="/aluno/redacoes"
|
||||
onClick={handleNavigation}
|
||||
className={({ isActive }) =>
|
||||
`flex items-center gap-2 px-4 py-2 rounded-lg text-sm ${
|
||||
isActive
|
||||
? 'bg-purple-50 text-purple-700'
|
||||
: 'text-gray-600 hover:bg-gray-50'
|
||||
}`
|
||||
}
|
||||
>
|
||||
<PenTool className="h-5 w-5" />
|
||||
{!isCollapsed && <span>Redações</span>}
|
||||
</NavLink>
|
||||
|
||||
{/* <NavLink
|
||||
to="/aluno/conquistas"
|
||||
onClick={handleNavigation}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user