-
Notifications
You must be signed in to change notification settings - Fork 508
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
feat: add placements #8213
feat: add placements #8213
Conversation
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.
First round of review (until client/src/setupProxy.js
)
.github/workflows/stage-build.yml
Outdated
@@ -231,6 +234,10 @@ jobs: | |||
|
|||
DEPLOYER_LAMBDA_PREFIX: stage- | |||
|
|||
KEVEL_SITE_ID: ${{ secrets.DEPLOYER_STAGE_KEVEL_SITE_ID }} | |||
KEVEL_NETWORK_ID: ${{ secrets.DEPLOYER_STAGE_KEVEL_NETWORK_ID }} | |||
SIGN_SECRET: ${{ secrets.DEPLOYER_STAGE_SIGN_KEY }} |
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.
This sign secret not specific to Kevel?
["updates", "Filter and sort updates"], | ||
["collections", "Collections of articles"], | ||
["offline", "MDN Offline"], | ||
["ads-free", "Ads free", "new"], |
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.
Feel like these should be objects 🤔
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.
Second round or review (A-Z)
pong: PlacementStatus, | ||
observer: IntersectionObserver | null = null | ||
) { | ||
navigator?.sendBeacon?.( |
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.
We wanted to pull the check inside here:
navigator?.sendBeacon?.( | |
navigator && navigator.sendBeacon?.( |
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.
Does this make a difference?
const userAgentHeader = request.headers["user-agent"]; | ||
const userAgent = userAgentHeader ? userAgentHeader[0].value : null; |
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.
We only use these in one branch.
return { | ||
status: 405, | ||
statusDescription: "METHOD_NOT_ALLOWED", | ||
}; |
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.
I'd almost extract these into const HTTP_405_METHOD_NOT_ALLOWED
for reuse.
deployer/aws-lambda/kevel/index.js
Outdated
} | ||
} else { | ||
payload = { | ||
copy: contents?.[0]?.data?.title || "🦖", |
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.
Perhaps just make this optional in the type in placement.tsx
, and deal with a null value there?
function getIsDocumentHidden() { | ||
if (typeof document !== "undefined") { | ||
return !document.hidden; | ||
} | ||
return false; | ||
} | ||
|
||
export function usePageVisibility() { | ||
const [isVisible, setIsVisible] = React.useState(getIsDocumentHidden()); | ||
const onVisibilityChange = () => setIsVisible(getIsDocumentHidden()); | ||
useEffect(() => { | ||
if (typeof document !== "undefined") { | ||
const visibilityChange = "visibilitychange"; | ||
document.addEventListener(visibilityChange, onVisibilityChange, false); | ||
return () => { | ||
document.removeEventListener(visibilityChange, onVisibilityChange); | ||
}; | ||
} | ||
}); | ||
return isVisible; | ||
} |
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.
This whole section of code is a bit weird, how about:
function getIsDocumentHidden() { | |
if (typeof document !== "undefined") { | |
return !document.hidden; | |
} | |
return false; | |
} | |
export function usePageVisibility() { | |
const [isVisible, setIsVisible] = React.useState(getIsDocumentHidden()); | |
const onVisibilityChange = () => setIsVisible(getIsDocumentHidden()); | |
useEffect(() => { | |
if (typeof document !== "undefined") { | |
const visibilityChange = "visibilitychange"; | |
document.addEventListener(visibilityChange, onVisibilityChange, false); | |
return () => { | |
document.removeEventListener(visibilityChange, onVisibilityChange); | |
}; | |
} | |
}); | |
return isVisible; | |
} | |
export function usePageVisibility() { | |
const [isVisible, setIsVisible] = React.useState( | |
typeof document === "undefined" | |
? false | |
: document.visibilityState === "visible" | |
); | |
useEffect(() => { | |
const onVisibilityChange = () => | |
setIsVisible(document.visibilityState === "visible"); | |
document.addEventListener("visibilitychange", onVisibilityChange); | |
return () => { | |
document.removeEventListener("visibilitychange", onVisibilityChange); | |
}; | |
}, []); | |
return isVisible; | |
} | |
} |
No description provided.