-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[LaunchDarkly] Add Deployment Metadata #143002
Conversation
Pinging @elastic/kibana-core (Team:Core) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kibana Platform Security changes LGTM 👍
@elasticmachine merge upstream |
}, | ||
fetch: () => { | ||
return { | ||
isCloudEnabled, | ||
isElasticStaffOwned, | ||
trialEndDate, | ||
...(trialEndDate ? { inTrial: Date.now() <= new Date(trialEndDate).getTime() } : {}), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT We should extract the new Date(...)
to the outer scope, so that we don't create a new Object at each fetch()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed :)
return usageCollection.makeUsageCollector<CloudUsage>({ | ||
type: 'cloud', | ||
isReady: () => true, | ||
schema: { | ||
isCloudEnabled: { type: 'boolean' }, | ||
trialEndDate: { type: 'date' }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused here, it seems that CloudUsage
defines the trialEndDate
as a string
, whereas this schema defines it as a Date
. But then looking at the fetch it would seem that we return a string
. 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha! yeah... type: 'date'
is a string
that's supposed to have the format of a date
. It's more a declarative intention for the schema reader in the Telemetry receiving side.
@elasticmachine merge upstream |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
type: 'boolean', | ||
_meta: { | ||
description: '`true` if the owner of the deployment is an Elastician', | ||
optional: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why optional? is it only for BWC reasons on the schema?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This information comes from the cloud configuration. It may not be provided by the cloud deployment configuration (mind the schema.maybe
).
if (!this.launchDarklyClient) return defaultValue; // Skip any action if no LD User is defined | ||
await this.launchDarklyClient.waitForInitialization(); | ||
return this.launchDarklyClient.variation(configKey, defaultValue); | ||
if (!this.launchDarklyClient) return defaultValue; // Skip any action if no LD Client is defined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT/optional: code style consistency
if (!this.launchDarklyClient) {
return defaultValue;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in commit elastic/kibana@48eaafc
(#143002)
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Page load bundle
Unknown metric groupsAPI count
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @afharo |
…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.
…t. (elastic#151548) ## Summary In-app chat should only be enabled in Cloud if a trial is still active. elastic#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. (cherry picked from commit 00ab82e)
…ng chat. (#151548) (#151946) # Backport This will backport the following commits from `main` to `8.7`: - [[drift] Determine if trial is active (plus buffer) before showing chat. (#151548)](#151548) <!--- Backport version: 8.9.7 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Clint Andrew Hall","email":"clint.hall@elastic.co"},"sourceCommit":{"committedDate":"2023-02-22T21:34:44Z","message":"[drift] Determine if trial is active (plus buffer) before showing chat. (#151548)\n\n## Summary\r\n\r\nIn-app chat should only be enabled in Cloud if a trial is still active.\r\nhttps://github.com//pull/143002 added metadata including\r\n`trial_end_date`. This PR:\r\n\r\n- adds a config key to `cloud_integrations` for a `trialBuffer`, in\r\ndays, which defaults to ~~`30`~~ `60`.\r\n- adds logic to not display chat if the trial end date + buffer exceeds\r\nthe current date.\r\n- adds logic to not add a server route if the trial end date + buffer\r\nexceeds the current date.\r\n\r\n## Testing Locally\r\n\r\nAdd the following config to `kibana.dev.yml`:\r\n\r\n```\r\nxpack.cloud.id: \"some-id\"\r\nxpack.cloud.trial_end_date: \"2023-02-21T00:00:00.000Z\"\r\n\r\nxpack.cloud_integrations.chat.enabled: true\r\nxpack.cloud_integrations.chat.chatURL: \"https://elasticcloud-production-chat-us-east-1.s3.amazonaws.com/drift-iframe.html\"\r\nxpack.cloud_integrations.chat.chatIdentitySecret: \"some-secret\"\r\n```\r\n\r\nAnd start Kibana. You can optionally change the default of `30` days by\r\nadding `xpack.cloud_integrations.chat.trialBuffer`.\r\n\r\n## Storybook\r\n\r\nRun `yarn storybook cloud_chat`.\r\n\r\n## Testing in Cloud\r\n\r\nSet the same config keys as above on a Cloud deployment.","sha":"00ab82ecd7e6c0e33977d7d37b26c6d88e367fd6","branchLabelMapping":{"^v8.8.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["review","loe:hours","release_note:skip","impact:high","ci:cloud-deploy","v8.7.0","v8.8.0","Feature:Chat"],"number":151548,"url":"https://github.com/elastic/kibana/pull/151548","mergeCommit":{"message":"[drift] Determine if trial is active (plus buffer) before showing chat. (#151548)\n\n## Summary\r\n\r\nIn-app chat should only be enabled in Cloud if a trial is still active.\r\nhttps://github.com//pull/143002 added metadata including\r\n`trial_end_date`. This PR:\r\n\r\n- adds a config key to `cloud_integrations` for a `trialBuffer`, in\r\ndays, which defaults to ~~`30`~~ `60`.\r\n- adds logic to not display chat if the trial end date + buffer exceeds\r\nthe current date.\r\n- adds logic to not add a server route if the trial end date + buffer\r\nexceeds the current date.\r\n\r\n## Testing Locally\r\n\r\nAdd the following config to `kibana.dev.yml`:\r\n\r\n```\r\nxpack.cloud.id: \"some-id\"\r\nxpack.cloud.trial_end_date: \"2023-02-21T00:00:00.000Z\"\r\n\r\nxpack.cloud_integrations.chat.enabled: true\r\nxpack.cloud_integrations.chat.chatURL: \"https://elasticcloud-production-chat-us-east-1.s3.amazonaws.com/drift-iframe.html\"\r\nxpack.cloud_integrations.chat.chatIdentitySecret: \"some-secret\"\r\n```\r\n\r\nAnd start Kibana. You can optionally change the default of `30` days by\r\nadding `xpack.cloud_integrations.chat.trialBuffer`.\r\n\r\n## Storybook\r\n\r\nRun `yarn storybook cloud_chat`.\r\n\r\n## Testing in Cloud\r\n\r\nSet the same config keys as above on a Cloud deployment.","sha":"00ab82ecd7e6c0e33977d7d37b26c6d88e367fd6"}},"sourceBranch":"main","suggestedTargetBranches":["8.7"],"targetPullRequestStates":[{"branch":"8.7","label":"v8.7.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.8.0","labelRegex":"^v8.8.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/151548","number":151548,"mergeCommit":{"message":"[drift] Determine if trial is active (plus buffer) before showing chat. (#151548)\n\n## Summary\r\n\r\nIn-app chat should only be enabled in Cloud if a trial is still active.\r\nhttps://github.com//pull/143002 added metadata including\r\n`trial_end_date`. This PR:\r\n\r\n- adds a config key to `cloud_integrations` for a `trialBuffer`, in\r\ndays, which defaults to ~~`30`~~ `60`.\r\n- adds logic to not display chat if the trial end date + buffer exceeds\r\nthe current date.\r\n- adds logic to not add a server route if the trial end date + buffer\r\nexceeds the current date.\r\n\r\n## Testing Locally\r\n\r\nAdd the following config to `kibana.dev.yml`:\r\n\r\n```\r\nxpack.cloud.id: \"some-id\"\r\nxpack.cloud.trial_end_date: \"2023-02-21T00:00:00.000Z\"\r\n\r\nxpack.cloud_integrations.chat.enabled: true\r\nxpack.cloud_integrations.chat.chatURL: \"https://elasticcloud-production-chat-us-east-1.s3.amazonaws.com/drift-iframe.html\"\r\nxpack.cloud_integrations.chat.chatIdentitySecret: \"some-secret\"\r\n```\r\n\r\nAnd start Kibana. You can optionally change the default of `30` days by\r\nadding `xpack.cloud_integrations.chat.trialBuffer`.\r\n\r\n## Storybook\r\n\r\nRun `yarn storybook cloud_chat`.\r\n\r\n## Testing in Cloud\r\n\r\nSet the same config keys as above on a Cloud deployment.","sha":"00ab82ecd7e6c0e33977d7d37b26c6d88e367fd6"}}]}] BACKPORT--> Co-authored-by: Clint Andrew Hall <clint.hall@elastic.co>
Summary
This PR adds deployment metadata so we can apply better segmentation and user targeting in our Cloud Experiments A/B tests:
is_elastic_staff_owned
:true
if the owner of the deployment on Elastic Cloud is an Elastician.trial_end_date
: The date on which the Elastic Cloud trial ends/ended.in_trial
: Periodically calculated fromtrial_end_date
: it indicates if the date has expired.has_data
:true
if the deployment holds user-created Data Views. While it'sfalse
, it is periodically calculated until it turnstrue
.In order to make this implementation (and future revisions) easier, this PR introduces 2 services in the CloudExperiments plugin:
MetadataService
: it holds the user metadata and the tools for running periodical calculationsLaunchDarkly client (browser and server)
: This PR moves the LaunchDarkly specifics to internal wrappers to make CloudExperiments plugin a bit simpler. Refer to this comment, where we agreed we'll separate the plugin and client implementation.Finally, this PR also makes use of the new metadata to enrich the telemetry we send.
Resolves #140055
Checklist
Delete any items that are not applicable to this PR.
For maintainers