Repository navigation
feat: enable analytics by default with hardcoded token #91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # DedPaste Environment Configuration | ||
|
|
||
| # API Configuration (optional - defaults to public instance) | ||
| DEDPASTE_API_URL=https://paste.d3d.dev |
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,312 @@ | ||||||||||||||
| import Mixpanel from "mixpanel"; | ||||||||||||||
| import { v4 as uuidv4 } from "uuid"; | ||||||||||||||
| import * as fs from "fs"; | ||||||||||||||
| import * as path from "path"; | ||||||||||||||
| import * as os from "os"; | ||||||||||||||
| import * as crypto from "crypto"; | ||||||||||||||
|
|
||||||||||||||
| interface AnalyticsConfig { | ||||||||||||||
| enabled: boolean; | ||||||||||||||
| userId: string; | ||||||||||||||
| optOutDate?: string; | ||||||||||||||
| firstSeen?: string; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| interface EventProperties { | ||||||||||||||
| [key: string]: any; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| interface QueuedEvent { | ||||||||||||||
| name: string; | ||||||||||||||
| properties: EventProperties; | ||||||||||||||
| timestamp: Date; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| class AnalyticsService { | ||||||||||||||
| private static instance: AnalyticsService; | ||||||||||||||
| private mixpanel: Mixpanel.Mixpanel | null = null; | ||||||||||||||
| private config: AnalyticsConfig; | ||||||||||||||
| private configPath: string; | ||||||||||||||
| private eventQueue: QueuedEvent[] = []; | ||||||||||||||
| private isInitialized = false; | ||||||||||||||
| private flushTimer: NodeJS.Timeout | null = null; | ||||||||||||||
|
|
||||||||||||||
| // Privacy-focused configuration | ||||||||||||||
| private readonly BATCH_SIZE = 10; | ||||||||||||||
| private readonly FLUSH_INTERVAL = 30000; // 30 seconds | ||||||||||||||
| private readonly CONFIG_DIR = ".dedpaste"; | ||||||||||||||
| private readonly CONFIG_FILE = "analytics.json"; | ||||||||||||||
|
|
||||||||||||||
| // Mixpanel project token | ||||||||||||||
| private readonly PROJECT_TOKEN = "9c4a09e9631e9675165a65a03c54dc6e"; | ||||||||||||||
|
|
||||||||||||||
| private constructor() { | ||||||||||||||
| this.configPath = path.join(os.homedir(), this.CONFIG_DIR, this.CONFIG_FILE); | ||||||||||||||
| this.config = this.loadConfig(); | ||||||||||||||
| this.initialize(); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| public static getInstance(): AnalyticsService { | ||||||||||||||
| if (!AnalyticsService.instance) { | ||||||||||||||
| AnalyticsService.instance = new AnalyticsService(); | ||||||||||||||
| } | ||||||||||||||
| return AnalyticsService.instance; | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| private loadConfig(): AnalyticsConfig { | ||||||||||||||
| try { | ||||||||||||||
| if (fs.existsSync(this.configPath)) { | ||||||||||||||
| const data = fs.readFileSync(this.configPath, "utf8"); | ||||||||||||||
| return JSON.parse(data); | ||||||||||||||
| } | ||||||||||||||
| } catch (error) { | ||||||||||||||
| // Silently handle errors - analytics should never break the app | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| // Default config with analytics enabled | ||||||||||||||
| return { | ||||||||||||||
| enabled: true, | ||||||||||||||
|
Comment on lines
+66
to
+68
|
||||||||||||||
| // Default config with analytics enabled | |
| return { | |
| enabled: true, | |
| // Default config with analytics disabled until user opts in | |
| return { | |
| enabled: false, |
Copilot
AI
Sep 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Analytics are forcibly enabled without user consent. This violates privacy best practices and may conflict with GDPR and other privacy regulations that require explicit user consent for data collection.
| // Always enable analytics | |
| this.config.enabled = true; | |
| // Only initialize analytics if enabled by user consent | |
| if (!this.config.enabled) { | |
| return; | |
| } |
Uh oh!
There was an error while loading. Please reload this page.