kibana/test/functional/services/usage_collection.ts
Alexey Antonov 913527036e
[Tests] add smoke functional tests for "render" telemetries (#143522)
## Summary

[Tests] add smoke functional tests for "render" telemetries

This PR blocked by #143734 and #143552

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Marco Liberati <dej611@users.noreply.github.com>
2022-11-21 15:44:05 +03:00

38 lines
1 KiB
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { FtrService } from '../ftr_provider_context';
const ANALYTICS_LOCAL_STORAGE_KEY = 'analytics';
export class UsageCollectionService extends FtrService {
private readonly browser = this.ctx.getService('browser');
public async getUICounterEvents(): Promise<
Array<{
key: string;
appName: string;
eventName: string;
type: string;
total: number;
}>
> {
try {
const rawValue = await this.browser.getLocalStorageItem(ANALYTICS_LOCAL_STORAGE_KEY);
if (rawValue) {
const { uiCounter } = JSON.parse(rawValue) ?? {};
return Object.values(uiCounter);
}
} catch (e) {
// nothing to be here
}
return [];
}
}