-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[drift] Determine if trial is active (plus buffer) before showing cha…
…t. (#151548) ## Summary In-app chat should only be enabled in Cloud if a trial is still active. #143002 added metadata including `trial_end_date`. This PR: - adds a config key to `cloud_integrations` for a `trialBuffer`, in days, which defaults to ~~`30`~~ `60`. - adds logic to not display chat if the trial end date + buffer exceeds the current date. - adds logic to not add a server route if the trial end date + buffer exceeds the current date. ## Testing Locally Add the following config to `kibana.dev.yml`: ``` xpack.cloud.id: "some-id" xpack.cloud.trial_end_date: "2023-02-21T00:00:00.000Z" xpack.cloud_integrations.chat.enabled: true xpack.cloud_integrations.chat.chatURL: "https://elasticcloud-production-chat-us-east-1.s3.amazonaws.com/drift-iframe.html" xpack.cloud_integrations.chat.chatIdentitySecret: "some-secret" ``` And start Kibana. You can optionally change the default of `30` days by adding `xpack.cloud_integrations.chat.trialBuffer`. ## Storybook Run `yarn storybook cloud_chat`. ## Testing in Cloud Set the same config keys as above on a Cloud deployment.
- Loading branch information
1 parent
629b876
commit 00ab82e
Showing
9 changed files
with
183 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
x-pack/plugins/cloud_integrations/cloud_chat/common/util.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
/** | ||
* Returns true if today's date is within the an end date + buffer, false otherwise. | ||
* | ||
* @param endDate The end date of the trial. | ||
* @param buffer The number of days to add to the end date. | ||
* @returns true if today's date is within the an end date + buffer, false otherwise. | ||
*/ | ||
export const isTodayInDateWindow = (endDate: Date, buffer: number) => { | ||
const endDateWithBuffer = new Date(endDate); | ||
endDateWithBuffer.setDate(endDateWithBuffer.getDate() + buffer); | ||
return endDateWithBuffer > new Date(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters