mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-01-01 07:11:23 +00:00
Compare commits
5 Commits
copilot_pu
...
2819766
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
49576f1e80 | ||
|
|
6af1925d15 | ||
|
|
b9cbfc924f | ||
|
|
1aa4c18119 | ||
|
|
0ab07419ce |
@@ -148,9 +148,6 @@ export function client(): Cosmos.CosmosClient {
|
|||||||
endpoint: endpoint() || "https://cosmos.azure.com", // CosmosClient gets upset if we pass a bad URL. This should never actually get called
|
endpoint: endpoint() || "https://cosmos.azure.com", // CosmosClient gets upset if we pass a bad URL. This should never actually get called
|
||||||
key: userContext.masterKey,
|
key: userContext.masterKey,
|
||||||
tokenProvider,
|
tokenProvider,
|
||||||
connectionPolicy: {
|
|
||||||
enableEndpointDiscovery: false,
|
|
||||||
},
|
|
||||||
userAgentSuffix: "Azure Portal",
|
userAgentSuffix: "Azure Portal",
|
||||||
defaultHeaders: _defaultHeaders,
|
defaultHeaders: _defaultHeaders,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -275,6 +275,7 @@ export default class Explorer {
|
|||||||
|
|
||||||
const NINETY_DAYS_IN_MS = 7776000000;
|
const NINETY_DAYS_IN_MS = 7776000000;
|
||||||
const ONE_DAY_IN_MS = 86400000;
|
const ONE_DAY_IN_MS = 86400000;
|
||||||
|
const THREE_DAYS_IN_MS = 259200000;
|
||||||
const isAccountNewerThanNinetyDays = isAccountNewerThanThresholdInMs(
|
const isAccountNewerThanNinetyDays = isAccountNewerThanThresholdInMs(
|
||||||
userContext.databaseAccount?.systemData?.createdAt || "",
|
userContext.databaseAccount?.systemData?.createdAt || "",
|
||||||
NINETY_DAYS_IN_MS,
|
NINETY_DAYS_IN_MS,
|
||||||
@@ -294,32 +295,32 @@ export default class Explorer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try Cosmos DB subscription - survey shown to random 25% of users at day 1 in Data Explorer.
|
// Try Cosmos DB subscription - survey shown to 100% of users at day 1 in Data Explorer.
|
||||||
if (userContext.isTryCosmosDBSubscription) {
|
if (userContext.isTryCosmosDBSubscription) {
|
||||||
if (
|
if (isAccountNewerThanThresholdInMs(userContext.databaseAccount?.systemData?.createdAt || "", ONE_DAY_IN_MS)) {
|
||||||
isAccountNewerThanThresholdInMs(userContext.databaseAccount?.systemData?.createdAt || "", ONE_DAY_IN_MS) &&
|
this.sendNPSMessage();
|
||||||
this.getRandomInt(100) < 25
|
|
||||||
) {
|
|
||||||
sendMessage({ type: MessageTypes.DisplayNPSSurvey });
|
|
||||||
localStorage.setItem("lastSubmitted", Date.now().toString());
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// An existing account is lesser than 90 days old. For existing account show to random 10 % of users in Data Explorer.
|
// An existing account is older than 3 days but less than 90 days old. For existing account show to 100% of users in Data Explorer.
|
||||||
if (isAccountNewerThanNinetyDays) {
|
if (
|
||||||
if (this.getRandomInt(100) < 10) {
|
!isAccountNewerThanThresholdInMs(userContext.databaseAccount?.systemData?.createdAt || "", THREE_DAYS_IN_MS) &&
|
||||||
sendMessage({ type: MessageTypes.DisplayNPSSurvey });
|
isAccountNewerThanNinetyDays
|
||||||
localStorage.setItem("lastSubmitted", Date.now().toString());
|
) {
|
||||||
}
|
this.sendNPSMessage();
|
||||||
} else {
|
} else {
|
||||||
// An existing account is greater than 90 days. For existing account show to random 25 % of users in Data Explorer.
|
// An existing account is greater than 90 days. For existing account show to random 33% of users in Data Explorer.
|
||||||
if (this.getRandomInt(100) < 25) {
|
if (this.getRandomInt(100) < 33) {
|
||||||
sendMessage({ type: MessageTypes.DisplayNPSSurvey });
|
this.sendNPSMessage();
|
||||||
localStorage.setItem("lastSubmitted", Date.now().toString());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private sendNPSMessage() {
|
||||||
|
sendMessage({ type: MessageTypes.DisplayNPSSurvey });
|
||||||
|
localStorage.setItem("lastSubmitted", Date.now().toString());
|
||||||
|
}
|
||||||
|
|
||||||
public async refreshDatabaseForResourceToken(): Promise<void> {
|
public async refreshDatabaseForResourceToken(): Promise<void> {
|
||||||
const databaseId = userContext.parsedResourceToken?.databaseId;
|
const databaseId = userContext.parsedResourceToken?.databaseId;
|
||||||
const collectionId = userContext.parsedResourceToken?.collectionId;
|
const collectionId = userContext.parsedResourceToken?.collectionId;
|
||||||
|
|||||||
@@ -1431,8 +1431,6 @@ export class AddCollectionPanel extends React.Component<AddCollectionPanelProps,
|
|||||||
this.setState({ isExecuting: false });
|
this.setState({ isExecuting: false });
|
||||||
TelemetryProcessor.traceSuccess(Action.CreateCollection, telemetryData, startKey);
|
TelemetryProcessor.traceSuccess(Action.CreateCollection, telemetryData, startKey);
|
||||||
useSidePanel.getState().closeSidePanel();
|
useSidePanel.getState().closeSidePanel();
|
||||||
// open NPS Survey Dialog once the collection is created
|
|
||||||
this.props.explorer.openNPSSurveyDialog();
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMessage: string = getErrorMessage(error);
|
const errorMessage: string = getErrorMessage(error);
|
||||||
this.setState({ isExecuting: false, errorMessage, showErrorDetails: true });
|
this.setState({ isExecuting: false, errorMessage, showErrorDetails: true });
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ export const WelcomeModal = ({ visible }: { visible: boolean }): JSX.Element =>
|
|||||||
<Text>
|
<Text>
|
||||||
Ask Copilot to generate a query by describing the query in your words.
|
Ask Copilot to generate a query by describing the query in your words.
|
||||||
<br />
|
<br />
|
||||||
<Link target="_blank" href="https://aka.ms/CopilotInAzureCDBDocs">
|
<Link target="_blank" href="https://aka.ms/MicrosoftCopilotForAzureInCDBHowTo">
|
||||||
Learn more
|
Learn more
|
||||||
</Link>
|
</Link>
|
||||||
</Text>
|
</Text>
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ exports[`Query Copilot Welcome Modal snapshot test should render when isOpen is
|
|||||||
Ask Copilot to generate a query by describing the query in your words.
|
Ask Copilot to generate a query by describing the query in your words.
|
||||||
<br />
|
<br />
|
||||||
<StyledLinkBase
|
<StyledLinkBase
|
||||||
href="https://aka.ms/CopilotInAzureCDBDocs"
|
href="https://aka.ms/MicrosoftCopilotForAzureInCDBHowTo"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
>
|
>
|
||||||
Learn more
|
Learn more
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
|
|||||||
const serverInfo = useQueryCopilot.getState().notebookServerInfo;
|
const serverInfo = useQueryCopilot.getState().notebookServerInfo;
|
||||||
const queryUri = userContext.features.disableCopilotPhoenixGateaway
|
const queryUri = userContext.features.disableCopilotPhoenixGateaway
|
||||||
? createUri("https://copilotorchestrater.azurewebsites.net/", "generateSQLQuery")
|
? createUri("https://copilotorchestrater.azurewebsites.net/", "generateSQLQuery")
|
||||||
: createUri(serverInfo.notebookServerEndpoint, "generateSQLQuery");
|
: createUri(serverInfo.notebookServerEndpoint, "public/generateSQLQuery");
|
||||||
const response = await fetch(queryUri, {
|
const response = await fetch(queryUri, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ describe("Query Copilot Client", () => {
|
|||||||
|
|
||||||
const feedbackUri = userContext.features.disableCopilotPhoenixGateaway
|
const feedbackUri = userContext.features.disableCopilotPhoenixGateaway
|
||||||
? createUri("https://copilotorchestrater.azurewebsites.net/", "feedback")
|
? createUri("https://copilotorchestrater.azurewebsites.net/", "feedback")
|
||||||
: createUri(useQueryCopilot.getState().notebookServerInfo.notebookServerEndpoint, "feedback");
|
: createUri(useQueryCopilot.getState().notebookServerInfo.notebookServerEndpoint, "public/feedback");
|
||||||
|
|
||||||
it("should call fetch with the payload with like", async () => {
|
it("should call fetch with the payload with like", async () => {
|
||||||
const mockFetch = jest.fn().mockResolvedValueOnce({});
|
const mockFetch = jest.fn().mockResolvedValueOnce({});
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ export const getCopilotEnabled = async (): Promise<boolean> => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!response?.ok) {
|
if (!response?.ok) {
|
||||||
throw new Error(await response?.text());
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const copilotPortalConfiguration = (await response?.json()) as CopilotEnabledConfiguration;
|
const copilotPortalConfiguration = (await response?.json()) as CopilotEnabledConfiguration;
|
||||||
@@ -215,7 +215,7 @@ export const SendQueryRequest = async ({
|
|||||||
|
|
||||||
const queryUri = userContext.features.disableCopilotPhoenixGateaway
|
const queryUri = userContext.features.disableCopilotPhoenixGateaway
|
||||||
? createUri("https://copilotorchestrater.azurewebsites.net/", "generateSQLQuery")
|
? createUri("https://copilotorchestrater.azurewebsites.net/", "generateSQLQuery")
|
||||||
: createUri(serverInfo.notebookServerEndpoint, "generateSQLQuery");
|
: createUri(serverInfo.notebookServerEndpoint, "public/generateSQLQuery");
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
containerSchema: userContext.features.enableCopilotFullSchema
|
containerSchema: userContext.features.enableCopilotFullSchema
|
||||||
@@ -298,7 +298,7 @@ export const SubmitFeedback = async ({
|
|||||||
const serverInfo = useQueryCopilot.getState().notebookServerInfo;
|
const serverInfo = useQueryCopilot.getState().notebookServerInfo;
|
||||||
const feedbackUri = userContext.features.disableCopilotPhoenixGateaway
|
const feedbackUri = userContext.features.disableCopilotPhoenixGateaway
|
||||||
? createUri("https://copilotorchestrater.azurewebsites.net/", "feedback")
|
? createUri("https://copilotorchestrater.azurewebsites.net/", "feedback")
|
||||||
: createUri(serverInfo.notebookServerEndpoint, "feedback");
|
: createUri(serverInfo.notebookServerEndpoint, "public/feedback");
|
||||||
await fetch(feedbackUri, {
|
await fetch(feedbackUri, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
|
|||||||
@@ -444,7 +444,7 @@ export default class QueryTabComponent extends React.Component<IQueryTabComponen
|
|||||||
this._toggleCopilot(!this.state.copilotActive);
|
this._toggleCopilot(!this.state.copilotActive);
|
||||||
},
|
},
|
||||||
commandButtonLabel: this.state.copilotActive ? "Disable Copilot" : "Enable Copilot",
|
commandButtonLabel: this.state.copilotActive ? "Disable Copilot" : "Enable Copilot",
|
||||||
ariaLabel: "Copilot",
|
ariaLabel: this.state.copilotActive ? "Disable Copilot" : "Enable Copilot",
|
||||||
hasPopup: false,
|
hasPopup: false,
|
||||||
};
|
};
|
||||||
buttons.push(toggleCopilotButton);
|
buttons.push(toggleCopilotButton);
|
||||||
|
|||||||
@@ -420,9 +420,11 @@ async function configurePortal(): Promise<Explorer> {
|
|||||||
updateContextsFromPortalMessage(inputs);
|
updateContextsFromPortalMessage(inputs);
|
||||||
explorer = new Explorer();
|
explorer = new Explorer();
|
||||||
resolve(explorer);
|
resolve(explorer);
|
||||||
if (userContext.apiType === "Postgres") {
|
|
||||||
explorer.openNPSSurveyDialog();
|
if (userContext.apiType === "Postgres" || userContext.apiType === "SQL" || userContext.apiType === "Mongo") {
|
||||||
|
setTimeout(() => explorer.openNPSSurveyDialog(), 3000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (openAction) {
|
if (openAction) {
|
||||||
handleOpenAction(openAction, useDatabases.getState().databases, explorer);
|
handleOpenAction(openAction, useDatabases.getState().databases, explorer);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user