-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Defining agent api methods for ts types #613
Conversation
Asset Size ReportMerging this pull request will result in the following CDN asset size changes:
Merging this pull request will result in the following NPM package consumer size changes:
Other Standard CDN AssetsReleased Assets
Built Assets
Other Polyfill CDN AssetsReleased Assets
Built Assets
|
Codecov Report
@@ Coverage Diff @@
## main #613 +/- ##
==========================================
- Coverage 67.00% 66.73% -0.27%
==========================================
Files 129 130 +1
Lines 5979 6003 +24
Branches 1137 1137
==========================================
Hits 4006 4006
- Misses 1608 1632 +24
Partials 365 365
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
This is a very elegant use of the abstract base class pattern. Well done 👏 |
* @param {string} key Used as the attribute name on the BrowserInteraction event. | ||
* @param {any} key Used as the attribute value on the BrowserInteraction event. This can be a string, number, boolean, or object. If it is an object, New Relic serializes it to a JSON string. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @property {createTracer} createTracer | ||
* @property {end} end | ||
* @property {getContext} getContext | ||
* @property {ignore} ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@patrickhousley I had some TS issues after updating... |
Thanks @villelahdenvuo I guess I was half asleep when I wrote that 😥 I will get a fix put in |
Updating the type interface of the Agent and MicroAgent classes to properly expose the agent API methods in the generated typescript types.
Overview
Added a new base agent class that contains stubbed methods for all the agent API methods with proper documentation. The Agent and MicroAgent classes now extend this base class. While this does add code to the bundle and a new inheritance, I could find no other way to expose the API methods on the classes in the generated typescript types and retain the code in javascript.
Related Issue(s)
https://issues.newrelic.com/browse/NR-139951
Closes #608
Testing
Run
npm run build:all
and start the test servernpm run test-server
. Once the server is up, access http://bam-test-1.nr-local.net:3333/tests/assets/test-builds/vite-react-wrapper/index.html and verify the interaction name has been updated.To test other API methods, update
tools/test-builds/vite-react-wrapper/src/newrelic.ts
and re-run the build.