diff --git a/src/lib/__snapshots__/create-config.test.ts.snap b/src/lib/__snapshots__/create-config.test.ts.snap index d5f1617b9b68..f040fb6a70f6 100644 --- a/src/lib/__snapshots__/create-config.test.ts.snap +++ b/src/lib/__snapshots__/create-config.test.ts.snap @@ -74,7 +74,6 @@ exports[`should create default config 1`] = ` "experiments": { "addonUsageMetrics": false, "adminTokenKillSwitch": false, - "anonymiseEventLog": false, "anonymizeProjectOwners": false, "archiveProjects": false, "automatedActions": false, diff --git a/src/lib/features/events/event-search-controller.ts b/src/lib/features/events/event-search-controller.ts index 5aea1fc83d18..58ff9c6dd001 100644 --- a/src/lib/features/events/event-search-controller.ts +++ b/src/lib/features/events/event-search-controller.ts @@ -22,7 +22,6 @@ import type { IEvent } from '../../types'; import { anonymiseKeys, extractUserIdFromUser } from '../../util'; const ANON_KEYS = ['email', 'username', 'createdBy']; -const version = 1 as const; export default class EventSearchController extends Controller { private eventService: EventService; @@ -97,9 +96,6 @@ export default class EventSearchController extends Controller { } maybeAnonymiseEvents(events: IEvent[]): IEvent[] { - if (this.flagResolver.isEnabled('anonymiseEventLog')) { - return anonymiseKeys(events, ANON_KEYS); - } - return events; + return anonymiseKeys(events, ANON_KEYS); } } diff --git a/src/lib/features/feature-search/feature-search-controller.ts b/src/lib/features/feature-search/feature-search-controller.ts index a29889cfdffb..4f34e509abcf 100644 --- a/src/lib/features/feature-search/feature-search-controller.ts +++ b/src/lib/features/feature-search/feature-search-controller.ts @@ -75,16 +75,13 @@ export default class FeatureSearchController extends Controller { maybeAnonymise( features: IFeatureSearchOverview[], ): IFeatureSearchOverview[] { - if (this.flagResolver.isEnabled('anonymiseEventLog')) { - return features.map((feature) => ({ - ...feature, - createdBy: { - ...feature.createdBy, - name: anonymise(feature.createdBy.name), - }, - })); - } - return features; + return features.map((feature) => ({ + ...feature, + createdBy: { + ...feature.createdBy, + name: anonymise(feature.createdBy.name), + }, + })); } async searchFeatures( diff --git a/src/lib/features/feature-search/feature.search.e2e.test.ts b/src/lib/features/feature-search/feature.search.e2e.test.ts index 86a8ee7d495a..93f43d7de78d 100644 --- a/src/lib/features/feature-search/feature.search.e2e.test.ts +++ b/src/lib/features/feature-search/feature.search.e2e.test.ts @@ -21,7 +21,6 @@ beforeAll(async () => { experimental: { flags: { strictSchemaValidation: true, - anonymiseEventLog: true, }, }, }, @@ -211,24 +210,22 @@ test('should paginate with offset', async () => { await app.createFeature('my_feature_c'); await app.createFeature('my_feature_d'); - const { body: firstPage, headers: firstHeaders } = - await searchFeaturesWithOffset({ - query: 'feature', - offset: '0', - limit: '2', - }); + const { body: firstPage } = await searchFeaturesWithOffset({ + query: 'feature', + offset: '0', + limit: '2', + }); expect(firstPage).toMatchObject({ features: [{ name: 'my_feature_a' }, { name: 'my_feature_b' }], total: 4, }); - const { body: secondPage, headers: secondHeaders } = - await searchFeaturesWithOffset({ - query: 'feature', - offset: '2', - limit: '2', - }); + const { body: secondPage } = await searchFeaturesWithOffset({ + query: 'feature', + offset: '2', + limit: '2', + }); expect(secondPage).toMatchObject({ features: [{ name: 'my_feature_c' }, { name: 'my_feature_d' }], diff --git a/src/lib/features/feature-toggle/feature-toggle-controller.ts b/src/lib/features/feature-toggle/feature-toggle-controller.ts index 58823ee511bd..f9da4a4fd26f 100644 --- a/src/lib/features/feature-toggle/feature-toggle-controller.ts +++ b/src/lib/features/feature-toggle/feature-toggle-controller.ts @@ -699,10 +699,7 @@ export default class ProjectFeaturesController extends Controller { } maybeAnonymise(feature: FeatureToggleView): FeatureToggleView { - if ( - this.flagResolver.isEnabled('anonymiseEventLog') && - feature.createdBy - ) { + if (feature.createdBy) { return { ...feature, ...(feature.collaborators @@ -754,7 +751,7 @@ export default class ProjectFeaturesController extends Controller { res: Response, ): Promise { const { projectId, featureName } = req.params; - const { createdAt, ...data } = req.body; + const { ...data } = req.body; if (data.name && data.name !== featureName) { throw new BadDataError('Cannot change name of feature flag'); } @@ -842,7 +839,7 @@ export default class ProjectFeaturesController extends Controller { res: Response, ): Promise { const { environment, featureName, projectId } = req.params; - const { defaultStrategy, ...environmentInfo } = + const { ...environmentInfo } = await this.featureService.getEnvironmentInfo( projectId, environment, @@ -852,13 +849,7 @@ export default class ProjectFeaturesController extends Controller { const result = { ...environmentInfo, strategies: environmentInfo.strategies.map((strategy) => { - const { - strategyName, - projectId: project, - environment: environmentId, - createdAt, - ...rest - } = strategy; + const { strategyName, ...rest } = strategy; return { ...rest, name: strategyName }; }), }; diff --git a/src/lib/features/feature-toggle/tests/feature-toggles.auth.e2e.test.ts b/src/lib/features/feature-toggle/tests/feature-toggles.auth.e2e.test.ts index 7e4fc39606e2..9ac6fca37c4b 100644 --- a/src/lib/features/feature-toggle/tests/feature-toggles.auth.e2e.test.ts +++ b/src/lib/features/feature-toggle/tests/feature-toggles.auth.e2e.test.ts @@ -24,7 +24,6 @@ beforeAll(async () => { experimental: { flags: { strictSchemaValidation: true, - anonymiseEventLog: true, }, }, }, diff --git a/src/lib/features/segment/admin-segment.e2e.test.ts b/src/lib/features/segment/admin-segment.e2e.test.ts index 019a822da6db..30d8660bd664 100644 --- a/src/lib/features/segment/admin-segment.e2e.test.ts +++ b/src/lib/features/segment/admin-segment.e2e.test.ts @@ -114,9 +114,7 @@ const validateSegment = ( beforeAll(async () => { const customOptions = { experimental: { - flags: { - anonymiseEventLog: true, - }, + flags: {}, }, }; diff --git a/src/lib/features/segment/segment-controller.ts b/src/lib/features/segment/segment-controller.ts index e5c1b9573519..3b7068bd37a1 100644 --- a/src/lib/features/segment/segment-controller.ts +++ b/src/lib/features/segment/segment-controller.ts @@ -286,11 +286,9 @@ export class SegmentsController extends Controller { const { strategyId } = req.params; const segments = await this.segmentService.getByStrategy(strategyId); - const responseBody = this.flagResolver.isEnabled('anonymiseEventLog') - ? { - segments: anonymiseKeys(segments, ['createdBy']), - } - : { segments }; + const responseBody = { + segments: anonymiseKeys(segments, ['createdBy']), + }; this.openApiService.respondWithValidation( 200, @@ -427,11 +425,7 @@ export class SegmentsController extends Controller { ): Promise { const id = Number(req.params.id); const segment = await this.segmentService.get(id); - if (this.flagResolver.isEnabled('anonymiseEventLog')) { - res.json(anonymiseKeys(segment, ['createdBy'])); - } else { - res.json(segment); - } + res.json(anonymiseKeys(segment, ['createdBy'])); } async createSegment( @@ -459,9 +453,7 @@ export class SegmentsController extends Controller { const segments = await this.segmentService.getAll(); const response = { - segments: this.flagResolver.isEnabled('anonymiseEventLog') - ? anonymiseKeys(segments, ['createdBy']) - : segments, + segments: anonymiseKeys(segments, ['createdBy']), }; this.openApiService.respondWithValidation( diff --git a/src/lib/routes/admin-api/event.ts b/src/lib/routes/admin-api/event.ts index 2985339e2daa..dc7c9e27e984 100644 --- a/src/lib/routes/admin-api/event.ts +++ b/src/lib/routes/admin-api/event.ts @@ -143,10 +143,7 @@ export default class EventController extends Controller { } maybeAnonymiseEvents(events: IEvent[]): IEvent[] { - if (this.flagResolver.isEnabled('anonymiseEventLog')) { - return anonymiseKeys(events, ANON_KEYS); - } - return events; + return anonymiseKeys(events, ANON_KEYS); } async getEvents( diff --git a/src/lib/routes/admin-api/events.test.ts b/src/lib/routes/admin-api/events.test.ts index 122cbd05a61e..12aaba34bf7a 100644 --- a/src/lib/routes/admin-api/events.test.ts +++ b/src/lib/routes/admin-api/events.test.ts @@ -12,14 +12,12 @@ import { ProjectUserRemovedEvent, } from '../../types/events'; import { TEST_AUDIT_USER } from '../../types'; - -const TEST_USER_ID = -9999; -async function getSetup(anonymise: boolean = false) { +async function getSetup() { const base = `/random${Math.round(Math.random() * 1000)}`; const stores = createStores(); const config = createTestConfig({ server: { baseUriPath: base }, - experimental: { flags: { anonymiseEventLog: anonymise } }, + experimental: { flags: {} }, }); const services = createServices(stores, config); const app = await getApp(config, stores, services); diff --git a/src/lib/routes/admin-api/user-admin.ts b/src/lib/routes/admin-api/user-admin.ts index 0f9e2448cf3e..61f3c29cbced 100644 --- a/src/lib/routes/admin-api/user-admin.ts +++ b/src/lib/routes/admin-api/user-admin.ts @@ -449,9 +449,7 @@ export default class UserAdminController extends Controller { typeof q === 'string' && q.length > 1 ? await this.userService.search(q) : []; - if (this.flagResolver.isEnabled('anonymiseEventLog')) { - users = this.anonymiseUsers(users); - } + users = this.anonymiseUsers(users); this.openApiService.respondWithValidation( 200, res, @@ -474,9 +472,7 @@ export default class UserAdminController extends Controller { accountType: u.accountType, } as IUser; }); - if (this.flagResolver.isEnabled('anonymiseEventLog')) { - users = this.anonymiseUsers(users); - } + users = this.anonymiseUsers(users); const allGroups = await this.groupService.getAll(); const groups = allGroups.map((g) => { @@ -565,7 +561,7 @@ export default class UserAdminController extends Controller { >, res: Response, ): Promise { - const { user, params, body } = req; + const { params, body } = req; const { id } = params; const { name, email, rootRole } = body; @@ -596,7 +592,7 @@ export default class UserAdminController extends Controller { } async deleteUser(req: IAuthRequest, res: Response): Promise { - const { user, params } = req; + const { params } = req; const { id } = params; await this.throwIfScimUser({ id: Number(id) }); diff --git a/src/lib/types/experimental.ts b/src/lib/types/experimental.ts index e6df34fecd5a..0f3faa2925fb 100644 --- a/src/lib/types/experimental.ts +++ b/src/lib/types/experimental.ts @@ -4,7 +4,6 @@ import { getDefaultVariant } from 'unleash-client/lib/variant'; export type IFlagKey = | 'accessLogs' - | 'anonymiseEventLog' | 'encryptEmails' | 'enableLicense' | 'enableLicenseChecker' @@ -72,7 +71,6 @@ export type IFlagKey = export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>; const flags: IFlags = { - anonymiseEventLog: false, enableLicense: false, enableLicenseChecker: false, embedProxy: parseEnvVarBoolean( diff --git a/src/lib/users/inactive/inactive-users-controller.ts b/src/lib/users/inactive/inactive-users-controller.ts index 6d30f21196aa..f53d1a824dff 100644 --- a/src/lib/users/inactive/inactive-users-controller.ts +++ b/src/lib/users/inactive/inactive-users-controller.ts @@ -89,9 +89,7 @@ export class InactiveUsersController extends Controller { ): Promise { this.logger.info('Hitting inactive users'); let inactiveUsers = await this.inactiveUsersService.getInactiveUsers(); - if (this.flagResolver.isEnabled('anonymiseEventLog')) { - inactiveUsers = this.anonymiseUsers(inactiveUsers); - } + inactiveUsers = this.anonymiseUsers(inactiveUsers); this.openApiService.respondWithValidation( 200, res, diff --git a/src/server-dev.ts b/src/server-dev.ts index 33037fd15747..60a0d0ee9d27 100644 --- a/src/server-dev.ts +++ b/src/server-dev.ts @@ -38,7 +38,6 @@ process.nextTick(async () => { flags: { embedProxy: true, embedProxyFrontend: true, - anonymiseEventLog: false, responseTimeWithAppNameKillSwitch: false, stripHeadersOnAPI: true, celebrateUnleash: true, diff --git a/src/test/e2e/api/admin/user-admin.e2e.test.ts b/src/test/e2e/api/admin/user-admin.e2e.test.ts index df670db1688f..a6e6755b2649 100644 --- a/src/test/e2e/api/admin/user-admin.e2e.test.ts +++ b/src/test/e2e/api/admin/user-admin.e2e.test.ts @@ -386,7 +386,7 @@ test('generates USER_UPDATED event', async () => { test('Anonymises name, username and email fields if anonymiseEventLog flag is set', async () => { const anonymisedApp = await setupAppWithCustomConfig( stores, - { experimental: { flags: { anonymiseEventLog: true } } }, + { experimental: { flags: {} } }, db.rawDatabase, ); await anonymisedApp.request