From 6f0cb5a21c505b27eaa30a8789ed7958c0f02a86 Mon Sep 17 00:00:00 2001 From: Sandor Trombitas Date: Thu, 7 Nov 2024 10:44:21 +0200 Subject: [PATCH] chore: disable v1 analytics --- src/lib/analytics/index.ts | 54 ++++---------------------------------- 1 file changed, 5 insertions(+), 49 deletions(-) diff --git a/src/lib/analytics/index.ts b/src/lib/analytics/index.ts index 3022873234..1ff88d6266 100644 --- a/src/lib/analytics/index.ts +++ b/src/lib/analytics/index.ts @@ -1,11 +1,8 @@ import * as createDebug from 'debug'; import * as needle from 'needle'; import stripAnsi = require('strip-ansi'); -import { getAuthHeader, someTokenExists } from '../api-token'; import config from '../config'; -import { makeRequest } from '../request'; import { config as userConfig } from '../user-config'; -import { getStandardData } from './getStandardData'; // Add flags whose values should be redacted in analytics here. // TODO make this less error-prone by baking the concept of sensitivity into the @@ -68,52 +65,11 @@ export function allowAnalytics(): boolean { * given by the data parameter, or called from {@link addDataAndSend}. * @param customData the analytics data to send to the backend. */ -async function postAnalytics( - customData, -): Promise { - // if the user opt'ed out of analytics, then let's bail out early - // ths applies to all sending to protect user's privacy - if (!allowAnalytics()) { - debug('analytics disabled'); - return Promise.resolve(); - } - - try { - const standardData = await getStandardData(customData.args); - const analyticsData = { - ...customData, - ...standardData, - }; - debug('analytics', JSON.stringify(analyticsData, null, ' ')); - - const headers = {}; - if (someTokenExists()) { - headers['authorization'] = getAuthHeader(); - } - - const queryStringParams = {}; - if (analyticsData.org) { - queryStringParams['org'] = analyticsData.org; - } - - const queryString = - Object.keys(queryStringParams).length > 0 ? queryStringParams : undefined; - - const res = await makeRequest({ - body: { - data: analyticsData, - }, - qs: queryString, - url: config.API + '/analytics/cli', - json: true, - method: 'post', - headers: headers, - }); - - return res; - } catch (err) { - debug('analytics', err); // this swallows the analytics error - } +// eslint-disable-next-line @typescript-eslint/no-unused-vars +async function postAnalytics(customData: Record): Promise { + // Analytics disabled until we can migrate to v2 analytics + debug('analytics disabled'); + return Promise.resolve(); } /**