Skip to content

Commit

Permalink
[7.9] [Telemetry] Swallow errors in opt-in remote notification from t…
Browse files Browse the repository at this point in the history
…he server (#75641) (#75787)
  • Loading branch information
afharo authored Aug 24, 2020
1 parent 8e8bb4a commit c00241a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/plugins/telemetry/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export class TelemetryPlugin implements Plugin {
config$,
currentKibanaVersion,
isDev,
logger: this.logger,
router,
telemetryCollectionManager,
});
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/telemetry/server/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { Observable } from 'rxjs';
import { IRouter } from 'kibana/server';
import { IRouter, Logger } from 'kibana/server';
import { TelemetryCollectionManagerPluginSetup } from 'src/plugins/telemetry_collection_manager/server';
import { registerTelemetryOptInRoutes } from './telemetry_opt_in';
import { registerTelemetryUsageStatsRoutes } from './telemetry_usage_stats';
Expand All @@ -28,6 +28,7 @@ import { TelemetryConfigType } from '../config';

interface RegisterRoutesParams {
isDev: boolean;
logger: Logger;
config$: Observable<TelemetryConfigType>;
currentKibanaVersion: string;
router: IRouter;
Expand Down
13 changes: 10 additions & 3 deletions src/plugins/telemetry/server/routes/telemetry_opt_in.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import moment from 'moment';
import { Observable } from 'rxjs';
import { take } from 'rxjs/operators';
import { schema } from '@kbn/config-schema';
import { IRouter } from 'kibana/server';
import { IRouter, Logger } from 'kibana/server';
import {
StatsGetterConfig,
TelemetryCollectionManagerPluginSetup,
Expand All @@ -39,12 +39,14 @@ import { TelemetryConfigType } from '../config';
interface RegisterOptInRoutesParams {
currentKibanaVersion: string;
router: IRouter;
logger: Logger;
config$: Observable<TelemetryConfigType>;
telemetryCollectionManager: TelemetryCollectionManagerPluginSetup;
}

export function registerTelemetryOptInRoutes({
config$,
logger,
router,
currentKibanaVersion,
telemetryCollectionManager,
Expand Down Expand Up @@ -95,11 +97,16 @@ export function registerTelemetryOptInRoutes({

if (config.sendUsageFrom === 'server') {
const optInStatusUrl = config.optInStatusUrl;
await sendTelemetryOptInStatus(
sendTelemetryOptInStatus(
telemetryCollectionManager,
{ optInStatusUrl, newOptInStatus },
statsGetterConfig
);
).catch((err) => {
// The server is likely behind a firewall and can't reach the remote service
logger.warn(
`Failed to notify "${optInStatusUrl}" from the server about the opt-in selection. Possibly blocked by a firewall? - Error: ${err.message}`
);
});
}

await updateTelemetrySavedObject(context.core.savedObjects.client, attributes);
Expand Down

0 comments on commit c00241a

Please sign in to comment.