diff --git a/README.md b/README.md index a55d9d29..8caae658 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,6 @@ const { getHistoricRates } = require('dukascopy-node'); |`cacheFolderPath`|`String`|false|`./.dukascopy-cache`|Folder path where all cache artifacts (binary data) will be stored| |`retryCount`|`Number`|false|`0`|Number of retries for a failed artifact download. If `0` no retries will happen even for failed requests.| |`pauseBetweenRetriesMs`|`Number`|false|`500`|Pause between retries. If `retryCount` is `0` this parameter will be ignored| -|`analytics`|`Boolean`|false|`true`|A flag indicating whether the library should send analytics remote report, which is used for improving the DX and the library itself| *** @@ -111,8 +110,7 @@ const { getHistoricRates } = require('dukascopy-node'); useCache: true, cacheFolderPath: '.dukascopy-cache', retryCount: 5, - pauseBetweenRetriesMs: 250, - analytics: true + pauseBetweenRetriesMs: 250 } ``` @@ -163,8 +161,6 @@ Options: -chpath, --cache-path Folder path for cache data (default: "./.dukascopy-cache") -r, --retries Number of retries for a failed artifact download (default: 0) -rp, --retry-pause Pause between retries in milliseconds (default: 500) - -a, --analytics Enable remote analytics (default: true) - --no-analytics Disable remote analytics -h, --help display help for command ``` diff --git a/package.json b/package.json index 292e5d75..c0030cd9 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,7 @@ "module": "dist/esm/index.js", "types": "dist/index.d.ts", "files": [ - "dist", - "scripts" + "dist" ], "bin": { "dukascopy-cli": "./dist/cli/index.js" @@ -20,8 +19,7 @@ "lint": "eslint ./src --ext ts --ext js", "gen:meta": "ts-node src/utils/instrument-meta-data/generate-data.ts", "gen:instruments-md": "ts-node src/utils/instrument-meta-data/generate-instrument-md.ts", - "release": "standard-version && git push --follow-tags origin master && pnpm build && npm publish", - "postinstall": "node scripts/install.js" + "release": "standard-version && git push --follow-tags origin master && pnpm build && npm publish" }, "author": "leonid.pyrlia", "license": "MIT", diff --git a/scripts/install.js b/scripts/install.js deleted file mode 100644 index afb35433..00000000 --- a/scripts/install.js +++ /dev/null @@ -1,22 +0,0 @@ -/* eslint-disable no-undef */ -/* eslint-disable @typescript-eslint/no-var-requires */ -const fetch = require('node-fetch'); -const path = require('path'); -const fs = require('fs').promises; - -async function run() { - try { - const { ip } = await fetch('https://dukascopy-node.leo4815162342.workers.dev').then(data => - data.json() - ); - await fs.writeFile( - path.resolve(__dirname, '..', 'dist', 'ip.js'), - `module.exports = { ip: "${ip}" };`, - { encoding: 'utf-8' } - ); - } catch (err) { - process.exit(0); - } -} - -run(); diff --git a/src/analytics/index.ts b/src/analytics/index.ts deleted file mode 100644 index 8479581c..00000000 --- a/src/analytics/index.ts +++ /dev/null @@ -1,53 +0,0 @@ -import os from 'os'; -import fetch from 'node-fetch'; -import { getSafeVal } from '../utils/getSafeVal'; -import { getIp } from '../utils/getIp'; -import { version } from '../../package.json'; -import { Config } from '../config'; - -export enum GOALS { - getHistoricalRates = 'getHistoricalRates' -} - -export function trackCustomGoal( - goalName: GOALS, - config: Config, - isValid: boolean, - source: 'cli' | 'node' -) { - const timezone = getSafeVal(() => Intl.DateTimeFormat().resolvedOptions().timeZone); - const os_type = getSafeVal(() => os.type()); - const os_release = getSafeVal(() => os.release()); - const os_platform = getSafeVal(() => os.platform()); - const ip = getSafeVal(getIp); - - try { - fetch('https://plausible.io/api/event', { - method: 'POST', - body: JSON.stringify({ - name: goalName, - url: 'app://localhost', - domain: 'dukascopy-node', - screen_width: 1000, - props: { - lib_version: version, - is_valid: isValid, - instrument: config.instrument, - timeframe: config.timeframe, - from_date: config.dates.from, - to_date: config.dates.to, - source, - node_version: process.version, - timezone, - os_type, - os_release, - os_platform - } - }), - headers: { 'X-Forwarded-For': ip || '127.0.0.1', 'Content-Type': 'application/json' } - }); - // eslint-disable-next-line no-empty - } catch (err) {} - - return true; -} diff --git a/src/cli/config.ts b/src/cli/config.ts index 19df8fdd..3024813e 100644 --- a/src/cli/config.ts +++ b/src/cli/config.ts @@ -29,9 +29,7 @@ program .option('-ch, --cache', 'Use cache', false) .option('-chpath, --cache-path ', 'Folder path for cache data', './.dukascopy-cache') .option('-r, --retries ', 'Number of retries for a failed artifact download', Number, 0) - .option('-rp, --retry-pause ', 'Pause between retries in milliseconds', Number, 500) - .option('-a, --analytics', 'Enable remote analytics', true) - .option('--no-analytics', 'Disable remote analytics'); + .option('-rp, --retry-pause ', 'Pause between retries in milliseconds', Number, 500); program.parse(process.argv); @@ -63,8 +61,7 @@ const cliConfig: CliConfig = { cacheFolderPath: options.cachePath, retryCount: options.retries, pauseBetweenRetriesMs: options.retryPause, - debug: options.debug, - analytics: options.analytics + debug: options.debug }; const cliSchema: InputSchema = { diff --git a/src/cli/index.ts b/src/cli/index.ts index c89b13ed..2f709ebf 100644 --- a/src/cli/index.ts +++ b/src/cli/index.ts @@ -18,7 +18,6 @@ import debug from 'debug'; import { Output } from '../output-formatter/types'; import { Timeframe } from '../config/timeframes'; -import { GOALS, trackCustomGoal } from '../analytics'; import { version } from '../../package.json'; const DEBUG_NAMESPACE = 'dukascopy-node:cli'; @@ -38,8 +37,7 @@ let { cacheFolderPath, dir, silent, - debug: isDebugActive, - analytics + debug: isDebugActive } = input; if (isDebugActive) { @@ -69,13 +67,6 @@ const filePath = resolve(folderPath, fileName); validationErrors }); - if (analytics) { - debug(`${DEBUG_NAMESPACE}:analytics`)( - `Sending "${GOALS.getHistoricalRates}" custom goal to analytics` - ); - trackCustomGoal(GOALS.getHistoricalRates, input, isValid, 'cli'); - } - if (isValid) { const [startDate, endDate] = normaliseDates({ instrument, diff --git a/src/config-validator/schema.ts b/src/config-validator/schema.ts index c7dc0d30..62a2cd75 100644 --- a/src/config-validator/schema.ts +++ b/src/config-validator/schema.ts @@ -84,10 +84,5 @@ export const schema: InputSchema = { integer: true, optional: true, default: defaultConfig.pauseBetweenRetriesMs - } as RuleNumber, - analytics: { - type: 'boolean', - optional: true, - default: defaultConfig.analytics - } as RuleBoolean + } as RuleNumber }; diff --git a/src/config/index.ts b/src/config/index.ts index 59aa9d58..1b0a7b00 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -24,7 +24,6 @@ export interface Config { cacheFolderPath?: string; retryCount?: number; pauseBetweenRetriesMs?: number; - analytics?: boolean; } export type DefaultConfig = Required>>; @@ -41,8 +40,7 @@ export const defaultConfig: DefaultConfig = { useCache: false, cacheFolderPath: '', retryCount: 0, - pauseBetweenRetriesMs: 500, - analytics: true + pauseBetweenRetriesMs: 500 }; export interface ConfigArrayTickItem extends Config { diff --git a/src/getHistoricRates.ts b/src/getHistoricRates.ts index d026e386..8e1833a7 100644 --- a/src/getHistoricRates.ts +++ b/src/getHistoricRates.ts @@ -16,7 +16,6 @@ import { formatOutput } from './output-formatter'; import { CacheManager } from './cache-manager'; import { formatBytes } from './utils/formatBytes'; import { Timeframe } from './config/timeframes'; -import { GOALS, trackCustomGoal } from './analytics'; import { ArrayItem, ArrayTickItem, JsonItem, JsonItemTick, Output } from './output-formatter/types'; import { NotifyFn } from './buffer-fetcher/types'; @@ -44,13 +43,6 @@ export async function getHistoricRates(config: Config): Promise { validationErrors }); - if (config.analytics) { - debug(`${DEBUG_NAMESPACE}:analytics`)( - `Sending "${GOALS.getHistoricalRates}" custom goal to analytics` - ); - trackCustomGoal(GOALS.getHistoricalRates, config, isValid, 'node'); - } - if (!isValid) { throw { validationErrors }; }