Skip to content

Commit

Permalink
Add event
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorus-nathaniel committed Mar 7, 2024
1 parent cce6754 commit 3b1407a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 7 deletions.
7 changes: 6 additions & 1 deletion src/components/auth/AuthorizationPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Button } from 'antd'
import { useSendEvent } from 'src/providers/AnalyticContext'
import { getCurrentUrlOrigin } from 'src/utils/url'
import urlJoin from 'src/utils/url-join'
import { NotificationsBell, useNotifCounterContext } from '../activity/NotifCounter'
Expand All @@ -15,6 +16,7 @@ function getCurrentPathanme() {
export const AuthorizationPanel = () => {
const address = useMyAddress()
const { unreadCount } = useNotifCounterContext()
const sendEvent = useSendEvent()

return (
<>
Expand All @@ -25,7 +27,10 @@ export const AuthorizationPanel = () => {
<MyAccountPopup className='profileName' />
</>
) : (
<a href={urlJoin('/c/widget/login', `?from=${getCurrentPathanme()}`)}>
<a
href={urlJoin('/c/widget/login', `?from=${getCurrentPathanme()}`)}
onClick={() => sendEvent('login_button_clicked', { eventSource: 'polkaverse-ui-navbar' })}
>
<Button type='default'>Sign in</Button>
</a>
)}
Expand Down
21 changes: 16 additions & 5 deletions src/components/auth/NotAuthorized.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import { Button } from 'antd'
import { useSendEvent } from 'src/providers/AnalyticContext'
import { redirectToLogin } from 'src/utils/url'
import NoData from '../utils/EmptyList'

export const NotAuthorized = () => (
<NoData description='Only signed in users can access this page'>
<Button onClick={() => redirectToLogin()}>Sign in</Button>
</NoData>
)
export const NotAuthorized = () => {
const sendEvent = useSendEvent()
return (
<NoData description='Only signed in users can access this page'>
<Button
onClick={() => {
redirectToLogin()
sendEvent('login_button_clicked', { eventSource: 'polkaverse-ui-not-authorized' })
}}
>
Sign in
</Button>
</NoData>
)
}

export default NotAuthorized
11 changes: 10 additions & 1 deletion src/components/posts/share/SharePostLink.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { EditOutlined } from '@ant-design/icons'
import React, { useState } from 'react'
import { useSendEvent } from 'src/providers/AnalyticContext'
import { PostWithSomeDetails } from 'src/types'
import { redirectToLogin } from 'src/utils/url'
import { useAuth } from '../../auth/AuthContext'
Expand Down Expand Up @@ -30,12 +31,20 @@ export const SharePostLink = ({
const [open, setOpen] = useState<boolean>()
const postId = isSharedPost ? ext && ext.post.struct.id : id
const title = 'Write a post'
const sendEvent = useSendEvent()

return (
<>
<a
className='DfBlackLink'
onClick={() => (isSignedIn ? setOpen(true) : redirectToLogin())}
onClick={() => {
if (isSignedIn) {
setOpen(true)
} else {
redirectToLogin()
sendEvent('login_button_clicked', { eventSource: 'polkaverse-ui-share-post' })
}
}}
title={title}
>
<IconWithLabel icon={EditIcon} label={title} />
Expand Down
1 change: 1 addition & 0 deletions src/components/voting/SuperLike.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export default function SuperLike({ post, iconClassName, isComment, ...props }:
if (isActive || isDisabled) return

if (!myAddress || !myGrillAddress) {
sendEvent('login_button_clicked', { eventSource: 'polkaverse-ui-super-like' })
redirectToLogin()
return
}
Expand Down

0 comments on commit 3b1407a

Please sign in to comment.