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

[Discover] Adding uiMetric to track Visualize link click #82344

Merged
merged 7 commits into from
Nov 5, 2020

Conversation

majagrubic
Copy link
Contributor

@majagrubic majagrubic commented Nov 2, 2020

Summary

As part of #58747, one of the metrics we'd like to add is "count the number of times Visualize is clicked from the field list". This PR introduces trackUiMetric to Discover and tracks metric for visualize link click.

I tested this by querying SavedObjects API:
<URL>/api/saved_objects/_find?type=ui-metric

which returned a saved object with the following structure

{
  "type":"ui-metric",
   "id":"discover:visualize_link_click",
   "attributes":{"count":3},
   "references":[],
   "updated_at":"2020-11-03T09:03:50.690Z",
   "version":"WzI3OSwxXQ==", 
   "score":0
}

Checklist

Delete any items that are not applicable to this PR.

- [ ] Any text added follows EUI's writing guidelines, uses sentence case text and includes i18n support
- [ ] Documentation was added for features that require explanation or tutorials

For maintainers

@majagrubic
Copy link
Contributor Author

@elasticmachine merge upstream

@majagrubic majagrubic changed the title [Discover] Adding uiMetric around Visualize link click [Discover] Adding uiMetric to track Visualize link click Nov 3, 2020
@majagrubic majagrubic added Team:Visualizations Visualization editors, elastic-charts and infrastructure Feature:Discover Discover Application labels Nov 3, 2020
@majagrubic majagrubic marked this pull request as ready for review November 3, 2020 09:22
@majagrubic majagrubic requested a review from a team November 3, 2020 09:22
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app (Team:KibanaApp)

@kertal
Copy link
Member

kertal commented Nov 4, 2020

ACK, will review

Copy link
Member

@kertal kertal left a comment

Choose a reason for hiding this comment

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

Tested in all browsers, works as expected 👍 Great to have telemetry in Discover. Added some minor code comments to discuss

@@ -67,6 +68,7 @@ export interface DiscoverServices {
getSavedSearchUrlById: (id: string) => Promise<string>;
getEmbeddableInjector: any;
uiSettings: IUiSettingsClient;
trackUiMetric: (metricType: UiStatsMetricType, eventName: string | string[]) => void;
Copy link
Member

Choose a reason for hiding this comment

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

I'd suggest, since trackUiMetric can be undefined, this should be considered in the type

Suggested change
trackUiMetric: (metricType: UiStatsMetricType, eventName: string | string[]) => void;
trackUiMetric?: (metricType: UiStatsMetricType, eventName: string | string[]) => void;

@@ -106,5 +113,6 @@ export async function buildServices(
timefilter: plugins.data.query.timefilter.timefilter,
toastNotifications: core.notifications.toasts,
uiSettings: core.uiSettings,
trackUiMetric,
Copy link
Member

Choose a reason for hiding this comment

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

you could save a few lines here

trackUiMetric: usageCollection?.reportUiStats.bind(usageCollection, 'discover')

* @param metricType
* @param eventName
*/
trackUiMetric: (metricType: UiStatsMetricType, eventName: string | string[]) => void;
Copy link
Member

Choose a reason for hiding this comment

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

Think, trackUiMetric should be optional

Suggested change
trackUiMetric: (metricType: UiStatsMetricType, eventName: string | string[]) => void;
trackUiMetric?: (metricType: UiStatsMetricType, eventName: string | string[]) => void;

@majagrubic
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

@kbn/optimizer bundle module count

id before after diff
discover 264 274 +10

async chunks size

id before after diff
discover 409.7KB 419.8KB +10.1KB

page load bundle size

id before after diff
discover 80.9KB 81.1KB +189.0B

History

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

Copy link
Member

@kertal kertal left a comment

Choose a reason for hiding this comment

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

Code LGTM, didn't test a second time due to only small code changes, great that Discover will provide more insights about the user behavior in the future!

@majagrubic majagrubic merged commit ef650f4 into elastic:master Nov 5, 2020
gmmorris added a commit to gmmorris/kibana that referenced this pull request Nov 5, 2020
* master: (127 commits)
  [ILM] Fix breadcrumbs (elastic#82594)
  [UX]Swap env filter with percentile (elastic#82246)
  Add platform's missing READMEs (elastic#82268)
  [Discover] Adding uiMetric to track Visualize link click (elastic#82344)
  [Search] Add used index pattern name to the search agg error field (elastic#82604)
  improve client-side SO client get pooling (elastic#82603)
  [Security Solution] Unskips Overview tests (elastic#82459)
  Embeddables/migrations (elastic#82296)
  [Enterprise Search] Refactor product server route registrations to their own files/folders (elastic#82663)
  Moving reinstall function outside of promise.all (elastic#82672)
  Load choropleth layer correctly (elastic#82628)
  Master  backport elastic#81233 (elastic#82642)
  [Fleet] Allow snake cased Kibana assets (elastic#77515)
  Reduce saved objects authorization checks (elastic#82204)
  [data.search] Add request handler context and asScoped pattern (elastic#80775)
  [ML] Fixes formatting of fields in index data visualizer (elastic#82593)
  Usage collector readme (elastic#82548)
  [Lens] Visualization validation and better error messages (elastic#81439)
  [ML] Add annotation markers to time series brush area to indicate annotations exist outside of selected range (elastic#81490)
  chore(NA): install microdnf in UBI docker build only (elastic#82611)
  ...
majagrubic pushed a commit that referenced this pull request Nov 5, 2020
…2697)

* [Discover] Adding uiMetric around Visualize link click

* Change metric name

* Fixing wrong merge

* Applying PR fixes

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
@majagrubic majagrubic deleted the discover-telemetry branch November 6, 2020 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Discover Discover Application Team:Visualizations Visualization editors, elastic-charts and infrastructure v7.11.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants