debug: more pres logs for slug tab.tsx
This commit is contained in:
parent
c26f960d9b
commit
996153bbc2
|
@ -95,55 +95,59 @@ export default function ArticlePage(props: RouteSectionProps<SlugPageProps>) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function InnerArticlePage(props: RouteSectionProps<ArticlePageProps>) {
|
function InnerArticlePage(props: RouteSectionProps<ArticlePageProps>) {
|
||||||
const loc = useLocation()
|
const loc = useLocation();
|
||||||
const { t } = useLocalize()
|
const { t } = useLocalize();
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
|
|
||||||
|
console.debug('Initial slug from useParams:', params.slug);
|
||||||
|
|
||||||
const data = createAsync(async () => {
|
const data = createAsync(async () => {
|
||||||
console.debug('Fetching article with slug (createAsync):', params.slug)
|
console.debug('Fetching article with slug (createAsync):', params.slug);
|
||||||
const result = props.data?.article || (await fetchShout(params.slug))
|
const result = props.data?.article || (await fetchShout(params.slug));
|
||||||
console.debug('Fetched article data (createAsync):', result)
|
console.debug('Fetched article data (createAsync):', result);
|
||||||
return result
|
return result;
|
||||||
})
|
});
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
|
console.debug('onMount triggered');
|
||||||
if (gaIdentity && data()?.id) {
|
if (gaIdentity && data()?.id) {
|
||||||
try {
|
try {
|
||||||
await loadGAScript(gaIdentity)
|
console.debug('Loading GA script');
|
||||||
initGA(gaIdentity)
|
await loadGAScript(gaIdentity);
|
||||||
|
initGA(gaIdentity);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn('[routes] [slug]/[...tab] Failed to connect Google Analytics:', error)
|
console.warn('[routes] [slug]/[...tab] Failed to connect Google Analytics:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
|
|
||||||
createEffect(
|
createEffect(
|
||||||
on(
|
on(
|
||||||
() => params.slug,
|
() => params.slug,
|
||||||
async (newSlug) => {
|
async (newSlug) => {
|
||||||
console.debug('Slug changed (useParams):', newSlug)
|
console.debug('Slug changed (useParams):', newSlug);
|
||||||
const result = await fetchShout(newSlug);
|
const result = await fetchShout(newSlug);
|
||||||
console.debug('Fetched article data (useParams):', result)
|
console.debug('Fetched article data (useParams):', result);
|
||||||
data(result);
|
data(result);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
)
|
);
|
||||||
|
|
||||||
createEffect(
|
createEffect(
|
||||||
on(
|
on(
|
||||||
data,
|
data,
|
||||||
(a?: Shout) => {
|
(a?: Shout) => {
|
||||||
if (!a?.id) return
|
if (!a?.id) return;
|
||||||
console.debug('Page view event for article:', a)
|
console.debug('Page view event for article:', a);
|
||||||
window?.gtag?.('event', 'page_view', {
|
window?.gtag?.('event', 'page_view', {
|
||||||
page_title: a.title,
|
page_title: a.title,
|
||||||
page_location: window?.location.href || '',
|
page_location: window?.location.href || '',
|
||||||
page_path: loc.pathname
|
page_path: loc.pathname
|
||||||
})
|
});
|
||||||
},
|
},
|
||||||
{ defer: true }
|
{ defer: true }
|
||||||
)
|
)
|
||||||
)
|
);
|
||||||
|
|
||||||
createEffect(async () => {
|
createEffect(async () => {
|
||||||
console.debug('Data from createAsync effect:', data());
|
console.debug('Data from createAsync effect:', data());
|
||||||
|
@ -151,8 +155,8 @@ function InnerArticlePage(props: RouteSectionProps<ArticlePageProps>) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ErrorBoundary fallback={() => {
|
<ErrorBoundary fallback={() => {
|
||||||
console.error('Rendering 500 error page')
|
console.error('Rendering 500 error page');
|
||||||
return <HttpStatusCode code={500} />
|
return <HttpStatusCode code={500} />;
|
||||||
}}>
|
}}>
|
||||||
<Suspense fallback={<Loading />}>
|
<Suspense fallback={<Loading />}>
|
||||||
<Show
|
<Show
|
||||||
|
@ -181,5 +185,5 @@ function InnerArticlePage(props: RouteSectionProps<ArticlePageProps>) {
|
||||||
</Show>
|
</Show>
|
||||||
</Suspense>
|
</Suspense>
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
)
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user