[sdk/local-evaluation] getEnvironmentFlags() evaluations are not tracked for analytics
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- Menos de una hora
- Aptitud para principiantes
- 85/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- nodejs, typescript
- Área
- analytics
Línea de trabajo
La incidencia apunta a getEnvironmentFlagsFromDocument en sdk/index.ts alrededor de la línea 640, donde se llama a Flags.fromEvaluationResult sin el procesador de analítica. Compáralo con getIdentityFlagsFromDocument cerca de la línea 669, que ya pasa this.analyticsProcessor. Ejecuta el script de reproducción de la incidencia: está terminado cuando la ejecución local muestra {"my_feature":5}, igual que la remota.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Problem
With enableLocalEvaluation: true, flag evaluations from getEnvironmentFlags() are never counted towards analytics. The same code against the same environment reports usage correctly when local evaluation is off, so flag analytics are effectively unavailable to anyone evaluating locally.
The cause looks like a missed argument in getEnvironmentFlagsFromDocument:
// sdk/index.ts:640
const flags = Flags.fromEvaluationResult(evaluationResult);
The other three evaluation paths all pass the processor through:
getIdentityFlagsFromDocument(local) ->sdk/index.ts:669, passesthis.analyticsProcessorgetEnvironmentFlagsFromApi(remote) ->sdk/index.ts:689getIdentityFlagsFromApi(remote) ->sdk/index.ts:710
Since the other local path already tracks, this doesn't look like a deliberate decision to skip analytics during local evaluation.
For what it's worth, the Python client passes it in the equivalent method, so the two SDKs behave differently here:
# flagsmith/flagsmith.py:535, _get_environment_flags_from_document
return Flags.from_evaluation_result(
evaluation_result=evaluation_result,
analytics_processor=self._analytics_processor,
default_flag_handler=self.default_flag_handler,
)
Impact
getEnvironmentFlags() is the common path for server-side usage, and local evaluation is the recommended mode there, so this combination silently reports no usage at all. Nothing warns or errors, and the dashboard just shows the flag as unused. We ran into it while using analytics to decide which stale flags were safe to delete, where a flag wrongly showing zero evaluations is the dangerous direction to be wrong in.
Reproduction
Standalone script, no account needed; it stubs the API locally and compares the two modes.
const http = require('node:http');
const { Flagsmith } = require('flagsmith-nodejs');
const ENV_DOC = {
api_key: 'ser.repro',
project: { id: 1, name: 'repro', organisation: { id: 1, name: 'org', feature_analytics: true,
stop_serving_flags: false, persist_trait_data: true }, hide_disabled_flags: false, segments: [] },
feature_states: [{ feature: { id: 1, name: 'my_feature', type: 'STANDARD' },
enabled: true, feature_state_value: null, featurestate_uuid: 'fs-1', multivariate_feature_state_values: [] }],
identity_overrides: []
};
const API_FLAGS = [{ feature: { id: 1, name: 'my_feature', type: 'STANDARD' },
enabled: true, feature_state_value: null }];
(async () => {
const server = http.createServer((req, res) => {
res.writeHead(200, { 'Content-Type': 'application/json' });
if (req.url.includes('environment-document')) return res.end(JSON.stringify(ENV_DOC));
if (req.url.includes('/flags')) return res.end(JSON.stringify(API_FLAGS));
res.end('{}');
});
await new Promise(r => server.listen(0, '127.0.0.1', r));
const apiUrl = `http://127.0.0.1:${server.address().port}/api/v1/`;
async function run(local) {
const f = new Flagsmith({ environmentKey: 'ser.repro', apiUrl,
enableLocalEvaluation: local, enableAnalytics: true });
const flags = await f.getEnvironmentFlags();
for (let i = 0; i < 5; i++) await flags.isFeatureEnabled('my_feature');
const buf = { ...(f.analyticsProcessor?.analyticsData ?? {}) };
f.environmentDataPollingManager?.stop();
console.log(`${local ? 'LOCAL ' : 'REMOTE'} -> buffer ${JSON.stringify(buf)}`);
}
await run(true);
await run(false);
server.close();
})();
Observed:
LOCAL -> buffer {}
REMOTE -> buffer {"my_feature":5}
Expected: both report {"my_feature":5}.
Version: [email protected] (current npm latest), Node 24.13.0. Line numbers above are from main as of today, which still has the same call.
Workaround
Calling trackFeature(name) on the processor after each evaluation restores the counts, which is what we're doing for now.
- Lenguaje dominante
- TypeScript
- Estrellas
- 30
- Forks
- 29
- Merge medio
- 7 d 23 h
- PR fusionados (30 d)
- 3
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Flagsmith/flagsmith-nodejs-client
-
Dificultad 4/5 3-5 días Aptitud para principiantes 65/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
-
Dependency DashboardAbierto
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 55/100
Flagsmith/flagsmith-nodejs-client#273 · 1 comentario ·
-
[sdk/local-evaluation] Duplicate identity override entries silently drop feature overridesPosiblemente ocupada @xolott-ark la tomó hace 159 días. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
Flagsmith/flagsmith-nodejs-client#267 · 5 comentarios ·
Todos los issues de Flagsmith/flagsmith-nodejs-client
Issues similares
-
e2e-failure ready-to-code
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
redhat-developer/rhdh-plugin-export-overlays#4391 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
Luligu/matterbridge#655 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
software-mansion/argent#1457 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
schmayterling/hibi#245 ·
Los mantenedores suelen responder en 1 día
-
After a failed save, the red error banner stays on every page until the app is reloadedPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertoai-driven-qa bug claude Minor
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
linagora/twake-contacts-frontend#241 ·
Los mantenedores suelen responder en 1 día