mirror of
https://github.com/strapi/strapi.git
synced 2025-11-01 10:23:34 +00:00
Update is truthy fn
Signed-off-by: Alexandre Bodin <bodin.alex@gmail.com>
This commit is contained in:
parent
24000818f4
commit
d60578c875
@ -1,4 +1,4 @@
|
||||
const isTruthyEnvVar = require('../truthy-var');
|
||||
const isTruthyEnvVar = require('../is-truthy');
|
||||
|
||||
describe('isTruthyEnvVar', () => {
|
||||
test('Handles boolean strings', () => {
|
||||
@ -12,13 +12,13 @@ const ciEnv = require('ci-info');
|
||||
const { scheduleJob } = require('node-schedule');
|
||||
|
||||
const createMiddleware = require('./middleware');
|
||||
const isTruthyEnvVar = require('./truthy-var');
|
||||
const isTruthy = require('./is-truthy');
|
||||
|
||||
const createTelemetryInstance = strapi => {
|
||||
const uuid = strapi.config.uuid;
|
||||
const deviceId = machineIdSync();
|
||||
|
||||
const isDisabled = !uuid || isTruthyEnvVar(process.env.STRAPI_TELEMETRY_DISABLED);
|
||||
const isDisabled = !uuid || isTruthy(process.env.STRAPI_TELEMETRY_DISABLED);
|
||||
|
||||
const anonymous_metadata = {
|
||||
environment: strapi.config.environment,
|
||||
|
||||
9
packages/strapi/lib/services/metrics/is-truthy.js
Normal file
9
packages/strapi/lib/services/metrics/is-truthy.js
Normal file
@ -0,0 +1,9 @@
|
||||
'use strict';
|
||||
|
||||
const _ = require('lodash');
|
||||
|
||||
const isTruthy = val => {
|
||||
return [1, true].includes(val) || ['true', '1'].includes(_.toLower(val));
|
||||
};
|
||||
|
||||
module.exports = isTruthy;
|
||||
@ -1,16 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
const isTruthyEnvVar = val => {
|
||||
if (val === null || val === undefined) return false;
|
||||
|
||||
if (val === true) return true;
|
||||
|
||||
if (val.toString().toLowerCase() === 'true') return true;
|
||||
if (val.toString().toLowerCase() === 'false') return false;
|
||||
|
||||
if (val === 1) return true;
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
module.exports = isTruthyEnvVar;
|
||||
Loading…
x
Reference in New Issue
Block a user