Skip to content

Commit

Permalink
LLD - Braze Content cards clicks tracking (#7857)
Browse files Browse the repository at this point in the history
* fix(lld): content cards clicks tracking

* remove log
  • Loading branch information
cgrellard-ledger authored Sep 20, 2024
1 parent 45a27dc commit 509d47d
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 14 deletions.
5 changes: 5 additions & 0 deletions .changeset/gentle-fireants-nail.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ledger-live-desktop": patch
---

LLD - Fix Content Cards clicks tracking and other issues
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ export const useDefaultSlides = (): {
if (currentCard) {
// For some reason braze won't log the click event if the card url is empty
// Setting it as the card id just to have a dummy non empty value
isTrackedUser &&
braze.logContentCardClick({ ...currentCard, url: currentCard.id } as braze.ClassicCard);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
currentCard.url = currentCard.id;
isTrackedUser && braze.logContentCardClick(currentCard as braze.ClassicCard);
}
},
[cachedContentCards, isTrackedUser],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,23 @@ const Carousel = ({
const [paused, setPaused] = useState(false);
const [reverse, setReverse] = useState(false);
const transitions = useTransition(index, p => p, getTransitions(type, reverse));
const [hasLoggedFirstImpression, setHasLoggedFirstImpression] = useState(false);

useEffect(() => {
logSlideImpression(0);
}, [logSlideImpression]);
if (!hasLoggedFirstImpression) {
setHasLoggedFirstImpression(true);
logSlideImpression(0);
}
}, [hasLoggedFirstImpression, logSlideImpression]);

const changeVisibleSlide = useCallback(
(index: number) => {
setIndex(index);
logSlideImpression(index);
(newIndex: number) => {
if (index !== newIndex) {
setIndex(newIndex);
logSlideImpression(newIndex);
}
},
[logSlideImpression],
[index, logSlideImpression],
);

const onChooseSlide = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ const useActionCards = () => {
if (currentCard) {
// For some reason braze won't log the click event if the card url is empty
// Setting it as the card id just to have a dummy non empty value
isTrackedUser &&
braze.logContentCardClick({ ...currentCard, url: currentCard.id } as braze.ClassicCard);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
currentCard.url = currentCard.id;
isTrackedUser && braze.logContentCardClick(currentCard as braze.ClassicCard);
link && openURL(link);
}
if (actionCard) {
Expand Down
2 changes: 0 additions & 2 deletions apps/ledger-live-desktop/src/renderer/hooks/useBraze.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ export async function useBraze() {

if (user) braze.changeUser(isTrackedUser ? user.id : anonymousBrazeId.current);

braze.requestPushPermission();

braze.requestContentCardsRefresh();

braze.subscribeToContentCardsUpdates(cards => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ export function useNotifications() {
if (currentCard) {
// For some reason braze won't log the click event if the card url is empty
// Setting it as the card id just to have a dummy non empty value
isTrackedUser &&
braze.logContentCardClick({ ...currentCard, url: currentCard.id } as braze.ClassicCard);
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-expect-error
currentCard.url = currentCard.id;
isTrackedUser && braze.logContentCardClick(currentCard as braze.ClassicCard);
}

track("contentcard_clicked", {
Expand Down

0 comments on commit 509d47d

Please sign in to comment.