Track share-modal-opened event only when the Share modal is opened (#6088)

GitOrigin-RevId: 1518b879d6b31cad578335192d5fe01f90b8a539
This commit is contained in:
Alf Eaton 2021-12-14 10:52:29 +00:00 committed by Copybot
parent 48186232bf
commit abbc0ff3f5
2 changed files with 15 additions and 5 deletions

View file

@ -11,7 +11,6 @@ import { useSplitTestContext } from '../../../shared/context/split-test-context'
import { Row } from 'react-bootstrap'
import PropTypes from 'prop-types'
import RecaptchaConditions from '../../../shared/components/recaptcha-conditions'
import * as eventTracking from '../../../infrastructure/event-tracking'
export default function ShareModalBody() {
const { isAdmin } = useShareProjectContext()
@ -19,10 +18,6 @@ export default function ShareModalBody() {
splitTestVariants: PropTypes.object,
})
eventTracking.sendMB('share-modal-opened', {
splitTestVariant: splitTestVariants['null-test-share-modal'],
})
const project = useProjectContext()
switch (splitTestVariants['project-share-modal-paywall']) {

View file

@ -8,6 +8,8 @@ import React, {
import PropTypes from 'prop-types'
import ShareProjectModalContent from './share-project-modal-content'
import { useProjectContext } from '../../../shared/context/project-context'
import { useSplitTestContext } from '../../../shared/context/split-test-context'
import { sendMB } from '../../../infrastructure/event-tracking'
const ShareProjectContext = createContext()
@ -72,6 +74,19 @@ const ShareProjectModal = React.memo(function ShareProjectModal({
const project = useProjectContext(projectShape)
const { splitTestVariants } = useSplitTestContext({
splitTestVariants: PropTypes.object,
})
// send tracking event when the modal is opened
useEffect(() => {
if (show) {
sendMB('share-modal-opened', {
splitTestVariant: splitTestVariants['null-test-share-modal'],
})
}
}, [splitTestVariants, show])
// reset error when the modal is opened
useEffect(() => {
if (show) {