diff --git a/src/Explorer/Explorer.tsx b/src/Explorer/Explorer.tsx index 245a96dc8..3e6b15816 100644 --- a/src/Explorer/Explorer.tsx +++ b/src/Explorer/Explorer.tsx @@ -275,6 +275,7 @@ export default class Explorer { const NINETY_DAYS_IN_MS = 7776000000; const ONE_DAY_IN_MS = 86400000; + const THREE_DAYS_IN_MS = 259200000; const isAccountNewerThanNinetyDays = isAccountNewerThanThresholdInMs( userContext.databaseAccount?.systemData?.createdAt || "", 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 ( - isAccountNewerThanThresholdInMs(userContext.databaseAccount?.systemData?.createdAt || "", ONE_DAY_IN_MS) && - this.getRandomInt(100) < 25 - ) { - sendMessage({ type: MessageTypes.DisplayNPSSurvey }); - localStorage.setItem("lastSubmitted", Date.now().toString()); + if (isAccountNewerThanThresholdInMs(userContext.databaseAccount?.systemData?.createdAt || "", ONE_DAY_IN_MS)) { + this.sendNPSMessage(); } } else { - // An existing account is lesser than 90 days old. For existing account show to random 10 % of users in Data Explorer. - if (isAccountNewerThanNinetyDays) { - if (this.getRandomInt(100) < 10) { - sendMessage({ type: MessageTypes.DisplayNPSSurvey }); - localStorage.setItem("lastSubmitted", Date.now().toString()); - } + // 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 ( + !isAccountNewerThanThresholdInMs(userContext.databaseAccount?.systemData?.createdAt || "", THREE_DAYS_IN_MS) && + isAccountNewerThanNinetyDays + ) { + this.sendNPSMessage(); } else { - // An existing account is greater than 90 days. For existing account show to random 25 % of users in Data Explorer. - if (this.getRandomInt(100) < 25) { - sendMessage({ type: MessageTypes.DisplayNPSSurvey }); - localStorage.setItem("lastSubmitted", Date.now().toString()); + // An existing account is greater than 90 days. For existing account show to random 33% of users in Data Explorer. + if (this.getRandomInt(100) < 33) { + this.sendNPSMessage(); } } } } + private sendNPSMessage() { + sendMessage({ type: MessageTypes.DisplayNPSSurvey }); + localStorage.setItem("lastSubmitted", Date.now().toString()); + } + public async refreshDatabaseForResourceToken(): Promise { const databaseId = userContext.parsedResourceToken?.databaseId; const collectionId = userContext.parsedResourceToken?.collectionId; diff --git a/src/Explorer/Panes/AddCollectionPanel.tsx b/src/Explorer/Panes/AddCollectionPanel.tsx index 2427c46d2..2a99a56a7 100644 --- a/src/Explorer/Panes/AddCollectionPanel.tsx +++ b/src/Explorer/Panes/AddCollectionPanel.tsx @@ -1431,8 +1431,6 @@ export class AddCollectionPanel extends React.Component { updateContextsFromPortalMessage(inputs); explorer = new 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) { handleOpenAction(openAction, useDatabases.getState().databases, explorer); }