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

[telemetry] expose getIsOptedIn function in plugin start contract #75143

Merged

Conversation

Bamieh
Copy link
Member

@Bamieh Bamieh commented Aug 17, 2020

  • Add getIsOptedIn to the start contract. We cannot expose this function to the setup function since SO savedObjects.createInternalRepository() is not exposed in setup.

  • Add getTelemetryUrl to the setup contract.

  • Add server plugin jest mocks

Closes #68942

@Bamieh Bamieh requested a review from a team as a code owner August 17, 2020 10:59
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-telemetry (Team:KibanaTelemetry)

Copy link
Member

@afharo afharo left a comment

Choose a reason for hiding this comment

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

I'm not sure we want to publicly expose the null behaviour. It seems very explicit to our own usage, doesn't it?.
Also, NIT: can we add some tests for this new piece of logic?

src/plugins/telemetry/server/plugin.ts Outdated Show resolved Hide resolved
src/plugins/telemetry/server/plugin.ts Outdated Show resolved Hide resolved
@Bamieh Bamieh requested a review from afharo August 17, 2020 13:48
Copy link
Member

@afharo afharo left a comment

Choose a reason for hiding this comment

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

LGTM!

NIT: It'd be great if we had some coverage for this API

Copy link
Contributor

@TinaHeiligers TinaHeiligers left a comment

Choose a reason for hiding this comment

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

We need unit tests for the new logic and also need to expose the plugin mock. Security will be using this new API and will most likely add tests for the implementation thereof.

@TinaHeiligers
Copy link
Contributor

@Bamieh There's an additional request to expose the telemetry url that came in through an email:

In addition to the opt-in status, I think we'll also need the telemetry URL. We'll ship to a v3 as in {telemetry_url}/v3/events, or similar.

If we can add it to this PR, let's do that. Otherwise we'll explicitly as for a new issue.

@TinaHeiligers TinaHeiligers self-requested a review August 17, 2020 18:13
Copy link
Contributor

@TinaHeiligers TinaHeiligers left a comment

Choose a reason for hiding this comment

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

Looks good thus far.

@Bamieh Bamieh dismissed TinaHeiligers’s stale review September 7, 2020 11:24

Addressed requested changes. exposed url and added plugin mocks

@Bamieh Bamieh requested a review from afharo September 7, 2020 11:24
Copy link
Member

@afharo afharo left a comment

Choose a reason for hiding this comment

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

The implementation looks great to me and I love it that we have a mock as well 🚀

I'm missing some unit tests to cover these new methods though (I'm happy to help on implementing them if you want 🙂).

I also added a comment in regards to the docs: Should we make it clear in some way that we'll only return false in the change of major/minor versions if the previous response was to opt-out?

src/plugins/telemetry/README.md Outdated Show resolved Hide resolved
const telemetrySavedObject = await getTelemetrySavedObject(internalRepository!);
const config = await this.config$.pipe(take(1)).toPromise();
const allowChangingOptInStatus = config.allowChangingOptInStatus;
const configTelemetryOptIn = typeof config.optIn === 'undefined' ? null : config.optIn;
Copy link
Member

Choose a reason for hiding this comment

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

NIT: I recently learned this can be also written as:

Suggested change
const configTelemetryOptIn = typeof config.optIn === 'undefined' ? null : config.optIn;
const configTelemetryOptIn = config.optIn ?? null;

🤯 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator

src/plugins/telemetry/server/plugin.ts Outdated Show resolved Hide resolved
Co-authored-by: Alejandro Fernández Haro <afharo@gmail.com>
@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Build metrics

✅ unchanged

History

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

