[Snapshot telemetry] Report to v3 (#159406)

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Alejandro Fernández Haro 2023-06-13 15:17:57 +02:00 committed by GitHub
parent 736252e5ef
commit 1d22dcce75
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 27 additions and 17 deletions

View file

@ -42,7 +42,7 @@ export const PAYLOAD_CONTENT_ENCODING = 'aes256gcm';
/**
* The endpoint version when hitting the remote telemetry service
*/
export const ENDPOINT_VERSION = 'v2';
export const ENDPOINT_VERSION = 'v3';
/**
* The staging telemetry endpoint for the remote telemetry service.
@ -60,6 +60,6 @@ export const ENDPOINT_PROD = 'https://telemetry.elastic.co/';
* The telemetry channels for the remote telemetry service.
*/
export const TELEMETRY_CHANNELS = {
SNAPSHOT_CHANNEL: 'xpack',
OPT_IN_STATUS_CHANNEL: 'opt_in_status',
SNAPSHOT_CHANNEL: 'kibana-snapshot',
OPT_IN_STATUS_CHANNEL: 'kibana-opt-in-reports',
};

View file

@ -41,12 +41,12 @@ describe('getChannel', () => {
it('returns correct snapshot channel name', () => {
const channelName = getChannel('snapshot');
expect(channelName).toMatchInlineSnapshot(`"xpack"`);
expect(channelName).toMatchInlineSnapshot(`"kibana-snapshot"`);
});
it('returns correct optInStatus channel name', () => {
const channelName = getChannel('optInStatus');
expect(channelName).toMatchInlineSnapshot(`"opt_in_status"`);
expect(channelName).toMatchInlineSnapshot(`"kibana-opt-in-reports"`);
});
});
@ -68,12 +68,14 @@ describe('getTelemetryChannelEndpoint', () => {
describe('snapshot channel', () => {
it('returns correct prod endpoint', () => {
const endpoint = getTelemetryChannelEndpoint({ env: 'prod', channelName: 'snapshot' });
expect(endpoint).toMatchInlineSnapshot(`"https://telemetry.elastic.co/xpack/v2/send"`);
expect(endpoint).toMatchInlineSnapshot(
`"https://telemetry.elastic.co/v3/send/kibana-snapshot"`
);
});
it('returns correct staging endpoint', () => {
const endpoint = getTelemetryChannelEndpoint({ env: 'staging', channelName: 'snapshot' });
expect(endpoint).toMatchInlineSnapshot(
`"https://telemetry-staging.elastic.co/xpack/v2/send"`
`"https://telemetry-staging.elastic.co/v3/send/kibana-snapshot"`
);
});
});
@ -82,13 +84,13 @@ describe('getTelemetryChannelEndpoint', () => {
it('returns correct prod endpoint', () => {
const endpoint = getTelemetryChannelEndpoint({ env: 'prod', channelName: 'optInStatus' });
expect(endpoint).toMatchInlineSnapshot(
`"https://telemetry.elastic.co/opt_in_status/v2/send"`
`"https://telemetry.elastic.co/v3/send/kibana-opt-in-reports"`
);
});
it('returns correct staging endpoint', () => {
const endpoint = getTelemetryChannelEndpoint({ env: 'staging', channelName: 'optInStatus' });
expect(endpoint).toMatchInlineSnapshot(
`"https://telemetry-staging.elastic.co/opt_in_status/v2/send"`
`"https://telemetry-staging.elastic.co/v3/send/kibana-opt-in-reports"`
);
});
});

View file

@ -49,5 +49,5 @@ export function getTelemetryChannelEndpoint({
const baseUrl = getBaseUrl(env);
const channelPath = getChannel(channelName);
return `${baseUrl}${channelPath}/${ENDPOINT_VERSION}/send`;
return `${baseUrl}${ENDPOINT_VERSION}/send/${channelPath}`;
}

View file

@ -12,6 +12,7 @@ import { FormattedMessage } from '@kbn/i18n-react';
import type { IBasePath } from '@kbn/core-http-browser';
import type { TelemetryService } from '../services';
import type { TelemetryConstants } from '..';
import { PATH_TO_ADVANCED_SETTINGS } from '../../common/constants';
export interface OptInMessageProps {
telemetryConstants: TelemetryConstants;
@ -94,7 +95,7 @@ function renderTelemetryEnabledOrDisabledText(
return (
/* eslint-disable-next-line @elastic/eui/href-or-on-click */
<EuiLink href={addBasePath('management/kibana/settings')} onClick={onClick}>
<EuiLink href={addBasePath(PATH_TO_ADVANCED_SETTINGS)} onClick={onClick}>
{actionMessage}
</EuiLink>
);

View file

@ -146,7 +146,7 @@ describe('TelemetryService', () => {
});
expect(telemetryService.getTelemetryUrl()).toMatchInlineSnapshot(
`"https://telemetry-staging.elastic.co/xpack/v2/send"`
`"https://telemetry-staging.elastic.co/v3/send/kibana-snapshot"`
);
});
@ -156,7 +156,7 @@ describe('TelemetryService', () => {
});
expect(telemetryService.getTelemetryUrl()).toMatchInlineSnapshot(
`"https://telemetry.elastic.co/xpack/v2/send"`
`"https://telemetry.elastic.co/v3/send/kibana-snapshot"`
);
});
});
@ -168,7 +168,7 @@ describe('TelemetryService', () => {
});
expect(telemetryService.getOptInStatusUrl()).toMatchInlineSnapshot(
`"https://telemetry-staging.elastic.co/opt_in_status/v2/send"`
`"https://telemetry-staging.elastic.co/v3/send/kibana-opt-in-reports"`
);
});
@ -178,7 +178,7 @@ describe('TelemetryService', () => {
});
expect(telemetryService.getOptInStatusUrl()).toMatchInlineSnapshot(
`"https://telemetry.elastic.co/opt_in_status/v2/send"`
`"https://telemetry.elastic.co/v3/send/kibana-opt-in-reports"`
);
});
});

View file

@ -40,7 +40,7 @@ describe('sendTelemetryOptInStatus', () => {
expect(fetch).toBeCalledTimes(1);
expect((fetch as jest.MockedFunction<typeof fetch>).mock.calls[0]).toMatchInlineSnapshot(`
Array [
"https://telemetry.elastic.co/opt_in_status/v2/send",
"https://telemetry.elastic.co/v3/send/kibana-opt-in-reports",
Object {
"body": "mock_opt_in_hashed_value",
"headers": Object {
@ -71,7 +71,7 @@ describe('sendTelemetryOptInStatus', () => {
expect(fetch).toBeCalledTimes(1);
expect((fetch as jest.MockedFunction<typeof fetch>).mock.calls[0]).toMatchInlineSnapshot(`
Array [
"https://telemetry-staging.elastic.co/opt_in_status/v2/send",
"https://telemetry-staging.elastic.co/v3/send/kibana-opt-in-reports",
Object {
"body": "mock_opt_in_hashed_value",
"headers": Object {

View file

@ -558,6 +558,13 @@ describe('getV3UrlFromV2', () => {
).toBe('https://telemetry.elastic.co/v3/send/alerts-endpoint');
});
it('should work when receiving a V3 URL', () => {
const sender = new TelemetryEventsSender(logger);
expect(
sender.getV3UrlFromV2('https://telemetry.elastic.co/v3/send/channel', 'alerts-endpoint')
).toBe('https://telemetry.elastic.co/v3/send/alerts-endpoint');
});
it('should return staging url', () => {
const sender = new TelemetryEventsSender(logger);
expect(