Skip to content

Commit

Permalink
feat: track add to calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
ncomerci committed Sep 8, 2023
1 parent 6396428 commit 922e830
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/components/Modal/CalendarAlertModal.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React, { useEffect, useMemo, useState } from 'react'

import { UnitTypeLongPlural } from 'dayjs'
import useTrackContext from 'decentraland-gatsby/dist/context/Track/useTrackContext'
import { Button } from 'decentraland-ui/dist/components/Button/Button'
import { Close } from 'decentraland-ui/dist/components/Close/Close'
import { Header } from 'decentraland-ui/dist/components/Header/Header'
import { Modal, ModalProps } from 'decentraland-ui/dist/components/Modal/Modal'

import { SegmentEvent } from '../../entities/Events/types'
import { ProposalAttributes } from '../../entities/Proposal/types'
import { proposalUrl } from '../../entities/Proposal/utils'
import useFormatMessage from '../../hooks/useFormatMessage'
Expand Down Expand Up @@ -38,6 +40,9 @@ function CalendarAlertModal({ proposal, onClose, ...props }: CalendarAlertModalP
const [timeValue, setTimeValue] = useState(0)
const [unit, setUnit] = useState<UnitTypeLongPlural | undefined>()
const [isDisabled, setIsDisabled] = useState(false)
const track = useTrackContext()

const trackAddToCalendar = () => track(SegmentEvent.ActionPerformed, { type: 'add to calendar' })

const handleClose = () => {
onClose()
Expand Down Expand Up @@ -81,7 +86,15 @@ function CalendarAlertModal({ proposal, onClose, ...props }: CalendarAlertModalP
/>
</div>
<div className="ProposalModal__Actions">
<Button fluid primary disabled={isDisabled} as="a" href={alertUrl} target="_blank">
<Button
fluid
primary
disabled={isDisabled}
as="a"
href={alertUrl}
target="_blank"
onClick={trackAddToCalendar}
>
{t('modal.calendar_alert.add_to_calendar')}
</Button>
<Button className="CalendarAlertModal__CancelButton" fluid basic onClick={handleClose}>
Expand Down
1 change: 1 addition & 0 deletions src/entities/Events/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export enum SegmentEvent {
ModalViewed = 'Modal Viewed',
IdentityStarted = 'Identity Started',
IdentityCompleted = 'Identity Completed',
ActionPerformed = 'Action Performed',
}

0 comments on commit 922e830

Please sign in to comment.