Skip to content

Commit 69cc135

Browse files
authored
Fix: Merge pull request #25 from PaperStrange/npm-build-error-patch
Update AnalyticsService.js to fix build error, Module not found:…
2 parents e3bab74 + 1e0aca3 commit 69cc135

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

src/features/beta-program/services/analytics/AnalyticsService.js

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
*/
55

66
import authService from '../../services/AuthService';
7-
import crypto from 'crypto';
87

98
// Mock data for different metrics - would be replaced with real API calls in production
109
const mockData = {
@@ -449,29 +448,28 @@ class AnalyticsService {
449448
const recordings = Array.from({ length: 25 }).map((_, index) => {
450449
const recordingDate = new Date(
451450
new Date(startDate).getTime() +
452-
(crypto.randomBytes(4).readUInt32BE(0) / 0xFFFFFFFF) * (new Date(endDate).getTime() - new Date(startDate).getTime())
451+
Math.random() * (new Date(endDate).getTime() - new Date(startDate).getTime())
453452
);
454453

455-
const duration = Math.floor((crypto.randomBytes(4).readUInt32BE(0) / 0xFFFFFFFF) * 600) + 30; // 30s to 10min
456-
const userType = (crypto.randomBytes(4).readUInt32BE(0) / 0xFFFFFFFF) > 0.3 ? 'returning' : 'new';
457-
const device = ['desktop', 'mobile', 'tablet'][Math.floor((crypto.randomBytes(4).readUInt32BE(0) / 0xFFFFFFFF) * 3)];
458-
454+
const duration = Math.floor(Math.random() * 600) + 30; // 30s to 10min
455+
const userType = Math.random() > 0.3 ? 'returning' : 'new';
456+
const device = ['desktop', 'mobile', 'tablet'][Math.floor(Math.random() * 3)];
457+
459458
const pages = [];
460459
const numPages = Math.floor(Math.random() * 5) + 1;
461460
const possiblePages = ['dashboard', 'search', 'profile', 'settings', 'tour_creation', 'tour_details', 'checkout'];
462-
461+
463462
for (let i = 0; i < numPages; i++) {
464-
const page = possiblePages[Math.floor((crypto.randomBytes(4).readUInt32BE(0) / 0xFFFFFFFF) * possiblePages.length)];
463+
const page = possiblePages[Math.floor(Math.random() * possiblePages.length)];
465464
if (!pages.includes(page)) {
466465
pages.push(page);
467466
}
468-
}
469467

470468
return {
471469
id: `hj-${(10000000 + index).toString(16)}`, // Mock Hotjar recording ID
472470
date: recordingDate.toISOString(),
473471
duration: duration,
474-
userId: (crypto.randomBytes(4).readUInt32BE(0) / 0xFFFFFFFF) > 0.2 ? `user_${Math.floor((crypto.randomBytes(4).readUInt32BE(0) / 0xFFFFFFFF) * 1000)}` : null,
472+
userId: Math.random() > 0.2 ? `user_${Math.floor(Math.random() * 1000)}` : null,
475473
userType: userType,
476474
device: device,
477475
browser: ['Chrome', 'Firefox', 'Safari', 'Edge'][Math.floor(Math.random() * 4)],
@@ -762,4 +760,4 @@ class AnalyticsService {
762760
// Create singleton instance
763761
const analyticsService = new AnalyticsService();
764762

765-
export default analyticsService;
763+
export default analyticsService;

0 commit comments

Comments
 (0)