mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 15:51:43 +00:00
[logging] Only record events if a new user was created (#64004)
This commit is contained in:
parent
a7f787a772
commit
777c7a0899
@ -261,9 +261,8 @@ func GetAndSaveUser(
|
||||
// closure, to ensure we cover all exit paths correctly after the other mega
|
||||
// closure above.
|
||||
//
|
||||
// We only store the event if a new user was created, or if a new external
|
||||
// account was added to an existing user.
|
||||
if newUserSaved || extAcctSaved {
|
||||
// We only store the event if a new user was created.
|
||||
if newUserSaved {
|
||||
defer func() {
|
||||
action := telemetry.ActionSucceeded
|
||||
if err != nil { // check final error
|
||||
@ -288,7 +287,6 @@ func GetAndSaveUser(
|
||||
telemetry.EventMetadata{
|
||||
"serviceVariant": telemetry.Number(serviceVariant),
|
||||
// Track the various outcomes of the massive signup closure above.
|
||||
"newUserSaved": telemetry.Bool(newUserSaved),
|
||||
"extAcctSaved": telemetry.Bool(extAcctSaved),
|
||||
},
|
||||
op.UserCreateEventProperties,
|
||||
|
||||
@ -43,7 +43,6 @@ func TestGetAndSaveUser(t *testing.T) {
|
||||
expSafeErr string
|
||||
expErr error
|
||||
expNewUserCreated bool
|
||||
expExtAcctSaved bool
|
||||
|
||||
// expected side effects
|
||||
expSavedExtAccts map[int32][]extsvc.AccountSpec
|
||||
@ -123,7 +122,6 @@ func TestGetAndSaveUser(t *testing.T) {
|
||||
1: {ext("st1", "s1", "c1", "s1/u1")},
|
||||
},
|
||||
expNewUserCreated: false,
|
||||
expExtAcctSaved: true,
|
||||
},
|
||||
{
|
||||
description: "ext acct exists, username and email don't exist",
|
||||
@ -139,7 +137,6 @@ func TestGetAndSaveUser(t *testing.T) {
|
||||
1: {ext("st1", "s1", "c1", "s1/u1")},
|
||||
},
|
||||
expNewUserCreated: false,
|
||||
expExtAcctSaved: true,
|
||||
},
|
||||
{
|
||||
description: "ext acct exists, email belongs to another user",
|
||||
@ -155,7 +152,6 @@ func TestGetAndSaveUser(t *testing.T) {
|
||||
1: {ext("st1", "s1", "c1", "s1/u1")},
|
||||
},
|
||||
expNewUserCreated: false,
|
||||
expExtAcctSaved: true,
|
||||
},
|
||||
{
|
||||
description: "ext acct doesn't exist, user with username and email exists",
|
||||
@ -513,7 +509,7 @@ func TestGetAndSaveUser(t *testing.T) {
|
||||
// of user) attached, and all code paths should generate
|
||||
// at least 1 user event if a new user was created.
|
||||
gotEvents := eventsStore.CollectStoredEvents()
|
||||
if c.expNewUserCreated || c.expExtAcctSaved {
|
||||
if c.expNewUserCreated {
|
||||
assert.NotEmpty(t, gotEvents)
|
||||
} else {
|
||||
assert.Empty(t, gotEvents)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user