Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional user_context #55

Merged
merged 2 commits into from
Feb 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/Sentry/SentryLaravel/SentryLaravelServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,16 +86,18 @@ public function register()
'app_path' => app_path(),
), $user_config));

// bind user context if available
try {
if ($app['auth']->check()) {
$user = $app['auth']->user();
$client->user_context(array(
'id' => $user->getAuthIdentifier(),
));
if($user_config['breadcrumbs.user_context']) {
Copy link
Member

@dcramer dcramer Feb 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we wouldnt want to call this breadcrumbs, but not sure if 'user_context' is descriptive enough.

maybe user_context.auto = True/False?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works for me. If you'd like I can write up a little blurb on this feature.

// bind user context if available
try {
if ($app['auth']->check()) {
$user = $app['auth']->user();
$client->user_context(array(
'id' => $user->getAuthIdentifier(),
));
}
} catch (\Exception $e) {
error_log(sprintf('sentry.breadcrumbs error=%s', $e->getMessage()));
}
} catch (\Exception $e) {
error_log(sprintf('sentry.breadcrumbs error=%s', $e->getMessage()));
}

return $client;
Expand Down
3 changes: 3 additions & 0 deletions src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@

// capture release as git sha
// 'release' => trim(exec('git --git-dir ' . base_path('.git') . ' log --pretty="%h" -n1 HEAD')),

// capture user context for breadcrumbs
'breadcrumbs.user_context' => true,
);