-
Notifications
You must be signed in to change notification settings - Fork 524
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
fix(placement): fix firing multiple impressions #9631
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.
Sorry, took me a little while to figure out why I was getting confused - skip straight to my last comment about reactifying the intersection observer, it should massively simplify the logic here
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.
Most of these are comments on my own code, haha - see what you think, but I think they all counts as nits (maybe apart from the test comment, if we want to ensure things don't error out on browsers which don't support IntersectionObserver)
timer.current = { timeout: -1 }; | ||
}, [pong, gleanClick, typ]); | ||
|
||
const place = useCallback((node: HTMLElement | 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.
nit (in my own code): we already have a node
const declared in the scope above. We could do what I did with the intersection observer hook and do something like: const [nodeState, setNodeState] = useState<HTMLElement>();
instead
client/src/document/index.test.tsx
Outdated
import { render, waitFor } from "@testing-library/react"; | ||
|
||
import { Document } from "./index"; | ||
|
||
declare var global: Window; | ||
|
||
// TODO: move this somewhere better once we have more use cases. | ||
class IntersectionObserver { |
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.
Considering our chat about progressive enhancement the other day, might it be better to remove this from the tests, and just ensure we wrap our code with if (typeof IntersectionObserver !== "undefined")
or similar, as necessary?
Unify sendViewed and empty placement.
by leo
abb30e1
to
bd198f5
Compare
Summary
Unify
sendViewed
and empty placement.Problem
We did not cancel our timer properly.
Solution
Use an unified
sendViewed
function.How did you test this change?
Locally