-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move maps telemetry to NP. Some clean-up, some ts conversion
- Loading branch information
Aaron Caldwell
committed
Jan 16, 2020
1 parent
5ba24b8
commit 6101b54
Showing
5 changed files
with
112 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
x-pack/legacy/plugins/maps/server/maps_telemetry/collectors/register.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* | ||
* 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 { UsageCollectionSetup } from 'src/plugins/usage_collection/server'; | ||
// @ts-ignore | ||
import { getMapsTelemetry, TELEMETRY_TYPE } from '../maps_telemetry'; | ||
|
||
export function registerMapsUsageCollector( | ||
usageCollection: UsageCollectionSetup, | ||
savedObjectsClient: any, | ||
config: Function | ||
): void { | ||
if (!usageCollection) { | ||
return; | ||
} | ||
|
||
const mapsUsageCollector = usageCollection.makeUsageCollector({ | ||
type: TELEMETRY_TYPE, | ||
isReady: () => true, | ||
fetch: async () => await getMapsTelemetry(savedObjectsClient, config), | ||
}); | ||
|
||
usageCollection.registerCollector(mapsUsageCollector); | ||
} |
38 changes: 38 additions & 0 deletions
38
x-pack/legacy/plugins/maps/server/maps_telemetry/collectors/register_collector.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* 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 { registerMapsUsageCollector } from './register'; | ||
|
||
describe('buildCollectorObj#fetch', () => { | ||
let makeUsageCollectorStub; | ||
let savedObjectsClient; | ||
let registerStub; | ||
let usageCollection; | ||
let config; | ||
|
||
beforeEach(() => { | ||
makeUsageCollectorStub = jest.fn(); | ||
savedObjectsClient = jest.fn(); | ||
registerStub = jest.fn(); | ||
config = jest.fn(); | ||
usageCollection = { | ||
makeUsageCollector: makeUsageCollectorStub, | ||
registerCollector: registerStub, | ||
}; | ||
}); | ||
|
||
test('makes and registers maps usage collector', async () => { | ||
registerMapsUsageCollector(usageCollection, savedObjectsClient, config); | ||
|
||
expect(registerStub).toHaveBeenCalledTimes(1); | ||
expect(makeUsageCollectorStub).toHaveBeenCalledTimes(1); | ||
expect(makeUsageCollectorStub).toHaveBeenCalledWith({ | ||
type: expect.any(String), | ||
isReady: expect.any(Function), | ||
fetch: expect.any(Function), | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters