mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-13 06:59:03 +08:00
chore: detect first registration
This commit is contained in:
parent
d5bd991417
commit
88af456915
@ -259,7 +259,7 @@ func RegisterFirstUser(ctx context.Context, req *RegisterRequest) (*model.User,
|
||||
OrgId: org.Id,
|
||||
}
|
||||
|
||||
return dao.DB().CreateUser(ctx, user)
|
||||
return dao.DB().CreateUser(ctx, user, true)
|
||||
}
|
||||
|
||||
// RegisterInvitedUser handles registering a invited user
|
||||
@ -338,7 +338,7 @@ func RegisterInvitedUser(ctx context.Context, req *RegisterRequest, nopassword b
|
||||
}
|
||||
|
||||
// TODO(Ahsan): Ideally create user and delete invitation should happen in a txn.
|
||||
user, apiErr = dao.DB().CreateUser(ctx, user)
|
||||
user, apiErr = dao.DB().CreateUser(ctx, user, false)
|
||||
if apiErr != nil {
|
||||
zap.S().Debugf("CreateUser failed, err: %v\n", apiErr.Err)
|
||||
return nil, apiErr
|
||||
|
@ -37,7 +37,7 @@ type Mutations interface {
|
||||
CreateInviteEntry(ctx context.Context, req *model.InvitationObject) *model.ApiError
|
||||
DeleteInvitation(ctx context.Context, email string) *model.ApiError
|
||||
|
||||
CreateUser(ctx context.Context, user *model.User) (*model.User, *model.ApiError)
|
||||
CreateUser(ctx context.Context, user *model.User, isFirstUser bool) (*model.User, *model.ApiError)
|
||||
EditUser(ctx context.Context, update *model.User) (*model.User, *model.ApiError)
|
||||
DeleteUser(ctx context.Context, id string) *model.ApiError
|
||||
|
||||
|
@ -176,7 +176,7 @@ func (mds *ModelDaoSqlite) DeleteOrg(ctx context.Context, id string) *model.ApiE
|
||||
}
|
||||
|
||||
func (mds *ModelDaoSqlite) CreateUser(ctx context.Context,
|
||||
user *model.User) (*model.User, *model.ApiError) {
|
||||
user *model.User, isFirstUser bool) (*model.User, *model.ApiError) {
|
||||
|
||||
_, err := mds.db.ExecContext(ctx,
|
||||
`INSERT INTO users (id, name, email, password, created_at, profile_picture_url, group_id, org_id)
|
||||
@ -190,9 +190,15 @@ func (mds *ModelDaoSqlite) CreateUser(ctx context.Context,
|
||||
}
|
||||
|
||||
data := map[string]interface{}{
|
||||
"name": user.Name,
|
||||
"email": user.Email,
|
||||
"name": user.Name,
|
||||
"email": user.Email,
|
||||
"firstRegistration": false,
|
||||
}
|
||||
|
||||
if isFirstUser {
|
||||
data["firstRegistration"] = true
|
||||
}
|
||||
|
||||
telemetry.GetInstance().IdentifyUser(user)
|
||||
telemetry.GetInstance().SendEvent(telemetry.TELEMETRY_EVENT_USER, data)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user