From afca4bf70160b6b15e3fe55e2cf8ba326a30597c Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 7 Dec 2023 18:48:23 -0600 Subject: [PATCH] Add more breadcrumbs (#2141) --- src/lib/analytics/analytics.tsx | 8 +++++++- src/lib/analytics/analytics.web.tsx | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/lib/analytics/analytics.tsx b/src/lib/analytics/analytics.tsx index 64b66904..3545a7f8 100644 --- a/src/lib/analytics/analytics.tsx +++ b/src/lib/analytics/analytics.tsx @@ -2,8 +2,10 @@ import React from 'react' import {AppState, AppStateStatus} from 'react-native' import AsyncStorage from '@react-native-async-storage/async-storage' import {createClient, SegmentClient} from '@segment/analytics-react-native' -import {useSession, SessionAccount} from '#/state/session' import {sha256} from 'js-sha256' +import {Native} from 'sentry-expo' + +import {useSession, SessionAccount} from '#/state/session' import {TrackEvent, AnalyticsMethods} from './types' import {logger} from '#/logger' @@ -28,6 +30,7 @@ function getClient(): SegmentClient { } export const track: TrackEvent = async (...args) => { + logger.info('analytics: track', {args}) await getClient().track(...args) } @@ -37,9 +40,11 @@ export function useAnalytics(): AnalyticsMethods { if (hasSession) { return { async screen(...args) { + logger.info('analytics: screen', {args}) await getClient().screen(...args) }, async track(...args) { + logger.info('analytics: track', {args}) await getClient().track(...args) }, } @@ -60,6 +65,7 @@ export function init(account: SessionAccount | undefined) { if (account.did) { const did_hashed = sha256(account.did) client.identify(did_hashed, {did_hashed}) + Native.setUser({id: did_hashed}) logger.debug('Ping w/hash') } else { logger.debug('Ping w/o hash') diff --git a/src/lib/analytics/analytics.web.tsx b/src/lib/analytics/analytics.web.tsx index 71c32d75..b717950a 100644 --- a/src/lib/analytics/analytics.web.tsx +++ b/src/lib/analytics/analytics.web.tsx @@ -1,8 +1,9 @@ import React from 'react' import {createClient} from '@segment/analytics-react' import {sha256} from 'js-sha256' -import {TrackEvent, AnalyticsMethods} from './types' +import {Browser} from 'sentry-expo' +import {TrackEvent, AnalyticsMethods} from './types' import {useSession, SessionAccount} from '#/state/session' import {logger} from '#/logger' @@ -29,6 +30,7 @@ function getClient(): SegmentClient { } export const track: TrackEvent = async (...args) => { + logger.info('analytics: track', {args}) await getClient().track(...args) } @@ -38,9 +40,11 @@ export function useAnalytics(): AnalyticsMethods { if (hasSession) { return { async screen(...args) { + logger.info('analytics: screen', {args}) await getClient().screen(...args) }, async track(...args) { + logger.info('analytics: track', {args}) await getClient().track(...args) }, } @@ -59,6 +63,7 @@ export function init(account: SessionAccount | undefined) { if (account.did) { const did_hashed = sha256(account.did) client.identify(did_hashed, {did_hashed}) + Browser.setUser({id: did_hashed}) logger.debug('Ping w/hash') } else { logger.debug('Ping w/o hash')