Skip to content
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

Simplify A/B test lookup via express-http-context #3191

Merged
merged 10 commits into from
Feb 24, 2020

Conversation

damassi
Copy link
Member

@damassi damassi commented Feb 22, 2020

See artsy/force#5099 for more info.

This updates our getENV isomorphic ENV lookup util with another server-side layer:

  • First, check to see if SOME_ENV var exists within the request / response cycle, stored within express-http-context. If so, return that value. Useful for A/B testing.
  • If undefined, fall back to process.env.SOME_ENV

@artsy-peril artsy-peril bot added the Version: Patch Indicates that this PR should have a patch deploy, usually for bug fixes label Feb 22, 2020
let envVar
if (isServer) {
const httpContext = require("express-http-context")
envVar = httpContext.get(ENV_VAR) ?? process.env[ENV_VAR]
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uses new nullish coalesing plugin, which always returns the left hand side of the operation unless null or undefined.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. I didn't fully get immediately how different is than ||. I do now recognize the subtle difference, but I think generally any sort of conditional assignment like this, if you are expecting a false-y/null/undefined to be possible (or even valid, esp. as a default), I almost always open a console to try it out (and/or mentally unpack it in my brain for a second).

Cool! I look forward to trying this.

@@ -19,6 +19,8 @@
}
],
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-optional-chaining",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suprised this wasn't already in! We can no do

const deepPropOrUndefined = foo?.bar?.baz?.bam

which should eliminate our need for the get util.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oo sick!

position: "absolute",
top: 0,
zIndex: 1100, // over top nav
}}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes long standing issue where when a user views an artwork in full screen, the top nav bar flops out due to z-index and position.

>
View all
</Button>
<RouterLink to={buttonHref}>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah cool, yea these custom window.location.href navigations in JS dont work with our router.

@mzikherman
Copy link
Collaborator

This looks good! Since this depends on Node v12, which still hasn't been fully deployed to production, so we hold off on merging these PR's until we're happy with v12 in prod?

@codecov
Copy link

codecov bot commented Feb 24, 2020

Codecov Report

Merging #3191 into master will increase coverage by <.1%.
The diff coverage is 66.6%.

@@           Coverage Diff            @@
##           master   #3191     +/-   ##
========================================
+ Coverage    82.4%   82.4%   +<.1%     
========================================
  Files         761     761             
  Lines       11357   11357             
  Branches     2245    2245             
========================================
+ Hits         9360    9361      +1     
+ Misses       1386    1385      -1     
  Partials      611     611

@mzikherman mzikherman merged commit 2008cd3 into artsy:master Feb 24, 2020
@damassi damassi deleted the wire-up-context branch February 24, 2020 23:21
@artsyit
Copy link
Contributor

artsyit commented Feb 24, 2020

🚀 PR was released in v25.18.1 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Version: Patch Indicates that this PR should have a patch deploy, usually for bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants