diff --git a/src/lib/__snapshots__/create-config.test.ts.snap b/src/lib/__snapshots__/create-config.test.ts.snap index bb1a454e1b..f845bd03b6 100644 --- a/src/lib/__snapshots__/create-config.test.ts.snap +++ b/src/lib/__snapshots__/create-config.test.ts.snap @@ -81,6 +81,7 @@ exports[`should create default config 1`] = ` "celebrateUnleash": false, "collectTrafficDataUsage": false, "createProjectWithEnvironmentConfig": false, + "debugMetrics": false, "demo": false, "disableBulkToggle": false, "disableMetrics": false, diff --git a/src/lib/features/metrics/client-metrics/metrics-service-v2.ts b/src/lib/features/metrics/client-metrics/metrics-service-v2.ts index 3365398ad9..af3d4f17d1 100644 --- a/src/lib/features/metrics/client-metrics/metrics-service-v2.ts +++ b/src/lib/features/metrics/client-metrics/metrics-service-v2.ts @@ -137,6 +137,10 @@ export default class ClientMetricsServiceV2 { data: ClientMetricsSchema, clientIp: string, ): Promise { + if (this.flagResolver.isEnabled('debugMetrics')) { + this.logger.debug(`Metrics received: ${JSON.stringify(data)}`); + } + const value = await clientMetricsSchema.validateAsync(data); const toggleNames = Object.keys(value.bucket.toggles).filter( (name) => diff --git a/src/lib/types/experimental.ts b/src/lib/types/experimental.ts index 6163b3071f..b32105dccc 100644 --- a/src/lib/types/experimental.ts +++ b/src/lib/types/experimental.ts @@ -62,7 +62,8 @@ export type IFlagKey = | 'createProjectWithEnvironmentConfig' | 'manyStrategiesPagination' | 'newCreateProjectUI' - | 'enableLegacyVariants'; + | 'enableLegacyVariants' + | 'debugMetrics'; export type IFlags = Partial<{ [key in IFlagKey]: boolean | Variant }>; @@ -299,6 +300,10 @@ const flags: IFlags = { process.env.UNLEASH_EXPERIMENTAL_ENABLE_LEGACY_VARIANTS, false, ), + debugMetrics: parseEnvVarBoolean( + process.env.UNLEASH_EXPERIMENTAL_DEBUG_METRICS, + false, + ), }; export const defaultExperimentalOptions: IExperimentalOptions = {