From 09f274e0f9b15c27e26865b21bd837f8573ff2ac Mon Sep 17 00:00:00 2001 From: koji Date: Wed, 24 Apr 2024 15:39:45 -0400 Subject: [PATCH] fix(app): add robot serial number to BuildrootAnalyticsData add robot serial number to BuildrootAnalyticsData close RQA-2386 --- app/src/redux/analytics/constants.ts | 7 +++++++ app/src/redux/analytics/make-event.ts | 12 ++++++------ app/src/redux/analytics/selectors.ts | 3 +++ app/src/redux/analytics/types.ts | 1 + 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/app/src/redux/analytics/constants.ts b/app/src/redux/analytics/constants.ts index 4eb663f0146..13d8c8bdf1d 100644 --- a/app/src/redux/analytics/constants.ts +++ b/app/src/redux/analytics/constants.ts @@ -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' diff --git a/app/src/redux/analytics/make-event.ts b/app/src/redux/analytics/make-event.ts index 8fdede1dbf2..77e350d1e61 100644 --- a/app/src/redux/analytics/make-event.ts +++ b/app/src/redux/analytics/make-event.ts @@ -28,7 +28,7 @@ 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 }, }) } @@ -36,7 +36,7 @@ export function makeEvent( 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 }, }) } @@ -44,7 +44,7 @@ export function makeEvent( 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 }, }) } @@ -52,7 +52,7 @@ export function makeEvent( case RobotUpdate.ROBOTUPDATE_START_UPDATE: { const data = getBuildrootAnalyticsData(state) return Promise.resolve({ - name: 'robotUpdateInitiate', + name: Constants.ANALYTICS_ROBOT_UPDATE_INITIATE, properties: { ...data }, }) } @@ -60,7 +60,7 @@ export function makeEvent( case RobotUpdate.ROBOTUPDATE_UNEXPECTED_ERROR: { const data = getBuildrootAnalyticsData(state) return Promise.resolve({ - name: 'robotUpdateError', + name: Constants.ANALYTICS_ROBOT_UPDATE_ERROR, properties: { ...data }, }) } @@ -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 }, }) } diff --git a/app/src/redux/analytics/selectors.ts b/app/src/redux/analytics/selectors.ts index fcb9ab18a2d..9bd49916a7a 100644 --- a/app/src/redux/analytics/selectors.ts +++ b/app/src/redux/analytics/selectors.ts @@ -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 @@ -42,6 +44,7 @@ export function getBuildrootAnalyticsData( currentSystem, updateVersion, error: session != null && 'error' in session ? session.error : null, + robotSerialNumber, } } diff --git a/app/src/redux/analytics/types.ts b/app/src/redux/analytics/types.ts index 0b85ce91718..197660f7794 100644 --- a/app/src/redux/analytics/types.ts +++ b/app/src/redux/analytics/types.ts @@ -41,6 +41,7 @@ export interface BuildrootAnalyticsData { currentSystem: string updateVersion: string error: string | null + robotSerialNumber: string | null } export interface PipetteOffsetCalibrationAnalyticsData {