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

[App Search] Fixed Documents view for Editor and Analyst roles #103113

Merged
merged 6 commits into from
Jun 24, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@
"@elastic/maki": "6.3.0",
"@elastic/node-crypto": "1.2.1",
"@elastic/numeral": "^2.5.1",
"@elastic/react-search-ui": "^1.5.1",
"@elastic/react-search-ui": "^1.6.0",
"@elastic/request-crypto": "1.1.4",
"@elastic/safer-lodash-set": "link:bazel-bin/packages/elastic-safer-lodash-set",
"@elastic/search-ui-app-search-connector": "^1.5.0",
"@elastic/search-ui-app-search-connector": "^1.6.0",
"@elastic/ui-ace": "0.2.3",
"@hapi/accept": "^5.0.2",
"@hapi/boom": "^9.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { i18n } from '@kbn/i18n';

import './search_experience.scss';

import { externalUrl } from '../../../../shared/enterprise_search_url';
import { HttpLogic } from '../../../../shared/http';
import { useLocalStorage } from '../../../../shared/use_local_storage';
import { EngineLogic } from '../../engine';

Expand Down Expand Up @@ -52,7 +52,8 @@ const DEFAULT_SORT_OPTIONS: SortOption[] = [

export const SearchExperience: React.FC = () => {
const { engine } = useValues(EngineLogic);
const endpointBase = externalUrl.enterpriseSearchUrl;
const { http } = useValues(HttpLogic);
const endpointBase = http.basePath.prepend('/api/app_search/search-ui');
Copy link
Contributor

Choose a reason for hiding this comment

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

nice find on this! 💯


const [showCustomizationModal, setShowCustomizationModal] = useState(false);
const openCustomizationModal = () => setShowCustomizationModal(true);
Expand All @@ -72,7 +73,9 @@ export const SearchExperience: React.FC = () => {
cacheResponses: false,
endpointBase,
engineName: engine.name,
searchKey: engine.apiKey,
additionalHeaders: {
'kbn-xsrf': true,
},
Comment on lines +76 to +78
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly awesome find, hope this wasn't a huge headache to figure out 🤔

});

const searchProviderConfig = buildSearchUIConfig(connector, engine.schema || {}, fields);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import { schema } from '@kbn/config-schema';

import { skipBodyValidation } from '../../lib/route_config_helpers';

import { RouteDependencies } from '../../plugin';

export function registerSearchRoutes({
Expand All @@ -36,4 +38,25 @@ export function registerSearchRoutes({
path: '/api/as/v1/engines/:engineName/search.json',
})
);

// For the Search UI routes below, Search UI always uses the full API path, like:
// "/api/as/v1/engines/{engineName}/search.json". We only have control over the base path
// in Search UI, so we created a common basepath of "/api/app_search/search-ui" here that
// Search UI can use.
//
// Search UI *also* uses the click tracking and query suggestion endpoints, however, since the
// App Search plugin doesn't use that portion of Search UI, we only set up a proxy for the search endpoint below.
Comment on lines +47 to +48
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I think my brain's a little fried this morning but just want to confirm I'm understanding this comment. By us not explicitly providing the click tracking and query suggestion routes in this PR, Search UI will no longer hit those endpoints. Is that correct?

Copy link
Contributor

@cee-chen cee-chen Jun 23, 2021

Choose a reason for hiding this comment

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

From my own testing:

  • It looks like Analytics search/query events are still getting logged
  • However, Analytics click events are not getting logged, leading to inaccurate Analytics results when only using the dashboard
  • It also it looks like API events are no longer getting logged, although this could be my local behaving strangely

@JasonStoltz I think the click event thing is potentially a blocker unfortunately, it prevents us from QAing Analytics accurately using the Documents view (important for things like E2E testing also). Is there any way we can update Search UI to either track clicks again, or (another option if that's easier) to completely not affect Analytics whatsoever?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just want to add also: I personally don't think this fix needs to get in by 7.14FF (or it's also OK if we take a little longer and get it in past FF, since it's a bugfix). It's been broken on ent-search for several minors now, and this is shipping as a beta UI, so comes with even less support - so I'm OK taking a little longer to figure this out for the long term and to help solidify our E2E tests.

This may even be a decent time also to discuss/address the tech debt item we've discussed in the past about whether dashboard API calls should count towards Analytics/API events or not.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, I think my brain's a little fried this morning but just want to confirm I'm understanding this comment. By us not explicitly providing the click tracking and query suggestion routes in this PR, Search UI will no longer hit those endpoints. Is that correct?

Documents view is not configured to use click tracking or query suggestions. Since it never hits those endpoints, we do not need to create proxy endpoints here.

It looks like Analytics search/query events are still getting logged

We should fix this, I don't think they should be logged

However, Analytics click events are not getting logged, leading to inaccurate Analytics results when only using the dashboard

I think the endgame is to not log any of these queries or clicks.

It also it looks like API events are no longer getting logged, although this could be my local behaving strangely

I don't know anything about that.

I think the click event thing is potentially a blocker unfortunately, it prevents us from QAing Analytics accurately using the Documents view (important for things like E2E testing also).

That behavior isn't introduced in this PR, so I don't think this is a blocker for this PR. It is a separate issue entirely.

Is there any way we can update Search UI to either track clicks again, or (another option if that's easier) to completely not affect Analytics whatsoever?

I think the answer is the latter. Any views in the Dashboard that hit the search endpoint Query Tester, Curations, Documents View ... none of them should be logging Analytics events, they don't provide any value to the user. This is something we discussed as part of the Search UI view transition.

I'd propose a simple header that indicates "this request should not be tracked".

Just want to add also: I personally don't think this fix needs to get in by 7.14FF (or it's also OK if we take a little longer and get it in past FF, since it's a bugfix). It's been broken on ent-search for several minors now, and this is shipping as a beta UI, so comes with even less support - so I'm OK taking a little longer to figure this out for the long term and to help solidify our E2E tests.

Just highlighting again that this PR is completely decoupled from that issue. If we want to enable click tracking we can, we just need to add a proxy endpoint for the click API route.

I think we should get this merged and fixed and handle analytics separately. I'm happy to create an issue for it in our backlog.

Copy link
Contributor

@cee-chen cee-chen Jun 23, 2021

Choose a reason for hiding this comment

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

That behavior isn't introduced in this PR, so I don't think this is a blocker for this PR. It is a separate issue entirely.

To be clear, it is introduced by this PR (I'm not sure why though). It's not a separate issue unfortunately.

On Kibana master and on ent-search, you can do the following:

  1. Go to the Documents view
  2. Type in "park" (or any search that has results)
  3. Click on any document
  4. Go to Analytics
  • Confirm that your "park" query shows up in Analytics in "Top queries" and in "Top queries with clicks" indicating that the click event triggered

On this branch, if you repeat the above 4 steps the "Top queries with clicks" panel does not update, indicating that click events stopped being recorded.

Unfortunately, even if this is a side effect of this PR, it's not one I feel 100% comfortable creating so close to FF since it's a distinct deviation from how ent-search currently behaves. FWIW, I do agree the best long term solution is to not have any dashboard actions show up in either Analytics or API logs - I'd just like to take the extra effort to get that in if possible 🤔

Copy link
Contributor

@cee-chen cee-chen Jun 23, 2021

Choose a reason for hiding this comment

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

I think we should get this merged and fixed and handle analytics separately. I'm happy to create an issue for it in our backlog.

Sorry, should have addressed this too. I'm OK with merging this in now only if we commit to fully handling (i.e., ignoring) dashboard analytics before 7.14 (so I guess after FF but before release). Otherwise, I think we should wait for 7.15. I really really worry about releasing this to 7.14 with an entire Analytics category (queries with clicks) incorrectly affected by our own dashboard in a way that it has not done so previously.

Would definitely appreciate it if you could try to repro my above steps and confirm behavior in master vs this branch! If I'm totally wrong about what's happening and click events are still being logged, then I'm GTG on this

Copy link
Member Author

Choose a reason for hiding this comment

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

I cannot reproduce.

Both on master kibana and this branch, clicking on a link will not send click data.

Inspect the network tab and you'll see for yourself, no API call is being made.

We did track these clicks in ent-search.

We do not, and never have tracked click analytics in the Documents view within Kibana. This PR does not change that. It doesn't prevent us from doing it in the future either. This PR is completely decoupled from your Analytics concern.

Whether we merge this PR or don't, it has no impact on Analytics.

Copy link
Contributor

Choose a reason for hiding this comment

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

Gah, yup, you're totally right. I just tried again on Kibana master with a fresh instance and clicks aren't showing up. Not sure if I was in a horrible fever dream, if my local elasticsearch instance got messed up, or if I got confused with ent-search 😰 (or all of the above?)

Thanks so much for taking the extra time to repro and confirm for me, I really appreciate that. Going to ahead and approve, and bring up filtering out dashboard analytics at next week's sync

Copy link
Contributor

Choose a reason for hiding this comment

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

After some thought I feel like the above comment does not convey my feeling of "Sorry for being totally wrong" enough so I'll fall back to my normal communication crutch of funny gifs

Copy link
Member Author

Choose a reason for hiding this comment

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

Haha, thanks for calling it out. Better to call it out and be wrong than say nothing.

We can definitely solve this Analytics thing. Maybe just enable click analytics for 7.14 and remove all analytics for 7.15.

router.post(
skipBodyValidation({
path: '/api/app_search/search-ui/api/as/v1/engines/{engineName}/search.json',
Copy link
Contributor

Choose a reason for hiding this comment

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

Actually sorry, just wanted to leave a comment on this: do we really need to version this or make it look exactly like AS's endpoint? Any thoughts on

Suggested change
path: '/api/app_search/search-ui/api/as/v1/engines/{engineName}/search.json',
path: '/api/app_search/engines/{engineName}/search-ui/search.json',

Instead to better match our other Kibana API endpoints?

Copy link
Member Author

@JasonStoltz JasonStoltz Jun 23, 2021

Choose a reason for hiding this comment

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

Sorry, I wondered if my comment above wasn't clear, I think this is evidence that it was not.

Search UI always posts its search query to:
{whatever base path you provide in configuration}/api/as/v1/engines/{engineName}/search.json.

EDIT: So yes, the last part of this path DOES need to match exactly, unfortunately.

I could update Search UI and the javascript client to accept a full path as configuration, and not just the base path, but that would be the long fix. I didn't anticipate this issue the last time I updated search-ui.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ohhh gotcha gotcha. No worries in that case, my bad for failing to understand!

Copy link
Member Author

Choose a reason for hiding this comment

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

It's not your bad, it's mine for poor writing 😢

validate: {
params: schema.object({
engineName: schema.string(),
}),
},
}),
enterpriseSearchRequestHandler.createRequest({
path: '/api/as/v1/engines/:engineName/search.json',
})
);
}
49 changes: 24 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1147,7 +1147,7 @@
dependencies:
regenerator-runtime "^0.12.0"

"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.10.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.14.0", "@babel/runtime@^7.3.1", "@babel/runtime@^7.4.4", "@babel/runtime@^7.4.5", "@babel/runtime@^7.5.0", "@babel/runtime@^7.5.4", "@babel/runtime@^7.5.5", "@babel/runtime@^7.6.2", "@babel/runtime@^7.6.3", "@babel/runtime@^7.7.2", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2":
"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.10.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.14.0", "@babel/runtime@^7.3.1", "@babel/runtime@^7.4.4", "@babel/runtime@^7.4.5", "@babel/runtime@^7.5.0", "@babel/runtime@^7.5.5", "@babel/runtime@^7.6.2", "@babel/runtime@^7.6.3", "@babel/runtime@^7.7.2", "@babel/runtime@^7.7.6", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2":
version "7.14.5"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.14.5.tgz#665450911c6031af38f81db530f387ec04cd9a98"
integrity sha512-121rumjddw9c3NCQ55KGkyE1h/nzWhU/owjhw0l4mQrkzz4x9SGS1X8gFLraHwX7td3Yo4QTL+qj0NcIzN87BA==
Expand Down Expand Up @@ -1352,10 +1352,10 @@
dependencies:
"@elastic/apm-rum-core" "^5.11.0"

"@elastic/app-search-javascript@^7.3.0":
version "7.8.0"
resolved "https://registry.yarnpkg.com/@elastic/app-search-javascript/-/app-search-javascript-7.8.0.tgz#cbc7af6bcdd224518f7f595145d6ec744e0b165d"
integrity sha512-EsAa/E/dQwBO72nrQ9YrXudP9KVY0sVUOvqPKZ3hBj9Mr3+MtWMyIKcyMf09bzdayk4qE+moetYDe5ahVbiA+Q==
"@elastic/app-search-javascript@^7.13.1":
version "7.13.1"
resolved "https://registry.yarnpkg.com/@elastic/app-search-javascript/-/app-search-javascript-7.13.1.tgz#07d84daa27e856ad14f3f840683288eab06577f4"
integrity sha512-ShzZtGWykLQ0+wXzfk6lJztv68fRcGa8rsLDxJLH/O/2CGY+PJDnj8Qu5lJPmsAPZlZgaB8u7l26YGVPOoaqSA==
dependencies:
object-hash "^1.3.0"

Expand Down Expand Up @@ -1538,22 +1538,22 @@
resolved "https://registry.yarnpkg.com/@elastic/numeral/-/numeral-2.5.1.tgz#96acf39c3d599950646ef8ccfd24a3f057cf4932"
integrity sha512-Tby6TKjixRFY+atVNeYUdGr9m0iaOq8230KTwn8BbUhkh7LwozfgKq0U98HRX7n63ZL62szl+cDKTYzh5WPCFQ==

"@elastic/react-search-ui-views@1.5.1":
version "1.5.1"
resolved "https://registry.yarnpkg.com/@elastic/react-search-ui-views/-/react-search-ui-views-1.5.1.tgz#766cd6b6049f7aa8ab711a6a3a4a060ee5fdd0ce"
integrity sha512-x4X2xc/69996IEId3VVBTwPICnx/sschnfQ6YmuU3+myRa+VUPkkAWIK/cBcyBW8TNsLtZHWZrjQYi24+H7YWA==
"@elastic/react-search-ui-views@1.6.0":
version "1.6.0"
resolved "https://registry.yarnpkg.com/@elastic/react-search-ui-views/-/react-search-ui-views-1.6.0.tgz#7211d47c29ef0636c853721491b9905ac7ae58da"
integrity sha512-VADJ18p8HoSPtxKEWFODzId08j0ahyHmHjXv1vP6O/PvtA+ECvi0gDSh/WgdRF792G0e+4d2Dke8LIhxaEvE+w==
dependencies:
downshift "^3.2.10"
rc-pagination "^1.20.1"
react-select "^2.4.4"

"@elastic/react-search-ui@^1.5.1":
version "1.5.1"
resolved "https://registry.yarnpkg.com/@elastic/react-search-ui/-/react-search-ui-1.5.1.tgz#2c261226d2eda3834b4779fbeea5693958169ff2"
integrity sha512-SI7uOF+jI+Z2D+2otym+4eLBYnocmxa+NA6VPSBrADZXyn8oUEzA4MBtJtxHLtcj64Tj8Riv0tw3t9q3b8iF+w==
"@elastic/react-search-ui@^1.6.0":
version "1.6.0"
resolved "https://registry.yarnpkg.com/@elastic/react-search-ui/-/react-search-ui-1.6.0.tgz#8d547d5e1f0a8eebe94798b29966f51643aa886f"
integrity sha512-bwSKuCQTQiBWr6QufQtZZGu6rcVYfoiUnyZbwZMS6ojedd5XY7FtMcE+QnR6/IIo0M2IUrxD74XtVNqkUhoCRg==
dependencies:
"@elastic/react-search-ui-views" "1.5.1"
"@elastic/search-ui" "1.5.1"
"@elastic/react-search-ui-views" "1.6.0"
"@elastic/search-ui" "1.6.0"

"@elastic/request-crypto@1.1.4":
version "1.1.4"
Expand All @@ -1568,18 +1568,17 @@
version "0.0.0"
uid ""

"@elastic/search-ui-app-search-connector@^1.5.0":
version "1.5.0"
resolved "https://registry.yarnpkg.com/@elastic/search-ui-app-search-connector/-/search-ui-app-search-connector-1.5.0.tgz#d379132c5015775acfaee5322ec019e9c0559ccc"
integrity sha512-lHuXBjaMaN1fsm1taQMR/7gfpAg4XOsvZOi8u1AoufUw9kGr6Xc00Gznj1qTyH0Qebi2aSmY0NBN6pdIEGvvGQ==
"@elastic/search-ui-app-search-connector@^1.6.0":
version "1.6.0"
resolved "https://registry.yarnpkg.com/@elastic/search-ui-app-search-connector/-/search-ui-app-search-connector-1.6.0.tgz#faf1c4a384285648ef7b5ef9cd0e65de0341d2b0"
integrity sha512-6oNvqzo4nuutmCM0zEzYrV6VwG8j0ML43SkaG6UrFzLUd6DeWUVGNN+SLNAlfQDWBUjc2m5EGvgdk/0GOWDZeA==
dependencies:
"@babel/runtime" "^7.5.4"
"@elastic/app-search-javascript" "^7.3.0"
"@elastic/app-search-javascript" "^7.13.1"

"@elastic/search-ui@1.5.1":
version "1.5.1"
resolved "https://registry.yarnpkg.com/@elastic/search-ui/-/search-ui-1.5.1.tgz#14c66a66f5e937ef5e24d6266620b49d986fb3ed"
integrity sha512-ssfvX1q76X1UwqYASWtBni4PZ+3SYk1PvHmOjpVf9BYai1OqZLGVaj8Sw+cE1ia56zl5In7viCfciC+CP31ovA==
"@elastic/search-ui@1.6.0":
version "1.6.0"
resolved "https://registry.yarnpkg.com/@elastic/search-ui/-/search-ui-1.6.0.tgz#8b2286cacff44735be96605b2929ca9b469c78de"
integrity sha512-i7htjET9uE4xngyzS8kX3DkSD5XNcr+3FS0Jjx3xRpKVc/dFst4bJyiSeRrQcq+2oBb4mEJJOCFaIrLZg3mdSA==
dependencies:
date-fns "^1.30.1"
deep-equal "^1.0.1"
Expand Down