Skip to content

Commit

Permalink
refactor(app): generify MQTT Analytics (#15065)
Browse files Browse the repository at this point in the history
Now that the OT-2 supports MQTT, we don't need to special-case analytics for only the Flex.
  • Loading branch information
mjhuff authored May 1, 2024
1 parent 3ff6c7b commit 4635d72
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 7 deletions.
3 changes: 0 additions & 3 deletions app/src/resources/__tests__/useNotifyService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { useNotifyService } from '../useNotifyService'
import { appShellListener } from '../../redux/shell/remote'
import { useTrackEvent } from '../../redux/analytics'
import { notifySubscribeAction } from '../../redux/shell'
import { useIsFlex } from '../../organisms/Devices/hooks/useIsFlex'

import type { Mock } from 'vitest'
import type { HostConfig } from '@opentrons/api-client'
Expand All @@ -21,7 +20,6 @@ vi.mock('../../redux/analytics')
vi.mock('../../redux/shell/remote', () => ({
appShellListener: vi.fn(),
}))
vi.mock('../../organisms/Devices/hooks/useIsFlex')

const MOCK_HOST_CONFIG: HostConfig = { hostname: 'MOCK_HOST' }
const MOCK_TOPIC = '/test/topic' as any
Expand All @@ -41,7 +39,6 @@ describe('useNotifyService', () => {
vi.mocked(useTrackEvent).mockReturnValue(mockTrackEvent)
vi.mocked(useDispatch).mockReturnValue(mockDispatch)
vi.mocked(useHost).mockReturnValue(MOCK_HOST_CONFIG)
vi.mocked(useIsFlex).mockReturnValue(true)
vi.mocked(appShellListener).mockClear()
})

Expand Down
5 changes: 1 addition & 4 deletions app/src/resources/useNotifyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
useTrackEvent,
ANALYTICS_NOTIFICATION_PORT_BLOCK_ERROR,
} from '../redux/analytics'
import { useIsFlex } from '../organisms/Devices/hooks/useIsFlex'

import type { UseQueryOptions } from 'react-query'
import type { HostConfig } from '@opentrons/api-client'
Expand Down Expand Up @@ -41,7 +40,6 @@ export function useNotifyService<TData, TError = Error>({
const host = hostOverride ?? hostFromProvider
const hostname = host?.hostname ?? null
const doTrackEvent = useTrackEvent()
const isFlex = useIsFlex(host?.robotName ?? '')
const seenHostname = React.useRef<string | null>(null)
const { enabled, staleTime, forceHttpPolling } = options

Expand Down Expand Up @@ -81,8 +79,7 @@ export function useNotifyService<TData, TError = Error>({
function onDataEvent(data: NotifyResponseData): void {
if (data === 'ECONNFAILED' || data === 'ECONNREFUSED') {
setRefetch('always')
// TODO(jh 2023-02-23): remove the robot type check once OT-2s support MQTT.
if (data === 'ECONNREFUSED' && isFlex) {
if (data === 'ECONNREFUSED') {
doTrackEvent({
name: ANALYTICS_NOTIFICATION_PORT_BLOCK_ERROR,
properties: {},
Expand Down

0 comments on commit 4635d72

Please sign in to comment.