-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add X-Glean headers for experimental features and deprecation testing #95
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
Conversation
…esting Add a new beforeRequest hook that sets X-Glean-Exclude-Deprecated-After and X-Glean-Experimental headers based on SDK options or environment variables. This allows users to test upcoming API changes and preview experimental features before they become the default behavior.
rwjblue-glean
left a comment
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.
Overall looks good to me, only a few minor inline comments. I would like to see some tests for this though.
README.md
Outdated
| // Set environment variables before initializing the SDK | ||
| process.env.X_Glean_Exclude_Deprecated_After = '2026-10-15'; | ||
| process.env.X_Glean_Include_Experimental = 'true'; |
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.
1/5 (nit, non-blocking)
I think I'd expect all caps for environment variables like this, WDYT?
| // Set environment variables before initializing the SDK | |
| process.env.X_Glean_Exclude_Deprecated_After = '2026-10-15'; | |
| process.env.X_Glean_Include_Experimental = 'true'; | |
| // Set environment variables before initializing the SDK | |
| process.env.X_GLEAN_EXCLUDE_DEPRECATED_AFTER = '2026-10-15'; | |
| process.env.X_GLEAN_INCLUDE_EXPERIMENTAL = 'true'; |
I know the header values are not case-sensitive, but the environment variables are.
I don't feel strongly here at all, so feel free to do whatever you think is best.
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.
Lets do all caps, will update.
| /** | ||
| * Exclude API endpoints that will be deprecated after this date. | ||
| * Use this to test your integration against upcoming deprecations. | ||
| * Format: YYYY-MM-DD (e.g., '2026-10-15') | ||
| */ | ||
| excludeDeprecatedAfter?: string | undefined; |
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.
3/5 (strong opinion: non-blocking)
Can you add a link to the developers.glean.com site for this (I think you've already written a guide that we can link to).
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.
Yep!
| /** | ||
| * When true, enables experimental API features that are not yet generally available. | ||
| * Use this to preview and test new functionality. | ||
| */ | ||
| includeExperimental?: boolean | undefined; |
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.
3/5 (strong opinion: non-blocking)
Same thing here, maybe a link to the website would be great.
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.
Right now we dont have anything on the experimental stuff (not sure if we want to list out experiments or not) but if we do then I will add a link to that here
| const deprecatedValue = getFirstValue( | ||
| process.env["X_Glean_Exclude_Deprecated_After"], | ||
| hookCtx.options.excludeDeprecatedAfter, | ||
| ); | ||
|
|
||
| const experimentalValue = getFirstValue( | ||
| process.env["X_Glean_Include_Experimental"], | ||
| hookCtx.options.includeExperimental === true ? "true" : undefined, | ||
| ); |
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.
2/5 (minor preference, non-blocking)
This is interesting. I do agree with you that the environment variable should override, but it feels a little bit weird for the constructor arg to be completely ignored without any sort of message, warning, or anything.
Also, is it possible in the current implementation to use the environment variable to disable or only enable? Like, if you pass true to the constructor, how do you unset it via environment variable?
I don't think we fundamentally have to do that, just something I thought about while reviewing.
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.
Ya right now if you pass via the constructor there isn't a way to unset that programmatically. I think for now if you need to be setting/unsetting our suggestion is to use environment vars or just create 2 separate instances (one experimental and one regular one)
Rename environment variables to follow standard uppercase naming: - X_Glean_Exclude_Deprecated_After -> X_GLEAN_EXCLUDE_DEPRECATED_AFTER - X_Glean_Include_Experimental -> X_GLEAN_INCLUDE_EXPERIMENTAL
Add comprehensive tests covering: - Headers set correctly via SDK constructor options - Headers set correctly via environment variables - Environment variables take precedence over SDK options - No headers set when neither option is configured
Summary
XGleanbeforeRequest hook that setsX-Glean-Exclude-Deprecated-AfterandX-Glean-ExperimentalheadersexcludeDeprecatedAfterandincludeExperimentalwith corresponding environment variable supportTest plan