Faro reported the app as `Shiny Frontend` (copied from Shiny). Dancefinder's browser logs and traces would then mix with Shiny's in VictoriaLogs/VictoriaTraces once shiny/frontend#3778 moves to faro.unbound.se. - `app.name`: `Shiny Frontend` → `dancefinder-app`. This follows the backend convention, where the OTel `service.name` is the repo name (`dancefinder`). - `version` (`1.0.0`, the same as package.json) and `environment` (`config.name`) are unchanged. `npm run lint` passes. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01VSC7dLAgao1afzL5DQfH8F Reviewed-on: #3107
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import { FetchTransport, getWebInstrumentations, initializeFaro,InternalLoggerLevel } from '@grafana/faro-web-sdk'
|
|
import { TracingInstrumentation } from '@grafana/faro-web-tracing'
|
|
import { FetchInstrumentation } from '@opentelemetry/instrumentation-fetch'
|
|
|
|
import { envConfig } from '~/utils/environment'
|
|
const config = envConfig(window.location.hostname)
|
|
|
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
if (config.grafanaUrl) {
|
|
const faro = initializeFaro({
|
|
app: {
|
|
name: 'dancefinder-app',
|
|
version: '1.0.0',
|
|
environment: config.name,
|
|
},
|
|
sessionTracking: {
|
|
samplingRate: config.tracesSampleRate,
|
|
},
|
|
instrumentations: [
|
|
// Mandatory, omits default instrumentations otherwise.
|
|
...getWebInstrumentations(),
|
|
|
|
// Tracing package to get end-to-end visibility for HTTP requests.
|
|
new TracingInstrumentation({
|
|
instrumentations: [
|
|
new FetchInstrumentation({
|
|
ignoreUrls: [
|
|
config.grafanaUrl,
|
|
config.apiUrl,
|
|
new RegExp('.*/sw.js$'),
|
|
new RegExp('.*_payload.json.*'),
|
|
new RegExp(`https://${config.auth.domain}/*`),
|
|
],
|
|
}),
|
|
],
|
|
}),
|
|
],
|
|
internalLoggerLevel: InternalLoggerLevel.VERBOSE,
|
|
transports: [
|
|
new FetchTransport({ url: config.grafanaUrl }),
|
|
],
|
|
})
|
|
console.log(`initialized faro for ${config.grafanaUrl}, sample-rate ${config.tracesSampleRate * 100}%`)
|
|
nuxtApp.provide('faro', faro)
|
|
}
|
|
})
|