mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-01-24 04:04:13 +00:00
Compare commits
14 Commits
2817454
...
copilot_pu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
497d82a88c | ||
|
|
da09ba671c | ||
|
|
6e1b104b72 | ||
|
|
5433d61bd8 | ||
|
|
feba77e2bf | ||
|
|
22ce69d20c | ||
|
|
d862b929ec | ||
|
|
e626f5218d | ||
|
|
58aff4f07b | ||
|
|
e406bf8190 | ||
|
|
45bd16e17f | ||
|
|
7d557df4e0 | ||
|
|
b4d6ad172b | ||
|
|
a12e8b050f |
@@ -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,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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 });
|
||||||
|
|||||||
@@ -53,9 +53,7 @@ export const WelcomeModal = ({ visible }: { visible: boolean }): JSX.Element =>
|
|||||||
</Stack>
|
</Stack>
|
||||||
<Stack horizontalAlign="center">
|
<Stack horizontalAlign="center">
|
||||||
<Stack.Item align="center" style={{ textAlign: "center" }}>
|
<Stack.Item align="center" style={{ textAlign: "center" }}>
|
||||||
<Text className="title bold" as={"h1"}>
|
<Text className="title bold">Welcome to Microsoft Copilot for Azure in Cosmos DB (preview)</Text>
|
||||||
Welcome to Microsoft Copilot for Azure in Cosmos DB (preview)
|
|
||||||
</Text>
|
|
||||||
</Stack.Item>
|
</Stack.Item>
|
||||||
<Stack.Item align="center" className="text">
|
<Stack.Item align="center" className="text">
|
||||||
<Stack horizontal>
|
<Stack horizontal>
|
||||||
|
|||||||
@@ -76,7 +76,6 @@ exports[`Query Copilot Welcome Modal snapshot test should render when isOpen is
|
|||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Text
|
<Text
|
||||||
as="h1"
|
|
||||||
className="title bold"
|
className="title bold"
|
||||||
>
|
>
|
||||||
Welcome to Microsoft Copilot for Azure in Cosmos DB (preview)
|
Welcome to Microsoft Copilot for Azure in Cosmos DB (preview)
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user