feat(app): tag User-Agent with concrete receiver class name (#1150)#2881
Open
tmchow wants to merge 1 commit intoslackapi:mainfrom
Open
feat(app): tag User-Agent with concrete receiver class name (#1150)#2881tmchow wants to merge 1 commit intoslackapi:mainfrom
tmchow wants to merge 1 commit intoslackapi:mainfrom
Conversation
The App constructor now emits a second `addAppMetadata` entry whose name includes the receiver's class name (e.g. `@slack/bolt-HTTPReceiver`). Having the receiver type in outbound WebClient User-Agent strings lets the Slack team see which receivers are actually deployed in the wild and prioritize missing features accordingly. Closes slackapi#1150
|
Thanks for the contribution! Before we can merge this, we need @tmchow to sign the Salesforce Inc. Contributor License Agreement. |
|
Author
|
I signed the CLA |
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.
Summary
Closes #1150.
The Slack team wants to see which receivers bolt-js apps are actually running so they can prioritize missing features based on real usage. Today the only tag the WebClient emits for a bolt app is
@slack/bolt/<version>, so every receiver is indistinguishable from every other.This registers a second
addAppMetadataentry whose name includes the concrete receiver class (for example@slack/bolt-HTTPReceiver,@slack/bolt-SocketModeReceiver,@slack/bolt-AwsLambdaReceiver, or the class name of a user-supplied custom receiver). It is registered from the App constructor afterthis.socketModeis resolved but beforenew WebClient(...)is constructed, becauseWebClientsnapshotsgetUserAgent()into its axios headers at construction time. The existing module-load-timeaddAppMetadata({ name: '@slack/bolt', version })entry is left in place so the base package tag remains, which keeps existing telemetry consumers working.addAppMetadatawrites to a module-global map inside@slack/web-api, so a Node process that constructs multiple App instances with different receiver types will accumulate both entries in every subsequent WebClient's User-Agent. In single-App processes (the common case) the tag is exact; in multi-App processes the tag set is a superset of the receiver types that App has constructed, which over-attributes but does not under-attribute receiver usage. A tighter per-App scoping would require piping a custom User-Agent throughclientOptionsand bypassing the module-global metadata path, which is a larger design decision; happy to take that route if you prefer.Verified with
npm run build(clean),npm run lint(Biome, 136 files, no fixes applied), andnpm run test:unit(465 tests, including a newreceiver-type app metadatacase intest/unit/App/basic.spec.tsthat assertsaddAppMetadatais called with a name ending in-FakeReceiverwhen an app is built with a custom receiver).Requirements