mirror of
https://github.com/suitenumerique/meet.git
synced 2026-08-16 05:28:53 +00:00
48c0cb320e
Introduce a telemetry module that exposes a `reportError` helper. Under the hood it forwards errors to PostHog, but the module is the only place that knows about PostHog. Replace `console.error` calls used for error reporting with `reportError`, so the codebase now goes through a single, consistent API for telemetry. This normalizes how errors are reported and makes it straightforward to swap PostHog for another backend later on, without touching every call site.
52 lines
1.2 KiB
TypeScript
52 lines
1.2 KiB
TypeScript
import { authUrl } from '@/features/auth/utils/authUrl'
|
|
import { PopupMessageType, CallbackCreationRoomData } from './types'
|
|
import { reportError } from '@/features/analytics/telemetry'
|
|
|
|
export class PopupWindow {
|
|
private sendMessageToManager(
|
|
type: PopupMessageType,
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
data: any,
|
|
callback?: () => void
|
|
) {
|
|
if (!window.opener) {
|
|
reportError('generic_failure', new Error('No manager window found'))
|
|
window.close()
|
|
return
|
|
}
|
|
window.opener.postMessage(
|
|
{
|
|
source: window.location.origin,
|
|
type,
|
|
...data,
|
|
},
|
|
window.location.origin
|
|
)
|
|
callback?.()
|
|
}
|
|
|
|
public sendRoomData(data: CallbackCreationRoomData, callback?: () => void) {
|
|
this.sendMessageToManager(
|
|
PopupMessageType.ROOM_DATA,
|
|
{ room: { slug: data.slug } },
|
|
callback
|
|
)
|
|
}
|
|
|
|
public sendCallbackId(callbackId: string, callback?: () => void) {
|
|
this.sendMessageToManager(
|
|
PopupMessageType.CALLBACK_ID,
|
|
{ callbackId },
|
|
callback
|
|
)
|
|
}
|
|
|
|
public close() {
|
|
window.close()
|
|
}
|
|
|
|
public navigateToAuthentication() {
|
|
window.location.href = authUrl({})
|
|
}
|
|
}
|