Update logic for NPS survey for existing accounts > 90 days (#1725)

* Update logic for NPS survey for existing accounts > 90 days

* Remove lint error

* Address comments

* Fix error in code
This commit is contained in:
sindhuba 2024-01-19 07:08:11 -08:00 committed by GitHub
parent 0975591945
commit 5a5bf34d4d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 12 deletions

View File

@ -277,10 +277,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 THREE_DAYS_IN_MS = 259200000;
const isAccountNewerThanNinetyDays = isAccountNewerThanThresholdInMs(
userContext.databaseAccount?.systemData?.createdAt || "",
NINETY_DAYS_IN_MS,
);
const lastSubmitted: string = localStorage.getItem("lastSubmitted"); const lastSubmitted: string = localStorage.getItem("lastSubmitted");
if (lastSubmitted !== null) { if (lastSubmitted !== null) {
@ -302,17 +298,11 @@ export default class Explorer {
this.sendNPSMessage(); this.sendNPSMessage();
} }
} 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. // Show survey when an existing account is older than 3 days
if ( if (
!isAccountNewerThanThresholdInMs(userContext.databaseAccount?.systemData?.createdAt || "", THREE_DAYS_IN_MS) && !isAccountNewerThanThresholdInMs(userContext.databaseAccount?.systemData?.createdAt || "", THREE_DAYS_IN_MS)
isAccountNewerThanNinetyDays
) { ) {
this.sendNPSMessage(); this.sendNPSMessage();
} else {
// 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();
}
} }
} }
} }