Skip to content

Commit

Permalink
Monitor more APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaudan committed May 7, 2024
1 parent 8997f62 commit bbbbef0
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/rum-core/src/boot/rumPublicApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ export function makeRumPublicApi(startRumImpl: StartRum, recorderApi: RecorderAp
startClocks: options?.startTime ? timeStampToClocks(options.startTime as TimeStamp) : clocksNow(),
context: sanitize(options?.context) as Context,
})
addTelemetryUsage({ feature: 'start-duration-vital' })
}
)

Expand Down Expand Up @@ -188,6 +189,7 @@ export function makeRumPublicApi(startRumImpl: StartRum, recorderApi: RecorderAp
} = monitor((options?: string | ViewOptions) => {
const sanitizedOptions = typeof options === 'object' ? options : { name: options }
strategy.startView(sanitizedOptions)
addTelemetryUsage({ feature: 'start-view' })
})
const rumPublicApi = makePublicApi({
init: monitor((initConfiguration: RumInitConfiguration) => strategy.init(initConfiguration)),
Expand All @@ -209,13 +211,19 @@ export function makeRumPublicApi(startRumImpl: StartRum, recorderApi: RecorderAp
addTelemetryUsage({ feature: 'set-tracking-consent', tracking_consent: trackingConsent })
}),

setGlobalContextProperty: monitor((key, value) => globalContextManager.setContextProperty(key, value)),
setGlobalContextProperty: monitor((key, value) => {
globalContextManager.setContextProperty(key, value)
addTelemetryUsage({ feature: 'set-global-context' })
}),

removeGlobalContextProperty: monitor((key) => globalContextManager.removeContextProperty(key)),

getGlobalContext: monitor(() => globalContextManager.getContext()),

setGlobalContext: monitor((context) => globalContextManager.setContext(context)),
setGlobalContext: monitor((context) => {
globalContextManager.setContext(context)
addTelemetryUsage({ feature: 'set-global-context' })
}),

clearGlobalContext: monitor(() => globalContextManager.clearContext()),

Expand All @@ -230,6 +238,7 @@ export function makeRumPublicApi(startRumImpl: StartRum, recorderApi: RecorderAp
startClocks: clocksNow(),
type: ActionType.CUSTOM,
})
addTelemetryUsage({ feature: 'add-action' })
}),

addError: (error: unknown, context?: object) => {
Expand All @@ -241,6 +250,7 @@ export function makeRumPublicApi(startRumImpl: StartRum, recorderApi: RecorderAp
context: sanitize(context) as Context,
startClocks: clocksNow(),
})
addTelemetryUsage({ feature: 'add-error' })
})
},

Expand All @@ -264,13 +274,15 @@ export function makeRumPublicApi(startRumImpl: StartRum, recorderApi: RecorderAp
if (checkUser(newUser)) {
userContextManager.setContext(sanitizeUser(newUser as Context))
}
addTelemetryUsage({ feature: 'set-user' })
}),

getUser: monitor(() => userContextManager.getContext()),

setUserProperty: monitor((key, property) => {
const sanitizedProperty = sanitizeUser({ [key]: property })[key]
userContextManager.setContextProperty(key, sanitizedProperty)
addTelemetryUsage({ feature: 'set-user' })
}),

removeUserProperty: monitor((key) => userContextManager.removeContextProperty(key)),
Expand All @@ -296,6 +308,7 @@ export function makeRumPublicApi(startRumImpl: StartRum, recorderApi: RecorderAp
*/
addFeatureFlagEvaluation: monitor((key: string, value: any) => {
strategy.addFeatureFlagEvaluation(sanitize(key)!, sanitize(value))
addTelemetryUsage({ feature: 'add-feature-flag-evaluation' })
}),

getSessionReplayLink: monitor(() => recorderApi.getSessionReplayLink()),
Expand Down

0 comments on commit bbbbef0

Please sign in to comment.