working faro changes

This commit is contained in:
Rares Mardare 2022-12-13 15:28:30 +02:00
parent 334a035122
commit e0175fa2ef
3 changed files with 19 additions and 20 deletions

View file

@ -37,6 +37,17 @@ export const makeRequest = async <RT = any>(path: string, config: RequestConfig)
const url = `${API_PROXY_PREFIX}${API_PATH_PREFIX}${path}`;
const response = await instance({
method,
url,
params,
data,
validateStatus,
});
// for now just return response.data and figure OTEL later on
return response.data as RT;
const otel = faro.api.getOTEL();
if (otel) {

View file

@ -1,6 +1,6 @@
import React, { useEffect, useMemo, useState } from 'react';
import { initializeFaro, getWebInstrumentations, ReactIntegration, ReactRouterVersion } from '@grafana/faro-react';
import { initializeFaro, getWebInstrumentations } from '@grafana/faro-react';
import { TracingInstrumentation } from '@grafana/faro-web-tracing';
import { locationService } from '@grafana/runtime';
import classnames from 'classnames';
@ -10,7 +10,6 @@ import isSameOrBefore from 'dayjs/plugin/isSameOrBefore';
import isoWeek from 'dayjs/plugin/isoWeek';
import localeData from 'dayjs/plugin/localeData';
import timezone from 'dayjs/plugin/timezone';
import { Route, useHistory } from 'react-router';
import utc from 'dayjs/plugin/utc';
import weekday from 'dayjs/plugin/weekday';
@ -64,7 +63,6 @@ export const Root = observer((props: AppRootProps) => {
const pathWithoutLeadingSlash = path.replace(/^\//, '');
const store = useStore();
const history = useHistory();
useEffect(() => {
updateBasicData();
@ -78,7 +76,7 @@ export const Root = observer((props: AppRootProps) => {
document.head.appendChild(link);
initFaro(store, history);
initFaro(store);
return () => {
document.head.removeChild(link);
@ -129,30 +127,21 @@ export const Root = observer((props: AppRootProps) => {
);
});
function initFaro(store: RootBaseStore, history: any) {
function initFaro(store: RootBaseStore) {
const faro = initializeFaro({
url: `http://localhost:${''}/collect`,
apiKey: '',
url: `http://localhost:12345/collect`,
apiKey: 'secret',
instrumentations: [
...getWebInstrumentations({
captureConsole: true,
}),
new TracingInstrumentation(),
new ReactIntegration({
router: {
version: ReactRouterVersion.V5,
dependencies: {
history,
Route,
},
},
}),
],
session: (window as any).__PRELOADED_STATE__?.faro?.session,
app: {
name: '',
version: '',
environment: '',
name: 'oncall',
version: '1.0.0',
environment: 'dev',
},
});

View file

@ -201,7 +201,6 @@ class PluginState {
): Promise<PluginSyncStatusResponse | string> => {
try {
const startSyncResponse = await makeRequest(`${this.ONCALL_BASE_URL}/sync`, { method: 'POST' });
if (typeof startSyncResponse === 'string') {
// an error occured trying to initiate the sync
return startSyncResponse;