Skip to content

Commit

Permalink
fix(app): add robot serial number to BuildrootAnalyticsData (#15000)
Browse files Browse the repository at this point in the history
* fix(app): add robot serial number to BuildrootAnalyticsData
  • Loading branch information
koji authored Apr 25, 2024
1 parent f6099c4 commit ee6e9fe
Show file tree
Hide file tree
Showing 16 changed files with 77 additions and 76 deletions.
1 change: 0 additions & 1 deletion .eslintcache

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { useRunControls } from '../../organisms/RunTimeControl/hooks'
import {
useTrackEvent,
ANALYTICS_PROTOCOL_PROCEED_TO_RUN,
ANALYTICS_PROTOCOL_RUN_AGAIN,
ANALYTICS_PROTOCOL_RUN_ACTION,
} from '../../redux/analytics'
import { getRobotUpdateDisplayInfo } from '../../redux/robot-update'
import { useDownloadRunLog, useTrackProtocolRunEvent, useRobot } from './hooks'
Expand Down Expand Up @@ -150,7 +150,7 @@ function MenuDropdown(props: MenuDropdownProps): JSX.Element {
robotSerialNumber,
},
})
trackProtocolRunEvent({ name: ANALYTICS_PROTOCOL_RUN_AGAIN })
trackProtocolRunEvent({ name: ANALYTICS_PROTOCOL_RUN_ACTION.AGAIN })
}

