-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathneko.ts
More file actions
65 lines (58 loc) · 1.74 KB
/
neko.ts
File metadata and controls
65 lines (58 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import { PluginObject } from 'vue'
import { NekoClient } from '~/neko'
import { getTelemetry, getConnectionCollector } from '~/telemetry'
declare global {
const $client: NekoClient
interface Window {
$client: NekoClient
}
}
declare module 'vue/types/vue' {
interface Vue {
$client: NekoClient
}
}
const plugin: PluginObject<undefined> = {
install(Vue) {
window.$client = new NekoClient()
.on('error', (error: Error) => {
window.$log.error(error)
// Track errors via telemetry
getTelemetry().track('error_webrtc', 'error', undefined, {
error: {
message: error.message,
errorType: error.name || 'WebRTCError',
stack: error.stack,
},
})
})
.on('warn', (...args: unknown[]) => {
window.$log.warn(...args)
})
.on('info', (...args: unknown[]) => {
window.$log.info(...args)
// Track connection-related info events
const message = args.join(' ')
if (message.includes('connected') || message.includes('disconnected')) {
getTelemetry().track('connection_webrtc_connected', 'debug', {
message,
timestamp: Date.now(),
})
}
})
.on('debug', (...args: unknown[]) => {
window.$log.debug(...args)
// Parse debug messages for connection state changes
const message = args.join(' ')
// Track WebSocket connection URL
if (message.includes('connecting to')) {
const url = message.match(/connecting to (\S+)/)?.[1]
if (url) {
getConnectionCollector().setServerInfo({ url })
}
}
})
Vue.prototype.$client = window.$client
},
}
export default plugin