Skip to content

Commit

Permalink
chore: fix frontend build issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Goldziher committed Nov 26, 2023
1 parent 7225de3 commit b6fd570
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions frontend/src/hooks/use-analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,6 @@ export interface AnalyticsHandlers {
* useAnalytics is a react hook for using analytics.
* */
export function useAnalytics(): AnalyticsHandlers {
const writeKey = process.env.NEXT_PUBLIC_SEGMENT_WRITE_KEY;

if (!writeKey) {
throw new ConfigurationError(
'missing required env variable NEXT_PUBLIC_SEGMENT_WRITE_KEY',
);
}

const analyticsRef = useRef<AnalyticsSnippet | AnalyticsBrowser | null>(
null,
);
Expand All @@ -42,6 +34,14 @@ export function useAnalytics(): AnalyticsHandlers {

useEffect(() => {
if (!analyticsRef.current) {
const writeKey = process.env.NEXT_PUBLIC_SEGMENT_WRITE_KEY;

if (!writeKey) {
throw new ConfigurationError(
'missing required env variable NEXT_PUBLIC_SEGMENT_WRITE_KEY',
);
}

if (window.analytics) {
analyticsRef.current = window.analytics;
} else {
Expand Down

0 comments on commit b6fd570

Please sign in to comment.