mirror of
https://github.com/Unleash/unleash.git
synced 2025-11-10 01:19:53 +01:00
chore(AI): originMiddlewareRequestLogging flag cleanup (#10864)
This PR cleans up the originMiddlewareRequestLogging flag. These changes were automatically generated by AI and should be reviewed carefully. Fixes #10863 ## 🧹 AI Flag Cleanup Summary This change removes the `originMiddlewareRequestLogging` feature flag and its associated code. The flag's outcome was to be discarded, so the logging it controlled has been removed from `originMiddleware`. ### 🚮 Removed - **Flag Definition** - Removed `originMiddlewareRequestLogging` from the `IFlagKey` type in `src/lib/types/experimental.ts`. - Removed the flag from the development server configuration in `src/server-dev.ts`. - **Logic** - Removed the conditional logging of API requests from `originMiddleware`. - **Tests** - Removed the test case for API request logging in `origin-middleware.test.ts`. - Removed the flag setup from the test configuration. ### 🛠 Kept - **Core functionality** - The core logic of the `originMiddleware` for emitting `REQUEST_ORIGIN` metric events for UI and API requests remains unchanged. ### 📝 Why The `originMiddlewareRequestLogging` feature flag was completed and its outcome was 'discarded'. This cleanup removes the flag and the now-dead code related to it, simplifying the middleware and tests. --------- Co-authored-by: unleash-bot <194219037+unleash-bot[bot]@users.noreply.github.com> Co-authored-by: Gastón Fournier <gaston@getunleash.io>
This commit is contained in:
parent
0ddf35656c
commit
25abe054a4
@ -30,11 +30,6 @@ describe('originMiddleware', () => {
|
||||
config = {
|
||||
...createTestConfig({
|
||||
getLogger,
|
||||
experimental: {
|
||||
flags: {
|
||||
originMiddlewareRequestLogging: true,
|
||||
},
|
||||
},
|
||||
}),
|
||||
eventBus,
|
||||
};
|
||||
@ -73,19 +68,4 @@ describe('originMiddleware', () => {
|
||||
source: 'Other',
|
||||
});
|
||||
});
|
||||
|
||||
it('should log API request', () => {
|
||||
const middleware = originMiddleware(config);
|
||||
|
||||
req.headers.authorization = TEST_UNLEASH_TOKEN;
|
||||
req.headers['user-agent'] = TEST_USER_AGENT;
|
||||
|
||||
middleware(req, res, next);
|
||||
|
||||
expect(loggerMock.info).toHaveBeenCalledWith('API request', {
|
||||
method: req.method,
|
||||
userAgent: TEST_USER_AGENT,
|
||||
origin: undefined,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@ -1,16 +1,12 @@
|
||||
import type { Request, Response, NextFunction } from 'express';
|
||||
import type { IUnleashConfig } from '../types/index.js';
|
||||
import { REQUEST_ORIGIN, emitMetricEvent } from '../metric-events.js';
|
||||
import {
|
||||
determineIntegrationSource,
|
||||
getFilteredOrigin,
|
||||
} from './integration-headers.js';
|
||||
import { determineIntegrationSource } from './integration-headers.js';
|
||||
|
||||
export const originMiddleware = ({
|
||||
getLogger,
|
||||
eventBus,
|
||||
flagResolver,
|
||||
}: Pick<IUnleashConfig, 'getLogger' | 'eventBus' | 'flagResolver'>) => {
|
||||
}: Pick<IUnleashConfig, 'getLogger' | 'eventBus'>) => {
|
||||
const logger = getLogger('/middleware/origin-middleware.ts');
|
||||
logger.debug('Enabling origin middleware');
|
||||
return (req: Request, _: Response, next: NextFunction) => {
|
||||
@ -27,14 +23,6 @@ export const originMiddleware = ({
|
||||
? determineIntegrationSource(userAgent)
|
||||
: 'Other';
|
||||
|
||||
if (flagResolver.isEnabled('originMiddlewareRequestLogging')) {
|
||||
logger.info('API request', {
|
||||
method: req.method,
|
||||
userAgent: req.headers['user-agent'],
|
||||
origin: getFilteredOrigin(req),
|
||||
});
|
||||
}
|
||||
|
||||
emitMetricEvent(eventBus, REQUEST_ORIGIN, {
|
||||
type: 'API',
|
||||
method: req.method,
|
||||
|
||||
@ -39,7 +39,6 @@ export type IFlagKey =
|
||||
| 'extendedMetrics'
|
||||
| 'removeUnsafeInlineStyleSrc'
|
||||
| 'projectRoleAssignment'
|
||||
| 'originMiddlewareRequestLogging'
|
||||
| 'webhookDomainLogging'
|
||||
| 'productivityReportEmail'
|
||||
| 'productivityReportUnsubscribers'
|
||||
@ -203,10 +202,6 @@ const flags: IFlags = {
|
||||
process.env.UNLEASH_EXPERIMENTAL_PROJECT_ROLE_ASSIGNMENT,
|
||||
false,
|
||||
),
|
||||
originMiddlewareRequestLogging: parseEnvVarBoolean(
|
||||
process.env.UNLEASH_ORIGIN_MIDDLEWARE_REQUEST_LOGGING,
|
||||
false,
|
||||
),
|
||||
webhookDomainLogging: parseEnvVarBoolean(
|
||||
process.env.UNLEASH_EXPERIMENT_WEBHOOK_DOMAIN_LOGGING,
|
||||
false,
|
||||
|
||||
@ -44,7 +44,6 @@ process.nextTick(async () => {
|
||||
manyStrategiesPagination: true,
|
||||
enableLegacyVariants: false,
|
||||
extendedMetrics: true,
|
||||
originMiddlewareRequestLogging: true,
|
||||
webhookDomainLogging: true,
|
||||
showUserDeviceCount: true,
|
||||
deltaApi: true,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user