From 53b6f271b98e2ce8d0b27736bc176b2c8ddb08f0 Mon Sep 17 00:00:00 2001 From: Matthew Stankiewicz Date: Fri, 3 May 2024 14:27:35 -0400 Subject: [PATCH] feat: add save organization analytics --- .../components/onc-organization/onc-organization.jsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app/components/onc-organization/onc-organization.jsx b/src/app/components/onc-organization/onc-organization.jsx index 0955d82030..9e71fed738 100755 --- a/src/app/components/onc-organization/onc-organization.jsx +++ b/src/app/components/onc-organization/onc-organization.jsx @@ -1,11 +1,13 @@ -import React, { useEffect, useState } from 'react'; +import React, { useContext, useEffect, useState } from 'react'; import { bool, func, string } from 'prop-types'; +import ReactGA from 'react-ga4'; import ChplOncOrganizationEdit from './onc-organization-edit'; import ChplOncOrganizationView from './onc-organization-view'; import { usePostAcb, usePutAcb } from 'api/acbs'; import { usePostAtl, usePutAtl } from 'api/atls'; +import { UserContext } from 'shared/contexts'; import { acb as acbPropType } from 'shared/prop-types'; function ChplOncOrganization(props) { @@ -15,6 +17,7 @@ function ChplOncOrganization(props) { orgType, isCreating, } = props; + const { hasAnyRole } = useContext(UserContext); const [isEditing, setIsEditing] = useState(false); const [isProcessing, setIsProcessing] = useState(false); const [organization, setOrganization] = useState(undefined); @@ -45,6 +48,11 @@ function ChplOncOrganization(props) { onSuccess: () => { setIsEditing(false); setIsProcessing(false); + ReactGA.event('save', { + category: 'Organizations', + label: organization.name, + group: hasAnyRole(['chpl-admin']) ? 'chpl-admin' : (hasAnyRole['chpl-onc'] ? 'chpl-onc' : 'chpl-onc-acb'), + }); dispatch('edit', ''); }, onError: (error) => {