-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Reporting/Telemetry] Do not send telemetry if we are in screenshot mode #100388
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
Changes from all commits
f9cc783
0f86d84
7e7f33b
2c31aa4
4f91bab
afe7dbd
1990c1f
fec95b6
3d5e140
e0a0b94
dca59ac
f00a895
ce7e4d2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -256,4 +256,24 @@ describe('TelemetryService', () => { | |
| expect(mockFetch).toHaveBeenCalledTimes(1); | ||
| }); | ||
| }); | ||
|
|
||
| describe('canSendTelemetry', () => { | ||
| it('does not send telemetry if screenshotMode is true', () => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we test the other scenario as well? |
||
| const telemetryService = mockTelemetryService({ | ||
| isScreenshotMode: true, | ||
| config: { optIn: true }, | ||
| }); | ||
|
|
||
| expect(telemetryService.canSendTelemetry()).toBe(false); | ||
| }); | ||
|
|
||
| it('does send telemetry if screenshotMode is false and we are opted in', () => { | ||
| const telemetryService = mockTelemetryService({ | ||
| isScreenshotMode: false, | ||
| config: { optIn: true }, | ||
| }); | ||
|
|
||
| expect(telemetryService.canSendTelemetry()).toBe(true); | ||
| }); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,6 +14,7 @@ interface TelemetryServiceConstructor { | |
| config: TelemetryPluginConfig; | ||
| http: CoreStart['http']; | ||
| notifications: CoreStart['notifications']; | ||
| isScreenshotMode: boolean; | ||
| currentKibanaVersion: string; | ||
| reportOptInStatusChange?: boolean; | ||
| } | ||
|
|
@@ -27,6 +28,7 @@ export class TelemetryService { | |
| private readonly reportOptInStatusChange: boolean; | ||
| private readonly notifications: CoreStart['notifications']; | ||
| private readonly defaultConfig: TelemetryPluginConfig; | ||
| private readonly isScreenshotMode: boolean; | ||
| private updatedConfig?: TelemetryPluginConfig; | ||
|
|
||
| /** Current version of Kibana */ | ||
|
|
@@ -35,11 +37,13 @@ export class TelemetryService { | |
| constructor({ | ||
| config, | ||
| http, | ||
| isScreenshotMode, | ||
| notifications, | ||
| currentKibanaVersion, | ||
| reportOptInStatusChange = true, | ||
| }: TelemetryServiceConstructor) { | ||
| this.defaultConfig = config; | ||
| this.isScreenshotMode = isScreenshotMode; | ||
| this.reportOptInStatusChange = reportOptInStatusChange; | ||
| this.notifications = notifications; | ||
| this.currentKibanaVersion = currentKibanaVersion; | ||
|
|
@@ -63,7 +67,7 @@ export class TelemetryService { | |
|
|
||
| /** Is the cluster opted-in to telemetry **/ | ||
| public get isOptedIn() { | ||
| return this.config.optIn; | ||
| return Boolean(this.config.optIn); | ||
| } | ||
|
|
||
| /** Changes the opt-in status **/ | ||
|
|
@@ -122,10 +126,15 @@ export class TelemetryService { | |
| } | ||
|
|
||
| /** Is the cluster opted-in to telemetry **/ | ||
| public getIsOptedIn = () => { | ||
| public getIsOptedIn = (): boolean => { | ||
| return this.isOptedIn; | ||
| }; | ||
|
|
||
| /** Are there any blockers for sending telemetry */ | ||
| public canSendTelemetry = (): boolean => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you mind adding the JSDocs to this public method? |
||
| return !this.isScreenshotMode && this.getIsOptedIn(); | ||
| }; | ||
|
|
||
| /** Fetches an unencrypted telemetry payload so we can show it to the user **/ | ||
| public fetchExample = async () => { | ||
| return await this.fetchTelemetry({ unencrypted: true }); | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "id": "telemetryTestPlugin", | ||
| "version": "0.0.1", | ||
| "kibanaVersion": "kibana", | ||
| "configPath": ["telemetryTestPlugin"], | ||
| "requiredPlugins": ["telemetry"], | ||
| "server": false, | ||
| "ui": true | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "name": "telemetry_test_plugin", | ||
| "version": "1.0.0", | ||
| "main": "target/test/plugin_functional/plugins/telemetry", | ||
| "kibana": { | ||
| "version": "kibana", | ||
| "templateVersion": "1.0.0" | ||
| }, | ||
| "license": "SSPL-1.0 OR Elastic License 2.0", | ||
| "scripts": { | ||
| "kbn": "node ../../../../scripts/kbn.js", | ||
| "build": "rm -rf './target' && ../../../../node_modules/.bin/tsc" | ||
| } | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.