-
Notifications
You must be signed in to change notification settings - Fork 357
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(llm): 🗒️ log content card impression when 50% of the card is shown #8526
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 4 Skipped Deployments
|
33c644d
to
1747c22
Compare
const { logImpressionCard } = useDynamicContent(); | ||
|
||
useInViewContext(ref, ({ isInView }) => { | ||
if (isInView) logImpressionCard(id); |
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 may also need to add normal analytics too 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.
Done!
import { Linking } from "react-native"; | ||
import useDynamicContent from "~/dynamicContent/useDynamicContent"; | ||
import LogContentCardWrapper from "~/newArch/features/DynamicContent/components/LogContentCardWrapper"; |
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.
import LogContentCardWrapper from "~/newArch/features/DynamicContent/components/LogContentCardWrapper"; | |
import LogContentCardWrapper from "LLM/features/DynamicContent/components/LogContentCardWrapper"; |
1747c22
to
8761dc7
Compare
Demos for the other content cardswith Notifications cards:Screen.Recording.2024-12-02.at.12.37.31.movWallet cards:(Nb: When the 3rd card is swipped back the 2de card impression is not retriggered because it did not completely left the screen. However when this card is swipped back the 1st card impression is retriggered) Screen.Recording.2024-12-02.at.10.36.53.movAsset cards:Screen.Recording.2024-12-02.at.11.20.26.movCarousel category cards:Screen.Recording.2024-12-02.at.14.15.53.movUique category cards:Screen.Recording.2024-12-02.at.14.17.11.mov |
8761dc7
to
45f1354
Compare
deps: DependencyList = [], | ||
) { | ||
const { addWatchedItem, removeWatchedItem } = useContext(InViewContext); | ||
const onInViewUpdateCb = useCallback(onInViewUpdate, deps); // eslint-disable-line react-hooks/exhaustive-deps |
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.
is the bypass really necessary ? We should avoid that
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 might be missing another posibility but here's how I see it:
The way I see not to bypass the react-hooks/exhaustive-deps
would be to go:
From version 1
// Declaration
function useInViewContext(
target: RefObject<View>,
onInViewUpdate: (entry: InViewEntry) => void,
deps: DependencyList = [],
)
...
// Usage
useInViewContext(target, ({ isInView }) => {
if (isInView) logImpressionCard(id);
}, [id]);
To version 2
// Declaration
function useInViewContext(
target: RefObject<View>,
onInViewUpdate: (entry: InViewEntry) => void
)
...
// Usage
useInViewContext(target, useCallback(({ isInView }) => {
if (isInView) logImpressionCard(id);
}, [id]));
The problem I have with version 2 is that the type signature doesn't make it clear onInViewUpdate
is a dependency which means writing this would be problematic:
useInViewContext(target, ({ isInView }) => {
if (isInView) logImpressionCard(id);
});
(because the internal useEffect
will rerender on every re-render).
In react we are used to pass functions to hooks directly (without wrapping them in useCallback
). So I think that here forwarding the dependencies to the hook is better to avoid mistakes. However it means that the variable used to forward the dependencies can't be statically analized by react-hooks/exhaustive-deps
which makes the bypass necessary.
That said I could add useInViewContext
to the config rules."react-hooks/exhaustive-deps".additionalHooks
. So I'll have to add logImpressionCard
to all the deps.
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.
Done: d444580
45f1354
to
d444580
Compare
/> | ||
<LogContentCardWrapper key={cardProps.id + index} id={cardProps.id}> | ||
<CarouselCard | ||
key={cardProps.id + index} |
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 think you can remove this key as it's already used on the parent
d444580
to
7378513
Compare
…wn (#8526) * feat(llm): log category cards impression when 50% of the card is visible * feat(llm): do not run in view checks when no items is being watched * feat(llm): log portfolio content cards impression on 50% visibility * chore: update change log * feat(llm): log dynamic content card impression when 50% is shown * feat(llm): log notification impression when 50% is shown * chore(llm): rename IsInViewContext to InViewContext * chore(llm): add InViewContextProvider to the AppProviders * fix(llm): undefined order in null * feat(lld): log category impression when 50% is shown * chore(llm): use LLM alias in imports * feat(llm): trigger segment event on card impression * fix(llm): rewatch card when `LogContentCardWrapper.id` change * fix(llm): use mobileCardsSelector to find the card to log the impression * fix(llm): race condition between interval and inViewStatus * chore(llm): check "exhaustive-deps" on `useInViewContext` * chore(llm): remove unnecessary key
…wn (#8526) * feat(llm): log category cards impression when 50% of the card is visible * feat(llm): do not run in view checks when no items is being watched * feat(llm): log portfolio content cards impression on 50% visibility * chore: update change log * feat(llm): log dynamic content card impression when 50% is shown * feat(llm): log notification impression when 50% is shown * chore(llm): rename IsInViewContext to InViewContext * chore(llm): add InViewContextProvider to the AppProviders * fix(llm): undefined order in null * feat(lld): log category impression when 50% is shown * chore(llm): use LLM alias in imports * feat(llm): trigger segment event on card impression * fix(llm): rewatch card when `LogContentCardWrapper.id` change * fix(llm): use mobileCardsSelector to find the card to log the impression * fix(llm): race condition between interval and inViewStatus * chore(llm): check "exhaustive-deps" on `useInViewContext` * chore(llm): remove unnecessary key
✅ Checklist
npx changeset
was attached.📝 Description
Depending on the type of content card, use a mix of:
FlatList.onViewableItemsChanged
Demo:
Screen.Recording.2024-11-29.at.18.02.02.mov
Screen.Recording.2024-11-29.at.17.55.46.mov
❓ Context
🧐 Checklist for the PR Reviewers