-
Notifications
You must be signed in to change notification settings - Fork 74
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
Changes from all commits
9a209f5
0631c7d
8ced144
94224f0
bafb28f
8707110
87e6a9a
99bf1b8
4ad03bd
a9447e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,7 @@ export interface Props { | |
artwork: ArtworkApp_artwork | ||
tracking?: TrackingProp | ||
routerPathname: string | ||
referrer: string | ||
} | ||
|
||
declare const window: any | ||
|
@@ -53,6 +54,7 @@ export class ArtworkApp extends React.Component<Props> { | |
trackPageview() { | ||
const { | ||
artwork: { listPrice, availability, is_offerable, is_acquireable }, | ||
referrer, | ||
} = this.props | ||
|
||
// FIXME: This breaks our global pageview tracking in the router level. | ||
|
@@ -64,6 +66,7 @@ export class ArtworkApp extends React.Component<Props> { | |
offerable: is_offerable, | ||
availability, | ||
price_listed: !!listPrice, | ||
referrer, | ||
} | ||
|
||
if (typeof window.analytics !== "undefined") { | ||
|
@@ -222,7 +225,14 @@ export class ArtworkApp extends React.Component<Props> { | |
</Col> | ||
</Row> | ||
|
||
<div id="lightbox-container" /> | ||
<div | ||
id="lightbox-container" | ||
style={{ | ||
position: "absolute", | ||
top: 0, | ||
zIndex: 1100, // over top nav | ||
}} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
/> | ||
<SystemContextConsumer> | ||
{({ mediator }) => <>{this.enableIntercomForBuyers(mediator)}</>} | ||
</SystemContextConsumer> | ||
|
@@ -236,11 +246,14 @@ export const ArtworkAppFragmentContainer = createFragmentContainer( | |
(props: Props) => { | ||
const { | ||
match: { | ||
location: { pathname }, | ||
location: { pathname, state }, | ||
}, | ||
} = useContext(RouterContext) | ||
|
||
return <ArtworkApp {...props} routerPathname={pathname} /> | ||
const referrer = state && state.previousHref | ||
return ( | ||
<ArtworkApp {...props} routerPathname={pathname} referrer={referrer} /> | ||
) | ||
}, | ||
{ | ||
artwork: graphql` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { Button, Flex, Serif } from "@artsy/palette" | ||
import { RouterLink } from "Artsy/Router/RouterLink" | ||
import React from "react" | ||
|
||
interface HeaderProps { | ||
|
@@ -16,14 +17,11 @@ export const Header: React.SFC<HeaderProps> = props => { | |
{title} | ||
</Serif> | ||
{buttonHref && ( | ||
<Button | ||
variant="secondaryOutline" | ||
mb={3} | ||
// FIXME: Move to <Link> component once https://github.com/artsy/palette/pull/130 is merged | ||
onClick={() => (window.location.href = buttonHref)} | ||
> | ||
View all | ||
</Button> | ||
<RouterLink to={buttonHref}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah cool, yea these custom |
||
<Button variant="secondaryOutline" mb={3}> | ||
View all | ||
</Button> | ||
</RouterLink> | ||
)} | ||
{children} | ||
</Flex> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,14 @@ import { data as sd } from "sharify" | |
|
||
export function getENV(ENV_VAR) { | ||
const isServer = typeof window === "undefined" | ||
const envVar = isServer ? process.env[ENV_VAR] : sd[ENV_VAR] | ||
|
||
let envVar | ||
if (isServer) { | ||
const httpContext = require("express-http-context") | ||
envVar = httpContext.get(ENV_VAR) ?? process.env[ENV_VAR] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting. I didn't fully get immediately how different is than Cool! I look forward to trying this. |
||
} else { | ||
envVar = sd[ENV_VAR] | ||
} | ||
|
||
return envVar | ||
} |
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.
Suprised this wasn't already in! We can no do
which should eliminate our need for the
get
util.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.
oo sick!