1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-08-18 13:48:58 +02:00

refactor: Unify SDK reporting under dedicated frontend/backend fields

This commit is contained in:
unleash-bot 2025-07-02 16:27:44 +00:00
parent 30fbc62f9b
commit 5aefac0edd
9 changed files with 21 additions and 64 deletions

View File

@ -16,7 +16,6 @@ import WarningAmberRounded from '@mui/icons-material/WarningAmberRounded';
import { TimeAgo } from 'component/common/TimeAgo/TimeAgo'; import { TimeAgo } from 'component/common/TimeAgo/TimeAgo';
import { usePlausibleTracker } from 'hooks/usePlausibleTracker'; import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
import { getApplicationIssues } from './ApplicationIssues/ApplicationIssues.tsx'; import { getApplicationIssues } from './ApplicationIssues/ApplicationIssues.tsx';
import { useUiFlag } from 'hooks/useUiFlag';
const StyledTable = styled('table')(({ theme }) => ({ const StyledTable = styled('table')(({ theme }) => ({
fontSize: theme.fontSizes.smallerBody, fontSize: theme.fontSizes.smallerBody,
@ -197,7 +196,6 @@ export const ApplicationChart = ({ data }: IApplicationChartProps) => {
const { elementRef, width } = useElementWidth(); const { elementRef, width } = useElementWidth();
const navigate = useNavigate(); const navigate = useNavigate();
const theme = useTheme(); const theme = useTheme();
const registerFrontendClientEnabled = useUiFlag('registerFrontendClient');
const mode = getApplicationIssues(data); const mode = getApplicationIssues(data);
@ -296,23 +294,7 @@ export const ApplicationChart = ({ data }: IApplicationChartProps) => {
{environment.instanceCount} {environment.instanceCount}
</StyledCell> </StyledCell>
</tr> </tr>
{!registerFrontendClientEnabled ? ( {environment.backendSdks.length > 0 ? (
<tr>
<StyledCell>SDK:</StyledCell>
<StyledCell>
{environment.sdks.map(
(sdk) => (
<div key={sdk}>
{sdk}
</div>
),
)}
</StyledCell>
</tr>
) : null}
{registerFrontendClientEnabled &&
environment.backendSdks.length > 0 ? (
<tr> <tr>
<StyledCell> <StyledCell>
Backend SDK: Backend SDK:
@ -329,8 +311,7 @@ export const ApplicationChart = ({ data }: IApplicationChartProps) => {
</tr> </tr>
) : null} ) : null}
{registerFrontendClientEnabled && {environment.frontendSdks.length > 0 ? (
environment.frontendSdks.length > 0 ? (
<tr> <tr>
<StyledCell> <StyledCell>
Frontend SDK: Frontend SDK:

View File

@ -84,7 +84,6 @@ export type UiFlags = {
showUserDeviceCount?: boolean; showUserDeviceCount?: boolean;
consumptionModel?: boolean; consumptionModel?: boolean;
edgeObservability?: boolean; edgeObservability?: boolean;
registerFrontendClient?: boolean;
customMetrics?: boolean; customMetrics?: boolean;
lifecycleMetrics?: boolean; lifecycleMetrics?: boolean;
createFlagDialogCache?: boolean; createFlagDialogCache?: boolean;

View File

@ -135,11 +135,7 @@ export class FrontendApiService {
ip, ip,
); );
if ( if (metrics.instanceId && typeof sdkVersion === 'string') {
metrics.instanceId &&
typeof sdkVersion === 'string' &&
this.flagResolver.isEnabled('registerFrontendClient')
) {
const client = { const client = {
appName: metrics.appName, appName: metrics.appName,
instanceId: metrics.instanceId, instanceId: metrics.instanceId,

View File

@ -282,10 +282,13 @@ export default class ClientInstanceService {
result.projects, result.projects,
); );
result.projects = accessibleProjects; result.projects = accessibleProjects;
result.environments.forEach((environment) => { result.environments.forEach((environment: any) => {
environment.issues.outdatedSdks = findOutdatedSDKs( const allSdks = [
environment.sdks, ...environment.backendSdks,
); ...environment.frontendSdks,
];
environment.issues.outdatedSdks = findOutdatedSDKs(allSdks);
delete environment.sdks;
}); });
return result; return result;
} }

View File

@ -45,13 +45,7 @@ let services: IUnleashServices;
let destroy: () => Promise<void>; let destroy: () => Promise<void>;
beforeAll(async () => { beforeAll(async () => {
const setup = await getSetup({ const setup = await getSetup();
experimental: {
flags: {
registerFrontendClient: true,
},
},
});
request = setup.request; request = setup.request;
stores = setup.stores; stores = setup.stores;
destroy = setup.destroy; destroy = setup.destroy;

View File

@ -238,20 +238,14 @@ export default class ClientMetricsController extends Controller {
app.sdkType === 'frontend' && app.sdkType === 'frontend' &&
typeof app.sdkVersion === 'string' typeof app.sdkVersion === 'string'
) { ) {
if ( this.clientInstanceService.registerFrontendClient({
this.flagResolver.isEnabled( appName: app.appName,
'registerFrontendClient', instanceId: app.instanceId,
) environment: app.environment,
) { sdkType: app.sdkType,
this.clientInstanceService.registerFrontendClient({ sdkVersion: app.sdkVersion,
appName: app.appName, projects: app.projects,
instanceId: app.instanceId, });
environment: app.environment,
sdkType: app.sdkType,
sdkVersion: app.sdkVersion,
projects: app.projects,
});
}
} else { } else {
promises.push( promises.push(
this.clientInstanceService.registerBackendClient( this.clientInstanceService.registerBackendClient(

View File

@ -54,7 +54,6 @@ export type IFlagKey =
| 'uniqueSdkTracking' | 'uniqueSdkTracking'
| 'consumptionModel' | 'consumptionModel'
| 'edgeObservability' | 'edgeObservability'
| 'registerFrontendClient'
| 'reportUnknownFlags' | 'reportUnknownFlags'
| 'lifecycleMetrics' | 'lifecycleMetrics'
| 'customMetrics' | 'customMetrics'
@ -260,10 +259,6 @@ const flags: IFlags = {
process.env.EXPERIMENTAL_EDGE_OBSERVABILITY, process.env.EXPERIMENTAL_EDGE_OBSERVABILITY,
false, false,
), ),
registerFrontendClient: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_REGISTER_FRONTEND_CLIENT,
false,
),
reportUnknownFlags: parseEnvVarBoolean( reportUnknownFlags: parseEnvVarBoolean(
process.env.UNLEASH_EXPERIMENTAL_REPORT_UNKNOWN_FLAGS, process.env.UNLEASH_EXPERIMENTAL_REPORT_UNKNOWN_FLAGS,
false, false,

View File

@ -51,7 +51,6 @@ process.nextTick(async () => {
deltaApi: true, deltaApi: true,
uniqueSdkTracking: true, uniqueSdkTracking: true,
strictSchemaValidation: true, strictSchemaValidation: true,
registerFrontendClient: true,
reportUnknownFlags: true, reportUnknownFlags: true,
customMetrics: true, customMetrics: true,
lifecycleMetrics: true, lifecycleMetrics: true,

View File

@ -55,7 +55,6 @@ beforeAll(async () => {
experimental: { experimental: {
flags: { flags: {
strictSchemaValidation: true, strictSchemaValidation: true,
registerFrontendClient: true,
}, },
}, },
}, },
@ -142,10 +141,6 @@ test('should show correct application metrics', async () => {
'unleash-client-node:3.2.1', 'unleash-client-node:3.2.1',
'unleash-client-node:3.2.2', 'unleash-client-node:3.2.2',
], ],
sdks: [
'unleash-client-node:3.2.1',
'unleash-client-node:3.2.2',
],
}, },
], ],
featureCount: 3, featureCount: 3,
@ -246,7 +241,8 @@ test('should show missing features and strategies', async () => {
{ {
instanceCount: 1, instanceCount: 1,
name: DEFAULT_ENV, name: DEFAULT_ENV,
sdks: ['unleash-client-node:1.0.0'], backendSdks: ['unleash-client-node:1.0.0'],
frontendSdks: [],
issues: { issues: {
missingFeatures: ['toggle-name-2', 'toggle-name-3'], missingFeatures: ['toggle-name-2', 'toggle-name-3'],
outdatedSdks: ['unleash-client-node:1.0.0'], outdatedSdks: ['unleash-client-node:1.0.0'],