Skip to content

Commit 5d9a4c3

Browse files
committed
Add new telemetry fields to telemetryAIEvent method (AST-113145)
1 parent 1a1ce3e commit 5d9a4c3

File tree

3 files changed

+37
-8
lines changed

3 files changed

+37
-8
lines changed

src/main/wrapper/CxConstants.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,8 @@ export enum CxConstants {
122122
AI_PROVIDER = "--ai-provider",
123123
TYPE = "--type",
124124
SUB_TYPE = "--sub-type",
125-
PROBLEM_SEVERITY = "--problem-severity"
125+
PROBLEM_SEVERITY = "--problem-severity",
126+
SCAN_TYPE_FLAG = "--scan-type",
127+
STATUS = "--status",
128+
TOTAL_COUNT = "--total-count",
126129
}

src/main/wrapper/CxWrapper.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ export class CxWrapper {
530530
return new ExecutionService().executeCommands(this.config.pathToExecutable, commands, CxConstants.MASK_TYPE);
531531
}
532532

533-
telemetryAIEvent(aiProvider: string, agent: string, eventType: string, subType: string, engine: string, problemSeverity: string): Promise<CxCommandOutput> {
533+
telemetryAIEvent(aiProvider: string, agent: string, eventType: string, subType: string, engine: string, problemSeverity: string, scanType: string, status: string, totalCount: number): Promise<CxCommandOutput> {
534534
const commands: string[] = [
535535
CxConstants.TELEMETRY,
536536
CxConstants.SUB_CMD_TELEMETRY_AI,
@@ -539,7 +539,10 @@ export class CxWrapper {
539539
CxConstants.TYPE, eventType,
540540
CxConstants.SUB_TYPE, subType,
541541
CxConstants.ENGINE, engine,
542-
CxConstants.PROBLEM_SEVERITY, problemSeverity
542+
CxConstants.PROBLEM_SEVERITY, problemSeverity,
543+
CxConstants.SCAN_TYPE_FLAG, scanType,
544+
CxConstants.STATUS, status,
545+
CxConstants.TOTAL_COUNT, totalCount.toString()
543546
];
544547
commands.push(...this.initializeCommands(false));
545548
const exec = new ExecutionService();

src/tests/TelemetryTest.test.ts

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,55 @@ import { BaseTest } from "./BaseTest";
55
describe("Telemetry cases", () => {
66
const cxScanConfig = new BaseTest();
77

8-
it.skip('TelemetryAIEvent Successful case with minimal parameters', async () => {
8+
it('TelemetryAIEvent Successful case with minimal parameters - ai log', async () => {
99
const wrapper = new CxWrapper(cxScanConfig);
1010
const cxCommandOutput: CxCommandOutput = await wrapper.telemetryAIEvent(
1111
"Cursor",
1212
"Cursos",
1313
"click",
1414
"ast-results.viewPackageDetails",
1515
"secrets",
16-
"high"
16+
"high",
17+
"",
18+
"",
19+
0
20+
);
21+
console.log("Json object from telemetryAIEvent successful case: " + JSON.stringify(cxCommandOutput));
22+
expect(cxCommandOutput.exitCode).toBe(0);
23+
});
24+
25+
it('TelemetryAIEvent Successful case with minimal parameters - detection log', async () => {
26+
const wrapper = new CxWrapper(cxScanConfig);
27+
const cxCommandOutput: CxCommandOutput = await wrapper.telemetryAIEvent(
28+
"",
29+
"",
30+
"",
31+
"",
32+
"",
33+
"",
34+
"asca",
35+
"Critical",
36+
10
1737
);
1838
console.log("Json object from telemetryAIEvent successful case: " + JSON.stringify(cxCommandOutput));
1939
expect(cxCommandOutput.exitCode).toBe(0);
2040
});
2141

2242

23-
it.skip('TelemetryAIEvent Successful case with edge case parameters', async () => {
43+
it('TelemetryAIEvent Successful case with edge case parameters', async () => {
2444
const wrapper = new CxWrapper(cxScanConfig);
2545
const cxCommandOutput: CxCommandOutput = await wrapper.telemetryAIEvent(
2646
"",
2747
"",
2848
"",
2949
"",
3050
"",
31-
""
51+
"",
52+
"",
53+
"",
54+
0
3255
);
3356
console.log("Json object from telemetryAIEvent with empty parameters: " + JSON.stringify(cxCommandOutput));
34-
expect(typeof cxCommandOutput.exitCode).toBe(0);
57+
expect(cxCommandOutput.exitCode).toBe(0);
3558
});
3659
});

0 commit comments

Comments
 (0)