# Backport This will backport the following commits from `main` to `8.14`: - [[Obs AI Assistant] Add tests for if chat telemetry is sent and correctly shaped (#181086)](https://github.com/elastic/kibana/pull/181086) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Milton Hultgren","email":"milton.hultgren@elastic.co"},"sourceCommit":{"committedDate":"2024-05-02T10:00:56Z","message":"[Obs AI Assistant] Add tests for if chat telemetry is sent and correctly shaped (#181086)\n\nCo-authored-by: Alejandro Fernández Haro <alejandro.haro@elastic.co>\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"a697da262f8820839d96702b5e6cf6ca02757e0e","branchLabelMapping":{"^v8.15.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Obs AI Assistant","ci:project-deploy-observability","Team:obs-knowledge","v8.14.0","v8.15.0"],"title":"[Obs AI Assistant] Add tests for if chat telemetry is sent and correctly shaped","number":181086,"url":"https://github.com/elastic/kibana/pull/181086","mergeCommit":{"message":"[Obs AI Assistant] Add tests for if chat telemetry is sent and correctly shaped (#181086)\n\nCo-authored-by: Alejandro Fernández Haro <alejandro.haro@elastic.co>\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"a697da262f8820839d96702b5e6cf6ca02757e0e"}},"sourceBranch":"main","suggestedTargetBranches":["8.14"],"targetPullRequestStates":[{"branch":"8.14","label":"v8.14.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.15.0","branchLabelMappingKey":"^v8.15.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/181086","number":181086,"mergeCommit":{"message":"[Obs AI Assistant] Add tests for if chat telemetry is sent and correctly shaped (#181086)\n\nCo-authored-by: Alejandro Fernández Haro <alejandro.haro@elastic.co>\r\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>","sha":"a697da262f8820839d96702b5e6cf6ca02757e0e"}}]}] BACKPORT--> Co-authored-by: Milton Hultgren <milton.hultgren@elastic.co>
1.6 KiB
FTR tests for the core.analytics
service
This suite allows us to test the event-based telemetry client provided by the core.analytics
service.
How to add my own tests
Implement your own tests in the tests/instrumented_events/(from_the_browser|from_the_server)/
directory and list it in the tests/instrumented_events/(from_the_browser|from_the_server)/index.ts
file.
There are 2 FTR helpers to allow you to retrieve the generated events:
- For events generated in the UI, you can use
kibana_ebt_ui
to retrieve the events. - For events generated in the server, you can use the
kibana_ebt_server
helper.
The API is the same for both of them:
// To retrieve 2 events of type "my-event-type"
const events = await getService('kibana_ebt_ui').getEvents(2, { eventTypes: ['my-event-type'] });
expect(events).to...
Refer to EBTHelpersContract
for more details about the existing APIs and all the options they accept.
Usage outside of this test suite
First, you'll need to add the services to your config, such as:
kibana_ebt_server: KibanaEBTServerProvider,
kibana_ebt_ui: KibanaEBTUIProvider,
The providers are found inside ./services/kibana_ebt.ts
You'll also need to inject a plugin to Kibana that loads the helper code, by adding a CLI flag like:
--plugin-path=PATH_TO/test/analytics/plugins/analytics_ftr_helpers
If you are reusing these helpers in another suite, please remember to make sure to optIn via await getService('kibana_ebt_ui').setOptIn(true);
Note: This opt in is only stored in memory, so a page refresh will reset it.