Skip to content

Commit 5d9c0c3

Browse files
committed
chore(COD-6066): remove unused telemetry
1 parent c559932 commit 5d9c0c3

4 files changed

Lines changed: 7 additions & 91 deletions

File tree

src/index.ts

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
1-
import { error, getInput, info, setOutput, warning } from '@actions/core'
2-
import { appendFileSync, existsSync, readFileSync } from 'fs'
1+
import { error, getInput, info, setOutput } from '@actions/core'
2+
import { existsSync, readFileSync } from 'fs'
33
import {
44
downloadArtifact,
55
postCommentIfInPr,
66
resolveExistingCommentIfFound,
77
uploadArtifact,
88
} from './actions'
9-
import {
10-
callLaceworkCli,
11-
debug,
12-
generateUILink,
13-
getActionRef,
14-
getMsSinceStart,
15-
getOptionalEnvVariable,
16-
getRequiredEnvVariable,
17-
getRunUrl,
18-
telemetryCollector,
19-
} from './util'
9+
import { callLaceworkCli, debug, generateUILink, getOptionalEnvVariable } from './util'
2010

2111
import path from 'path'
2212

@@ -41,17 +31,7 @@ async function runAnalysis() {
4131
const toUpload: string[] = []
4232

4333
// command to print both sarif and lwjson formats
44-
var args = [
45-
'sca',
46-
'scan',
47-
'.',
48-
'--formats',
49-
'sarif',
50-
'--output',
51-
sarifReportPath,
52-
'--deployment',
53-
'ci',
54-
]
34+
var args = ['scan', '.', '--formats', 'sarif', '--output', sarifReportPath, '--deployment', 'ci']
5535
if (target === 'push') {
5636
args.push('--save-results')
5737
}
@@ -64,14 +44,11 @@ async function runAnalysis() {
6444
const uploadStart = Date.now()
6545

6646
await uploadArtifact(getArtifactName(target), ...toUpload)
67-
68-
telemetryCollector.addField('duration.upload-artifacts', (Date.now() - uploadStart).toString())
6947
setOutput(`${target}-completed`, true)
7048
}
7149

7250
export async function compareResults(oldReport: string, newReport: string): Promise<string> {
7351
const args = [
74-
'sca',
7552
'compare',
7653
'--old',
7754
oldReport,
@@ -101,10 +78,6 @@ async function displayResults() {
10178
const downloadStart = Date.now()
10279
const artifactOld = await downloadArtifact(getArtifactName('old'))
10380
const artifactNew = await downloadArtifact(getArtifactName('new'))
104-
telemetryCollector.addField(
105-
'duration.download-artifacts',
106-
(Date.now() - downloadStart).toString()
107-
)
10881
const sarifFileOld = path.join(artifactOld, sarifReportPath)
10982
const sarifFileNew = path.join(artifactNew, sarifReportPath)
11083

@@ -129,7 +102,6 @@ async function displayResults() {
129102
} else {
130103
await resolveExistingCommentIfFound()
131104
}
132-
telemetryCollector.addField('duration.comment', (Date.now() - commentStart).toString())
133105
setOutput(`display-completed`, true)
134106
}
135107

@@ -142,29 +114,15 @@ function getArtifactName(target: string): string {
142114
}
143115

144116
async function main() {
145-
telemetryCollector.addField('duration.install', getMsSinceStart())
146-
telemetryCollector.addField('version', getActionRef())
147-
telemetryCollector.addField('url', getRunUrl())
148-
telemetryCollector.addField('repository', getRequiredEnvVariable('GITHUB_REPOSITORY'))
149117
if (getInput('target') !== '') {
150-
telemetryCollector.addField('run-type', 'analysis')
151118
await runAnalysis()
152119
} else {
153-
telemetryCollector.addField('run-type', 'display')
154120
await displayResults()
155121
}
156122
}
157123

158124
main()
159125
.catch((e) => {
160-
telemetryCollector.addError('error', e)
161126
error(e.message) // TODO: Use setFailed once we want failures to be fatal
162127
})
163-
.finally(async () => {
164-
telemetryCollector.addField('metadata.integration', 'github')
165-
telemetryCollector.addField('duration.total', getMsSinceStart())
166-
await telemetryCollector.report().catch((err) => {
167-
warning('Failed to report telemetry: ' + err.message)
168-
})
169-
appendFileSync(getRequiredEnvVariable('GITHUB_ENV'), 'LACEWORK_WROTE_TELEMETRY=true\n')
170-
})
128+
.finally(async () => {})

src/post.ts

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,7 @@
11
import { info, warning } from '@actions/core'
22
import { context } from '@actions/github'
33
import { getActionsApi } from './actions'
4-
import {
5-
getActionRef,
6-
getMsSinceStart,
7-
getOptionalEnvVariable,
8-
getRequiredEnvVariable,
9-
getRunUrl,
10-
telemetryCollector,
11-
} from './util'
4+
import { getOptionalEnvVariable, getRequiredEnvVariable } from './util'
125

136
async function main() {
147
if (getOptionalEnvVariable('LACEWORK_WROTE_TELEMETRY', 'false') !== 'true') {
@@ -27,12 +20,6 @@ async function main() {
2720
}
2821

2922
info('Reporting unknown failure')
30-
telemetryCollector.addField('version', getActionRef())
31-
telemetryCollector.addField('url', getRunUrl())
32-
telemetryCollector.addField('repository', getRequiredEnvVariable('GITHUB_REPOSITORY'))
33-
telemetryCollector.addField('duration.total', getMsSinceStart())
34-
telemetryCollector.addField('error', 'Unknown catastrophic error')
35-
await telemetryCollector.report()
3623
} else {
3724
info('Telemetry has been reported previously')
3825
}

src/telemetry.ts

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/util.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ import { error, getInput, info, isDebug } from '@actions/core'
22
import { context } from '@actions/github'
33
import { spawn } from 'child_process'
44
import { readFileSync } from 'fs'
5-
import { TelemetryCollector } from './telemetry'
6-
7-
export const telemetryCollector = new TelemetryCollector()
85

96
export function getMsSinceStart(): string {
107
const now = Date.now()
@@ -74,6 +71,7 @@ export async function callLaceworkCli(...args: string[]) {
7471
apiKey,
7572
'--api_secret',
7673
apiSecret,
74+
'sca',
7775
...args,
7876
]
7977
info('Calling lacework ' + expandedArgs.join(' '))

0 commit comments

Comments
 (0)