Merge pull request #516 from omnivore-app/fix/non-user-events

Move the analytics event for link_read out of the container, supply userId
This commit is contained in:
Jackson Harper 2022-04-29 14:51:13 -07:00 committed by GitHub
commit 834afe7877
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 8 deletions

View file

@ -79,14 +79,6 @@ export function ArticleContainer(props: ArticleContainerProps): JSX.Element {
}
})
useEffect(() => {
window.analytics?.track('link_read', {
link: props.article.id,
slug: props.article.slug,
url: props.article.originalArticleUrl,
})
}, [props.article])
const styles = {
fontSize,
margin: props.margin ?? 360,

View file

@ -107,6 +107,17 @@ export default function Home(): JSX.Element {
})
)
useEffect(() => {
if (article && viewerData?.me) {
window.analytics?.track('link_read', {
link: article.id,
slug: article.slug,
url: article.originalArticleUrl,
userId: viewerData.me.id
})
}
}, [article, viewerData])
return (
<PrimaryLayout
pageTestId="home-page-tag"