diff --git a/src/Phoenix/PhoenixClient.ts b/src/Phoenix/PhoenixClient.ts index 833c18c42..7629ffac5 100644 --- a/src/Phoenix/PhoenixClient.ts +++ b/src/Phoenix/PhoenixClient.ts @@ -10,7 +10,7 @@ import { HttpStatusCodes, Notebook, } from "../Common/Constants"; -import { getErrorMessage } from "../Common/ErrorHandlingUtils"; +import { getErrorMessage, getErrorStack } from "../Common/ErrorHandlingUtils"; import * as Logger from "../Common/Logger"; import { configContext } from "../ConfigContext"; import { @@ -160,13 +160,35 @@ export class PhoenixClient { } public async isDbAcountWhitelisted(): Promise { + const startKey = TelemetryProcessor.traceStart(Action.PhoenixDBAccountAllowed, { + dataExplorerArea: Areas.Notebook, + }); try { const response = await window.fetch(`${this.getPhoenixControlPlanePathPrefix()}`, { method: "GET", headers: PhoenixClient.getHeaders(), }); + if (response.status !== HttpStatusCodes.OK) { + throw new Error(`Received status code: ${response?.status}`); + } + TelemetryProcessor.traceSuccess( + Action.PhoenixDBAccountAllowed, + { + dataExplorerArea: Areas.Notebook, + }, + startKey + ); return response.status === HttpStatusCodes.OK; } catch (error) { + TelemetryProcessor.traceFailure( + Action.PhoenixDBAccountAllowed, + { + dataExplorerArea: Areas.Notebook, + error: getErrorMessage(error), + errorStack: getErrorStack(error), + }, + startKey + ); Logger.logError(getErrorMessage(error), "PhoenixClient/IsDbAcountWhitelisted"); return false; } diff --git a/src/Shared/Telemetry/TelemetryConstants.ts b/src/Shared/Telemetry/TelemetryConstants.ts index 71bf6cb5a..2f43adb03 100644 --- a/src/Shared/Telemetry/TelemetryConstants.ts +++ b/src/Shared/Telemetry/TelemetryConstants.ts @@ -84,6 +84,7 @@ export enum Action { PhoenixConnection, PhoenixHeartBeat, PhoenixResetWorkspace, + PhoenixDBAccountAllowed, DeleteCellFromMenu, OpenTerminal, CreateMongoCollectionWithWildcardIndex, diff --git a/src/hooks/useKnockoutExplorer.ts b/src/hooks/useKnockoutExplorer.ts index af9ab2640..de019e599 100644 --- a/src/hooks/useKnockoutExplorer.ts +++ b/src/hooks/useKnockoutExplorer.ts @@ -44,6 +44,11 @@ export function useKnockoutExplorer(platform: Platform): Explorer { useEffect(() => { const effect = async () => { if (platform) { + //Updating phoenix feature flags for MPAC based of config context + if (configContext.isPhoenixEnabled === true) { + userContext.features.phoenixNotebooks = true; + userContext.features.phoenixFeatures = true; + } if (platform === Platform.Hosted) { const explorer = await configureHosted(); setExplorer(explorer); @@ -351,11 +356,6 @@ function updateContextsFromPortalMessage(inputs: DataExplorerInputsFrame) { if (inputs.features) { Object.assign(userContext.features, extractFeatures(new URLSearchParams(inputs.features))); } - //Updating phoenix feature flags for MPAC based of config context - if (configContext.isPhoenixEnabled === true) { - userContext.features.phoenixNotebooks = true; - userContext.features.phoenixFeatures = true; - } if (inputs.flights) { if (inputs.flights.indexOf(Flights.AutoscaleTest) !== -1) { userContext.features.autoscaleDefault;