When `cacheFlags` is on, `identity` is not updated in localStorage cache after being updated in practice
Roeefl opened this issue · comments
Flow description:
-
Clearing localStorage to start fresh
-
My user in our web app belongs to an organization with id
281
, which results in us generating and passing anidentity
param to theflagsmith.init()
function with281
-
Everything works well and in localStorage inside
BULLET_TRAIN_DB
object, theidentity
attribute is stored with the latest value:identity: "281___Perception-Point_Test"
-
Changing my user in our back office to belong to an organization with id
76
-
Refreshing our web app
-
The
identity
variable we generate and pass toflagsmith.init()
is correct and contains the organization id76
.
Nevertheless, this is overridden by the one stored in localStorage cache, which is NOT UPDATED after the change, and stays as it was in 3 (containsidentity: "281___Perception-Point_Test"
)
The Request URL to flagsmith looks like this:
Request URL: https://api.flagsmith.com/api/v1/identities/?identifier=281___Perception-Point_Test
Why is the localStorage cache not updated ? and why is the identity overridden by the one from the cache, even though we generate it properly and pass it to flagsmith.init()
explicitly ?
This has actually apparently become a severe issue for us which we did not realize (until yesterday) what was causing.
Would appreciate you guys taking a look or explaining / pointing us to what we might be missing or doing wrong.
Thanks!
Roee
Percpetion Point
gz#197
+1
I see, yes I think you're correct. It's quite a specific use case but it sounds like if a different identity was provided prior to async storage retrieval then the stored data should be totally ignored. I'll adjust and test this case now and provide an update on findings.
Please let me know if the version resolves the issue for you, and feel free to reopen if you believe there is still an issue!
@kyle-ssg That sounds awesome. Thank you for the quick response and sorry that it took me well over a month to reply, I actually missed your answers . 💟
I'm upgrading our flagsmith package to the latest version now and checking if this issue has been resolved for us.
Much obliged good Ser.