diff --git a/airbyte-webapp/src/config/utils.ts b/airbyte-webapp/src/config/utils.ts deleted file mode 100644 index 2a1e3c48c4be..000000000000 --- a/airbyte-webapp/src/config/utils.ts +++ /dev/null @@ -1,4 +0,0 @@ -import { ConnectionScheduleDataBasicSchedule } from "core/request/AirbyteClient"; - -export const getFrequencyType = (schedule?: ConnectionScheduleDataBasicSchedule) => - schedule ? `${schedule.units} ${schedule.timeUnit}` : "manual"; diff --git a/airbyte-webapp/src/core/analytics/utils.ts b/airbyte-webapp/src/core/analytics/utils.ts new file mode 100644 index 000000000000..a11cd82bb259 --- /dev/null +++ b/airbyte-webapp/src/core/analytics/utils.ts @@ -0,0 +1,13 @@ +import { ConnectionScheduleData } from "core/request/AirbyteClient"; + +export const getFrequencyFromScheduleData = (scheduleData?: ConnectionScheduleData) => { + if (!scheduleData) { + return "manual"; + } else if (scheduleData.cron) { + return `${scheduleData.cron.cronExpression} ${scheduleData.cron.cronTimeZone}`; + } else if (scheduleData.basicSchedule) { + return `${scheduleData.basicSchedule.units} ${scheduleData.basicSchedule.timeUnit}`; + } + // this should never get called but the linter wants a catch-all + return null; +}; diff --git a/airbyte-webapp/src/hooks/services/useConnectionHook.tsx b/airbyte-webapp/src/hooks/services/useConnectionHook.tsx index b8eeaa89d9cc..f5261686ea04 100644 --- a/airbyte-webapp/src/hooks/services/useConnectionHook.tsx +++ b/airbyte-webapp/src/hooks/services/useConnectionHook.tsx @@ -1,8 +1,8 @@ import { useCallback } from "react"; import { useMutation, useQueryClient } from "react-query"; -import { getFrequencyType } from "config/utils"; import { Action, Namespace } from "core/analytics"; +import { getFrequencyFromScheduleData } from "core/analytics/utils"; import { SyncSchema } from "core/domain/catalog"; import { WebBackendConnectionService } from "core/domain/connection"; import { ConnectionService } from "core/domain/connection/ConnectionService"; @@ -100,7 +100,7 @@ export const useSyncConnection = () => { connector_source_definition_id: connection.source?.sourceDefinitionId, connector_destination: connection.destination?.destinationName, connector_destination_definition_id: connection.destination?.destinationDefinitionId, - frequency: getFrequencyType(connection.scheduleData?.basicSchedule), + frequency: getFrequencyFromScheduleData(connection.scheduleData), }); return service.sync(connection.connectionId); @@ -145,7 +145,7 @@ const useCreateConnection = () => { analyticsService.track(Namespace.CONNECTION, Action.CREATE, { actionDescription: "New connection created", - frequency: getFrequencyType(values.scheduleData?.basicSchedule), + frequency: getFrequencyFromScheduleData(values.scheduleData), connector_source_definition: source?.sourceName, connector_source_definition_id: sourceDefinition?.sourceDefinitionId, connector_destination_definition: destination?.destinationName, @@ -228,7 +228,7 @@ export const useEnableConnection = () => { const action = connection.status === ConnectionStatus.active ? Action.REENABLE : Action.DISABLE; analyticsService.track(Namespace.CONNECTION, action, { - frequency: getFrequencyType(connection.scheduleData?.basicSchedule), + frequency: getFrequencyFromScheduleData(connection.scheduleData), connector_source: connection.source?.sourceName, connector_source_definition_id: connection.source?.sourceDefinitionId, connector_destination: connection.destination?.destinationName, diff --git a/airbyte-webapp/src/pages/ConnectionPage/pages/ConnectionItemPage/ConnectionItemPage.tsx b/airbyte-webapp/src/pages/ConnectionPage/pages/ConnectionItemPage/ConnectionItemPage.tsx index 909d8499e975..6228239a3e7d 100644 --- a/airbyte-webapp/src/pages/ConnectionPage/pages/ConnectionItemPage/ConnectionItemPage.tsx +++ b/airbyte-webapp/src/pages/ConnectionPage/pages/ConnectionItemPage/ConnectionItemPage.tsx @@ -4,8 +4,8 @@ import { Navigate, Route, Routes, useParams } from "react-router-dom"; import { LoadingPage, MainPageWithScroll } from "components"; import HeadTitle from "components/HeadTitle"; -import { getFrequencyType } from "config/utils"; import { Action, Namespace } from "core/analytics"; +import { getFrequencyFromScheduleData } from "core/analytics/utils"; import { ConnectionStatus } from "core/request/AirbyteClient"; import { useAnalyticsService, useTrackPage, PageTrackingCodes } from "hooks/services/Analytics"; import { useGetConnection } from "hooks/services/useConnectionHook"; @@ -38,7 +38,7 @@ export const ConnectionItemPage: React.FC = () => { connector_source_definition_id: source.sourceDefinitionId, connector_destination: destination.destinationName, connector_destination_definition_id: destination.destinationDefinitionId, - frequency: getFrequencyType(connection.scheduleData?.basicSchedule), + frequency: getFrequencyFromScheduleData(connection.scheduleData), }); }; diff --git a/airbyte-webapp/src/pages/ConnectionPage/pages/ConnectionItemPage/ConnectionStatusTab.tsx b/airbyte-webapp/src/pages/ConnectionPage/pages/ConnectionItemPage/ConnectionStatusTab.tsx index 6c49a2966b76..fb88ac1e3f40 100644 --- a/airbyte-webapp/src/pages/ConnectionPage/pages/ConnectionItemPage/ConnectionStatusTab.tsx +++ b/airbyte-webapp/src/pages/ConnectionPage/pages/ConnectionItemPage/ConnectionStatusTab.tsx @@ -11,8 +11,8 @@ import { Button } from "components/ui/Button"; import { Card } from "components/ui/Card"; import { Tooltip } from "components/ui/Tooltip"; -import { getFrequencyType } from "config/utils"; import { Action, Namespace } from "core/analytics"; +import { getFrequencyFromScheduleData } from "core/analytics/utils"; import { ConnectionStatus, JobWithAttemptsRead, WebBackendConnectionRead } from "core/request/AirbyteClient"; import Status from "core/statuses"; import { useTrackPage, PageTrackingCodes, useAnalyticsService } from "hooks/services/Analytics"; @@ -144,7 +144,7 @@ export const ConnectionStatusTab: React.FC = ({ connec connector_source_definition_id: connection.source?.sourceDefinitionId, connector_destination: connection.destination?.destinationName, connector_destination_definition_id: connection.destination?.destinationDefinitionId, - frequency: getFrequencyType(connection.schedule), + frequency: getFrequencyFromScheduleData(connection.scheduleData), job_page_size: jobPageSize, }); }; diff --git a/airbyte-webapp/src/pages/ConnectionPage/pages/ConnectionItemPage/EnabledControl.tsx b/airbyte-webapp/src/pages/ConnectionPage/pages/ConnectionItemPage/EnabledControl.tsx index 8da2df5e7daf..72518f55d7d4 100644 --- a/airbyte-webapp/src/pages/ConnectionPage/pages/ConnectionItemPage/EnabledControl.tsx +++ b/airbyte-webapp/src/pages/ConnectionPage/pages/ConnectionItemPage/EnabledControl.tsx @@ -6,6 +6,7 @@ import styled from "styled-components"; import { Switch } from "components/ui/Switch"; import { Action, Namespace } from "core/analytics"; +import { getFrequencyFromScheduleData } from "core/analytics/utils"; import { buildConnectionUpdate } from "core/domain/connection"; import { ConnectionStatus, WebBackendConnectionRead } from "core/request/AirbyteClient"; import { useAnalyticsService } from "hooks/services/Analytics"; @@ -31,11 +32,10 @@ const Content = styled.div` interface EnabledControlProps { connection: WebBackendConnectionRead; disabled?: boolean; - frequencyType?: string; onStatusUpdating?: (updating: boolean) => void; } -const EnabledControl: React.FC = ({ connection, disabled, frequencyType, onStatusUpdating }) => { +const EnabledControl: React.FC = ({ connection, disabled, onStatusUpdating }) => { const { mutateAsync: updateConnection, isLoading } = useUpdateConnection(); const analyticsService = useAnalyticsService(); @@ -54,7 +54,7 @@ const EnabledControl: React.FC = ({ connection, disabled, f connector_source_definition_id: connection.source?.sourceDefinitionId, connector_destination: connection.destination?.destinationName, connector_destination_definition_id: connection.destination?.destinationDefinitionId, - frequency: frequencyType, + frequency: getFrequencyFromScheduleData(connection.scheduleData), }); }; diff --git a/airbyte-webapp/src/pages/ConnectionPage/pages/ConnectionItemPage/StatusMainInfo.tsx b/airbyte-webapp/src/pages/ConnectionPage/pages/ConnectionItemPage/StatusMainInfo.tsx index 920b66333e26..4d77cdec4249 100644 --- a/airbyte-webapp/src/pages/ConnectionPage/pages/ConnectionItemPage/StatusMainInfo.tsx +++ b/airbyte-webapp/src/pages/ConnectionPage/pages/ConnectionItemPage/StatusMainInfo.tsx @@ -5,7 +5,6 @@ import { Link } from "react-router-dom"; import { ConnectorCard } from "components"; -import { getFrequencyType } from "config/utils"; import { ConnectionStatus, SourceRead, DestinationRead, WebBackendConnectionRead } from "core/request/AirbyteClient"; import { FeatureItem, useFeature } from "hooks/services/Feature"; import { RoutePaths } from "pages/routePaths"; @@ -59,12 +58,7 @@ export const StatusMainInfo: React.FC = ({ {connection.status !== ConnectionStatus.deprecated && (
- +
)}