mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-14 06:26: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,
|
OrgId: org.Id,
|
||||||
}
|
}
|
||||||
|
|
||||||
return dao.DB().CreateUser(ctx, user)
|
return dao.DB().CreateUser(ctx, user, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// RegisterInvitedUser handles registering a invited user
|
// 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.
|
// 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 {
|
if apiErr != nil {
|
||||||
zap.S().Debugf("CreateUser failed, err: %v\n", apiErr.Err)
|
zap.S().Debugf("CreateUser failed, err: %v\n", apiErr.Err)
|
||||||
return nil, apiErr
|
return nil, apiErr
|
||||||
|
@ -37,7 +37,7 @@ type Mutations interface {
|
|||||||
CreateInviteEntry(ctx context.Context, req *model.InvitationObject) *model.ApiError
|
CreateInviteEntry(ctx context.Context, req *model.InvitationObject) *model.ApiError
|
||||||
DeleteInvitation(ctx context.Context, email string) *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)
|
EditUser(ctx context.Context, update *model.User) (*model.User, *model.ApiError)
|
||||||
DeleteUser(ctx context.Context, id string) *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,
|
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,
|
_, err := mds.db.ExecContext(ctx,
|
||||||
`INSERT INTO users (id, name, email, password, created_at, profile_picture_url, group_id, org_id)
|
`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{}{
|
data := map[string]interface{}{
|
||||||
"name": user.Name,
|
"name": user.Name,
|
||||||
"email": user.Email,
|
"email": user.Email,
|
||||||
|
"firstRegistration": false,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if isFirstUser {
|
||||||
|
data["firstRegistration"] = true
|
||||||
|
}
|
||||||
|
|
||||||
telemetry.GetInstance().IdentifyUser(user)
|
telemetry.GetInstance().IdentifyUser(user)
|
||||||
telemetry.GetInstance().SendEvent(telemetry.TELEMETRY_EVENT_USER, data)
|
telemetry.GetInstance().SendEvent(telemetry.TELEMETRY_EVENT_USER, data)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user