Skip to content

Commit 294912f

Browse files
committed
Nest all user info but particular keys in 'data'
Sentry treats 'id', 'username', 'email', and 'ip_address' specially, displaying only these. It displays other keys only if they're within a 'data' substructure. See the relevant Sentry source at https://github.com/getsentry/sentry/blob/e7a295784f10a296ace7aa98e1b7216328feac5d/src/sentry/interfaces/user.py#L31
1 parent fe19797 commit 294912f

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Processors/UserDataProcessor.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,19 @@ public function __invoke(array $record)
7777
}
7878
}
7979

80-
$record['context']['user'] = array_merge($data, array_get($record, 'context.user', []));
80+
// Nest all but the particular keys Sentry treats specially in a 'data'
81+
// substructure; see
82+
// https://github.com/getsentry/sentry/blob/e7a295784f10a296ace7aa98e1b7216328feac5d/src/sentry/interfaces/user.py#L31
83+
$topLevel = [
84+
'id',
85+
'username',
86+
'email',
87+
'ip_address',
88+
];
89+
$userArray = array_only($data, $topLevel);
90+
$userArray['data'] = array_except($data, $topLevel);
91+
92+
$record['context']['user'] = array_merge($userArray, array_get($record, 'context.user', []));
8193

8294
return $record;
8395
}

0 commit comments

Comments
 (0)