mirror of
https://github.com/lucasrcsantana/story-generator.git
synced 2025-12-18 14:27: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';
|
import { UserTraits } from '../types/analytics';
|
||||||
|
|
||||||
export function useRudderstack() {
|
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>) => {
|
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);
|
analytics.track(eventName, properties);
|
||||||
};
|
};
|
||||||
|
|
||||||
const page = (name?: string, properties?: Record<string, unknown>) => {
|
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);
|
analytics.page(name, properties);
|
||||||
};
|
};
|
||||||
|
|
||||||
const identify = (userId: string, traits?: UserTraits) => {
|
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);
|
analytics.identify({ id: userId, user_metadata: traits } as any);
|
||||||
};
|
};
|
||||||
|
|
||||||
const group = (groupId: string, traits?: Record<string, unknown>) => {
|
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);
|
analytics.group(groupId, traits);
|
||||||
};
|
};
|
||||||
|
|
||||||
const reset = () => {
|
const reset = () => {
|
||||||
|
if (!shouldTrack) {
|
||||||
|
console.log('Reset não executado em desenvolvimento');
|
||||||
|
return;
|
||||||
|
}
|
||||||
analytics.reset();
|
analytics.reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -27,6 +53,6 @@ export function useRudderstack() {
|
|||||||
page,
|
page,
|
||||||
identify,
|
identify,
|
||||||
group,
|
group,
|
||||||
reset,
|
reset
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -54,6 +54,21 @@ export function StudentDashboardLayout() {
|
|||||||
{!isCollapsed && <span>Minhas Histórias</span>}
|
{!isCollapsed && <span>Minhas Histórias</span>}
|
||||||
</NavLink>
|
</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
|
<NavLink
|
||||||
to="/aluno/painel"
|
to="/aluno/painel"
|
||||||
end
|
end
|
||||||
@ -70,21 +85,6 @@ export function StudentDashboardLayout() {
|
|||||||
{!isCollapsed && <span>Painel</span>}
|
{!isCollapsed && <span>Painel</span>}
|
||||||
</NavLink>
|
</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
|
{/* <NavLink
|
||||||
to="/aluno/conquistas"
|
to="/aluno/conquistas"
|
||||||
onClick={handleNavigation}
|
onClick={handleNavigation}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user