Skip to content

Commit

Permalink
refactor(app): remove unused analytics structures (#13893)
Browse files Browse the repository at this point in the history
  • Loading branch information
b-cooper authored Nov 9, 2023
1 parent d84b5bc commit e117a19
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 481 deletions.
11 changes: 6 additions & 5 deletions app/src/organisms/Devices/hooks/useRobotAnalyticsData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useSelector, useDispatch } from 'react-redux'
import { useRobot } from './'
import { getAttachedPipettes } from '../../../redux/pipettes'
import { getRobotSettings, fetchSettings } from '../../../redux/robot-settings'
import { FF_PREFIX } from '../../../redux/analytics'
import {
getRobotApiVersion,
getRobotFirmwareVersion,
Expand All @@ -13,6 +12,8 @@ import {
import type { State, Dispatch } from '../../../redux/types'
import type { RobotAnalyticsData } from '../../../redux/analytics/types'

const FF_PREFIX = 'robotFF_'

/**
*
* @param {string} robotName
Expand Down Expand Up @@ -45,10 +46,10 @@ export function useRobotAnalyticsData(
}),
// @ts-expect-error RobotAnalyticsData type needs boolean values should it be boolean | string
{
robotApiServerVersion: getRobotApiVersion(robot) || '',
robotSmoothieVersion: getRobotFirmwareVersion(robot) || '',
robotLeftPipette: pipettes.left?.model || '',
robotRightPipette: pipettes.right?.model || '',
robotApiServerVersion: getRobotApiVersion(robot) ?? '',
robotSmoothieVersion: getRobotFirmwareVersion(robot) ?? '',
robotLeftPipette: pipettes.left?.model ?? '',
robotRightPipette: pipettes.right?.model ?? '',
}
)
}
Expand Down
82 changes: 0 additions & 82 deletions app/src/redux/analytics/__tests__/make-event.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,6 @@ const getAnalyticsSessionExitDetails = selectors.getAnalyticsSessionExitDetails
const getSessionInstrumentAnalyticsData = selectors.getSessionInstrumentAnalyticsData as jest.MockedFunction<
typeof selectors.getSessionInstrumentAnalyticsData
>
const getAnalyticsHealthCheckData = selectors.getAnalyticsHealthCheckData as jest.MockedFunction<
typeof selectors.getAnalyticsHealthCheckData
>
const getAnalyticsDeckCalibrationData = selectors.getAnalyticsDeckCalibrationData as jest.MockedFunction<
typeof selectors.getAnalyticsDeckCalibrationData
>
const getAnalyticsPipetteCalibrationData = selectors.getAnalyticsPipetteCalibrationData as jest.MockedFunction<
typeof selectors.getAnalyticsPipetteCalibrationData
>
const getAnalyticsTipLengthCalibrationData = selectors.getAnalyticsTipLengthCalibrationData as jest.MockedFunction<
typeof selectors.getAnalyticsTipLengthCalibrationData
>

describe('analytics events map', () => {
beforeEach(() => {
Expand Down Expand Up @@ -63,18 +51,10 @@ describe('analytics events map', () => {
someStuff: 'some-other-stuff',
},
} as any
getAnalyticsPipetteCalibrationData.mockReturnValue({
markedBad: true,
calibrationExists: true,
pipetteModel: 'my pipette model',
})
return expect(makeEvent(action, state)).resolves.toEqual({
name: 'pipetteOffsetCalibrationStarted',
properties: {
...action.payload,
calibrationExists: true,
markedBad: true,
pipetteModel: 'my pipette model',
},
})
})
Expand All @@ -87,76 +67,14 @@ describe('analytics events map', () => {
someStuff: 'some-other-stuff',
},
} as any
getAnalyticsTipLengthCalibrationData.mockReturnValue({
markedBad: true,
calibrationExists: true,
pipetteModel: 'pipette-model',
})
return expect(makeEvent(action, state)).resolves.toEqual({
name: 'tipLengthCalibrationStarted',
properties: {
...action.payload,
calibrationExists: true,
markedBad: true,
pipetteModel: 'pipette-model',
},
})
})

it('sessions:ENSURE_SESSION for deck cal -> deckCalibrationStarted event', () => {
const state = {} as any
const action = {
type: 'sessions:ENSURE_SESSION',
payload: {
sessionType: 'deckCalibration',
},
} as any
getAnalyticsDeckCalibrationData.mockReturnValue({
calibrationStatus: 'IDENTITY',
markedBad: true,
pipettes: { left: { model: 'my pipette model' } },
} as any)

return expect(makeEvent(action, state)).resolves.toEqual({
name: 'deckCalibrationStarted',
properties: {
calibrationStatus: 'IDENTITY',
markedBad: true,
pipettes: { left: { model: 'my pipette model' } },
},
})
})

it('sessions:ENSURE_SESSION for health check -> calibrationHealthCheckStarted event', () => {
const state = {} as any
const action = {
type: 'sessions:ENSURE_SESSION',
payload: {
sessionType: 'calibrationCheck',
},
} as any
getAnalyticsHealthCheckData.mockReturnValue({
pipettes: { left: { model: 'my pipette model' } },
} as any)
return expect(makeEvent(action, state)).resolves.toEqual({
name: 'calibrationHealthCheckStarted',
properties: {
pipettes: { left: { model: 'my pipette model' } },
},
})
})

it('sessions:ENSURE_SESSION for other session -> no event', () => {
const state = {} as any
const action = {
type: 'sessions:ENSURE_SESSION',
payload: {
sessionType: 'some-other-session',
},
} as any
return expect(makeEvent(action, state)).resolves.toBeNull()
})

it('sessions:CREATE_SESSION_COMMAND for exit -> {type}Exit', () => {
const state = {} as any
const action = {
Expand Down
6 changes: 0 additions & 6 deletions app/src/redux/analytics/__tests__/selectors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ describe('analytics selectors', () => {
})

describe('analytics calibration selectors', () => {
describe('getAnalyticsHealthCheckData', () => {
it('should return null if no robot connected', () => {
const mockState: State = {} as any
expect(Selectors.getAnalyticsHealthCheckData(mockState)).toBeNull()
})
})
describe('getAnalyticsSessionExitDetails', () => {
const mockGetRobotSessionById = SessionsSelectors.getRobotSessionById as jest.MockedFunction<
typeof SessionsSelectors.getRobotSessionById
Expand Down
Loading

0 comments on commit e117a19

Please sign in to comment.