Add event system with metrics and typings - #9
Merged
Merged
Conversation
Introduces Event.js implementing a publish/subscribe event system with Prometheus metrics tracking, and Event.d.ts for TypeScript definitions. Updates package.json exports to use the new event files.
Eliminated unnecessary inline comments from Event.js, Event.ts, and Event.d.ts to improve code readability and maintain consistency. No functional changes were made.
Changed logging from console.debug to console.log for subscription and unsubscription events. Also removed some redundant comments to clean up the code.
Adds error handling for JSON.stringify when calculating payload size in the publish function. If stringification fails, logs the error, increments an error metric, and sets payload size to 0 to prevent crashes.
Deleted an unnecessary comment related to tracking unsubscription in the subscribe function for improved code clarity.
Removed src/Event.js and src/Event.d.ts, consolidating all event logic into src/Event.ts. Updated package.json build script to compile src/Event.ts. This change improves type safety and maintainability by using TypeScript directly for the Event module.
canmingir
approved these changes
Aug 28, 2025
There was a problem hiding this comment.
Pull Request Overview
Refactors the existing event system by updating imports, removing comments, and modifying the build configuration to support compiled JavaScript output with TypeScript definitions.
- Updated import statement from default to namespace import for prom-client
- Removed inline comments throughout the metrics tracking code
- Modified package.json to build TypeScript files and export compiled JavaScript with type definitions
Reviewed Changes
Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/Event.ts | Updated prom-client import and removed inline comments from metrics code |
| package.json | Added TypeScript compilation step and updated exports to use compiled .js and .d.ts files |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Introduces Event.js implementing a publish/subscribe event system with Prometheus metrics tracking, and Event.d.ts for TypeScript definitions. Updates package.json exports to use the new event files.