Skip to content

Commit

Permalink
fix(app): add robot serial number to BuildrootAnalyticsData
Browse files Browse the repository at this point in the history
add robot serial number to BuildrootAnalyticsData

close RQA-2386
  • Loading branch information
koji committed Apr 24, 2024
1 parent 9d75e1f commit 09f274e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
7 changes: 7 additions & 0 deletions app/src/redux/analytics/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,10 @@ export const ANALYTICS_ODD_APP_ERROR = 'oddError'
export const ANALYTICS_NOTIFICATION_PORT_BLOCK_ERROR =
'notificationPortBlockError'
export const ANALYTICS_DESKTOP_APP_ERROR = 'desktopAppError'

export const ANALYTICS_ROBOT_UPDATE_VIEW = 'robotUpdateView'
export const ANALYTICS_ROBOT_UPDATE_CHANGE_LOG_VIEW = 'robotUpdateChangeLogView'
export const ANALYTICS_ROBOT_UPDATE_IGNORE = 'robotUpdateIgnore'
export const ANALYTICS_ROBOT_UPDATE_INITIATE = 'robotUpdateInitiate'
export const ANALYTICS_ROBOT_UPDATE_ERROR = 'robotUpdateError'
export const ANALYTICS_ROBOT_UPDATE_COMPLETE = 'robotUpdateComplete'
12 changes: 6 additions & 6 deletions app/src/redux/analytics/make-event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,39 +28,39 @@ export function makeEvent(
case RobotUpdate.ROBOTUPDATE_SET_UPDATE_SEEN: {
const data = getBuildrootAnalyticsData(state, action.meta.robotName)
return Promise.resolve({
name: 'robotUpdateView',
name: Constants.ANALYTICS_ROBOT_UPDATE_VIEW,
properties: { ...data },
})
}

case RobotUpdate.ROBOTUPDATE_CHANGELOG_SEEN: {
const data = getBuildrootAnalyticsData(state, action.meta.robotName)
return Promise.resolve({
name: 'robotUpdateChangeLogView',
name: Constants.ANALYTICS_ROBOT_UPDATE_CHANGE_LOG_VIEW,
properties: { ...data },
})
}

case RobotUpdate.ROBOTUPDATE_UPDATE_IGNORED: {
const data = getBuildrootAnalyticsData(state, action.meta.robotName)
return Promise.resolve({
name: 'robotUpdateIgnore',
name: Constants.ANALYTICS_ROBOT_UPDATE_IGNORE,
properties: { ...data },
})
}

case RobotUpdate.ROBOTUPDATE_START_UPDATE: {
const data = getBuildrootAnalyticsData(state)
return Promise.resolve({
name: 'robotUpdateInitiate',
name: Constants.ANALYTICS_ROBOT_UPDATE_INITIATE,
properties: { ...data },
})
}

case RobotUpdate.ROBOTUPDATE_UNEXPECTED_ERROR: {
const data = getBuildrootAnalyticsData(state)
return Promise.resolve({
name: 'robotUpdateError',
name: Constants.ANALYTICS_ROBOT_UPDATE_ERROR,
properties: { ...data },
})
}
Expand All @@ -69,7 +69,7 @@ export function makeEvent(
if (action.payload !== 'finished') return Promise.resolve(null)
const data = getBuildrootAnalyticsData(state)
return Promise.resolve({
name: 'robotUpdateComplete',
name: Constants.ANALYTICS_ROBOT_UPDATE_COMPLETE,
properties: { ...data },
})
}
Expand Down
3 changes: 3 additions & 0 deletions app/src/redux/analytics/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ export function getBuildrootAnalyticsData(
robotName === null
? getRobotUpdateRobot(state)
: getViewableRobots(state).find(r => r.name === robotName) ?? null
const robotSerialNumber =
robot?.health?.robot_serial ?? robot?.serverHealth?.serialNumber ?? null

if (updateVersion === null || robot === null) return null

Expand All @@ -42,6 +44,7 @@ export function getBuildrootAnalyticsData(
currentSystem,
updateVersion,
error: session != null && 'error' in session ? session.error : null,
robotSerialNumber,
}
}

Expand Down
1 change: 1 addition & 0 deletions app/src/redux/analytics/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface BuildrootAnalyticsData {
currentSystem: string
updateVersion: string
error: string | null
robotSerialNumber: string | null
}

export interface PipetteOffsetCalibrationAnalyticsData {
Expand Down

0 comments on commit 09f274e

Please sign in to comment.