Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: collect org name for identifier (#2231)
ecmadao411aaa78459f
diff --git a/.github/workflows/sql-review.yml b/.github/workflows/sql-review.ymlindex 9cb48d7ed5..e0c8d07cfe 100644--- a/.github/workflows/sql-review.yml+++ b/.github/workflows/sql-review.yml@@ -7,7 +7,7 @@ jobs:steps:- uses: actions/checkout@v3- name: Check SQL- uses: bytebase/[email protected]+ uses: bytebase/[email protected]with:override-file-path: ./sql-review-override.ymldatabase-type: POSTGRESdiff --git a/enterprise/api/license.go b/enterprise/api/license.goindex 1eeb5fb7f3..56c9a7978a 100644--- a/enterprise/api/license.go+++ b/enterprise/api/license.go@@ -22,6 +22,7 @@ type License struct {IssuedTs int64Plan api.PlanTypeTrialing bool+ OrgName string}// Valid will check if license expired or has correct plan type.diff --git a/enterprise/api/subscription.go b/enterprise/api/subscription.goindex 9ae142c888..c931738607 100644--- a/enterprise/api/subscription.go+++ b/enterprise/api/subscription.go@@ -16,4 +16,5 @@ type Subscription struct {Plan api.PlanType `jsonapi:"attr,plan"`Trialing bool `jsonapi:"attr,trialing"`OrgID string `jsonapi:"attr,orgId"`+ OrgName string `jsonapi:"attr,orgName"`}diff --git a/enterprise/service/license.go b/enterprise/service/license.goindex dfe3eeb8b2..0f9978a7df 100644--- a/enterprise/service/license.go+++ b/enterprise/service/license.go@@ -25,6 +25,7 @@ type Claims struct {InstanceCount int `json:"instanceCount"`Trialing bool `json:"trialing"`Plan string `json:"plan"`+ OrgName string `json:"orgName"`jwt.RegisteredClaims}@@ -128,6 +129,7 @@ func (s *LicenseService) parseClaims(claims *Claims) (*enterpriseAPI.License, erPlan: planType,Subject: claims.Subject,Trialing: claims.Trialing,+ OrgName: claims.OrgName,}if err := license.Valid(); err != nil {diff --git a/plugin/metric/metric.go b/plugin/metric/metric.goindex d1c5dfc40a..22b4e0b9d1 100644--- a/plugin/metric/metric.go+++ b/plugin/metric/metric.go@@ -14,5 +14,6 @@ type Metric struct {type Identifier struct {ID stringEmail string+ Name stringLabels map[string]string}diff --git a/plugin/metric/segment/reporter.go b/plugin/metric/segment/reporter.goindex fb88e22d26..a933a7eee2 100644--- a/plugin/metric/segment/reporter.go+++ b/plugin/metric/segment/reporter.go@@ -57,6 +57,7 @@ func (r *reporter) Report(metric *metric.Metric) error {func (r *reporter) Identify(identifier *metric.Identifier) error {traits := analytics.NewTraits()traits.SetEmail(identifier.Email)+ traits.SetName(identifier.Name)for key, value := range identifier.Labels {traits.Set(key, value)}diff --git a/server/metric_reporter.go b/server/metric_reporter.goindex 3dc7c10358..da7ce0a2e5 100644--- a/server/metric_reporter.go+++ b/server/metric_reporter.go@@ -118,10 +118,12 @@ func (m *MetricReporter) Register(metricName metric.Name, collector metric.Collefunc (m *MetricReporter) identify(ctx context.Context) {plan := api.FREE.String()orgID := ""+ orgName := ""if m.subscription != nil {plan = m.subscription.Plan.String()orgID = m.subscription.OrgID+ orgName = m.subscription.OrgName}principal, err := m.store.GetPrincipalByID(ctx, principalIDForFirstUser)@@ -136,6 +138,7 @@ func (m *MetricReporter) identify(ctx context.Context) {if err := m.reporter.Identify(&metric.Identifier{ID: m.workspaceID,Email: email,+ Name: orgName,Labels: map[string]string{identifyTraitForPlan: plan,identifyTraitForVersion: m.version,diff --git a/server/subscription.go b/server/subscription.goindex 3c1ccb8353..aaa603569a 100644--- a/server/subscription.go+++ b/server/subscription.go@@ -65,6 +65,7 @@ func (s *Server) loadSubscription() enterpriseAPI.Subscription {InstanceCount: license.InstanceCount,Trialing: license.Trialing,OrgID: license.OrgID(),+ OrgName: license.OrgName,}}