Skip to content

FFL-2510: Add tests for allocationKey in OpenFeature flagMetadata#1303

Open
typotter wants to merge 5 commits into
developfrom
typo/thread-allocation-key-to-flag-details-metadata
Open

FFL-2510: Add tests for allocationKey in OpenFeature flagMetadata#1303
typotter wants to merge 5 commits into
developfrom
typo/thread-allocation-key-to-flag-details-metadata

Conversation

@typotter

@typotter typotter commented Jun 11, 2026

Copy link
Copy Markdown

What does this PR do?

Adds test coverage for allocationKey surfacing in OpenFeature flagMetadata. The threading itself (toFlagResolution setting flagMetadata: allocationKey ? { allocationKey } : undefined) was already present in main. This PR verifies the behavior with tests.

Motivation

FFL-2510 — ensures allocationKey threading is covered by tests, consistent with Android and iOS.

Additional Notes

  • packages/react-native-openfeature/src/__tests__/provider.test.ts: tests allocationKey present in flagMetadata and absent (null) when not set
  • packages/react-native-openfeature/__mocks__/react-native.ts: mock module needed by the new test suite
  • packages/core/src/flags/__tests__/FlagsClient.test.ts: coverage for allocationKey in FlagDetails
  • packages/react-native-openfeature/src/provider.ts: import cleanup (PrimitiveValue moved to correct source)

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)
  • If this PR is auto-generated, please make sure also to manually update the code related to the change

…tadata

- Add extraLogging field to FlagDetails<T> typed as Record<string, PrimitiveValue>
- Add buildExtraLogging helper in FlagsClient that filters to primitives and drops allocationKey key
- Populate extraLogging in getDetails from flag cache entry
- Update toFlagResolution in provider.ts to spread extraLogging into flagMetadata, with allocationKey winning on collision
- Add __mocks__/react-native.ts to openfeature package for test infrastructure
- Add provider.test.ts covering extraLogging threading and allocationKey collision semantics
Copilot AI review requested due to automatic review settings June 11, 2026 22:05
@typotter typotter requested review from a team as code owners June 11, 2026 22:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

…ation

- Fix prettier formatting on multi-line import in FlagsClient.ts
- Add curly braces to if/continue statements in buildExtraLogging (curly rule)
- Fix import ordering and remove blank line between same-section imports in provider.test.ts (arca rules)
- Narrow flagMetadata type to Record<string, string | number | boolean> in provider.ts to match OpenFeature FlagMetadata; filter null values when building flagMetadata
@typotter typotter changed the base branch from main to develop June 12, 2026 04:35
@typotter typotter requested a review from Copilot June 12, 2026 04:56

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Comment on lines +171 to +188
// Build flagMetadata: extraLogging primitives first, allocationKey last (wins on collision).
// OpenFeature FlagMetadata does not support null values, so null entries are omitted.
let flagMetadata: Record<string, string | number | boolean> | undefined;
const hasExtraLogging =
extraLogging && Object.keys(extraLogging).length > 0;
if (allocationKey || hasExtraLogging) {
flagMetadata = {};
if (extraLogging) {
for (const [k, v] of Object.entries(extraLogging)) {
if (v !== null) {
flagMetadata[k] = v;
}
}
}
if (allocationKey) {
flagMetadata.allocationKey = allocationKey;
}
}
@evazorro evazorro removed the request for review from a team June 12, 2026 16:24
@evazorro

Copy link
Copy Markdown

It looks like this PR didn't actually touch any docs files, so I've dismissed documentation as a reviewer. Let me know if I missed something, though!

typotter added 2 commits June 15, 2026 08:51
hasExtraLogging now checks for at least one non-null value rather than
any key at all, so extraLogging with only null entries no longer
produces an empty {} flagMetadata when allocationKey is absent.
Only allocationKey is surfaced in flagMetadata; extraLogging is no
longer built or stored on FlagDetails. Remove buildExtraLogging(),
FlagDetails.extraLogging, and related provider logic and tests.
Copilot AI review requested due to automatic review settings June 18, 2026 20:14
@typotter typotter closed this Jun 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread packages/react-native-openfeature/src/provider.ts
Comment thread packages/react-native-openfeature/src/__tests__/provider.test.ts
@typotter typotter reopened this Jun 18, 2026
@sbarrio sbarrio requested review from marco-saia-datadog and removed request for marco-saia-datadog June 19, 2026 10:45
@typotter typotter changed the title FFL-2510: Thread extraLogging into FlagDetails and OpenFeature flagMetadata FFL-2510: Thread allocationKey into FlagDetails and OpenFeature flagMetadata Jun 19, 2026

@leoromanovsky leoromanovsky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description doesn't match what's in the diff; it appears as though only tests are being added here?

@sbarrio

sbarrio commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

The PR description doesn't match what's in the diff; it appears as though only tests are being added here?

Apart from this, the description does not follow the PR template set on the repository, could you please modify it?

@typotter typotter changed the title FFL-2510: Thread allocationKey into FlagDetails and OpenFeature flagMetadata FFL-2510: Add tests for allocationKey in OpenFeature flagMetadata Jul 6, 2026
@typotter

typotter commented Jul 6, 2026

Copy link
Copy Markdown
Author

my bad. we're just adding tests here now, pr updated

@typotter typotter requested a review from leoromanovsky July 6, 2026 17:14

@leoromanovsky leoromanovsky left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice structuring of test cases

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants