Skip to content

Commit

Permalink
chore: remove raygun, debugbear etc. code (#2364)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabis94 authored Jun 13, 2024
1 parent bd9faa2 commit bd042bd
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 234 deletions.
5 changes: 0 additions & 5 deletions packages/frontend-2/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ NUXT_REDIS_URL=redis://localhost:6379
NUXT_PUBLIC_VIEWER_DEBUG=false

# RUM monitoring
NUXT_PUBLIC_RAYGUN_KEY=
NUXT_PUBLIC_LOGROCKET_APP_ID=
NUXT_PUBLIC_SPEEDCURVE_ID=
NUXT_PUBLIC_DEBUGBEAR_ID=

NUXT_PUBLIC_DATADOG_APP_ID=
NUXT_PUBLIC_DATADOG_CLIENT_TOKEN=
NUXT_PUBLIC_DATADOG_SITE=
Expand Down
4 changes: 0 additions & 4 deletions packages/frontend-2/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,6 @@ export default defineNuxtConfig({
speckleServerVersion: SPECKLE_SERVER_VERSION || 'unknown',
serverName: 'UNDEFINED',
viewerDebug: false,
raygunKey: '',
logrocketAppId: '',
speedcurveId: 0,
debugbearId: '',
debugCoreWebVitals: false,
datadogAppId: '',
datadogClientToken: '',
Expand Down
2 changes: 0 additions & 2 deletions packages/frontend-2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
"pino": "^8.14.1",
"pino-http": "^8.3.3",
"portal-vue": "^3.0.0",
"raygun": "^0.13.2",
"seq-logging": "^2.1.1",
"subscriptions-transport-ws": "^0.11.0",
"tweetnacl-sealedbox-js": "^1.2.0",
Expand Down Expand Up @@ -106,7 +105,6 @@
"@types/mixpanel-browser": "^2.38.0",
"@types/node": "^18.17.5",
"@types/pino-http": "^5.8.1",
"@types/raygun4js": "^3.0.0",
"@typescript-eslint/eslint-plugin": "^7.12.0",
"@typescript-eslint/parser": "^7.12.0",
"@vitejs/plugin-legacy": "^5.4.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ definePageMeta({
middleware: ['require-valid-project'],
pageTransition: false, // NOTE: transitions fuck viewer up
layoutTransition: false,
key: '/projects/:id/models/resources', // To prevent controls flickering on resource url param changes
raygunTags: ['viewer']
key: '/projects/:id/models/resources' // To prevent controls flickering on resource url param changes
})
const ViewerScope = resolveComponent('ViewerScope')
Expand Down
125 changes: 4 additions & 121 deletions packages/frontend-2/plugins/002-rum.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { trimStart } from 'lodash-es'
import {
useGetInitialAuthState,
useOnAuthStateChange
Expand All @@ -11,74 +10,13 @@ import { isBrave, isSafari } from '@speckle/shared'

type PluginNuxtApp = Parameters<Plugin>[0]

async function initRumClient(app: PluginNuxtApp) {
const { keys, baseUrl, speckleServerVersion } = resolveInitParams(app)
function initRumClient(app: PluginNuxtApp) {
const { keys } = resolveInitParams(app)
const router = useRouter()
const onAuthStateChange = useOnAuthStateChange()
const registerErrorTransport = useCreateErrorLoggingTransport()
const reqId = useRequestId()

// RayGun
const rg4js = window.rg4js
if (keys.raygun && rg4js) {
const setupTags = (extraTags: string[]) => {
rg4js('withTags', [
`baseUrl:${baseUrl}`,
`version:${speckleServerVersion}`,
...extraTags
])
}

router.beforeEach((to, from) => {
// Update with tags
const newTags = (to.meta.raygunTags || []) as string[]
setupTags(newTags)

if (!from?.path || from.path === to.path) return

rg4js('trackEvent', {
type: 'pageView',
path: '/' + trimStart(to.path, '/')
})
})

await onAuthStateChange(
(user, { resolveDistinctId }) => {
const distinctId = resolveDistinctId(user)
rg4js('setUser', {
identifier: distinctId || '',
isAnonymous: !distinctId
})
},
{ immediate: true }
)

registerErrorTransport({
onError: ({ args, firstError, firstString, otherData, nonObjectOtherData }) => {
const error = firstError || firstString || args[0]
rg4js('send', {
error,
customData: {
...otherData,
extraData: nonObjectOtherData,
mainErrorMessage: firstString
}
})
}
// Apparently unhandleds are auto-handled by raygun
// onUnhandledError: ({ isUnhandledRejection, error, message }) => {
// rg4js('send', {
// error: error || message,
// customData: {
// isUnhandledRejection,
// message,
// mainErrorMessage: message
// }
// })
// }
})
}

// Datadog
const datadog = window.DD_RUM
if (keys.datadog && datadog) {
Expand Down Expand Up @@ -160,8 +98,7 @@ async function initRumClient(app: PluginNuxtApp) {
}

async function initRumServer(app: PluginNuxtApp) {
const registerErrorTransport = useCreateErrorLoggingTransport()
const { keys, baseUrl, speckleServerVersion, debug, debugCoreWebVitals } =
const { keys, baseUrl, speckleServerVersion, debugCoreWebVitals } =
resolveInitParams(app)
const initUser = useGetInitialAuthState()

Expand Down Expand Up @@ -193,57 +130,6 @@ async function initRumServer(app: PluginNuxtApp) {
})
}

// RayGun
if (keys.raygun) {
const raygun = (await import('raygun')).default
const raygunClient = new raygun.Client().init({
apiKey: keys.raygun,
batch: true,
reportUncaughtExceptions: true
})

registerErrorTransport({
onError: ({ firstError, firstString, otherData, nonObjectOtherData }) => {
const error = firstError || firstString || 'Unknown error'
raygunClient.send(error, {
...otherData,
extraData: nonObjectOtherData,
mainErrorMessage: firstString
})
}
})

// Add client-side snippet
app.hook('app:rendered', (context) => {
const initRaygunTags = app._route?.meta.raygunTags || []

context.ssrContext!.head.push({
script: [
{
innerHTML: `!function(a,b,c,d,e,f,g,h){a.RaygunObject=e,a[e]=a[e]||function(){
(a[e].o=a[e].o||[]).push(arguments)},f=b.createElement(c),g=b.getElementsByTagName(c)[0],
f.async=1,f.src=d,g.parentNode.insertBefore(f,g),h=a.onerror,a.onerror=function(b,c,d,f,g){
h&&h(b,c,d,f,g),g||(g=new Error(b)),a[e].q=a[e].q||[],a[e].q.push({
e:g})}}(window,document,"script","//cdn.raygun.io/raygun4js/raygun.min.js","rg4js");`
},
{
innerHTML: `
rg4js('apiKey', '${keys.raygun}')
rg4js('enableCrashReporting', true)
rg4js('enablePulse', true)
rg4js('withTags', ['baseUrl:${baseUrl}', 'version:${speckleServerVersion}', ...${JSON.stringify(
initRaygunTags
)}])
rg4js('options', {
debugMode: ${!!debug},
})
`
}
]
})
})
}

// Datadog
if (keys.datadog) {
const {
Expand Down Expand Up @@ -330,7 +216,6 @@ async function initRumServer(app: PluginNuxtApp) {
function resolveInitParams(app: PluginNuxtApp) {
const {
public: {
raygunKey,
speckleServerVersion,
logCsrEmitProps,
baseUrl,
Expand All @@ -343,7 +228,6 @@ function resolveInitParams(app: PluginNuxtApp) {
}
} = useRuntimeConfig()
const logger = useLogger()
const raygun = raygunKey?.length ? raygunKey : null
const datadog =
datadogClientToken?.length &&
datadogAppId?.length &&
Expand All @@ -357,7 +241,6 @@ function resolveInitParams(app: PluginNuxtApp) {

return {
keys: {
raygun,
datadog
},
speckleServerVersion,
Expand All @@ -372,6 +255,6 @@ export default defineNuxtPlugin(async (app) => {
if (import.meta.server) {
await initRumServer(app)
} else {
await initRumClient(app)
initRumClient(app)
}
})
4 changes: 0 additions & 4 deletions packages/frontend-2/type-augmentations/vue.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
declare module 'nuxt/dist/pages/runtime' {
interface PageMeta {
/**
* Optional tags to be sent to Raygun
*/
raygunTags?: string[]
/**
* Optional view name to override the default one
*/
Expand Down
1 change: 0 additions & 1 deletion packages/frontend-2/type-augmentations/window.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
declare global {
interface Window {
rg4js?: import('raygun4js').RaygunV2
DD_RUM?:
| Pick<import('@datadog/browser-rum').RumGlobal, 'onReady'>
| import('@datadog/browser-rum').RumGlobal
Expand Down
16 changes: 0 additions & 16 deletions utils/helm/speckle-server/templates/frontend_2/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,22 +89,6 @@ spec:
secretKeyRef:
name: {{ default .Values.secretName .Values.redis.connectionString.secretName }}
key: {{ default "redis_url" .Values.redis.connectionString.secretKey }}
{{- if .Values.analytics.raygun_key }}
- name: NUXT_PUBLIC_RAYGUN_KEY
value: {{ .Values.analytics.raygun_key | quote }}
{{- end }}
{{- if .Values.analytics.logrocket_app_id }}
- name: NUXT_PUBLIC_LOGROCKET_APP_ID
value: {{ .Values.analytics.logrocket_app_id | quote }}
{{- end }}
{{- if .Values.analytics.speedcurve_id }}
- name: NUXT_PUBLIC_SPEEDCURVE_ID
value: {{ .Values.analytics.speedcurve_id | quote }}
{{- end }}
{{- if .Values.analytics.debugbear_id }}
- name: NUXT_PUBLIC_DEBUGBEAR_ID
value: {{ .Values.analytics.debugbear_id | quote }}
{{- end }}
{{- if .Values.analytics.datadog_app_id }}
- name: NUXT_PUBLIC_DATADOG_APP_ID
value: {{ .Values.analytics.datadog_app_id | quote }}
Expand Down
Loading

0 comments on commit bd042bd

Please sign in to comment.