From 28ade2f3e5f40bd24187b8c575afaa389889c62e Mon Sep 17 00:00:00 2001 From: Joe Karow <58997957+JoeKarow@users.noreply.github.com> Date: Wed, 11 Oct 2023 19:07:19 -0400 Subject: [PATCH] add ga events --- packages/analytics/events/index.ts | 8 ++++++++ packages/ui/components/core/Donate/index.tsx | 2 ++ packages/ui/modals/Login.tsx | 4 ++-- packages/ui/modals/SignUp/index.tsx | 4 +++- 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/packages/analytics/events/index.ts b/packages/analytics/events/index.ts index 6c7de64d9a..333f3b72e6 100644 --- a/packages/analytics/events/index.ts +++ b/packages/analytics/events/index.ts @@ -42,3 +42,11 @@ export const serviceModalEvent = { opened: ({ serviceId, serviceName, orgSlug }: ServiceModalOpenedAction) => event('select_content', { content_type: 'orgService', content_id: serviceId, serviceName, orgSlug }), } + +export const donateEvent = { + click: () => event('select_content', { content_type: 'donation_button' }), +} +export const userEvent = { + signup: (userType?: string) => event('sign_up', { userType }), + login: () => event('login'), +} diff --git a/packages/ui/components/core/Donate/index.tsx b/packages/ui/components/core/Donate/index.tsx index 574f6ffa19..a3b77eae24 100644 --- a/packages/ui/components/core/Donate/index.tsx +++ b/packages/ui/components/core/Donate/index.tsx @@ -5,6 +5,7 @@ import Script from 'next/script' import { useTranslation } from 'next-i18next' import { type ReactElement, useEffect, useState } from 'react' +import { donateEvent } from '@weareinreach/analytics/events' import { Button } from '~ui/components/core/Button' import { Link } from '~ui/components/core/Link' import { useCustomVariant } from '~ui/hooks/useCustomVariant' @@ -52,6 +53,7 @@ export const DonateModal = ({ children }: DonateModalProps) => { const buttonPosition = isMobile ? { bottom: rem(100), right: rem(12) } : { bottom: rem(40), right: rem(40) } const buttonHandler = () => { + donateEvent.click() if (isMobile) { if (!showEmoji || opened) { handler.close() diff --git a/packages/ui/modals/Login.tsx b/packages/ui/modals/Login.tsx index 22c6e1896f..cbad80d140 100644 --- a/packages/ui/modals/Login.tsx +++ b/packages/ui/modals/Login.tsx @@ -1,4 +1,3 @@ -/* eslint-disable react/no-unescaped-entities */ import { Box, type ButtonProps, @@ -19,6 +18,7 @@ import { type Route } from 'nextjs-routes' import { forwardRef, useState } from 'react' import { z } from 'zod' +import { userEvent } from '@weareinreach/analytics/events' import { Button } from '~ui/components/core/Button' import { Link } from '~ui/components/core/Link' import { useCustomVariant, useScreenSize, useShake } from '~ui/hooks' @@ -66,6 +66,7 @@ export const LoginBody = forwardRef( } } if (result?.ok) { + userEvent.login() if (modalHandler) { modalHandler.close() } else if (callbackUrl) { @@ -92,7 +93,6 @@ export const LoginBody = forwardRef( {...form.getInputProps('password')} />