File size: 1,149 Bytes
ddce7e8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | import { randomUUID } from "crypto"
function generateCreatedAt() {
const now = new Date();
const isoString = now.toISOString();
const nanos = String(now.getMilliseconds()).padStart(3, '0') + '000000';
return isoString.replace(/\.\d{3}Z$/, `.${nanos}Z`);
}
function buildRecordCodeAssistMetricsBody(token, id) {
const traceId = randomUUID().replace(/-/g, '');
const firstLatency = (Math.random() * 5 + 1).toFixed(9);
const totalLatency = (Math.random() * 10 + 5).toFixed(9);
return {
project: token.projectId,
requestId: randomUUID(),
metadata: {
ideType: "ANTIGRAVITY",
ideVersion: "1.18.3",
platform: "WINDOWS_AMD64"
},
metrics: [
{
timestamp: generateCreatedAt(),
conversationOffered: {
status: "ACTION_STATUS_NO_ERROR",
traceId: traceId,
streamingLatency: {
firstMessageLatency: `${firstLatency}s`,
totalLatency: `${totalLatency}s`
},
isAgentic: true,
initiationMethod: "AGENT",
trajectoryId: id
}
}
]
}
}
export {
buildRecordCodeAssistMetricsBody
}
|