mirror of
https://github.com/selfxyz/self.git
synced 2026-04-05 03:00:53 -04:00
SEL-425: Add document management analytics events (#706)
* Add document management analytics * coderabbit feedback
This commit is contained in:
@@ -105,3 +105,15 @@ export const MockDataEvents = {
|
||||
SELECT_COUNTRY: 'Mock Data: Select Country',
|
||||
TOGGLE_OFAC_LIST: 'Mock Data: Toggle OFAC List',
|
||||
};
|
||||
|
||||
export const DocumentEvents = {
|
||||
MANAGE_SCREEN_OPENED: 'Document: Manage Documents Screen Opened',
|
||||
DOCUMENTS_FETCHED: 'Document: Documents Fetched',
|
||||
NO_DOCUMENTS_FOUND: 'Document: No Documents Found',
|
||||
DOCUMENT_SELECTED: 'Document: Document Selected',
|
||||
DOCUMENT_DELETED: 'Document: Document Deleted',
|
||||
ADD_NEW_SCAN_SELECTED: 'Document: Add New Document via Scan',
|
||||
ADD_NEW_MOCK_SELECTED: 'Document: Add New Document via Mock',
|
||||
PASSPORT_INFO_OPENED: 'Document: Passport Info Screen Opened',
|
||||
PASSPORT_METADATA_LOADED: 'Document: Passport Metadata Loaded',
|
||||
};
|
||||
|
||||
@@ -10,11 +10,15 @@ import { Button, ScrollView, Spinner, Text, XStack, YStack } from 'tamagui';
|
||||
import { PrimaryButton } from '../../components/buttons/PrimaryButton';
|
||||
import { SecondaryButton } from '../../components/buttons/SecondaryButton';
|
||||
import ButtonsContainer from '../../components/ButtonsContainer';
|
||||
import { DocumentEvents } from '../../consts/analytics';
|
||||
import { usePassport } from '../../providers/passportDataProvider';
|
||||
import analytics from '../../utils/analytics';
|
||||
import { borderColor, textBlack, white } from '../../utils/colors';
|
||||
import { extraYPadding } from '../../utils/constants';
|
||||
import { impactLight } from '../../utils/haptic';
|
||||
|
||||
const { trackEvent } = analytics();
|
||||
|
||||
interface ManageDocumentsScreenProps {}
|
||||
|
||||
const PassportDataSelector = () => {
|
||||
@@ -40,6 +44,12 @@ const PassportDataSelector = () => {
|
||||
const docs = await getAllDocuments();
|
||||
setDocumentCatalog(catalog);
|
||||
setAllDocuments(docs);
|
||||
trackEvent(DocumentEvents.DOCUMENTS_FETCHED, {
|
||||
count: catalog.documents.length,
|
||||
});
|
||||
if (catalog.documents.length === 0) {
|
||||
trackEvent(DocumentEvents.NO_DOCUMENTS_FOUND);
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
@@ -50,11 +60,13 @@ const PassportDataSelector = () => {
|
||||
const docs = await getAllDocuments();
|
||||
setDocumentCatalog(catalog);
|
||||
setAllDocuments(docs);
|
||||
trackEvent(DocumentEvents.DOCUMENT_SELECTED);
|
||||
};
|
||||
|
||||
const handleDeleteSpecific = async (documentId: string) => {
|
||||
setLoading(true);
|
||||
await deleteDocument(documentId);
|
||||
trackEvent(DocumentEvents.DOCUMENT_DELETED);
|
||||
await loadPassportDataInfo();
|
||||
};
|
||||
|
||||
@@ -240,13 +252,19 @@ const ManageDocumentsScreen: React.FC<ManageDocumentsScreenProps> = ({}) => {
|
||||
const navigation = useNavigation();
|
||||
const { bottom } = useSafeAreaInsets();
|
||||
|
||||
useEffect(() => {
|
||||
trackEvent(DocumentEvents.MANAGE_SCREEN_OPENED);
|
||||
}, []);
|
||||
|
||||
const handleScanDocument = () => {
|
||||
impactLight();
|
||||
trackEvent(DocumentEvents.ADD_NEW_SCAN_SELECTED);
|
||||
navigation.navigate('PassportOnboarding' as any);
|
||||
};
|
||||
|
||||
const handleGenerateMock = () => {
|
||||
impactLight();
|
||||
trackEvent(DocumentEvents.ADD_NEW_MOCK_SELECTED);
|
||||
navigation.navigate('CreateMock' as any);
|
||||
};
|
||||
|
||||
|
||||
@@ -7,10 +7,14 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
||||
import { ScrollView, Separator, XStack, YStack } from 'tamagui';
|
||||
|
||||
import { Caption } from '../../components/typography/Caption';
|
||||
import { DocumentEvents } from '../../consts/analytics';
|
||||
import { usePassport } from '../../providers/passportDataProvider';
|
||||
import analytics from '../../utils/analytics';
|
||||
import { black, slate200, white } from '../../utils/colors';
|
||||
import { extraYPadding } from '../../utils/constants';
|
||||
|
||||
const { trackEvent } = analytics();
|
||||
|
||||
// TODO clarify if we need more/less keys to be displayed
|
||||
const dataKeysToLabels: Record<
|
||||
keyof Omit<PassportMetadata, 'countryCode' | 'dsc' | 'csca'>,
|
||||
@@ -74,9 +78,11 @@ const PassportDataInfoScreen: React.FC<PassportDataInfoScreenProps> = ({}) => {
|
||||
}
|
||||
|
||||
setMetadata(result.data.passportMetadata!);
|
||||
trackEvent(DocumentEvents.PASSPORT_METADATA_LOADED);
|
||||
}, [metadata, getData]);
|
||||
|
||||
useFocusEffect(() => {
|
||||
trackEvent(DocumentEvents.PASSPORT_INFO_OPENED);
|
||||
loadData();
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user