From 2f765a1d4b6a94776fb7b1b3ca551ed344a57069 Mon Sep 17 00:00:00 2001 From: Gianluca Zuccarelli Date: Tue, 1 Jul 2025 16:03:13 +0100 Subject: [PATCH] multi: fix analytics for on-prem This commit fixes some more analytics calls happening in the on-prem frontend. --- .../Blueprints/BuildImagesButton.tsx | 12 ++++--- src/Components/ImagesTable/ImageDetails.tsx | 36 ++++++++++--------- src/store/wizardSlice.ts | 11 ++++++ 3 files changed, 38 insertions(+), 21 deletions(-) diff --git a/src/Components/Blueprints/BuildImagesButton.tsx b/src/Components/Blueprints/BuildImagesButton.tsx index 5d505704..9bc3d7ba 100644 --- a/src/Components/Blueprints/BuildImagesButton.tsx +++ b/src/Components/Blueprints/BuildImagesButton.tsx @@ -57,11 +57,13 @@ export const BuildImagesButton = ({ children }: BuildImagesButtonPropTypes) => { ), }, }); - analytics.track(`${AMPLITUDE_MODULE_NAME} - Image Requested`, { - module: AMPLITUDE_MODULE_NAME, - trigger: 'synchronize images', - account_id: userData?.identity.internal?.account_id || 'Not found', - }); + if (!process.env.IS_ON_PREMISE) { + analytics.track(`${AMPLITUDE_MODULE_NAME} - Image Requested`, { + module: AMPLITUDE_MODULE_NAME, + trigger: 'synchronize images', + account_id: userData?.identity.internal?.account_id || 'Not found', + }); + } } }; const [isOpen, setIsOpen] = useState(false); diff --git a/src/Components/ImagesTable/ImageDetails.tsx b/src/Components/ImagesTable/ImageDetails.tsx index 45cca690..9e830c22 100644 --- a/src/Components/ImagesTable/ImageDetails.tsx +++ b/src/Components/ImagesTable/ImageDetails.tsx @@ -163,13 +163,15 @@ export const AwsDetails = ({ compose }: AwsDetailsPropTypes) => { clickTip="Copied" variant="inline-compact" onClick={() => { - analytics.track(`${AMPLITUDE_MODULE_NAME} - Copy UUID`, { - module: AMPLITUDE_MODULE_NAME, - link_name: compose.id, - current_path: window.location.pathname, - account_id: - userData?.identity.internal?.account_id || 'Not found', - }); + if (!process.env.IS_ON_PREMISE) { + analytics.track(`${AMPLITUDE_MODULE_NAME} - Copy UUID`, { + module: AMPLITUDE_MODULE_NAME, + link_name: compose.id, + current_path: window.location.pathname, + account_id: + userData?.identity.internal?.account_id || 'Not found', + }); + } }} > {compose.id} @@ -203,16 +205,18 @@ export const AwsDetails = ({ compose }: AwsDetailsPropTypes) => { // https://docs.aws.amazon.com/signin/latest/userguide/sign-in-urls-defined.html href={`https://${options.share_with_accounts[0]}.signin.aws.amazon.com/console/`} onClick={() => { - analytics.track(`${AMPLITUDE_MODULE_NAME} - Link Clicked`, { - module: AMPLITUDE_MODULE_NAME, + if (!process.env.IS_ON_PREMISE) { + analytics.track(`${AMPLITUDE_MODULE_NAME} - Link Clicked`, { + module: AMPLITUDE_MODULE_NAME, - link_name: options.share_with_accounts - ? options.share_with_accounts[0] - : '', - current_path: window.location.pathname, - account_id: - userData?.identity.internal?.account_id || 'Not found', - }); + link_name: options.share_with_accounts + ? options.share_with_accounts[0] + : '', + current_path: window.location.pathname, + account_id: + userData?.identity.internal?.account_id || 'Not found', + }); + } }} > {options.share_with_accounts[0]} diff --git a/src/store/wizardSlice.ts b/src/store/wizardSlice.ts index ada5f2c6..9f1b7733 100644 --- a/src/store/wizardSlice.ts +++ b/src/store/wizardSlice.ts @@ -94,6 +94,7 @@ export type wizardState = { shareMethod: AwsShareMethod; source: V1ListSourceResponseItem | undefined; sourceId?: string | undefined; + region?: string | undefined; }; azure: { shareMethod: AzureShareMethod; @@ -189,6 +190,7 @@ export const initialState: wizardState = { accountId: '', shareMethod: 'sources', source: undefined, + region: 'us-east-1', }, azure: { shareMethod: 'sources', @@ -312,6 +314,10 @@ export const selectAwsShareMethod = (state: RootState) => { return state.wizard.aws.shareMethod; }; +export const selectAwsRegion = (state: RootState) => { + return state.wizard.aws.region; +}; + export const selectAzureTenantId = (state: RootState) => { return state.wizard.azure.tenantId; }; @@ -534,10 +540,14 @@ export const wizardSlice = createSlice({ changeAwsSourceId: (state, action: PayloadAction) => { state.aws.sourceId = action.payload; }, + changeAwsRegion: (state, action: PayloadAction) => { + state.aws.region = action.payload; + }, reinitializeAws: (state) => { state.aws.accountId = ''; state.aws.shareMethod = 'sources'; state.aws.source = undefined; + state.aws.region = 'us-east-1'; }, changeAzureTenantId: (state, action: PayloadAction) => { state.azure.tenantId = action.payload; @@ -1136,6 +1146,7 @@ export const { changeAwsAccountId, changeAwsShareMethod, changeAwsSourceId, + changeAwsRegion, reinitializeAws, changeAzureTenantId, changeAzureShareMethod,