Skip to content

Commit

Permalink
replace telemetryOptedIn in oss instead of xpack_main
Browse files Browse the repository at this point in the history
  • Loading branch information
Bamieh committed Oct 16, 2019
1 parent dba4e9d commit c03c567
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
10 changes: 9 additions & 1 deletion src/legacy/core_plugins/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { i18n } from '@kbn/i18n';
import mappings from './mappings.json';
import { CONFIG_TELEMETRY, getConfigTelemetryDesc } from './common/constants';
import { getXpackConfigWithDeprecated } from './common/get_xpack_config_with_deprecated';
import { telemetryPlugin } from './server';
import { telemetryPlugin, getTelemetryOptIn } from './server';

import {
createLocalizationUsageCollector,
Expand Down Expand Up @@ -76,6 +76,14 @@ const telemetry = (kibana: any) => {
isNamespaceAgnostic: true,
},
},
async replaceInjectedVars(originalInjectedVars: any, request: any) {
const telemetryOptedIn = await getTelemetryOptIn(request);

return {
...originalInjectedVars,
telemetryOptedIn,
};
},
injectDefaultVars(server: Server) {
const config = server.config();
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import { toastNotifications } from 'ui/notify';
import { npStart } from 'ui/new_platform';
import { i18n } from '@kbn/i18n';

let bannerId: string | null = null;
let currentOptInStatus = false;

export function TelemetryOptInProvider($injector: any, chrome: any) {
let currentOptInStatus = npStart.core.injectedMetadata.getInjectedVar(
'telemetryOptedIn'
) as boolean;
let bannerId: string | null = null;
currentOptInStatus = npStart.core.injectedMetadata.getInjectedVar('telemetryOptedIn') as boolean;

setCanTrackUiMetrics(currentOptInStatus);
const provider = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@
*/

import { KibanaRequest } from '../../../../../../src/core/server';
import { getTelemetryOptIn } from '../../../../../../src/legacy/core_plugins/telemetry/server';

export async function replaceInjectedVars(originalInjectedVars, request, server) {
const xpackInfo = server.plugins.xpack_main.info;

const withXpackInfo = async () => ({
...originalInjectedVars,
telemetryOptedIn: await getTelemetryOptIn(request),
xpackInitialInfo: xpackInfo.isAvailable() ? xpackInfo.toJSON() : undefined,
});

Expand Down

0 comments on commit c03c567

Please sign in to comment.