Skip to content
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(llm): ⚡️ fix braze related performance issues #8872

Merged
merged 1 commit into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/poor-students-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": minor
---

Fix braze related performance issues
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import Braze from "@braze/react-native-sdk";
import { useCallback, useRef } from "react";
import { useSelector, useDispatch, shallowEqual } from "react-redux";
import { useSelector, useDispatch } from "react-redux";
import { track } from "~/analytics";
import { setDismissedContentCard } from "~/actions/settings";
import { trackingEnabledSelector } from "~/reducers/settings";
import { mobileCardsSelector } from "~/reducers/dynamicContent";

export const useBrazeContentCard = () => {
export const useBrazeContentCard = (mobileCards: Braze.ContentCard[]) => {
const isTrackedUser = useSelector(trackingEnabledSelector);
const mobileCards = useSelector(mobileCardsSelector, shallowEqual);
const mobileCardRef = useRef(mobileCards);
const dispatch = useDispatch();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ import { setDynamicContentMobileCards } from "~/actions/dynamicContent";

const useDynamicContent = () => {
const dispatch = useDispatch();
const { logClickCard, logDismissCard, logImpressionCard, refreshDynamicContent } =
useBrazeContentCard();
const notificationCards = useSelector(notificationsCardsSelector);
const assetsCards = useSelector(assetsCardsSelector);
const walletCards = useSelector(walletCardsSelector);
Expand All @@ -35,6 +33,9 @@ const useDynamicContent = () => {
const mobileCards = useSelector(mobileCardsSelector);
const hiddenCards: string[] = useSelector(dismissedDynamicCardsSelector);

const { logClickCard, logDismissCard, logImpressionCard, refreshDynamicContent } =
useBrazeContentCard(mobileCards);

const walletCardsDisplayed = useMemo(
() => walletCards.filter((wc: WalletContentCard) => !hiddenCards.includes(wc.id)),
[walletCards, hiddenCards],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Braze from "@braze/react-native-sdk";
import { useCallback } from "react";
import { useDispatch, useSelector } from "react-redux";
import {
Expand All @@ -10,7 +11,6 @@ import {
setIsDynamicContentLoading,
setDynamicContentLandingPageStickyCtaCards,
} from "../actions/dynamicContent";
import { useBrazeContentCard } from "./brazeContentCard";
import {
filterByPage,
filterByType,
Expand All @@ -31,7 +31,7 @@ import { clearDismissedContentCards } from "~/actions/settings";

export const useDynamicContentLogic = () => {
const dispatch = useDispatch();
const { Braze, refreshDynamicContent } = useBrazeContentCard();
const refreshDynamicContent = useCallback(() => Braze.requestContentCardsRefresh(), []);
const dismissedContentCards = useSelector(dismissedContentCardsSelector) || {};
const dismissedContentCardsIds = Object.keys(dismissedContentCards);

Expand Down Expand Up @@ -90,7 +90,7 @@ export const useDynamicContentLogic = () => {
dispatch(setDynamicContentLearnCards(learnCards));
dispatch(setDynamicContentLandingPageStickyCtaCards(landingPageStickyCtaCards));
dispatch(setIsDynamicContentLoading(false));
}, [Braze, dismissedContentCardsIds, dispatch]);
}, [dismissedContentCardsIds, dispatch]);

const clearOldDismissedContentCards = () => {
const oldCampaignIds = getOldCampaignIds(dismissedContentCards || {});
Expand Down
Loading