mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 01:13:23 -04:00
[Bug] fix memory info extraction for fullstory (#115756)
* fix memory info extraction * ts
This commit is contained in:
parent
a7fff86390
commit
f1fe71650b
2 changed files with 24 additions and 10 deletions
|
@ -138,14 +138,22 @@ describe('Cloud Plugin', () => {
|
|||
|
||||
describe('with memory', () => {
|
||||
beforeAll(() => {
|
||||
// @ts-expect-error
|
||||
// @ts-expect-error 2339
|
||||
window.performance.memory = {
|
||||
someMetric: 1,
|
||||
get jsHeapSizeLimit() {
|
||||
return 3;
|
||||
},
|
||||
get totalJSHeapSize() {
|
||||
return 2;
|
||||
},
|
||||
get usedJSHeapSize() {
|
||||
return 1;
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
// @ts-expect-error
|
||||
// @ts-expect-error 2339
|
||||
delete window.performance.memory;
|
||||
});
|
||||
|
||||
|
@ -159,7 +167,9 @@ describe('Cloud Plugin', () => {
|
|||
|
||||
expect(fullStoryApiMock.event).toHaveBeenCalledWith('Loaded Kibana', {
|
||||
kibana_version_str: initContext.env.packageInfo.version,
|
||||
some_metric_int: 1,
|
||||
memory_js_heap_size_limit_int: 3,
|
||||
memory_js_heap_size_total_int: 2,
|
||||
memory_js_heap_size_used_int: 1,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -16,7 +16,6 @@ import {
|
|||
} from 'src/core/public';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { mapKeys, snakeCase } from 'lodash';
|
||||
import type {
|
||||
AuthenticatedUser,
|
||||
SecurityPluginSetup,
|
||||
|
@ -250,11 +249,16 @@ export class CloudPlugin implements Plugin<CloudSetup> {
|
|||
}
|
||||
|
||||
// Get performance information from the browser (non standard property
|
||||
const memoryInfo = mapKeys(
|
||||
// @ts-expect-error
|
||||
window.performance.memory || {},
|
||||
(_, key) => `${snakeCase(key)}_int`
|
||||
);
|
||||
// @ts-expect-error 2339
|
||||
const memory = window.performance.memory;
|
||||
let memoryInfo = {};
|
||||
if (memory) {
|
||||
memoryInfo = {
|
||||
memory_js_heap_size_limit_int: memory.jsHeapSizeLimit,
|
||||
memory_js_heap_size_total_int: memory.totalJSHeapSize,
|
||||
memory_js_heap_size_used_int: memory.usedJSHeapSize,
|
||||
};
|
||||
}
|
||||
// Record an event that Kibana was opened so we can easily search for sessions that use Kibana
|
||||
fullStory.event('Loaded Kibana', {
|
||||
// `str` suffix is required, see docs: https://help.fullstory.com/hc/en-us/articles/360020623234
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue