Compare commits

..

14 Commits

Author SHA1 Message Date
Sung-Hyun Kang (from Dev Box)
497d82a88c Merge remote-tracking branch 'origin/master' into copilot_publicpreview 2023-11-10 18:43:55 -06:00
Sung-Hyun Kang (from Dev Box)
da09ba671c Updated the endpoint 2023-11-10 18:41:40 -06:00
Sung-Hyun Kang (from Dev Box)
6e1b104b72 don't call ARM when connectionstring login 2023-11-10 15:55:28 -06:00
Sung-Hyun Kang (from Dev Box)
5433d61bd8 fix formatting 2023-11-10 15:31:53 -06:00
Sung-Hyun Kang (from Dev Box)
feba77e2bf fix formatting 2023-11-10 15:27:33 -06:00
Sung-Hyun Kang (from Dev Box)
22ce69d20c fix formatting 2023-11-10 15:23:54 -06:00
Sung-Hyun Kang (from Dev Box)
d862b929ec fix formatting 2023-11-10 15:18:51 -06:00
Sung-Hyun Kang (from Dev Box)
e626f5218d increase test timeout 2023-11-10 15:15:28 -06:00
Sung-Hyun Kang (from Dev Box)
58aff4f07b add timeout for ARM calls 2023-11-10 15:04:27 -06:00
Sung-Hyun Kang (from Dev Box)
e406bf8190 Update branding and AFEC 2023-11-10 12:44:47 -06:00
Sung-Hyun Kang (from Dev Box)
45bd16e17f Update branding and AFEC 2023-11-10 11:47:11 -06:00
Sung-Hyun Kang (from Dev Box)
7d557df4e0 P1 bugs for copilot 2023-11-09 20:43:43 -06:00
Sung-Hyun Kang (from Dev Box)
b4d6ad172b P1 bugs for copilot 2023-11-09 20:38:14 -06:00
Sung-Hyun Kang (from Dev Box)
a12e8b050f P1 bugs for copilot 2023-11-09 20:36:26 -06:00
10 changed files with 37 additions and 45 deletions

View File

@@ -148,6 +148,9 @@ 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,
}; };

View File

