mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-01-10 21:19:08 +00:00
Compare commits
5 Commits
copilot_pu
...
2817454
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
275dd6e199 | ||
|
|
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 });
|
||||||
|
|||||||
@@ -53,7 +53,9 @@ 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">Welcome to Microsoft Copilot for Azure in Cosmos DB (preview)</Text>
|
<Text className="title bold" as={"h1"}>
|
||||||
|
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,6 +76,7 @@ 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) {
|
||||||
throw new Error(await response?.text());
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const copilotPortalConfiguration = (await response?.json()) as CopilotEnabledConfiguration;
|
const copilotPortalConfiguration = (await response?.json()) as CopilotEnabledConfiguration;
|
||||||
|
|||||||
@@ -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