Skip to content
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
3 changes: 2 additions & 1 deletion frontend/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@
"microphonePermission": "Allow Keepsafe to access your microphone."
}
],
"expo-background-task"
"expo-background-task",
"expo-localization"
],
"experiments": {
"typedRoutes": true
Expand Down
11 changes: 11 additions & 0 deletions frontend/app/capture/details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useUserEntries } from '@/hooks/use-user-entries';
import { usePrivacySettings } from '@/hooks/use-privacy-settings';
import { PrivacySettings } from '@/types/privacy';
import { MediaCapture } from '@/types/media';
import { posthog } from '@/constants/posthog';

import { moderateScale, verticalScale } from 'react-native-size-matters';
import * as Crypto from 'expo-crypto';
Expand Down Expand Up @@ -215,6 +216,16 @@ export default function DetailsScreen() {
});

if (result.success) {
try {
posthog.capture('entry_captured', {
type: capture.type,
is_private: isPrivate,
is_everyone: isEveryone,
friends_count: selectedFriends.length
});
} catch (error) {
if (__DEV__) console.warn('Analytics capture failed:', error);
}
toast(result.message, 'success');
setTimeout(() => {
router.push('/capture');
Expand Down
25 changes: 20 additions & 5 deletions frontend/bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions frontend/constants/posthog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { PostHog } from 'posthog-react-native';

const apiKey = process.env.EXPO_PUBLIC_POSTHOG_API_KEY;
const host = process.env.EXPO_PUBLIC_POSTHOG_HOST;

if (!apiKey || !host) {
if (__DEV__) {
console.warn('PostHog environment variables not configured. Analytics will be disabled.');
}
}

export const posthog = apiKey && host
? new PostHog(apiKey, { host })
: {
// Provide a no-op mock for when PostHog is not configured
capture: (_event: string, _properties?: object) => Promise.resolve(),
identify: (_distinctId: string, _properties?: object) => Promise.resolve(),
reset: () => Promise.resolve(),
screen: (_screenName: string, _properties?: object) => Promise.resolve(),
group: (_groupType: string, _groupKey: string, _properties?: object) => Promise.resolve(),
alias: (_alias: string) => Promise.resolve(),
reloadFeatureFlags: () => {},
isFeatureEnabled: () => false,
getFeatureFlag: () => null,
getFeatureFlagPayload: () => null,
} as unknown as PostHog;
7 changes: 7 additions & 0 deletions frontend/hooks/use-friends.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Database } from '@/types/database';
import { deviceStorage } from '@/services/device-storage';
import { FriendService } from '@/services/friend-service';
import { useAuthContext } from '@/providers/auth-provider';
import { posthog } from '@/constants/posthog';
import { FriendWithProfile } from '@/types/friends';


Expand Down Expand Up @@ -161,6 +162,12 @@ export function useFriends(userId?: string): UseFriendsResult {
status: FRIENDSHIP_STATUS.BLOCKED,
blocked_by: userId
});
try {
// Omitting friendship_id for privacy compliance
posthog.capture('friend_blocked', {});
} catch (error) {
if (__DEV__) console.warn('Analytics capture failed:', error);
}
return { success: true };
} catch (error) {
return {
Expand Down
8 changes: 8 additions & 0 deletions frontend/hooks/use-invite-acceptance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useState, useCallback } from 'react';
import { useMutation, useQuery } from '@tanstack/react-query';
import { supabase } from '@/lib/supabase';
import { TABLES, FRIENDSHIP_STATUS } from '@/constants/supabase';
import { posthog } from '@/constants/posthog';

export interface InviteData {
id: string;
Expand Down Expand Up @@ -130,6 +131,13 @@ export function useInviteAcceptance(inviteId?: string): UseInviteAcceptanceResul
userId: userId
});

if (inviteeId && userId) {
posthog.capture('invite_accepted', {
inviter_id: inviteeId,
invitee_id: userId
});
}

return {
success: true,
message: 'Invitation accepted successfully!',
Expand Down
7 changes: 5 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"axios": "^1.12.2",
"date-fns": "^4.1.0",
"expo": "54",
"expo-application": "~7.0.8",
"expo-audio": "~1.0.13",
"expo-av": "~16.0.7",
"expo-background-task": "~1.0.8",
Expand All @@ -45,15 +46,16 @@
"expo-contacts": "~15.0.8",
"expo-crypto": "~15.0.7",
"expo-dev-client": "~6.0.12",
"expo-device": "^8.0.8",
"expo-device": "~8.0.10",
"expo-document-picker": "~14.0.7",
"expo-file-system": "~19.0.12",
"expo-file-system": "~19.0.21",
"expo-font": "~14.0.8",
"expo-haptics": "~15.0.7",
"expo-image": "~3.0.8",
"expo-image-picker": "~17.0.8",
"expo-linear-gradient": "~15.0.7",
"expo-linking": "~8.0.8",
"expo-localization": "~17.0.8",
"expo-location": "~19.0.7",
"expo-notifications": "~0.32.11",
"expo-router": "~6.0.1",
Expand All @@ -67,6 +69,7 @@
"expo-video": "~3.0.11",
"expo-web-browser": "~15.0.7",
"lucide-react-native": "^0.475.0",
"posthog-react-native": "^4.17.0",
"react": "19.1.0",
"react-dom": "19.1.0",
"react-native": "0.81.4",
Expand Down
6 changes: 1 addition & 5 deletions frontend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,5 @@
"expo-env.d.ts",
"nativewind-env.d.ts"
],
"exclude": [
"node_modules",
"**/*.flow.js",
"**/*.flow"
]
"exclude": ["node_modules", "**/*.flow.js", "**/*.flow"]
}