Skip to content
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

[cloud] Create IFRAME chat component; add to Unified Integrations #123772

Merged
merged 13 commits into from
Jan 31, 2022

Conversation

clintandrewhall
Copy link
Contributor

@clintandrewhall clintandrewhall commented Jan 25, 2022

Summary

Based on the code and feedback from #123339

This PR creates the Chat component for Cloud and adds it to Unified Integrations.

Screen Shot 2022-01-26 at 3 37 56 PM

Screen Shot 2022-01-26 at 3 38 48 PM

Testing

You can test the component in Storybook: /kibana yarn storybook cloud

You can also test locally by adding the following to kibana.dev.yml:

xpack.cloud.id: "some-id"
xpack.cloud.chat.enabled: true
xpack.cloud.chat.chatURL: "https://elasticcloud-production-chat-us-east-1.s3.amazonaws.com/drift-iframe.html"
xpack.cloud.chatIdentitySecret: "some-secret" <- you have to get this from the Drift Widget Security console

Integration tests can be run by adding CHAT_URL and CHAT_IDENTITY_SECRET to both the functional test server and runner:

CHAT_URL="some-url" CHAT_IDENTITY_SECRET="some-secret" node scripts/functional_tests_server.js --config x-pack/test/cloud_integration/config.ts
CHAT_URL="some-url" CHAT_IDENTITY_SECRET="some-secret" node scripts/functional_test_runner.js --config x-pack/test/cloud_integration/config.ts

@clintandrewhall clintandrewhall added WIP Work in progress Team:Cloud v8.1.0 Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) labels Jan 25, 2022
@clintandrewhall clintandrewhall requested review from a team as code owners January 25, 2022 22:26
@botelastic botelastic bot added the Team:Fleet Team label for Observability Data Collection Fleet team label Jan 25, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@clintandrewhall clintandrewhall marked this pull request as draft January 25, 2022 22:26
@clintandrewhall clintandrewhall added the release_note:skip Skip the PR/issue when compiling release notes label Jan 25, 2022
Copy link
Member

@lukeelmers lukeelmers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass; added a handful of comments with some ideas on how to simplify. I'm admittedly not a storybook expert, so I focused mainly on the rest of the changes to cloud.

Still needs tests, but overall I think it makes sense so far.

x-pack/plugins/cloud/.storybook/decorator.tsx Outdated Show resolved Hide resolved
x-pack/plugins/cloud/.storybook/decorator.tsx Outdated Show resolved Hide resolved
Comment on lines +8 to +10
import { defaultConfig } from '@kbn/storybook';

module.exports = defaultConfig;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit

Suggested change
import { defaultConfig } from '@kbn/storybook';
module.exports = defaultConfig;
export { defaultConfig } from '@kbn/storybook';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FFR: Storybook crashes if you do this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really? interesting

x-pack/plugins/cloud/public/plugin.tsx Outdated Show resolved Hide resolved
x-pack/plugins/cloud/public/plugin.tsx Outdated Show resolved Hide resolved
x-pack/plugins/cloud/server/util/generate_jwt.ts Outdated Show resolved Hide resolved
x-pack/plugins/fleet/kibana.json Outdated Show resolved Hide resolved
x-pack/plugins/cloud/public/plugin.tsx Outdated Show resolved Hide resolved
x-pack/plugins/cloud/public/plugin.tsx Outdated Show resolved Hide resolved
x-pack/plugins/cloud/public/index.ts Outdated Show resolved Hide resolved
@clintandrewhall
Copy link
Contributor Author

@elasticmachine merge upstream

@SergeyPoluektov
Copy link
Contributor

SergeyPoluektov commented Jan 28, 2022

@osmanis To be clear, you're saying Drift has all it needs to hide the chat iframe without Kibana sending any additional information? Because, at present, the chat icon always appears. It doesn't appear that any rules are currently in place to not display it.

