Install @mosaicstack/telemetry-client in API #369
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Add the
@mosaicstack/telemetry-clientnpm package toapps/apiand create a NestJS module that provides a singleton telemetry client for the entire API.Requirements
Package Installation
@mosaicstack/telemetry-clientfrom Gitea npm registry (https://git.mosaicstack.dev/api/packages/mosaic/npm/).npmrcscoped registry config if not already presentNestJS Module:
MosaicTelemetryModule@Global()) so all services can injectTelemetryClientsingleton initialized from environment variablesonModuleInit()→client.start(),onModuleDestroy()→client.stop()Configuration (env vars)
Injectable Service:
MosaicTelemetryServiceTelemetryClientwith convenience methodstrackTaskCompletion(event: TaskCompletionEvent)— queue eventgetPrediction(query)— read cached predictionrefreshPredictions(queries)— fetch from serverEventBuilderfor constructing eventsMOSAIC_TELEMETRY_ENABLED=falseKey SDK Details
onErrorcallback (log via NestJS Logger)Acceptance Criteria
Completed in commit
0c4ad7con feature/m10-telemetry. Installed @mosaicstack/telemetry-client, created MosaicTelemetryModule (global NestJS module), MosaicTelemetryService wrapper, config from env vars. 32 unit tests.