mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	chore: remove detectSegmentUsageInChangeRequests flag (#6080)
What it says on the tin. Removes all uses of the detectSegmentUsageInChangeRequests flag.
This commit is contained in:
		
							parent
							
								
									d7eb950f3a
								
							
						
					
					
						commit
						73322f12f7
					
				@ -82,7 +82,6 @@ exports[`should create default config 1`] = `
 | 
				
			|||||||
      "createdByUserIdDataMigration": false,
 | 
					      "createdByUserIdDataMigration": false,
 | 
				
			||||||
      "customRootRolesKillSwitch": false,
 | 
					      "customRootRolesKillSwitch": false,
 | 
				
			||||||
      "demo": false,
 | 
					      "demo": false,
 | 
				
			||||||
      "detectSegmentUsageInChangeRequests": false,
 | 
					 | 
				
			||||||
      "disableBulkToggle": false,
 | 
					      "disableBulkToggle": false,
 | 
				
			||||||
      "disableMetrics": false,
 | 
					      "disableMetrics": false,
 | 
				
			||||||
      "disableNotifications": false,
 | 
					      "disableNotifications": false,
 | 
				
			||||||
 | 
				
			|||||||
@ -11,9 +11,7 @@ let segmentStore: ISegmentStore;
 | 
				
			|||||||
beforeAll(async () => {
 | 
					beforeAll(async () => {
 | 
				
			||||||
    db = await dbInit('segment_store_serial', getLogger, {
 | 
					    db = await dbInit('segment_store_serial', getLogger, {
 | 
				
			||||||
        experimental: {
 | 
					        experimental: {
 | 
				
			||||||
            flags: {
 | 
					            flags: {},
 | 
				
			||||||
                detectSegmentUsageInChangeRequests: true,
 | 
					 | 
				
			||||||
            },
 | 
					 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
    stores = db.stores;
 | 
					    stores = db.stores;
 | 
				
			||||||
 | 
				
			|||||||
@ -115,10 +115,7 @@ export default class SegmentStore implements ISegmentStore {
 | 
				
			|||||||
    async getAll(
 | 
					    async getAll(
 | 
				
			||||||
        includeChangeRequestUsageData: boolean = false,
 | 
					        includeChangeRequestUsageData: boolean = false,
 | 
				
			||||||
    ): Promise<ISegment[]> {
 | 
					    ): Promise<ISegment[]> {
 | 
				
			||||||
        if (
 | 
					        if (includeChangeRequestUsageData) {
 | 
				
			||||||
            includeChangeRequestUsageData &&
 | 
					 | 
				
			||||||
            this.flagResolver.isEnabled('detectSegmentUsageInChangeRequests')
 | 
					 | 
				
			||||||
        ) {
 | 
					 | 
				
			||||||
            const pendingCRs = await this.db
 | 
					            const pendingCRs = await this.db
 | 
				
			||||||
                .select('id', 'project')
 | 
					                .select('id', 'project')
 | 
				
			||||||
                .from('change_requests')
 | 
					                .from('change_requests')
 | 
				
			||||||
 | 
				
			|||||||
@ -362,24 +362,21 @@ export class SegmentsController extends Controller {
 | 
				
			|||||||
            environment: strategy.environment,
 | 
					            environment: strategy.environment,
 | 
				
			||||||
        }));
 | 
					        }));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (this.flagResolver.isEnabled('detectSegmentUsageInChangeRequests')) {
 | 
					        const changeRequestStrategies = strategies.changeRequestStrategies.map(
 | 
				
			||||||
            const changeRequestStrategies =
 | 
					            (strategy) => ({
 | 
				
			||||||
                strategies.changeRequestStrategies.map((strategy) => ({
 | 
					                ...('id' in strategy ? { id: strategy.id } : {}),
 | 
				
			||||||
                    ...('id' in strategy ? { id: strategy.id } : {}),
 | 
					                projectId: strategy.projectId,
 | 
				
			||||||
                    projectId: strategy.projectId,
 | 
					                featureName: strategy.featureName,
 | 
				
			||||||
                    featureName: strategy.featureName,
 | 
					                strategyName: strategy.strategyName,
 | 
				
			||||||
                    strategyName: strategy.strategyName,
 | 
					                environment: strategy.environment,
 | 
				
			||||||
                    environment: strategy.environment,
 | 
					                changeRequest: strategy.changeRequest,
 | 
				
			||||||
                    changeRequest: strategy.changeRequest,
 | 
					            }),
 | 
				
			||||||
                }));
 | 
					        );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            res.json({
 | 
					        res.json({
 | 
				
			||||||
                strategies: segmentStrategies,
 | 
					            strategies: segmentStrategies,
 | 
				
			||||||
                changeRequestStrategies,
 | 
					            changeRequestStrategies,
 | 
				
			||||||
            });
 | 
					        });
 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            res.json({ strategies: segmentStrategies });
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    async removeSegment(
 | 
					    async removeSegment(
 | 
				
			||||||
@ -389,12 +386,7 @@ export class SegmentsController extends Controller {
 | 
				
			|||||||
        const id = Number(req.params.id);
 | 
					        const id = Number(req.params.id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        let segmentIsInUse = false;
 | 
					        let segmentIsInUse = false;
 | 
				
			||||||
        if (this.flagResolver.isEnabled('detectSegmentUsageInChangeRequests')) {
 | 
					        segmentIsInUse = await this.segmentService.isInUse(id);
 | 
				
			||||||
            segmentIsInUse = await this.segmentService.isInUse(id);
 | 
					 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            const strategies = await this.segmentService.getAllStrategies(id);
 | 
					 | 
				
			||||||
            segmentIsInUse = strategies.strategies.length > 0;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (segmentIsInUse) {
 | 
					        if (segmentIsInUse) {
 | 
				
			||||||
            res.status(409).send();
 | 
					            res.status(409).send();
 | 
				
			||||||
 | 
				
			|||||||
@ -115,10 +115,7 @@ export class SegmentService implements ISegmentService {
 | 
				
			|||||||
        const strategies =
 | 
					        const strategies =
 | 
				
			||||||
            await this.featureStrategiesStore.getStrategiesBySegment(id);
 | 
					            await this.featureStrategiesStore.getStrategiesBySegment(id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (
 | 
					        if (this.config.isEnterprise) {
 | 
				
			||||||
            this.flagResolver.isEnabled('detectSegmentUsageInChangeRequests') &&
 | 
					 | 
				
			||||||
            this.config.isEnterprise
 | 
					 | 
				
			||||||
        ) {
 | 
					 | 
				
			||||||
            const changeRequestStrategies =
 | 
					            const changeRequestStrategies =
 | 
				
			||||||
                await this.changeRequestSegmentUsageReadModel.getStrategiesUsedInActiveChangeRequests(
 | 
					                await this.changeRequestSegmentUsageReadModel.getStrategiesUsedInActiveChangeRequests(
 | 
				
			||||||
                    id,
 | 
					                    id,
 | 
				
			||||||
 | 
				
			|||||||
@ -28,7 +28,6 @@ export type IFlagKey =
 | 
				
			|||||||
    | 'customRootRolesKillSwitch'
 | 
					    | 'customRootRolesKillSwitch'
 | 
				
			||||||
    | 'disableMetrics'
 | 
					    | 'disableMetrics'
 | 
				
			||||||
    | 'scheduledConfigurationChanges'
 | 
					    | 'scheduledConfigurationChanges'
 | 
				
			||||||
    | 'detectSegmentUsageInChangeRequests'
 | 
					 | 
				
			||||||
    | 'stripClientHeadersOn304'
 | 
					    | 'stripClientHeadersOn304'
 | 
				
			||||||
    | 'newStrategyConfiguration'
 | 
					    | 'newStrategyConfiguration'
 | 
				
			||||||
    | 'stripHeadersOnAPI'
 | 
					    | 'stripHeadersOnAPI'
 | 
				
			||||||
@ -133,11 +132,6 @@ const flags: IFlags = {
 | 
				
			|||||||
        process.env.UNLEASH_EXPERIMENTAL_SCHEDULED_CONFIGURATION_CHANGES,
 | 
					        process.env.UNLEASH_EXPERIMENTAL_SCHEDULED_CONFIGURATION_CHANGES,
 | 
				
			||||||
        false,
 | 
					        false,
 | 
				
			||||||
    ),
 | 
					    ),
 | 
				
			||||||
    detectSegmentUsageInChangeRequests: parseEnvVarBoolean(
 | 
					 | 
				
			||||||
        process.env
 | 
					 | 
				
			||||||
            .UNLEASH_EXPERIMENTAL_DETECT_SEGMENT_USAGE_IN_CHANGE_REQUESTS,
 | 
					 | 
				
			||||||
        false,
 | 
					 | 
				
			||||||
    ),
 | 
					 | 
				
			||||||
    stripClientHeadersOn304: parseEnvVarBoolean(
 | 
					    stripClientHeadersOn304: parseEnvVarBoolean(
 | 
				
			||||||
        process.env
 | 
					        process.env
 | 
				
			||||||
            .UNLEASH_EXPERIMENTAL_DETECT_SEGMENT_USAGE_IN_CHANGE_REQUESTS,
 | 
					            .UNLEASH_EXPERIMENTAL_DETECT_SEGMENT_USAGE_IN_CHANGE_REQUESTS,
 | 
				
			||||||
 | 
				
			|||||||
@ -106,7 +106,6 @@ beforeAll(async () => {
 | 
				
			|||||||
        experimental: {
 | 
					        experimental: {
 | 
				
			||||||
            flags: {
 | 
					            flags: {
 | 
				
			||||||
                anonymiseEventLog: true,
 | 
					                anonymiseEventLog: true,
 | 
				
			||||||
                detectSegmentUsageInChangeRequests: true,
 | 
					 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
@ -588,9 +587,7 @@ describe('detect strategy usage in change requests', () => {
 | 
				
			|||||||
                ui: { environment: 'Enterprise' },
 | 
					                ui: { environment: 'Enterprise' },
 | 
				
			||||||
                isEnterprise: true,
 | 
					                isEnterprise: true,
 | 
				
			||||||
                experimental: {
 | 
					                experimental: {
 | 
				
			||||||
                    flags: {
 | 
					                    flags: {},
 | 
				
			||||||
                        detectSegmentUsageInChangeRequests: true,
 | 
					 | 
				
			||||||
                    },
 | 
					 | 
				
			||||||
                },
 | 
					                },
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            db.rawDatabase,
 | 
					            db.rawDatabase,
 | 
				
			||||||
 | 
				
			|||||||
@ -188,9 +188,7 @@ beforeAll(async () => {
 | 
				
			|||||||
        db.stores,
 | 
					        db.stores,
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            experimental: {
 | 
					            experimental: {
 | 
				
			||||||
                flags: {
 | 
					                flags: {},
 | 
				
			||||||
                    detectSegmentUsageInChangeRequests: true,
 | 
					 | 
				
			||||||
                },
 | 
					 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        db.rawDatabase,
 | 
					        db.rawDatabase,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user