Skip to content

Commit

Permalink
fix: [sc-9938] move to sha256 in user (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
noamApps authored Jul 24, 2023
1 parent 9f24352 commit 0d7699e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/segment/user.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package segment

import (
"crypto/sha256"
"fmt"

"github.com/segmentio/analytics-go/v3"
Expand All @@ -13,17 +14,17 @@ var userId string
func NewUser(email string, org string) error {
var err error

SetUser(email)
SetUser(userId)

user := analytics.Identify{
UserId: email,
UserId: userId,
Traits: analytics.NewTraits().SetEmail(email).Set(ORG_TRAIT_NAME, org),
}

tenantUniqueId := fmt.Sprintf("%s@%s", org, org)
orgGroup := analytics.Group{
GroupId: tenantUniqueId,
UserId: user.UserId,
UserId: userId,
Traits: analytics.NewTraits().SetEmail(email).SetName(tenantUniqueId),
}

Expand All @@ -39,5 +40,5 @@ func NewUser(email string, org string) error {
}

func SetUser(email string) {
userId = email
userId = fmt.Sprintf("%x", sha256.Sum256([]byte(email)))
}

0 comments on commit 0d7699e

Please sign in to comment.