Просмотр исходного кода

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

GitOrigin-RevId: 1518b879d6b31cad578335192d5fe01f90b8a539
Alf Eaton 4 лет назад
Родитель
Сommit
abbc0ff3f5

+ 0 - 5
services/web/frontend/js/features/share-project-modal/components/share-modal-body.js

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

+ 15 - 0
services/web/frontend/js/features/share-project-modal/components/share-project-modal.js

@@ -8,6 +8,8 @@ import React, {
 import PropTypes from 'prop-types'
 import PropTypes from 'prop-types'
 import ShareProjectModalContent from './share-project-modal-content'
 import ShareProjectModalContent from './share-project-modal-content'
 import { useProjectContext } from '../../../shared/context/project-context'
 import { useProjectContext } from '../../../shared/context/project-context'
+import { useSplitTestContext } from '../../../shared/context/split-test-context'
+import { sendMB } from '../../../infrastructure/event-tracking'
 
 
 const ShareProjectContext = createContext()
 const ShareProjectContext = createContext()
 
 
@@ -72,6 +74,19 @@ const ShareProjectModal = React.memo(function ShareProjectModal({
 
 
   const project = useProjectContext(projectShape)
   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
   // reset error when the modal is opened
   useEffect(() => {
   useEffect(() => {
     if (show) {
     if (show) {