Skip to content

Commit

Permalink
feat(deviceDetector): ACT-760 send device info to amplitude
Browse files Browse the repository at this point in the history
  • Loading branch information
yuri-wolf3d committed Aug 6, 2024
1 parent 95e47a1 commit 4f0d441
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/hooks/useDeviceDetector/use-device-detector.hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';
import { getGPUTier, TierResult as GpuTierResult } from 'detect-gpu';
import { stringify } from 'qs';
import { checkDownloadSpeed } from 'src/services/DownloadSpeed.service';
import { trackEvent } from 'src/services/Analytics.service';

type TierPresets = { [key: number]: Record<string, any> };

Expand Down Expand Up @@ -48,6 +49,8 @@ class DeviceDetectorService {
if (props.tierPresets) {
this.tierPresets = { ...TIER_PRESETS, ...props.tierPresets };
}

trackEvent('device detected', this.result);
}

get result() {
Expand Down
9 changes: 9 additions & 0 deletions src/services/Analytics.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { track } from '@amplitude/analytics-browser';

export function trackEvent(event: string, data?: Record<string, any>) {
try {
track(event, data);
} catch (error) {
console.error('Failed to track event', error);

Check warning on line 7 in src/services/Analytics.service.ts

View workflow job for this annotation

GitHub Actions / Linting

Unexpected console statement
}
}

0 comments on commit 4f0d441

Please sign in to comment.