Skip to content

Commit

Permalink
fix: catch segment errors
Browse files Browse the repository at this point in the history
  • Loading branch information
nounspaceryan committed Jul 4, 2024
1 parent 307f1bd commit 5186357
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions src/common/providers/AnalyticsProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,25 @@ export const analytics = {
eventName: T,
properties?: AnalyticsEventProperties[T],
) => {
segment.track(eventName, properties);
try {
segment.track(eventName, properties);
} catch (e) {
console.error(e);
}
},
identify: (id?: string, properties?: any) => {
try {
segment.identify(id, properties);
} catch (e) {
console.error(e);
}
},
identify: (id: string, properties: any) => {
segment.identify(id, properties);
page: () => {
try {
segment.page();
} catch (e) {
console.error(e);
}
},
};

Expand All @@ -64,10 +79,10 @@ export const AnalyticsProvider: React.FC<{ children: ReactNode }> = ({
}, [identityPublicKey, fid]);

useEffect(() => {
segment.page();
analytics.page();

const handleRouteChange = () => {
segment.page();
analytics.page();
};

router.events.on("routeChangeComplete", handleRouteChange);
Expand Down

0 comments on commit 5186357

Please sign in to comment.