"Fossies" - the Fresh Open Source Software Archive 
Member "cli-1.1260.0/src/lib/query-strings.ts" (4 Dec 2023, 1048 Bytes) of package /linux/misc/snyk-cli-1.1260.0.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) TypeScript source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1 import * as url from 'url';
2 import * as os from 'os';
3 import { ArgsOptions } from './../cli/args';
4 import { isDocker } from './is-docker';
5 import { getIntegrationName, getIntegrationVersion } from './analytics/sources';
6
7 export function getQueryParamsAsString(args: ArgsOptions[]): string {
8 const utm_source = process.env.SNYK_UTM_SOURCE || 'cli';
9 const utm_medium = process.env.SNYK_UTM_MEDIUM || 'cli';
10 const utm_campaign =
11 process.env.SNYK_UTM_CAMPAIGN || getIntegrationName(args) || 'cli';
12 const utm_campaign_content =
13 process.env.SNYK_UTM_CAMPAIGN_CONTENT || getIntegrationVersion(args);
14 const osType = os.type()?.toLowerCase();
15 const docker = isDocker().toString();
16
17 const queryParams = new url.URLSearchParams({
18 utm_medium,
19 utm_source,
20 utm_campaign,
21 utm_campaign_content,
22 os: osType,
23 docker,
24 });
25
26 // It may not be set and URLSearchParams won't filter out undefined values
27 if (!utm_campaign_content) {
28 queryParams.delete('utm_campaign_content');
29 }
30
31 return queryParams.toString();
32 }