* File an emission. Returns the record as stored (with its session call * index), or `null` if the emission was unusable.
(emission: ExploreEmission)
| 218 | * index), or `null` if the emission was unusable. |
| 219 | */ |
| 220 | record(emission: ExploreEmission): ExploreCallRecord | null { |
| 221 | if (!emission || typeof emission.projectRoot !== 'string' || !emission.projectRoot) return null; |
| 222 | const key = exploreProjectKey(emission.projectRoot); |
| 223 | const state = this.touch(key, emission.projectRoot); |
| 224 | |
| 225 | state.callCount += 1; |
| 226 | state.responseBytes += Math.max(0, emission.responseBytes || 0); |
| 227 | |
| 228 | const record: ExploreCallRecord = { |
| 229 | index: state.callCount, |
| 230 | projectRoot: emission.projectRoot, |
| 231 | query: typeof emission.query === 'string' ? emission.query : '', |
| 232 | files: this.boundFiles(emission.files), |
| 233 | sourceBytes: Math.max(0, emission.sourceBytes || 0), |
| 234 | responseBytes: Math.max(0, emission.responseBytes || 0), |
| 235 | }; |
| 236 | state.calls.push(record); |
| 237 | if (state.calls.length > EXPLORE_SESSION_LIMITS.MAX_CALLS_RETAINED) { |
| 238 | state.calls.splice(0, state.calls.length - EXPLORE_SESSION_LIMITS.MAX_CALLS_RETAINED); |
| 239 | } |
| 240 | return record; |
| 241 | } |
| 242 | |
| 243 | /** Full state for one project, or `null` if it was never queried this session. */ |
| 244 | forProject(projectRoot: string): ExploreProjectState | null { |
no test coverage detected