/
analytics-sources.ts
65 lines (52 loc) · 2.1 KB
/
analytics-sources.ts
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
We are collecting Snyk CLI usage in our official integrations
We distinguish them by either:
- Setting integrationNameHeader or integrationVersionHeader in environment when CLI is run
- passing an --integration-name or --integration-version flags on CLI invocation
Integration name is validated with a list
*/
export const integrationNameHeader = 'SNYK_INTEGRATION_NAME';
export const integrationVersionHeader = 'SNYK_INTEGRATION_VERSION';
enum TrackedIntegration {
// Distribution builds/packages
NPM = 'NPM', // registry - how can we detect this one? Not standalone?
STANDALONE = 'STANDALONE', // Tracked by detecting "isStandalone" flag
// tracked by passing envvar on CLI invocation
HOMEBREW = 'HOMEBREW',
SCOOP = 'SCOOP',
// Our Docker images - tracked by passing envvar on CLI invocation
DOCKER_SNYK_CLI = 'DOCKER_SNYK_CLI', // docker snyk/snyk-cli
DOCKER_SNYK = 'DOCKER_SNYK', // docker snyk/snyk
// IDE plugins - tracked by passing flag or envvar on CLI invocation
JETBRAINS_IDE = 'JETBRAINS_IDE',
ECLIPSE = 'ECLIPSE',
VS_CODE_VULN_COST = 'VS_CODE_VULN_COST',
// CI - tracked by passing flag or envvar on CLI invocation
JENKINS = 'JENKINS',
TEAMCITY = 'TEAMCITY',
BITBUCKET_PIPELINES = 'BITBUCKET_PIPELINES',
AZURE_PIPELINES = 'AZURE_PIPELINES',
CIRCLECI_ORB = 'CIRCLECI_ORB',
GITHUB_ACTIONS = 'GITHUB_ACTIONS',
// Partner integrations - tracked by passing envvar on CLI invocation
DOCKER_DESKTOP = 'DOCKER_DESKTOP',
}
// TODO: propagate these to the UTM params
export const getIntegrationName = (args: Array<any>): string => {
const integrationName = String(
args[0]?.integrationName || // Integration details passed through CLI flag
process.env[integrationNameHeader] ||
'',
).toUpperCase();
if (integrationName in TrackedIntegration) {
return integrationName;
}
return '';
};
export const getIntegrationVersion = (args): string => {
// Integration details passed through CLI flag
const integrationVersion = String(
args[0]?.integrationVersion || process.env[integrationVersionHeader] || '',
);
return integrationVersion;
};