Skip to content

Commit

Permalink
enrich telemetry events
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaudan committed Jan 10, 2024
1 parent 1220b92 commit 5cd13bb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions packages/core/src/domain/telemetry/telemetry.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type { ExperimentalFeature } from '../../tools/experimentalFeatures'
import { resetExperimentalFeatures, addExperimentalFeatures } from '../../tools/experimentalFeatures'
import type { Configuration } from '../configuration'
import { INTAKE_SITE_US1, INTAKE_SITE_US1_FED } from '../configuration'
import { setNavigatorOnLine, setNavigatorConnection } from '../../../test'
import {
resetTelemetry,
startTelemetry,
Expand Down Expand Up @@ -93,6 +94,22 @@ describe('telemetry', () => {
})
})

it('should contain connectivity information', () => {
setNavigatorOnLine(false)
setNavigatorConnection({ type: 'wifi', effectiveType: '4g' })

const { notifySpy } = startAndSpyTelemetry()
callMonitored(() => {
throw new Error('message')
})

expect(notifySpy.calls.mostRecent().args[0].telemetry.connectivity).toEqual({
status: 'not_connected',
interfaces: ['wifi'],
effective_type: '4g',
})
})

describe('telemetry context', () => {
it('should be added to telemetry events', () => {
const { telemetry, notifySpy } = startAndSpyTelemetry()
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/domain/telemetry/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { combine } from '../../tools/mergeInto'
import { NonErrorPrefix } from '../error/error.types'
import type { StackTrace } from '../error/computeStackTrace'
import { computeStackTrace } from '../error/computeStackTrace'
import { getConnectivity } from '../connectivity'
import type { TelemetryEvent } from './telemetryEvent.types'
import type { RawTelemetryConfiguration, RawTelemetryEvent, RuntimeEnvInfo } from './rawTelemetryEvent.types'
import { StatusType, TelemetryType } from './rawTelemetryEvent.types'
Expand Down Expand Up @@ -94,6 +95,7 @@ export function startTelemetry(telemetryService: TelemetryService, configuration
},
telemetry: combine(event, {
runtime_env: runtimeEnvInfo,
connectivity: getConnectivity(),
}),
experimental_features: arrayFrom(getExperimentalFeatures()),
},
Expand Down

0 comments on commit 5cd13bb

Please sign in to comment.