Skip to content

feat(feature-flags): support non-boolean flag values (string, integer, float) per SDK spec #21157

@Ardmort

Description

@Ardmort

Summary

The SDK integration spec states that add_feature_flag should accept:

"a value which is a union of string, boolean, integer, float, and structure."

However, the current JS SDK implementation silently drops any non-boolean value as a no-op.

Relevant code

In packages/core/src/utils/featureFlags.ts:

// _INTERNAL_insertToFlagBuffer
if (typeof value !== 'boolean') {
  return; // silently ignored
}

// _INTERNAL_addFeatureFlagToActiveSpan
if (typeof value !== 'boolean') {
  return; // silently ignored
}

The FeatureFlag type also restricts result to boolean:

export type FeatureFlag = { readonly flag: string; readonly result: boolean };

The conflict

The event payload contexts spec defines the result field as boolean only:

"The boolean result of flag evaluation."

This contradicts the SDK integration spec which allows a broader union type. It seems the JS SDK was intentionally restricted to match the narrower wire protocol definition.

Ask

  1. Is the result: boolean constraint in the contexts spec intentional/permanent, or is broadening it to string | boolean | integer | float planned?
  2. Would a PR to the JS SDK (and the spec docs if needed) be welcome once the protocol question is resolved?

Use case

Many feature flag providers (e.g. Rollout/rox-ssr, LaunchDarkly, Statsig) support string variant flags (e.g. "control", "variant-a", "variant-b"). Currently there is no way to send these to Sentry via the feature flags integration — setContext is the only workaround, which bypasses the structured flags UI entirely.

Metadata

Metadata

Assignees

No one assigned
    No fields configured for issues without a type.

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions