Skip to content

Commit f16ad68

Browse files
authored
fix: refresh Flagsmith organisation traits when the selected organisation changes (#8485)
1 parent 13e8543 commit f16ad68

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

frontend/common/stores/account-store.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,16 @@ const controller = {
350350
API.setCookie('organisation', `${id}`)
351351
store.organisation = find(store.model.organisations, { id })
352352
getStore().dispatch(setSelectedOrganisationId(id))
353+
// Keep the org-scoped traits pointing at the organisation on screen, so
354+
// org-scoped segments are evaluated against it. setTraits rather than
355+
// identify: the identity is unchanged, so bucketing is undisturbed.
356+
flagsmith
357+
.setTraits({
358+
'organisation.id': String(id),
359+
'organisation.name': store.organisation?.name ?? '',
360+
'subscription.plan': store.organisation?.subscription?.plan ?? '',
361+
})
362+
.catch(() => {})
353363
store.changed()
354364
identifyChatUser()
355365
},

0 commit comments

Comments
 (0)