@Bamieh Bamieh merged commit 992f5cc into elastic:master Sep 7, 2020
@Bamieh Bamieh deleted the telemetry/expose_start_contract_opt_in_status branch September 7, 2020 14:28
Bamieh added a commit that referenced this pull request Sep 7, 2020
…ct (#75143) (#76882)

Co-authored-by: Alejandro Fernández Haro <afharo@gmail.com>

Co-authored-by: Alejandro Fernández Haro <afharo@gmail.com>
jloleysens added a commit to jloleysens/kibana that referenced this pull request Sep 8, 2020
…' of github.com:jloleysens/kibana into ilm/fix/pre-existing-policy-with-no-existing-repository

* 'ilm/fix/pre-existing-policy-with-no-existing-repository' of github.com:jloleysens/kibana:
  fix empty string in selected indices (elastic#76855)
  [Security Solution] Refactor OverviewHost and OverviewNetwork to use Search Strategy (elastic#76409)
  Use Search API in Timelion (sync) (elastic#75115)
  [telemetry] expose getIsOptedIn function in plugin start contract (elastic#75143)
  [ILM] Clean up remaining js files and any typings (elastic#76803)
  [Logs UI] Shared `<LogStream />` component (elastic#76262)
  [Security Solution] Add unit test for all hosts (elastic#76752)
  [Security Solution] Add unit test for authentications search strategy (elastic#76665)
  Do not apply search source data for tsvb (elastic#75137)
  [Security Solution] Refactor NetworkDns to use Search Strategy (elastic#76250)
  [SECURITY SOLUTION] Adds 'cypress:open-as-ci' command (elastic#76125)
  [Logs UI] Update alert executor tests (elastic#75764)
  [Functional] Unskip vega tests and fix flakiness (elastic#76600)
  [Data] Query String Input accepts classname prop (elastic#76848)
  [ML] Swim lane pagination for viewing by job id (elastic#76847)
  [Security Solution] Refactor MatrixHistogram to use Search Strategy (elastic#76603)
  [APM] Use the outcome field to calculate the transaction error rate chart (elastic#75528)
  [APM] Use observer.hostname instead of observer.name (elastic#76074)
  Legacy logging: fix remoteAddress being duplicated in userAgent field (elastic#76751)
jloleysens added a commit to jloleysens/kibana that referenced this pull request Sep 8, 2020
…s-for-710

* 'master' of github.com:elastic/kibana:
  [Search] Use async es client endpoints (elastic#76872)
  fix empty string in selected indices (elastic#76855)
  [Security Solution] Refactor OverviewHost and OverviewNetwork to use Search Strategy (elastic#76409)
  Use Search API in Timelion (sync) (elastic#75115)
  [telemetry] expose getIsOptedIn function in plugin start contract (elastic#75143)
  [ILM] Clean up remaining js files and any typings (elastic#76803)
  [Logs UI] Shared `<LogStream />` component (elastic#76262)
  [Security Solution] Add unit test for all hosts (elastic#76752)
  [Security Solution] Add unit test for authentications search strategy (elastic#76665)
  Do not apply search source data for tsvb (elastic#75137)
  [Security Solution] Refactor NetworkDns to use Search Strategy (elastic#76250)
  [SECURITY SOLUTION] Adds 'cypress:open-as-ci' command (elastic#76125)
  [Logs UI] Update alert executor tests (elastic#75764)
  [Functional] Unskip vega tests and fix flakiness (elastic#76600)
  [Data] Query String Input accepts classname prop (elastic#76848)
  [ML] Swim lane pagination for viewing by job id (elastic#76847)
  [Security Solution] Refactor MatrixHistogram to use Search Strategy (elastic#76603)
  [APM] Use the outcome field to calculate the transaction error rate chart (elastic#75528)
  [APM] Use observer.hostname instead of observer.name (elastic#76074)
  Legacy logging: fix remoteAddress being duplicated in userAgent field (elastic#76751)

# Conflicts:
#	x-pack/plugins/index_lifecycle_management/__jest__/components/edit_policy.test.tsx
#	x-pack/plugins/index_lifecycle_management/common/types/index.ts
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/node_allocation.tsx
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.tsx
#	x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/phases/warm_phase.tsx
#	x-pack/plugins/index_lifecycle_management/public/application/services/api.ts
@lukeelmers lukeelmers added the Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc label Oct 1, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-core (Team:Core)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Telemetry release_note:skip Skip the PR/issue when compiling release notes Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v7.10.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow additional solutions to take advantage of the telemetry opt-in
6 participants