From 898d4f0b70e96b9021ba00a9e64d9202b6a76b36 Mon Sep 17 00:00:00 2001 From: Mateusz Kwasniewski Date: Thu, 9 Mar 2023 16:20:12 +0100 Subject: [PATCH] feat: clean api behind a flag (#3288) --- .../__snapshots__/create-config.test.ts.snap | 2 + src/lib/services/feature-toggle-service.ts | 58 ++++++++++--------- src/lib/types/experimental.ts | 1 + 3 files changed, 34 insertions(+), 27 deletions(-) diff --git a/src/lib/__snapshots__/create-config.test.ts.snap b/src/lib/__snapshots__/create-config.test.ts.snap index f0f3bf4187..f232782994 100644 --- a/src/lib/__snapshots__/create-config.test.ts.snap +++ b/src/lib/__snapshots__/create-config.test.ts.snap @@ -71,6 +71,7 @@ exports[`should create default config 1`] = ` "anonymiseEventLog": false, "bulkOperations": false, "caseInsensitiveInOperators": false, + "cleanClientApi": false, "crOnVariants": false, "embedProxy": true, "embedProxyFrontend": true, @@ -95,6 +96,7 @@ exports[`should create default config 1`] = ` "anonymiseEventLog": false, "bulkOperations": false, "caseInsensitiveInOperators": false, + "cleanClientApi": false, "crOnVariants": false, "embedProxy": true, "embedProxyFrontend": true, diff --git a/src/lib/services/feature-toggle-service.ts b/src/lib/services/feature-toggle-service.ts index b99346d2ea..5eddd6d76d 100644 --- a/src/lib/services/feature-toggle-service.ts +++ b/src/lib/services/feature-toggle-service.ts @@ -692,33 +692,37 @@ class FeatureToggleService { query, includeIds, ); - return result.map( - ({ - name, - type, - enabled, - project, - stale, - strategies, - variants, - description, - createdAt, - lastSeenAt, - impressionData, - }) => ({ - name, - type, - enabled, - project, - stale, - strategies, - variants, - description, - createdAt, - lastSeenAt, - impressionData, - }), - ); + if (this.flagResolver.isEnabled('cleanClientApi')) { + return result.map( + ({ + name, + type, + enabled, + project, + stale, + strategies, + variants, + description, + createdAt, + lastSeenAt, + impressionData, + }) => ({ + name, + type, + enabled, + project, + stale, + strategies, + variants, + description, + createdAt, + lastSeenAt, + impressionData, + }), + ); + } else { + return result; + } } /** diff --git a/src/lib/types/experimental.ts b/src/lib/types/experimental.ts index 5f7bff67b7..6abc207cb9 100644 --- a/src/lib/types/experimental.ts +++ b/src/lib/types/experimental.ts @@ -72,6 +72,7 @@ const flags = { process.env.PROJECT_SCOPED_SEGMENTS, false, ), + cleanClientApi: parseEnvVarBoolean(process.env.CLEAN_CLIENT_API, false), }; export const defaultExperimentalOptions: IExperimentalOptions = {