flagsmith icon indicating copy to clipboard operation
flagsmith copied to clipboard

Segment rules should be able to operate on Identity IDs

Open dabeeeenster opened this issue 4 years ago • 3 comments
trafficstars

Currently segment rule definitions can only be run against Identity traits. Users often expect the rules to operate on Identity ids as well.

We should introduce a reserved trait name, suggest id, which evaluates to the Identity unique identifier when the rules are being evaluated.

Technical Implementation

We can add the id transiently to the segment list with a special name e.g. id or similar before processing the rules.

Issues

It would mean that SDKs could not set a trait with id which would be a breaking change. What would happen to existing traits that have an ID set? Suggest that if they do, this overrides the coercion of the id.

dabeeeenster avatar Jun 18 '21 08:06 dabeeeenster

We should have a special prefix for internal traits like this, one thing that was originally planned was automated traits such as device, browser. Doing so would also allow for this.

e.g $FS_id, $FS_browser

kyle-ssg avatar Jun 18 '21 09:06 kyle-ssg

We should also consider adding date / time based values like: $FS_currentday, $FS_currenthour, $FS_currentminute. This would allow people to use segment overrides to create recurring schedules for their flags.

matthewelwell avatar Jun 22 '23 12:06 matthewelwell

This has been implemented in https://github.com/Flagsmith/flagsmith-engine/pull/198 with the '$_' prefix for external values.

Now that I think of it, I'm in favour of adopting OpenAPI's reference syntax for local references, e.g.:

  • #/identity/identifier
  • #/event/datetime
  • #/contexts/company/address/postalCode

khvn26 avatar Apr 22 '24 15:04 khvn26