Skip to content

Commit 3e818dd

Browse files
committed
feat(event): Allow multitenancy via tenant id
Signed-off-by: Loïc Saint-Roch <[email protected]>
1 parent 1ae4a46 commit 3e818dd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

event/event.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type Event struct {
3636
IsAnonymous bool `json:"is_anonymous"`
3737
UserID string `json:"user_id,omitempty"`
3838
GroupID string `json:"group_id,omitempty"`
39+
TenantID string `json:"tenant_id,omitempty"`
3940
IP net.IP `json:"ip,omitempty"`
4041
UserAgent string `json:"user_agent,omitempty"`
4142
Locale string `json:"locale,omitempty"`
@@ -85,6 +86,7 @@ func injectEventToFlatMap(e Event, flatten map[string]string) {
8586
flatten["event.is_anonymous"] = strconv.FormatBool(e.IsAnonymous)
8687
flatten["event.user_id"] = e.UserID
8788
flatten["event.group_id"] = e.GroupID
89+
flatten["event.tenant_id"] = e.TenantID
8890
flatten["event.ip"] = e.IP.String()
8991
flatten["event.user_agent"] = e.UserAgent
9092
flatten["event.locale"] = e.Locale
@@ -158,6 +160,8 @@ func extractEventFromBaggage(b baggage.Baggage) Event {
158160
e.UserID = b.Member("event.user_id").Value()
159161
case "group_id":
160162
e.GroupID = b.Member("event.group_id").Value()
163+
case "tenant_id":
164+
e.TenantID = b.Member("event.tenant_id").Value()
161165
case "ip":
162166
e.IP = net.ParseIP(b.Member("event.ip").Value())
163167
case "user_agent":

0 commit comments

Comments
 (0)