Skip to content

Commit aad1da1

Browse files
internal: Don't track script_validated event when validation is triggered automatically (#930)
1 parent 63726a8 commit aad1da1

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

src/handlers/script/index.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ export function initialize() {
9292

9393
ipcMain.handle(
9494
ScriptHandler.RunFromGenerator,
95-
async (event, script: string) => {
95+
async (event, script: string, shouldTrack = true) => {
9696
console.info(`${ScriptHandler.RunFromGenerator} event received`)
9797
await writeFile(TEMP_GENERATOR_SCRIPT_PATH, script)
9898

@@ -105,12 +105,14 @@ export function initialize() {
105105
usageReport: k6StudioState.appSettings.telemetry.usageReport,
106106
})
107107

108-
trackEvent({
109-
event: UsageEventName.ScriptValidated,
110-
payload: {
111-
isExternal: false,
112-
},
113-
})
108+
if (shouldTrack) {
109+
trackEvent({
110+
event: UsageEventName.ScriptValidated,
111+
payload: {
112+
isExternal: false,
113+
},
114+
})
115+
}
114116

115117
await unlink(TEMP_GENERATOR_SCRIPT_PATH)
116118
}

src/handlers/script/preload.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ export function openScript(scriptPath: string) {
1717
) as Promise<OpenScriptResult>
1818
}
1919

20-
export function runScriptFromGenerator(script: string) {
20+
export function runScriptFromGenerator(script: string, shouldTrack = true) {
2121
return ipcRenderer.invoke(
2222
ScriptHandler.RunFromGenerator,
23-
script
23+
script,
24+
shouldTrack
2425
) as Promise<void>
2526
}
2627

src/utils/validateScript.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import { processProxyData } from './proxyData'
77
*/
88
export async function validateScript(
99
script: string,
10-
signal?: AbortSignal
10+
signal?: AbortSignal,
11+
shouldTrack = true
1112
): Promise<ProxyData[]> {
1213
let collectedData: ProxyData[] = []
1314

@@ -51,9 +52,11 @@ export async function validateScript(
5152
})
5253

5354
// Run the script
54-
window.studio.script.runScriptFromGenerator(script).catch((error) => {
55-
cleanup()
56-
reject(error)
57-
})
55+
window.studio.script
56+
.runScriptFromGenerator(script, shouldTrack)
57+
.catch((error) => {
58+
cleanup()
59+
reject(error)
60+
})
5861
})
5962
}

src/views/Generator/AutoCorrelation/useGenerateRules.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ export const useGenerateRules = ({
165165

166166
const validationResult = await validateScript(
167167
script,
168-
abortControllerRef.current?.signal
168+
abortControllerRef.current?.signal,
169+
false
169170
)
170171

171172
const result = validationMatchesRecording(

0 commit comments

Comments
 (0)