| 152 | } |
| 153 | |
| 154 | private loadOrCreateFirstSeen(stateDir: string): string { |
| 155 | const filePath = path.join(stateDir, "memos-local", ".first-seen"); |
| 156 | try { |
| 157 | const existing = fs.readFileSync(filePath, "utf-8").trim(); |
| 158 | if (existing.length === 10) return existing; |
| 159 | } catch {} |
| 160 | const today = new Date().toISOString().slice(0, 10); |
| 161 | try { |
| 162 | fs.mkdirSync(path.dirname(filePath), { recursive: true }); |
| 163 | fs.writeFileSync(filePath, today, "utf-8"); |
| 164 | } catch {} |
| 165 | return today; |
| 166 | } |
| 167 | |
| 168 | private capture(event: string, properties?: Record<string, unknown>): void { |
| 169 | if (!this.enabled) return; |