Skip to content

Commit

Permalink
feat(llm): trigger segment event on card impression
Browse files Browse the repository at this point in the history
  • Loading branch information
thesan committed Nov 29, 2024
1 parent 21b8ac2 commit 8761dc7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion apps/ledger-live-mobile/src/dynamicContent/brazeContentCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useCallback } from "react";
import Braze from "@braze/react-native-sdk";
import { trackingEnabledSelector } from "../reducers/settings";
import { useSelector, useDispatch } from "react-redux";
import { track } from "~/analytics";
import { setDismissedContentCard } from "../actions/settings";

export const useBrazeContentCard = () => {
Expand All @@ -22,7 +23,16 @@ export const useBrazeContentCard = () => {
);

const logImpressionCard = useCallback(
(cardId: string) => isTrackedUser && Braze.logContentCardImpression(cardId),
async (cardId: string) => {
if (!isTrackedUser) return;

Braze.logContentCardImpression(cardId);

const allCachedContentCards = await Braze.getCachedContentCards();
const card = allCachedContentCards.find(card => card.id === cardId);
if (!card) return;
track("contentcard_impression", { ...card.extras, page: card.extras.location });
},
[isTrackedUser],
);

Expand Down

0 comments on commit 8761dc7

Please sign in to comment.