mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[Cloud] Add deploymentId
to the EBT context (#155182)
This commit is contained in:
parent
4c79ef4009
commit
031bc369bd
5 changed files with 28 additions and 4 deletions
|
@ -5,7 +5,7 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { parseDeploymentIdFromDeploymentUrl } from './utils';
|
||||
import { parseDeploymentIdFromDeploymentUrl } from './parse_deployment_id_from_deployment_url';
|
||||
|
||||
describe('parseDeploymentIdFromDeploymentUrl', () => {
|
||||
it('should return undefined if there is no deploymentUrl configured', () => {
|
|
@ -29,4 +29,17 @@ describe('registerCloudDeploymentIdAnalyticsContext', () => {
|
|||
cloudId: 'cloud_id',
|
||||
});
|
||||
});
|
||||
|
||||
test('it registers the context provider and emits the cloudId and deploymentId', async () => {
|
||||
registerCloudDeploymentMetadataAnalyticsContext(analytics, {
|
||||
id: 'cloud_id',
|
||||
deployment_url: 'deployments/uuid-of-my-deployment',
|
||||
});
|
||||
expect(analytics.registerContextProvider).toHaveBeenCalledTimes(1);
|
||||
const [{ context$ }] = analytics.registerContextProvider.mock.calls[0];
|
||||
await expect(firstValueFrom(context$)).resolves.toEqual({
|
||||
cloudId: 'cloud_id',
|
||||
deploymentId: 'uuid-of-my-deployment',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -7,11 +7,13 @@
|
|||
|
||||
import type { AnalyticsClient } from '@kbn/analytics-client';
|
||||
import { of } from 'rxjs';
|
||||
import { parseDeploymentIdFromDeploymentUrl } from './parse_deployment_id_from_deployment_url';
|
||||
|
||||
export interface CloudDeploymentMetadata {
|
||||
id?: string;
|
||||
trial_end_date?: string;
|
||||
is_elastic_staff_owned?: boolean;
|
||||
deployment_url?: string;
|
||||
}
|
||||
|
||||
export function registerCloudDeploymentMetadataAnalyticsContext(
|
||||
|
@ -29,11 +31,20 @@ export function registerCloudDeploymentMetadataAnalyticsContext(
|
|||
|
||||
analytics.registerContextProvider({
|
||||
name: 'Cloud Deployment Metadata',
|
||||
context$: of({ cloudId, cloudTrialEndDate, cloudIsElasticStaffOwned }),
|
||||
context$: of({
|
||||
cloudId,
|
||||
deploymentId: parseDeploymentIdFromDeploymentUrl(cloudMetadata.deployment_url),
|
||||
cloudTrialEndDate,
|
||||
cloudIsElasticStaffOwned,
|
||||
}),
|
||||
schema: {
|
||||
cloudId: {
|
||||
type: 'keyword',
|
||||
_meta: { description: 'The Cloud Deployment ID' },
|
||||
_meta: { description: 'The Cloud ID' },
|
||||
},
|
||||
deploymentId: {
|
||||
type: 'keyword',
|
||||
_meta: { description: 'The Deployment ID', optional: true },
|
||||
},
|
||||
cloudTrialEndDate: {
|
||||
type: 'date',
|
||||
|
|
|
@ -11,7 +11,7 @@ import { registerCloudDeploymentMetadataAnalyticsContext } from '../common/regis
|
|||
import type { CloudConfigType } from './config';
|
||||
import { registerCloudUsageCollector } from './collectors';
|
||||
import { getIsCloudEnabled } from '../common/is_cloud_enabled';
|
||||
import { parseDeploymentIdFromDeploymentUrl } from './utils';
|
||||
import { parseDeploymentIdFromDeploymentUrl } from '../common/parse_deployment_id_from_deployment_url';
|
||||
import { readInstanceSizeMb } from './env';
|
||||
|
||||
interface PluginsSetup {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue