[Reporting/Screenshots] Add step to skip telemetry (#48312)
This commit is contained in:
parent
77247773b9
commit
853ddcd09c
|
@ -25,6 +25,7 @@ import { waitForElementsToBeInDOM } from './wait_for_dom_elements';
|
|||
import { getTimeRange } from './get_time_range';
|
||||
import { getElementPositionAndAttributes } from './get_element_position_data';
|
||||
import { getScreenshots } from './get_screenshots';
|
||||
import { skipTelemetry } from './skip_telemetry';
|
||||
|
||||
// NOTE: Typescript does not throw an error if this interface has errors!
|
||||
interface ScreenshotResults {
|
||||
|
@ -56,6 +57,10 @@ export function screenshotsObservableFactory(server: KbnServer) {
|
|||
(browser: HeadlessBrowser) => openUrl(browser, url, conditionalHeaders, logger),
|
||||
browser => browser
|
||||
),
|
||||
mergeMap(
|
||||
(browser: HeadlessBrowser) => skipTelemetry(browser, logger),
|
||||
browser => browser
|
||||
),
|
||||
mergeMap(
|
||||
(browser: HeadlessBrowser) => {
|
||||
logger.debug(
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License;
|
||||
* you may not use this file except in compliance with the Elastic License.
|
||||
*/
|
||||
|
||||
import { HeadlessChromiumDriver as HeadlessBrowser } from '../../../../server/browsers/chromium/driver';
|
||||
import { LevelLogger } from '../../../../server/lib';
|
||||
|
||||
const LAST_REPORT_STORAGE_KEY = 'xpack.data';
|
||||
|
||||
export async function skipTelemetry(browser: HeadlessBrowser, logger: LevelLogger) {
|
||||
const storageData = await browser.evaluate({
|
||||
fn: storageKey => {
|
||||
// set something
|
||||
const optOutJSON = JSON.stringify({ lastReport: Date.now() });
|
||||
localStorage.setItem(storageKey, optOutJSON);
|
||||
|
||||
// get it
|
||||
const session = localStorage.getItem(storageKey);
|
||||
|
||||
// return it
|
||||
return session;
|
||||
},
|
||||
args: [LAST_REPORT_STORAGE_KEY],
|
||||
});
|
||||
|
||||
logger.debug(`added data to localStorage to skip telmetry: ${storageData}`);
|
||||
}
|
Loading…
Reference in a new issue