File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -90,22 +90,20 @@ public function add(
9090 $ log ->setAttribute ('sentry.sdk.version ' , $ client ->getSdkVersion ());
9191 }
9292
93- if ($ options ->shouldSendDefaultPii ()) {
94- $ hub ->configureScope (static function (Scope $ scope ) use ($ log ) {
95- $ user = $ scope ->getUser ();
96- if ($ user !== null ) {
97- if ($ user ->getId () !== null ) {
98- $ log ->setAttribute ('user.id ' , $ user ->getId ());
99- }
100- if ($ user ->getEmail () !== null ) {
101- $ log ->setAttribute ('user.email ' , $ user ->getEmail ());
102- }
103- if ($ user ->getUsername () !== null ) {
104- $ log ->setAttribute ('user.name ' , $ user ->getUsername ());
105- }
93+ $ hub ->configureScope (static function (Scope $ scope ) use ($ log ) {
94+ $ user = $ scope ->getUser ();
95+ if ($ user !== null ) {
96+ if ($ user ->getId () !== null ) {
97+ $ log ->setAttribute ('user.id ' , $ user ->getId ());
10698 }
107- });
108- }
99+ if ($ user ->getEmail () !== null ) {
100+ $ log ->setAttribute ('user.email ' , $ user ->getEmail ());
101+ }
102+ if ($ user ->getUsername () !== null ) {
103+ $ log ->setAttribute ('user.name ' , $ user ->getUsername ());
104+ }
105+ }
106+ });
109107
110108 if (\count ($ values )) {
111109 $ log ->setAttribute ('sentry.message.template ' , $ message );
Original file line number Diff line number Diff line change @@ -81,22 +81,20 @@ public function add(
8181 $ defaultAttributes ['sentry.sdk.version ' ] = $ client ->getSdkVersion ();
8282 }
8383
84- if ($ options ->shouldSendDefaultPii ()) {
85- $ hub ->configureScope (static function (Scope $ scope ) use (&$ defaultAttributes ) {
86- $ user = $ scope ->getUser ();
87- if ($ user !== null ) {
88- if ($ user ->getId () !== null ) {
89- $ defaultAttributes ['user.id ' ] = $ user ->getId ();
90- }
91- if ($ user ->getEmail () !== null ) {
92- $ defaultAttributes ['user.email ' ] = $ user ->getEmail ();
93- }
94- if ($ user ->getUsername () !== null ) {
95- $ defaultAttributes ['user.name ' ] = $ user ->getUsername ();
96- }
84+ $ hub ->configureScope (static function (Scope $ scope ) use (&$ defaultAttributes ) {
85+ $ user = $ scope ->getUser ();
86+ if ($ user !== null ) {
87+ if ($ user ->getId () !== null ) {
88+ $ defaultAttributes ['user.id ' ] = $ user ->getId ();
9789 }
98- });
99- }
90+ if ($ user ->getEmail () !== null ) {
91+ $ defaultAttributes ['user.email ' ] = $ user ->getEmail ();
92+ }
93+ if ($ user ->getUsername () !== null ) {
94+ $ defaultAttributes ['user.name ' ] = $ user ->getUsername ();
95+ }
96+ }
97+ });
10098
10199 $ release = $ options ->getRelease ();
102100 if ($ release !== null ) {
Original file line number Diff line number Diff line change @@ -211,7 +211,7 @@ public function testAttributesAreAddedToLogMessage(): void
211211 $ this ->assertSame ('my_user ' , $ attributes ->get ('user.name ' )->getValue ());
212212 }
213213
214- public function testUserAttributesAreNotAddedToLogMessageWhenSendDefaultPiiIsDisabled (): void
214+ public function testUserAttributesCanBeSetManuallyWithDefaultPiiOff (): void
215215 {
216216 $ client = ClientBuilder::create ([
217217 'enable_logs ' => true ,
@@ -237,9 +237,9 @@ public function testUserAttributesAreNotAddedToLogMessageWhenSendDefaultPiiIsDis
237237
238238 $ attributes = $ logs [0 ]->attributes ();
239239
240- $ this ->assertNull ( $ attributes ->get ('user.id ' ));
241- $ this ->assertNull ( $ attributes ->get ('user.email ' ));
242- $ this ->assertNull ( $ attributes ->get ('user.name ' ));
240+ $ this ->assertSame ( ' unique_id ' , $ attributes ->get ('user.id ' )-> getValue ( ));
241+ $ this ->assertSame ( ' foo@example.com ' , $ attributes ->get ('user.email ' )-> getValue ( ));
242+ $ this ->assertSame ( ' my_user ' , $ attributes ->get ('user.name ' )-> getValue ( ));
243243 }
244244
245245 public function testFlushesImmediatelyWhenThresholdIsReached (): void
You can’t perform that action at this time.
0 commit comments