Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions src/platform/telemetry/initDatadogRum.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ describe('initDatadogRum', () => {
hoisted.init.mockImplementation(() => {
expect(hoisted.context).toEqual({
bucket: 'canary',
comfyui_frontend_version: __COMFYUI_FRONTEND_VERSION__,
version: __COMFYUI_FRONTEND_COMMIT__
})
})
Expand All @@ -94,6 +95,7 @@ describe('initDatadogRum', () => {

expect(hoisted.context).toEqual({
bucket: 'canary',
comfyui_frontend_version: __COMFYUI_FRONTEND_VERSION__,
version: __COMFYUI_FRONTEND_COMMIT__
})
expect(hoisted.init).toHaveBeenCalledOnce()
Expand Down Expand Up @@ -124,6 +126,7 @@ describe('initDatadogRum', () => {
expect(hoisted.init).toHaveBeenCalledOnce()
expect(hoisted.context).toEqual({
bucket: 'canary',
comfyui_frontend_version: __COMFYUI_FRONTEND_VERSION__,
version: __COMFYUI_FRONTEND_COMMIT__
})
})
Expand All @@ -139,6 +142,7 @@ describe('initDatadogRum', () => {

expect(hoisted.context).toEqual({
bucket: 'stable',
comfyui_frontend_version: __COMFYUI_FRONTEND_VERSION__,
version: __COMFYUI_FRONTEND_COMMIT__
})
})
Expand All @@ -152,7 +156,9 @@ describe('initDatadogRum', () => {

await initDatadogRum('cloud.comfy.org')

expect(hoisted.context).toEqual({})
expect(hoisted.context).toEqual({
comfyui_frontend_version: __COMFYUI_FRONTEND_VERSION__
})
})

it('leaves traffic unclassified when the probe reaches another version', async () => {
Expand All @@ -167,15 +173,19 @@ describe('initDatadogRum', () => {

await initDatadogRum('cloud.comfy.org')

expect(hoisted.context).toEqual({})
expect(hoisted.context).toEqual({
comfyui_frontend_version: __COMFYUI_FRONTEND_VERSION__
})
})

it('leaves traffic unclassified when the header probe fails', async () => {
hoisted.fetch.mockResolvedValue(new Response(null, { status: 503 }))

await initDatadogRum('cloud.comfy.org')

expect(hoisted.context).toEqual({})
expect(hoisted.context).toEqual({
comfyui_frontend_version: __COMFYUI_FRONTEND_VERSION__
})
expect(hoisted.init).toHaveBeenCalledOnce()
})

Expand All @@ -184,7 +194,9 @@ describe('initDatadogRum', () => {

await initDatadogRum('cloud.comfy.org')

expect(hoisted.context).toEqual({})
expect(hoisted.context).toEqual({
comfyui_frontend_version: __COMFYUI_FRONTEND_VERSION__
})
expect(hoisted.init).toHaveBeenCalledOnce()
})

Expand All @@ -204,7 +216,9 @@ describe('initDatadogRum', () => {
abortController.abort()
await initialization

expect(hoisted.context).toEqual({})
expect(hoisted.context).toEqual({
comfyui_frontend_version: __COMFYUI_FRONTEND_VERSION__
})
expect(hoisted.init).toHaveBeenCalledOnce()
})

Expand Down
4 changes: 4 additions & 0 deletions src/platform/telemetry/initDatadogRum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ async function setFrontendContext(): Promise<void> {
}

async function initializeDatadogRum(env: string): Promise<void> {
datadogRum.setGlobalContextProperty(
'comfyui_frontend_version',
__COMFYUI_FRONTEND_VERSION__
)
await setFrontendContext().catch(() => {})
if (datadogRum.getInitConfiguration()) return

Expand Down
Loading