@clintandrewhall I can confirm that Drift already will have all the user data it needs to control the chat display logic by the time a user visits Kibana. We assume that a user visits Kibana after they visit Cloud UI and a user in Kibana has the same email as a user in Cloud UI. In that case we already have sent all the relevant data over to Drift (trial status, domain, etc). And at the moment a user visits Kibana we send a user's email to a Drift as a part of SET_CONTEXT message. That means that Drift can match a user up by email and apply predefined rules to display or hide a chat in Kibana.

At present the chat icon always appears because there is a playbook in Drift matching a visitor context (see screenshot).
image

If we remove that playbook, then no playbook is matched, then no chat icon displayed in Kibana.

@clintandrewhall
Copy link
Contributor Author

clintandrewhall commented Jan 28, 2022

@pgayvallet I started with its own plugin in #123339. 🤷

It's going to be placed in a few plugins, yes. I think if we hit a circular dependency, we'll have to extract it out. I'll take a look when I'm back at my desk, see if we have a conflict.

Thank you so much for your review, as well!!

@lukeelmers
Copy link
Member

I started with its own plugin in #123339. 🤷

It's going to be placed in a few plugins, yes. I think if we hit a circular dependency, we'll have to extract it out. I'll take a look when I'm back at my desk, see if we have a conflict.

I had advocated for keeping this centralized in the Cloud plugin until we have an agreed-upon long term plan (Clint is cooking up an RFC for that). My reasoning was mainly that we could have 3rd party code -- Fullstory & Drift -- living in one place in Kibana, which would make it very clear to on-prem users where cloud-specific code lives, and give us some assurance that this code would never run unless explicitly configured in a cloud deployment.

But I agree that eventually we'll need a generalized solution for handling 3rd party code in Kibana, and due to the existing cloud plugin dependencies, this may need to be its own plugin.

@clintandrewhall
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine kibanamachine requested a review from a team as a code owner January 28, 2022 17:28
@pgayvallet
Copy link
Contributor

It's going to be placed in a few plugins, yes. I think if we hit a circular dependency, we'll have to extract it out

But I agree that eventually we'll need a generalized solution for handling 3rd party code in Kibana, and due to the existing cloud plugin dependencies, this may need to be its own plugin.

Keeping it in the cloud plugin until we encounter such cyclic dependencies issues is fine with me, I just wanted to point this out in case it was overlooked in the design decision.

@clintandrewhall
Copy link
Contributor Author

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
cloud 11 18 +7

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
cloud 22 23 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
cloud 12.3KB 14.2KB +1.9KB
fleet 644.5KB 644.7KB +192.0B
total +2.1KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
cloud 6.5KB 8.5KB +2.0KB
fleet 112.8KB 113.0KB +223.0B
total +2.2KB
Unknown metric groups

API count

id before after diff
cloud 22 28 +6

async chunk count

id before after diff
cloud 1 2 +1

ESLint disabled line counts

id before after diff
actions 27 25 -2
cloud 5 7 +2
total -0

References to deprecated APIs

id before after diff
cloud 1 2 +1

Total ESLint disabled count

id before after diff
actions 32 30 -2
cloud 7 9 +2
total -0

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Member

@lukeelmers lukeelmers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall I am comfortable with where we ended up on this. Thanks for all your patience @clintandrewhall ❤️

Could we wait to merge until Monday afternoon (NASA time) so that @pgayvallet has an opportunity to provide any remaining feedback he may have?

x-pack/plugins/cloud/public/plugin.test.ts Show resolved Hide resolved
Copy link
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the observable changes

Copy link
Contributor

@ymao1 ymao1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResponseOps changes LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Feature:Chat The integration of Live Chat (Drift) into Kibana. impact:high Addressing this issue will have a high level of impact on the quality/strength of our product. loe:medium Medium Level of Effort release_note:skip Skip the PR/issue when compiling release notes review Team:Cloud Team:Fleet Team label for Observability Data Collection Fleet team Team:SharedUX Team label for AppEx-SharedUX (formerly Global Experience) v8.1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet