* 核心追踪接口 * @param type 事件类型,如 'translation', 'launch', 'heartbeat' * @param key 细分标识,如 'deepseek', 'startup'
(type: string, key: string = 'default')
| 49 | * @param key 细分标识,如 'deepseek', 'startup' |
| 50 | */ |
| 51 | public track(type: string, key: string = 'default'): void { |
| 52 | const compositeKey = `${type}|${key}`; |
| 53 | const currentCount = this.buffer.get(compositeKey) || 0; |
| 54 | this.buffer.set(compositeKey, currentCount + 1); |
| 55 | |
| 56 | // 如果缓冲区条目过多,立即触发同步 |
| 57 | if (this.buffer.size >= this.threshold) { |
| 58 | this.flush(); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * 手动或自动触发同步 |
no test coverage detected