mirror of
https://github.com/Unleash/unleash.git
synced 2025-05-12 01:17:04 +02:00
fix: missing events in the event store (#4335)
## About the changes We are losing some events because of not having "created by" which is required by a constraint in the DB. One scenario where this can happen is with the default user admin, because it doesn't have a username or an email (unless configured by the administrator). Our code makes assumptions on the existence of one of these 2 attributes (e.g.248118af7c/src/lib/services/user-service.ts (L220-L222)
). Event lost metrics:  ## Discussion points The solution proposed here is falling back to a default value. I've chosen `"admin"` because it covers one of the use cases, but it can also be `"system"` mimicking248118af7c/src/lib/services/user-service.ts (L32)
which is used as a default, or `"unknown"` which is sometimes used as a default:248118af7c/src/lib/services/project-service.ts (L57)
Anyway, I believe it's better not to lose the event rather than be accurate with the "created by" that can be fixed later
This commit is contained in:
parent
5de4958b0f
commit
ed5a7960a5
@ -371,7 +371,7 @@ class EventStore implements IEventStore {
|
||||
eventToDbRow(e: IBaseEvent): Omit<IEventTable, 'id' | 'created_at'> {
|
||||
return {
|
||||
type: e.type,
|
||||
created_by: e.createdBy,
|
||||
created_by: e.createdBy ?? 'admin',
|
||||
data: Array.isArray(e.data) ? JSON.stringify(e.data) : e.data,
|
||||
pre_data: Array.isArray(e.preData)
|
||||
? JSON.stringify(e.preData)
|
||||
|
Loading…
Reference in New Issue
Block a user