const handleDeleteClick: React.MouseEventHandler<HTMLButtonElement> = e => {
Expand Down
18 changes: 7 additions & 11 deletions app/src/organisms/Devices/ProtocolRun/ProtocolRunHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@ import { Banner } from '../../../atoms/Banner'
import {
useTrackEvent,
ANALYTICS_PROTOCOL_PROCEED_TO_RUN,
ANALYTICS_PROTOCOL_RUN_AGAIN,
ANALYTICS_PROTOCOL_RUN_FINISH,
ANALYTICS_PROTOCOL_RUN_PAUSE,
ANALYTICS_PROTOCOL_RUN_START,
ANALYTICS_PROTOCOL_RUN_RESUME,
ANALYTICS_PROTOCOL_RUN_ACTION,
} from '../../../redux/analytics'
import { getIsHeaterShakerAttached } from '../../../redux/config'
import { Tooltip } from '../../../atoms/Tooltip'
Expand Down Expand Up @@ -252,7 +248,7 @@ export function ProtocolRunHeader({
// After a user-initiated stopped run, close the run current run automatically.
if (runStatus === RUN_STATUS_STOPPED && isRunCurrent && runId != null) {
trackProtocolRunEvent({
name: ANALYTICS_PROTOCOL_RUN_FINISH,
name: ANALYTICS_PROTOCOL_RUN_ACTION.FINISH,
properties: {
...robotAnalyticsData,
},
Expand Down Expand Up @@ -301,7 +297,7 @@ export function ProtocolRunHeader({

const handleClearClick = (): void => {
trackProtocolRunEvent({
name: ANALYTICS_PROTOCOL_RUN_FINISH,
name: ANALYTICS_PROTOCOL_RUN_ACTION.FINISH,
properties: robotAnalyticsData ?? undefined,
})
closeCurrentRun()
Expand Down Expand Up @@ -701,7 +697,7 @@ function ActionButton(props: ActionButtonProps): JSX.Element {
buttonText = t('pause_run')
handleButtonClick = (): void => {
pause()
trackProtocolRunEvent({ name: ANALYTICS_PROTOCOL_RUN_PAUSE })
trackProtocolRunEvent({ name: ANALYTICS_PROTOCOL_RUN_ACTION.PAUSE })
}
} else if (runStatus === RUN_STATUS_STOP_REQUESTED) {
buttonIconName = 'ot-spinner'
Expand All @@ -725,8 +721,8 @@ function ActionButton(props: ActionButtonProps): JSX.Element {
trackProtocolRunEvent({
name:
runStatus === RUN_STATUS_IDLE
? ANALYTICS_PROTOCOL_RUN_START
: ANALYTICS_PROTOCOL_RUN_RESUME,
? ANALYTICS_PROTOCOL_RUN_ACTION.START
: ANALYTICS_PROTOCOL_RUN_ACTION.RESUME,
properties:
runStatus === RUN_STATUS_IDLE && robotAnalyticsData != null
? robotAnalyticsData
Expand All @@ -744,7 +740,7 @@ function ActionButton(props: ActionButtonProps): JSX.Element {
properties: { sourceLocation: 'RunRecordDetail', robotSerialNumber },
})
trackProtocolRunEvent({
name: ANALYTICS_PROTOCOL_RUN_AGAIN,
name: ANALYTICS_PROTOCOL_RUN_ACTION.AGAIN,
})
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ import { mockHeaterShaker } from '../../../../redux/modules/__fixtures__'
import {
useTrackEvent,
ANALYTICS_PROTOCOL_PROCEED_TO_RUN,
ANALYTICS_PROTOCOL_RUN_AGAIN,
ANALYTICS_PROTOCOL_RUN_FINISH,
ANALYTICS_PROTOCOL_RUN_PAUSE,
ANALYTICS_PROTOCOL_RUN_START,
ANALYTICS_PROTOCOL_RUN_RESUME,
ANALYTICS_PROTOCOL_RUN_ACTION,
} from '../../../../redux/analytics'
import { mockConnectableRobot } from '../../../../redux/discovery/__fixtures__'
import { getRobotUpdateDisplayInfo } from '../../../../redux/robot-update'
Expand Down Expand Up @@ -427,7 +423,7 @@ describe('ProtocolRunHeader', () => {
fireEvent.click(button)
expect(mockTrackProtocolRunEvent).toBeCalledTimes(1)
expect(mockTrackProtocolRunEvent).toBeCalledWith({
name: ANALYTICS_PROTOCOL_RUN_START,
name: ANALYTICS_PROTOCOL_RUN_ACTION.START,
properties: {},
})
})
Expand All @@ -445,7 +441,7 @@ describe('ProtocolRunHeader', () => {
expect(mockCloseCurrentRun).toBeCalled()
expect(mockTrackProtocolRunEvent).toBeCalled()
expect(mockTrackProtocolRunEvent).toBeCalledWith({
name: ANALYTICS_PROTOCOL_RUN_FINISH,
name: ANALYTICS_PROTOCOL_RUN_ACTION.FINISH,
properties: {},
})
})
Expand Down Expand Up @@ -526,7 +522,7 @@ describe('ProtocolRunHeader', () => {
screen.getByText('Protocol end')
fireEvent.click(button)
expect(mockTrackProtocolRunEvent).toBeCalledWith({
name: ANALYTICS_PROTOCOL_RUN_PAUSE,
name: ANALYTICS_PROTOCOL_RUN_ACTION.PAUSE,
})
})

Expand Down Expand Up @@ -564,7 +560,7 @@ describe('ProtocolRunHeader', () => {
screen.getByText('Paused')
fireEvent.click(button)
expect(mockTrackProtocolRunEvent).toBeCalledWith({
name: ANALYTICS_PROTOCOL_RUN_RESUME,
name: ANALYTICS_PROTOCOL_RUN_ACTION.RESUME,
properties: {},
})
})
Expand Down Expand Up @@ -649,7 +645,7 @@ describe('ProtocolRunHeader', () => {
screen.getByText(formatTimestamp(COMPLETED_AT))
fireEvent.click(button)
expect(mockTrackProtocolRunEvent).toBeCalledWith({
name: ANALYTICS_PROTOCOL_RUN_AGAIN,
name: ANALYTICS_PROTOCOL_RUN_ACTION.AGAIN,
})
})

Expand All @@ -676,7 +672,7 @@ describe('ProtocolRunHeader', () => {
screen.getByText(formatTimestamp(COMPLETED_AT))
fireEvent.click(button)
expect(mockTrackProtocolRunEvent).toBeCalledWith({
name: ANALYTICS_PROTOCOL_RUN_AGAIN,
name: ANALYTICS_PROTOCOL_RUN_ACTION.AGAIN,
})
})

Expand Down Expand Up @@ -710,7 +706,7 @@ describe('ProtocolRunHeader', () => {
},
})
expect(mockTrackProtocolRunEvent).toBeCalledWith({
name: ANALYTICS_PROTOCOL_RUN_AGAIN,
name: ANALYTICS_PROTOCOL_RUN_ACTION.AGAIN,
})
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { useTrackProtocolRunEvent } from '../useTrackProtocolRunEvent'
import { useProtocolRunAnalyticsData } from '../useProtocolRunAnalyticsData'
import {
useTrackEvent,
ANALYTICS_PROTOCOL_RUN_START,
ANALYTICS_PROTOCOL_RUN_ACTION,
} from '../../../../redux/analytics'
import { mockConnectableRobot } from '../../../../redux/discovery/__fixtures__'
import { useRobot } from '../useRobot'
Expand Down Expand Up @@ -85,12 +85,12 @@ describe('useTrackProtocolRunEvent hook', () => {
)
await waitFor(() =>
result.current.trackProtocolRunEvent({
name: ANALYTICS_PROTOCOL_RUN_START,
name: ANALYTICS_PROTOCOL_RUN_ACTION.START,
properties: {},
})
)
expect(mockTrackEvent).toHaveBeenCalledWith({
name: ANALYTICS_PROTOCOL_RUN_START,
name: ANALYTICS_PROTOCOL_RUN_ACTION.START,
properties: PROTOCOL_PROPERTIES,
})
})
Expand All @@ -112,12 +112,12 @@ describe('useTrackProtocolRunEvent hook', () => {
)
await waitFor(() =>
result.current.trackProtocolRunEvent({
name: ANALYTICS_PROTOCOL_RUN_START,
name: ANALYTICS_PROTOCOL_RUN_ACTION.START,
properties: {},
})
)
expect(mockTrackEvent).toHaveBeenCalledWith({
name: ANALYTICS_PROTOCOL_RUN_START,
name: ANALYTICS_PROTOCOL_RUN_ACTION.START,
properties: {},
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { SmallButton } from '../../../atoms/buttons'
import { Modal } from '../../../molecules/Modal'
import { useTrackProtocolRunEvent } from '../../../organisms/Devices/hooks'
import { useRunStatus } from '../../../organisms/RunTimeControl/hooks'
import { ANALYTICS_PROTOCOL_RUN_CANCEL } from '../../../redux/analytics'
import { ANALYTICS_PROTOCOL_RUN_ACTION } from '../../../redux/analytics'
import { getLocalRobot } from '../../../redux/discovery'
import { CancelingRunModal } from './CancelingRunModal'

Expand Down Expand Up @@ -71,7 +71,7 @@ export function ConfirmCancelRunModal({

React.useEffect(() => {
if (runStatus === RUN_STATUS_STOPPED) {
trackProtocolRunEvent({ name: ANALYTICS_PROTOCOL_RUN_CANCEL })
trackProtocolRunEvent({ name: ANALYTICS_PROTOCOL_RUN_ACTION.CANCEL })
dismissCurrentRun(runId)
if (!isActiveRun) {
if (protocolId != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@ import { CommandText } from '../../CommandText'
import { RunTimer } from '../../Devices/ProtocolRun/RunTimer'
import { PlayPauseButton } from './PlayPauseButton'
import { StopButton } from './StopButton'
import {
ANALYTICS_PROTOCOL_RUN_START,
ANALYTICS_PROTOCOL_RUN_RESUME,
ANALYTICS_PROTOCOL_RUN_PAUSE,
} from '../../../redux/analytics'
import { ANALYTICS_PROTOCOL_RUN_ACTION } from '../../../redux/analytics'

import type {
CompletedProtocolAnalysis,
Expand Down Expand Up @@ -168,14 +164,14 @@ export function CurrentRunningProtocolCommand({
const onTogglePlayPause = (): void => {
if (runStatus === RUN_STATUS_RUNNING) {
pauseRun()
trackProtocolRunEvent({ name: ANALYTICS_PROTOCOL_RUN_PAUSE })
trackProtocolRunEvent({ name: ANALYTICS_PROTOCOL_RUN_ACTION.PAUSE })
} else {
playRun()
trackProtocolRunEvent({
name:
runStatus === RUN_STATUS_IDLE
? ANALYTICS_PROTOCOL_RUN_START
: ANALYTICS_PROTOCOL_RUN_RESUME,
? ANALYTICS_PROTOCOL_RUN_ACTION.START
: ANALYTICS_PROTOCOL_RUN_ACTION.RESUME,
properties:
runStatus === RUN_STATUS_IDLE && robotAnalyticsData != null
? robotAnalyticsData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,7 @@ import { CommandText } from '../../CommandText'
import { CommandIcon } from '../../RunPreview/CommandIcon'
import { PlayPauseButton } from './PlayPauseButton'
import { StopButton } from './StopButton'
import {
ANALYTICS_PROTOCOL_RUN_START,
ANALYTICS_PROTOCOL_RUN_RESUME,
ANALYTICS_PROTOCOL_RUN_PAUSE,
} from '../../../redux/analytics'
import { ANALYTICS_PROTOCOL_RUN_ACTION } from '../../../redux/analytics'

import type {
CompletedProtocolAnalysis,
Expand Down Expand Up @@ -119,14 +115,14 @@ export function RunningProtocolCommandList({
const onTogglePlayPause = (): void => {
if (runStatus === RUN_STATUS_RUNNING) {
pauseRun()
trackProtocolRunEvent({ name: ANALYTICS_PROTOCOL_RUN_PAUSE })
trackProtocolRunEvent({ name: ANALYTICS_PROTOCOL_RUN_ACTION.PAUSE })
} else {
playRun()
trackProtocolRunEvent({
name:
runStatus === RUN_STATUS_IDLE
? ANALYTICS_PROTOCOL_RUN_START
: ANALYTICS_PROTOCOL_RUN_RESUME,
? ANALYTICS_PROTOCOL_RUN_ACTION.START
: ANALYTICS_PROTOCOL_RUN_ACTION.RESUME,
properties:
runStatus === RUN_STATUS_IDLE && robotAnalyticsData != null
? robotAnalyticsData
Expand Down
4 changes: 2 additions & 2 deletions app/src/organisms/RunDetails/ConfirmCancelModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { getModalPortalEl } from '../../App/portal'
import { LegacyModal } from '../../molecules/LegacyModal'
import { useTrackProtocolRunEvent, useIsFlex } from '../Devices/hooks'
import { useRunStatus } from '../RunTimeControl/hooks'
import { ANALYTICS_PROTOCOL_RUN_CANCEL } from '../../redux/analytics'
import { ANALYTICS_PROTOCOL_RUN_ACTION } from '../../redux/analytics'

export interface ConfirmCancelModalProps {
onClose: () => unknown
Expand Down Expand Up @@ -53,7 +53,7 @@ export function ConfirmCancelModal(
setIsCanceling(true)
stopRun(runId, {
onSuccess: () => {
trackProtocolRunEvent({ name: ANALYTICS_PROTOCOL_RUN_CANCEL })
trackProtocolRunEvent({ name: ANALYTICS_PROTOCOL_RUN_ACTION.CANCEL })
},
onError: () => {
setIsCanceling(false)
Expand Down
4 changes: 2 additions & 2 deletions app/src/pages/ProtocolSetup/__tests__/ProtocolSetup.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
useTrackProtocolRunEvent,
} from '../../../organisms/Devices/hooks'
import { getLocalRobot } from '../../../redux/discovery'
import { ANALYTICS_PROTOCOL_RUN_START } from '../../../redux/analytics'
import { ANALYTICS_PROTOCOL_RUN_ACTION } from '../../../redux/analytics'
import { ProtocolSetupLiquids } from '../../../organisms/ProtocolSetupLiquids'
import { getProtocolModulesInfo } from '../../../organisms/Devices/ProtocolRun/utils/getProtocolModulesInfo'
import { ProtocolSetupModulesAndDeck } from '../../../organisms/ProtocolSetupModulesAndDeck'
Expand Down Expand Up @@ -419,7 +419,7 @@ describe('ProtocolSetup', () => {
fireEvent.click(screen.getByRole('button', { name: 'play' }))
expect(mockTrackProtocolRunEvent).toBeCalledTimes(1)
expect(mockTrackProtocolRunEvent).toHaveBeenCalledWith({
name: ANALYTICS_PROTOCOL_RUN_START,
name: ANALYTICS_PROTOCOL_RUN_ACTION.START,
properties: {},
})
})
Expand Down
4 changes: 2 additions & 2 deletions app/src/pages/ProtocolSetup/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ import { getLabwareSetupItemGroups } from '../Protocols/utils'
import { getLocalRobot, getRobotSerialNumber } from '../../redux/discovery'
import {
ANALYTICS_PROTOCOL_PROCEED_TO_RUN,
ANALYTICS_PROTOCOL_RUN_START,
ANALYTICS_PROTOCOL_RUN_ACTION,
useTrackEvent,
} from '../../redux/analytics'
import { getIsHeaterShakerAttached } from '../../redux/config'
Expand Down Expand Up @@ -492,7 +492,7 @@ function PrepareToRun({
if (isReadyToRun) {
play()
trackProtocolRunEvent({
name: ANALYTICS_PROTOCOL_RUN_START,
name: ANALYTICS_PROTOCOL_RUN_ACTION.START,
properties: robotAnalyticsData != null ? robotAnalyticsData : {},
})
} else {
Expand Down
8 changes: 3 additions & 5 deletions app/src/pages/RunSummary/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ import { EMPTY_TIMESTAMP } from '../../organisms/Devices/constants'
import { RunTimer } from '../../organisms/Devices/ProtocolRun/RunTimer'
import {
useTrackEvent,
// ANALYTICS_PROTOCOL_RUN_CANCEL,
ANALYTICS_PROTOCOL_RUN_AGAIN,
ANALYTICS_PROTOCOL_RUN_FINISH,
ANALYTICS_PROTOCOL_RUN_ACTION,
ANALYTICS_PROTOCOL_PROCEED_TO_RUN,
} from '../../redux/analytics'
import { getLocalRobot } from '../../redux/discovery'
Expand Down Expand Up @@ -175,7 +173,7 @@ export function RunSummary(): JSX.Element {
name: ANALYTICS_PROTOCOL_PROCEED_TO_RUN,
properties: { sourceLocation: 'RunSummary', robotSerialNumber },
})
trackProtocolRunEvent({ name: ANALYTICS_PROTOCOL_RUN_AGAIN })
trackProtocolRunEvent({ name: ANALYTICS_PROTOCOL_RUN_ACTION.AGAIN })
}
}
}
Expand All @@ -186,7 +184,7 @@ export function RunSummary(): JSX.Element {

const handleClickSplash = (): void => {
trackProtocolRunEvent({
name: ANALYTICS_PROTOCOL_RUN_FINISH,
name: ANALYTICS_PROTOCOL_RUN_ACTION.FINISH,
properties: robotAnalyticsData ?? undefined,
})
setShowSplash(false)
Expand Down
Loading

0 comments on commit ee6e9fe

Please sign in to comment.