|
|
@ -2,7 +2,8 @@ import { BuildInfo } from '@grafana/data'; |
|
|
|
import { GrafanaEdition } from '@grafana/data/internal'; |
|
|
|
import { GrafanaEdition } from '@grafana/data/internal'; |
|
|
|
import { Faro, Instrumentation } from '@grafana/faro-core'; |
|
|
|
import { Faro, Instrumentation } from '@grafana/faro-core'; |
|
|
|
import * as faroWebSdkModule from '@grafana/faro-web-sdk'; |
|
|
|
import * as faroWebSdkModule from '@grafana/faro-web-sdk'; |
|
|
|
import { BrowserConfig, FetchTransport } from '@grafana/faro-web-sdk'; |
|
|
|
import { BrowserConfig, FetchTransport, SessionInstrumentation } from '@grafana/faro-web-sdk'; |
|
|
|
|
|
|
|
import { TracingInstrumentation } from '@grafana/faro-web-tracing'; |
|
|
|
|
|
|
|
|
|
|
|
import { EchoSrvTransport } from './EchoSrvTransport'; |
|
|
|
import { EchoSrvTransport } from './EchoSrvTransport'; |
|
|
|
import { |
|
|
|
import { |
|
|
@ -32,7 +33,7 @@ describe('GrafanaJavascriptAgentEchoBackend', () => { |
|
|
|
error: jest.fn(), |
|
|
|
error: jest.fn(), |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
initializeFaroMock = jest.spyOn(faroWebSdkModule, 'initializeFaro').mockReturnValueOnce({ |
|
|
|
initializeFaroMock = jest.spyOn(faroWebSdkModule, 'initializeFaro').mockReturnValue({ |
|
|
|
...faroWebSdkModule.faro, |
|
|
|
...faroWebSdkModule.faro, |
|
|
|
api: { |
|
|
|
api: { |
|
|
|
...faroWebSdkModule.faro.api, |
|
|
|
...faroWebSdkModule.faro.api, |
|
|
@ -130,6 +131,27 @@ describe('GrafanaJavascriptAgentEchoBackend', () => { |
|
|
|
expect(end - start).toBeLessThanOrEqual(maxExecutionTime); |
|
|
|
expect(end - start).toBeLessThanOrEqual(maxExecutionTime); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('correctly set instrumentation based on options', async () => { |
|
|
|
|
|
|
|
let opts = { |
|
|
|
|
|
|
|
...options, |
|
|
|
|
|
|
|
allInstrumentationsEnabled: false, |
|
|
|
|
|
|
|
errorInstrumentalizationEnabled: false, |
|
|
|
|
|
|
|
consoleInstrumentalizationEnabled: false, |
|
|
|
|
|
|
|
webVitalsInstrumentalizationEnabled: false, |
|
|
|
|
|
|
|
tracingInstrumentalizationEnabled: false, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
new GrafanaJavascriptAgentBackend(opts); |
|
|
|
|
|
|
|
expect(initializeFaroMock.mock.calls[0][0].instrumentations?.length).toEqual(1); |
|
|
|
|
|
|
|
expect(initializeFaroMock.mock.calls[0][0].instrumentations?.[0]).toBeInstanceOf(SessionInstrumentation); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
opts.tracingInstrumentalizationEnabled = true; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new GrafanaJavascriptAgentBackend(opts); |
|
|
|
|
|
|
|
expect(initializeFaroMock.mock.calls[1][0].instrumentations?.length).toEqual(2); |
|
|
|
|
|
|
|
expect(initializeFaroMock.mock.calls[1][0].instrumentations?.[0]).toBeInstanceOf(TracingInstrumentation); |
|
|
|
|
|
|
|
expect(initializeFaroMock.mock.calls[1][0].instrumentations?.[1]).toBeInstanceOf(SessionInstrumentation); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
//@FIXME - make integration test work
|
|
|
|
//@FIXME - make integration test work
|
|
|
|
|
|
|
|
|
|
|
|
// it('integration test with EchoSrv and GrafanaJavascriptAgent', async () => {
|
|
|
|
// it('integration test with EchoSrv and GrafanaJavascriptAgent', async () => {
|
|
|
|