@@ -275,7 +275,6 @@ 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,
@@ -295,32 +294,32 @@ export default class Explorer {
} }
} }
// Try Cosmos DB subscription - survey shown to 100% of users at day 1 in Data Explorer. // Try Cosmos DB subscription - survey shown to random 25% of users at day 1 in Data Explorer.
if (userContext.isTryCosmosDBSubscription) { if (userContext.isTryCosmosDBSubscription) {
if (isAccountNewerThanThresholdInMs(userContext.databaseAccount?.systemData?.createdAt || "", ONE_DAY_IN_MS)) { if (
this.sendNPSMessage(); isAccountNewerThanThresholdInMs(userContext.databaseAccount?.systemData?.createdAt || "", ONE_DAY_IN_MS) &&
this.getRandomInt(100) < 25
) {
sendMessage({ type: MessageTypes.DisplayNPSSurvey });
localStorage.setItem("lastSubmitted", Date.now().toString());
} }
} else { } else {
// 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. // An existing account is lesser than 90 days old. For existing account show to random 10 % of users in Data Explorer.
if ( if (isAccountNewerThanNinetyDays) {
!isAccountNewerThanThresholdInMs(userContext.databaseAccount?.systemData?.createdAt || "", THREE_DAYS_IN_MS) && if (this.getRandomInt(100) < 10) {
isAccountNewerThanNinetyDays sendMessage({ type: MessageTypes.DisplayNPSSurvey });
) { localStorage.setItem("lastSubmitted", Date.now().toString());
this.sendNPSMessage(); }
} else { } else {
// An existing account is greater than 90 days. For existing account show to random 33% of users in Data Explorer. // An existing account is greater than 90 days. For existing account show to random 25 % of users in Data Explorer.
if (this.getRandomInt(100) < 33) { if (this.getRandomInt(100) < 25) {
this.sendNPSMessage(); sendMessage({ type: MessageTypes.DisplayNPSSurvey });
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;
@@ -1397,7 +1396,6 @@ export default class Explorer {
]); ]);
useQueryCopilot.getState().setCopilotEnabled(copilotEnabled); useQueryCopilot.getState().setCopilotEnabled(copilotEnabled);
useQueryCopilot.getState().setCopilotUserDBEnabled(copilotUserDBEnabled); useQueryCopilot.getState().setCopilotUserDBEnabled(copilotUserDBEnabled);
useQueryCopilot.getState().setShowWelcomeModal(window.localStorage.getItem("hideWelcomeModal") !== "true");
} }
public async refreshSampleData(): Promise<void> { public async refreshSampleData(): Promise<void> {

View File

@@ -1431,6 +1431,8 @@ 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 });

View File

@@ -336,8 +336,7 @@ exports[`AddCollectionPanel should render Default properly 1`] = `
directionalHint={4} directionalHint={4}
> >
<Icon <Icon
ariaLabel="Enable analytical store capability to perform near real-time analytics on your operational data, without ariaLabel="Enable analytical store capability to perform near real-time analytics on your operational data, without impacting the performance of transactional workloads."
impacting the performance of transactional workloads."
className="panelInfoIcon" className="panelInfoIcon"
iconName="Info" iconName="Info"
tabIndex={0} tabIndex={0}

View File

@@ -1,6 +1,5 @@
import { IconButton, Image, Link, Modal, PrimaryButton, Stack, StackItem, Text } from "@fluentui/react"; import { IconButton, Image, Link, Modal, PrimaryButton, Stack, StackItem, Text } from "@fluentui/react";
import { useBoolean } from "@fluentui/react-hooks"; import { useBoolean } from "@fluentui/react-hooks";
import { useQueryCopilot } from "hooks/useQueryCopilot";
import React from "react"; import React from "react";
import Flash from "../../../../images/CopilotFlash.svg"; import Flash from "../../../../images/CopilotFlash.svg";
import Thumb from "../../../../images/CopilotThumb.svg"; import Thumb from "../../../../images/CopilotThumb.svg";
@@ -14,11 +13,7 @@ export const WelcomeModal = ({ visible }: { visible: boolean }): JSX.Element =>
if (visible) { if (visible) {
window.localStorage.setItem("hideWelcomeModal", "true"); window.localStorage.setItem("hideWelcomeModal", "true");
} }
}, []); });
React.useEffect(() => {
useQueryCopilot.getState().setShowWelcomeModal(isModalVisible);
}, [isModalVisible]);
return ( return (
<> <>

View File

@@ -35,7 +35,7 @@ import { GenerateSQLQueryResponse, QueryCopilotProps } from "Explorer/QueryCopil
import { SamplePrompts, SamplePromptsProps } from "Explorer/QueryCopilot/Shared/SamplePrompts/SamplePrompts"; import { SamplePrompts, SamplePromptsProps } from "Explorer/QueryCopilot/Shared/SamplePrompts/SamplePrompts";
import { Action } from "Shared/Telemetry/TelemetryConstants"; import { Action } from "Shared/Telemetry/TelemetryConstants";
import { userContext } from "UserContext"; import { userContext } from "UserContext";
import { QueryCopilotState, useQueryCopilot } from "hooks/useQueryCopilot"; import { useQueryCopilot } from "hooks/useQueryCopilot";
import React, { useRef, useState } from "react"; import React, { useRef, useState } from "react";
import HintIcon from "../../../images/Hint.svg"; import HintIcon from "../../../images/Hint.svg";
import CopilotIcon from "../../../images/QueryCopilotNewLogo.svg"; import CopilotIcon from "../../../images/QueryCopilotNewLogo.svg";
@@ -72,6 +72,7 @@ export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
containerId, containerId,
}: QueryCopilotPromptProps): JSX.Element => { }: QueryCopilotPromptProps): JSX.Element => {
const [copilotTeachingBubbleVisible, { toggle: toggleCopilotTeachingBubbleVisible }] = useBoolean(false); const [copilotTeachingBubbleVisible, { toggle: toggleCopilotTeachingBubbleVisible }] = useBoolean(false);
const inputEdited = useRef(false);
const { const {
openFeedbackModal, openFeedbackModal,
hideFeedbackModalForLikedQueries, hideFeedbackModalForLikedQueries,
@@ -109,8 +110,6 @@ export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
errorMessage, errorMessage,
} = useCopilotStore(); } = useCopilotStore();
const inputEdited = useRef(!!userPrompt);
const sampleProps: SamplePromptsProps = { const sampleProps: SamplePromptsProps = {
isSamplePromptsOpen: isSamplePromptsOpen, isSamplePromptsOpen: isSamplePromptsOpen,
setIsSamplePromptsOpen: setIsSamplePromptsOpen, setIsSamplePromptsOpen: setIsSamplePromptsOpen,
@@ -275,7 +274,7 @@ export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
const showTeachingBubble = (): void => { const showTeachingBubble = (): void => {
if (!inputEdited.current) { if (!inputEdited.current) {
setTimeout(() => { setTimeout(() => {
if (!useQueryCopilot.getState().showWelcomeModal && !userPrompt && !inputEdited.current) { if (!inputEdited.current && !isWelcomModalVisible()) {
toggleCopilotTeachingBubbleVisible(); toggleCopilotTeachingBubbleVisible();
inputEdited.current = true; inputEdited.current = true;
} }
@@ -283,6 +282,10 @@ export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
} }
}; };
const isWelcomModalVisible = (): boolean => {
return localStorage.getItem("hideWelcomeModal") !== "true";
};
const clearFeedback = () => { const clearFeedback = () => {
resetButtonState(); resetButtonState();
resetQueryResults(); resetQueryResults();
@@ -302,7 +305,6 @@ export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
React.useEffect(() => { React.useEffect(() => {
showTeachingBubble(); showTeachingBubble();
useQueryCopilot.subscribe(showTeachingBubble, (state: QueryCopilotState) => state.showWelcomeModal);
useTabs.getState().setIsQueryErrorThrown(false); useTabs.getState().setIsQueryErrorThrown(false);
}, []); }, []);
@@ -589,7 +591,7 @@ export const QueryCopilotPromptbar: React.FC<QueryCopilotPromptProps> = ({
</CommandBarButton> </CommandBarButton>
</Stack> </Stack>
)} )}
<WelcomeModal visible={useQueryCopilot.getState().showWelcomeModal} /> <WelcomeModal visible={isWelcomModalVisible()} />
{isSamplePromptsOpen && <SamplePrompts sampleProps={sampleProps} />} {isSamplePromptsOpen && <SamplePrompts sampleProps={sampleProps} />}
{query !== "" && query.trim().length !== 0 && ( {query !== "" && query.trim().length !== 0 && (
<DeletePopup <DeletePopup

View File

@@ -93,7 +93,7 @@ export const getCopilotEnabled = async (): Promise<boolean> => {
} }
if (!response?.ok) { if (!response?.ok) {
return false; throw new Error(await response?.text());
} }
const copilotPortalConfiguration = (await response?.json()) as CopilotEnabledConfiguration; const copilotPortalConfiguration = (await response?.json()) as CopilotEnabledConfiguration;

View File

@@ -104,13 +104,12 @@ interface IQueryTabStates {
export const QueryTabFunctionComponent = (props: IQueryTabComponentProps): any => { export const QueryTabFunctionComponent = (props: IQueryTabComponentProps): any => {
const copilotStore = useCopilotStore(); const copilotStore = useCopilotStore();
const copilotGlobalStore = useQueryCopilot();
const isSampleCopilotActive = useSelectedNode.getState().isQueryCopilotCollectionSelected(); const isSampleCopilotActive = useSelectedNode.getState().isQueryCopilotCollectionSelected();
const queryTabProps = { const queryTabProps = {
...props, ...props,
copilotEnabled: copilotEnabled:
copilotGlobalStore.copilotEnabled && useQueryCopilot().copilotEnabled &&
(copilotGlobalStore.copilotUserDBEnabled || (isSampleCopilotActive && !!userContext.sampleDataConnectionInfo)), (useQueryCopilot().copilotUserDBEnabled || (isSampleCopilotActive && !!userContext.sampleDataConnectionInfo)),
isSampleCopilotActive: isSampleCopilotActive, isSampleCopilotActive: isSampleCopilotActive,
copilotStore: copilotStore, copilotStore: copilotStore,
}; };

View File

@@ -420,11 +420,9 @@ async function configurePortal(): Promise<Explorer> {
updateContextsFromPortalMessage(inputs); updateContextsFromPortalMessage(inputs);
explorer = new Explorer(); explorer = new Explorer();
resolve(explorer); resolve(explorer);
if (userContext.apiType === "Postgres") {
if (userContext.apiType === "Postgres" || userContext.apiType === "SQL" || userContext.apiType === "Mongo") { explorer.openNPSSurveyDialog();
setTimeout(() => explorer.openNPSSurveyDialog(), 3000);
} }
if (openAction) { if (openAction) {
handleOpenAction(openAction, useDatabases.getState().databases, explorer); handleOpenAction(openAction, useDatabases.getState().databases, explorer);
} }

View File

@@ -36,7 +36,6 @@ export interface QueryCopilotState {
generatedQueryComments: string; generatedQueryComments: string;
wasCopilotUsed: boolean; wasCopilotUsed: boolean;
showWelcomeSidebar: boolean; showWelcomeSidebar: boolean;
showWelcomeModal: boolean;
showCopilotSidebar: boolean; showCopilotSidebar: boolean;
chatMessages: CopilotMessage[]; chatMessages: CopilotMessage[];
shouldIncludeInMessages: boolean; shouldIncludeInMessages: boolean;
@@ -78,7 +77,6 @@ export interface QueryCopilotState {
setGeneratedQueryComments: (generatedQueryComments: string) => void; setGeneratedQueryComments: (generatedQueryComments: string) => void;
setWasCopilotUsed: (wasCopilotUsed: boolean) => void; setWasCopilotUsed: (wasCopilotUsed: boolean) => void;
setShowWelcomeSidebar: (showWelcomeSidebar: boolean) => void; setShowWelcomeSidebar: (showWelcomeSidebar: boolean) => void;
setShowWelcomeModal: (showWelcomeModal: boolean) => void;
setShowCopilotSidebar: (showCopilotSidebar: boolean) => void; setShowCopilotSidebar: (showCopilotSidebar: boolean) => void;
setChatMessages: (chatMessages: CopilotMessage[]) => void; setChatMessages: (chatMessages: CopilotMessage[]) => void;
setShouldIncludeInMessages: (shouldIncludeInMessages: boolean) => void; setShouldIncludeInMessages: (shouldIncludeInMessages: boolean) => void;
@@ -124,7 +122,6 @@ export const useQueryCopilot: QueryCopilotStore = create((set) => ({
generatedQueryComments: "", generatedQueryComments: "",
wasCopilotUsed: false, wasCopilotUsed: false,
showWelcomeSidebar: true, showWelcomeSidebar: true,
showWelcomeModal: true,
showCopilotSidebar: false, showCopilotSidebar: false,
chatMessages: [], chatMessages: [],
shouldIncludeInMessages: true, shouldIncludeInMessages: true,
@@ -177,7 +174,6 @@ export const useQueryCopilot: QueryCopilotStore = create((set) => ({
setGeneratedQueryComments: (generatedQueryComments: string) => set({ generatedQueryComments }), setGeneratedQueryComments: (generatedQueryComments: string) => set({ generatedQueryComments }),
setWasCopilotUsed: (wasCopilotUsed: boolean) => set({ wasCopilotUsed }), setWasCopilotUsed: (wasCopilotUsed: boolean) => set({ wasCopilotUsed }),
setShowWelcomeSidebar: (showWelcomeSidebar: boolean) => set({ showWelcomeSidebar }), setShowWelcomeSidebar: (showWelcomeSidebar: boolean) => set({ showWelcomeSidebar }),
setShowWelcomeModal: (showWelcomeModal: boolean) => set({ showWelcomeModal }),
setShowCopilotSidebar: (showCopilotSidebar: boolean) => set({ showCopilotSidebar }), setShowCopilotSidebar: (showCopilotSidebar: boolean) => set({ showCopilotSidebar }),
setChatMessages: (chatMessages: CopilotMessage[]) => set({ chatMessages }), setChatMessages: (chatMessages: CopilotMessage[]) => set({ chatMessages }),
setShouldIncludeInMessages: (shouldIncludeInMessages: boolean) => set({ shouldIncludeInMessages }), setShouldIncludeInMessages: (shouldIncludeInMessages: boolean) => set({ shouldIncludeInMessages }),