mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-02-16 17:25:58 +00:00
Make Phoenix enabled based of config context (#1250)
* Have phoenix enabled based of config context irrespective of hosted or portal explorer * Add telemetry start and success * Add error code in failure case
This commit is contained in:
parent
2e3e547a46
commit
cea3978ca6
@ -10,7 +10,7 @@ import {
|
|||||||
HttpStatusCodes,
|
HttpStatusCodes,
|
||||||
Notebook,
|
Notebook,
|
||||||
} from "../Common/Constants";
|
} from "../Common/Constants";
|
||||||
import { getErrorMessage } from "../Common/ErrorHandlingUtils";
|
import { getErrorMessage, getErrorStack } from "../Common/ErrorHandlingUtils";
|
||||||
import * as Logger from "../Common/Logger";
|
import * as Logger from "../Common/Logger";
|
||||||
import { configContext } from "../ConfigContext";
|
import { configContext } from "../ConfigContext";
|
||||||
import {
|
import {
|
||||||
@ -160,13 +160,35 @@ export class PhoenixClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public async isDbAcountWhitelisted(): Promise<boolean> {
|
public async isDbAcountWhitelisted(): Promise<boolean> {
|
||||||
|
const startKey = TelemetryProcessor.traceStart(Action.PhoenixDBAccountAllowed, {
|
||||||
|
dataExplorerArea: Areas.Notebook,
|
||||||
|
});
|
||||||
try {
|
try {
|
||||||
const response = await window.fetch(`${this.getPhoenixControlPlanePathPrefix()}`, {
|
const response = await window.fetch(`${this.getPhoenixControlPlanePathPrefix()}`, {
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: PhoenixClient.getHeaders(),
|
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;
|
return response.status === HttpStatusCodes.OK;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
TelemetryProcessor.traceFailure(
|
||||||
|
Action.PhoenixDBAccountAllowed,
|
||||||
|
{
|
||||||
|
dataExplorerArea: Areas.Notebook,
|
||||||
|
error: getErrorMessage(error),
|
||||||
|
errorStack: getErrorStack(error),
|
||||||
|
},
|
||||||
|
startKey
|
||||||
|
);
|
||||||
Logger.logError(getErrorMessage(error), "PhoenixClient/IsDbAcountWhitelisted");
|
Logger.logError(getErrorMessage(error), "PhoenixClient/IsDbAcountWhitelisted");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,7 @@ export enum Action {
|
|||||||
PhoenixConnection,
|
PhoenixConnection,
|
||||||
PhoenixHeartBeat,
|
PhoenixHeartBeat,
|
||||||
PhoenixResetWorkspace,
|
PhoenixResetWorkspace,
|
||||||
|
PhoenixDBAccountAllowed,
|
||||||
DeleteCellFromMenu,
|
DeleteCellFromMenu,
|
||||||
OpenTerminal,
|
OpenTerminal,
|
||||||
CreateMongoCollectionWithWildcardIndex,
|
CreateMongoCollectionWithWildcardIndex,
|
||||||
|
@ -44,6 +44,11 @@ export function useKnockoutExplorer(platform: Platform): Explorer {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const effect = async () => {
|
const effect = async () => {
|
||||||
if (platform) {
|
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) {
|
if (platform === Platform.Hosted) {
|
||||||
const explorer = await configureHosted();
|
const explorer = await configureHosted();
|
||||||
setExplorer(explorer);
|
setExplorer(explorer);
|
||||||
@ -351,11 +356,6 @@ function updateContextsFromPortalMessage(inputs: DataExplorerInputsFrame) {
|
|||||||
if (inputs.features) {
|
if (inputs.features) {
|
||||||
Object.assign(userContext.features, extractFeatures(new URLSearchParams(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) {
|
||||||
if (inputs.flights.indexOf(Flights.AutoscaleTest) !== -1) {
|
if (inputs.flights.indexOf(Flights.AutoscaleTest) !== -1) {
|
||||||
userContext.features.autoscaleDefault;
|
userContext.features.autoscaleDefault;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user