[8.8] [Telemetry] Log opt-in status at the INFO level (#158830) (#158971)

# Backport

This will backport the following commits from `main` to `8.8`:
- [[Telemetry] Log opt-in status at the INFO level
(#158830)](https://github.com/elastic/kibana/pull/158830)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Alejandro Fernández
Haro","email":"alejandro.haro@elastic.co"},"sourceCommit":{"committedDate":"2023-06-02T20:59:04Z","message":"[Telemetry]
Log opt-in status at the INFO level
(#158830)","sha":"18e145ccb608b2cdd4f21fc766ebb3e19ff0e38d","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Docs","Team:Core","Feature:Telemetry","release_note:skip","backport:prev-minor","v8.9.0"],"number":158830,"url":"https://github.com/elastic/kibana/pull/158830","mergeCommit":{"message":"[Telemetry]
Log opt-in status at the INFO level
(#158830)","sha":"18e145ccb608b2cdd4f21fc766ebb3e19ff0e38d"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/158830","number":158830,"mergeCommit":{"message":"[Telemetry]
Log opt-in status at the INFO level
(#158830)","sha":"18e145ccb608b2cdd4f21fc766ebb3e19ff0e38d"}}]}]
BACKPORT-->

Co-authored-by: Alejandro Fernández Haro <alejandro.haro@elastic.co>
This commit is contained in:
Kibana Machine 2023-06-02 18:09:20 -04:00 committed by GitHub
parent 836308b411
commit 7224b92a05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View file

@ -755,5 +755,8 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
synthetics: {
featureRoles: `${ELASTIC_WEBSITE_URL}guide/en/observability/${DOC_LINK_VERSION}/synthetics-feature-roles.html`,
},
telemetry: {
settings: `${KIBANA_DOCS}telemetry-settings-kbn.html`,
},
});
};

View file

@ -524,4 +524,7 @@ export interface DocLinks {
readonly synthetics: {
readonly featureRoles: string;
};
readonly telemetry: {
readonly settings: string;
};
}

View file

@ -149,9 +149,16 @@ export class TelemetryPlugin implements Plugin<TelemetryPluginSetup, TelemetryPl
}
public setup(
{ analytics, http, savedObjects }: CoreSetup,
{ analytics, docLinks, http, savedObjects }: CoreSetup,
{ usageCollection, telemetryCollectionManager }: TelemetryPluginsDepsSetup
): TelemetryPluginSetup {
this.isOptedIn$.subscribe((optedIn) => {
const optInStatusMsg = optedIn ? 'enabled' : 'disabled';
this.logger.info(
`Telemetry collection is ${optInStatusMsg}. For more information on telemetry settings, refer to ${docLinks.links.telemetry.settings}.`
);
});
if (this.isOptedIn !== undefined) {
analytics.optIn({ global: { enabled: this.isOptedIn } });
}