-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Reporting/Telemetry] Do not send telemetry if we are in screenshot mode #100388
Changes from 1 commit
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,15 @@ describe('TelemetryService', () => { | |
expect(mockFetch).toHaveBeenCalledTimes(1); | ||
}); | ||
}); | ||
|
||
describe('shouldSendTelemetry', () => { | ||
it('does not send telemetry if screenshotMode is true', () => { | ||
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); | ||
}); | ||
}); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,11 +9,13 @@ | |
import { i18n } from '@kbn/i18n'; | ||
import { CoreStart } from 'kibana/public'; | ||
import { TelemetryPluginConfig } from '../plugin'; | ||
import { ScreenshotModePluginSetup } from '../../../screenshot_mode/public'; | ||
|
||
interface TelemetryServiceConstructor { | ||
config: TelemetryPluginConfig; | ||
http: CoreStart['http']; | ||
notifications: CoreStart['notifications']; | ||
isScreenshotMode: boolean; | ||
currentKibanaVersion: string; | ||
reportOptInStatusChange?: boolean; | ||
} | ||
|
@@ -27,6 +29,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 +38,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; | ||
|
@@ -126,6 +131,10 @@ export class TelemetryService { | |
return this.isOptedIn; | ||
}; | ||
|
||
public canSendTelemetry = (): boolean => { | ||
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 Boolean(this.getIsOptedIn() && !this.isScreenshotMode); | ||
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. NITs:
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.
I wanted to be explicit about the return type and
Can do! |
||
}; | ||
|
||
/** Fetches an unencrypted telemetry payload so we can show it to the user **/ | ||
public fetchExample = async () => { | ||
return await this.fetchTelemetry({ unencrypted: true }); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: