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

analytics: fix identify calls #5442

Merged
merged 1 commit into from
Feb 28, 2024
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
9 changes: 9 additions & 0 deletions src/analytics/userProperties.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { NativeCurrencyKey } from '@/entities';
import { Language } from '@/languages';

// have to put this here or redux gets important and tests break
type PushNotificationPermissionStatus = 'enabled' | 'disabled' | 'never asked';

// these are all reported seperately so they must be optional
export interface UserProperties {
// settings
Expand All @@ -11,6 +14,7 @@ export interface UserProperties {
enabledFlashbots?: boolean;
pinnedCoins?: string[];
hiddenCOins?: string[];
appIcon?: string;

// assets
NFTs?: number;
Expand All @@ -27,6 +31,11 @@ export interface UserProperties {
numberOfFreeMints?: number;
numberOfPaidMints?: number;

// notifications:
notificationsPermissionStatus?: PushNotificationPermissionStatus;
numberOfImportedWalletsWithNotificationsTurnedOn?: number;
numberOfWatchedWalletsWithNotificationsTurnedOn?: number;

// ens
// TODO: remove ensProfile tracking the entire object
ensProfile?: Record<any, any>;
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useTrackENSProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useQuery } from '@tanstack/react-query';
import { useCallback, useMemo } from 'react';
import { fetchENSRecords } from './useENSRecords';
import useWallets from './useWallets';
import { analytics } from '@/analytics';
import { analyticsV2 } from '@/analytics';
import { EthereumAddress } from '@/entities';
import { fetchAccountDomains } from '@/handlers/ens';
import { ENS_RECORDS } from '@/helpers/ens';
Expand Down Expand Up @@ -56,7 +56,7 @@ export default function useTrackENSProfile() {
});

const trackENSProfile = useCallback(() => {
isSuccess && analytics.identify(undefined, data);
isSuccess && data && analyticsV2.identify(data);
}, [isSuccess, data]);

return { trackENSProfile };
Expand Down
10 changes: 5 additions & 5 deletions src/notifications/analytics.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { analytics } from '@/analytics';
import { analytics, analyticsV2 } from '@/analytics';
import { MinimalNotification } from '@/notifications/types';
import { getPermissionStatus } from '@/notifications/permissions';
import messaging from '@react-native-firebase/messaging';
Expand Down Expand Up @@ -36,8 +36,8 @@ export const trackChangedNotificationSettings = (
});
};

export const trackPushNotificationPermissionStatus = (status: PushNotificationPermissionStatus) => {
analytics.identify(undefined, { notificationsPermissionStatus: status });
export const trackPushNotificationPermissionStatus = async (status: PushNotificationPermissionStatus) => {
analyticsV2.identify({ notificationsPermissionStatus: status });
};

type PushNotificationPermissionStatus = 'enabled' | 'disabled' | 'never asked';
Expand Down Expand Up @@ -130,8 +130,8 @@ const countWalletsWithNotificationsTurnedOn = (wallets: WalletNotificationSettin
};
};

const trackNumberOfWalletsWithNotificationsTurnedOn = (imported: number, watched: number) => {
analytics.identify(undefined, {
const trackNumberOfWalletsWithNotificationsTurnedOn = async (imported: number, watched: number) => {
analyticsV2.identify({
numberOfImportedWalletsWithNotificationsTurnedOn: imported,
numberOfWatchedWalletsWithNotificationsTurnedOn: watched,
});
Expand Down
4 changes: 2 additions & 2 deletions src/screens/WalletScreen/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { position } from '@/styles';
import { Toast, ToastPositionContainer } from '@/components/toasts';
import { useRecoilValue } from 'recoil';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { analytics } from '@/analytics';
import { analyticsV2 } from '@/analytics';
import { AppState } from '@/redux/store';
import { addressCopiedToastAtom } from '@/recoil/addressCopiedToastAtom';
import { usePositions } from '@/resources/defi/PositionsQuery';
Expand Down Expand Up @@ -137,7 +137,7 @@ const WalletScreen: React.FC<any> = ({ navigation, route }) => {

// track current app icon
useEffect(() => {
analytics.identify(undefined, { appIcon });
analyticsV2.identify({ appIcon });
}, [appIcon]);

const isAddressCopiedToastActive = useRecoilValue(addressCopiedToastAtom);
Expand Down
Loading