Skip to content

Commit

Permalink
Debug log for grafana faro
Browse files Browse the repository at this point in the history
  • Loading branch information
max-nav committed Jan 2, 2024
1 parent 89dc189 commit 90b2c4d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
Binary file modified bun.lockb
Binary file not shown.
4 changes: 3 additions & 1 deletion packages/client/src/client.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AppState } from 'decorator-shared/types';
import { Faro } from '@grafana/faro-web-sdk';

declare global {
interface Window {
Expand All @@ -21,6 +22,7 @@ declare global {
vngageReady: () => void;
vngage: {
join: (queue: string, options: unknown) => void;
}
},
faro?: Faro
}
}
4 changes: 2 additions & 2 deletions packages/client/src/helpers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export async function fetchSession() {

return await sessionResponse.json();
} catch (error) {
throw new Error(`Error fetching auth: ${error}`);
console.log(`User is not logged in`);
}
}

Expand All @@ -41,7 +41,7 @@ export async function fethRenew() {

return await sessionResponse.json();
} catch (error) {
throw new Error(`Error fetching auth: ${error}`);
console.log(`User is not logged in`);
}
}

Expand Down
17 changes: 8 additions & 9 deletions packages/client/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { formatParams } from 'decorator-shared/json';
import { LoginLevel, type Context, type Params } from 'decorator-shared/params';
import Cookies from 'js-cookie';
import 'vite/modulepreload-polyfill';
import { type AnalyticsEventArgs } from './analytics/constants';
import * as api from './api';
import { logoutWarningController } from './controllers/logout-warning';
import { onLoadListeners } from './listeners';
Expand All @@ -26,20 +25,13 @@ import './views/screensharing-modal';
import './views/search-input';
import './views/search-menu';
import { Auth } from './api';
import { initializeFaro } from '@grafana/faro-web-sdk';
import { c } from 'vitest/dist/reporters-5f784f42';

import.meta.glob('./styles/*.css', { eager: true });

// Just for testing
const CONTEXTS = ['privatperson', 'arbeidsgiver', 'samarbeidspartner'] as const;

initializeFaro({
url: 'https://telemetry.nav.no/collect',
app: {
// @NOTE: for testing purposes
name: 'decorator-next',
},
});

const updateDecoratorParams = (params: Partial<Params>) => {
window.__DECORATOR_DATA__.params = {
Expand Down Expand Up @@ -173,3 +165,10 @@ window.addEventListener('load', () => {
userState: Cookies.get('psCurrentState'),
});
});

if (window.faro) {
console.log('Faro is available');
console.log(window.faro)
} else {
console.log('Faro is not available');
}

0 comments on commit 90b2c4d

Please sign in to comment.