Skip to content

Can set user context via config (fixes #741) #762

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

Merged
merged 1 commit into from
Nov 11, 2016
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
2 changes: 1 addition & 1 deletion src/raven.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Raven.prototype = {
if (options) {
each(options, function(key, value){
// tags and extra are special and need to be put into context
if (key === 'tags' || key === 'extra') {
if (key === 'tags' || key === 'extra' || key === 'user') {
self._globalContext[key] = value;
} else {
globalOptions[key] = value;
Expand Down
14 changes: 14 additions & 0 deletions test/raven.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1535,6 +1535,20 @@ describe('Raven (public API)', function() {
assert.isTrue(Raven._logDebug.called);
});

it('should populate global context for tags, extra, and user', function() {
Raven.config('//abc@example.com/sentry/2', {
tags: {tag1: 'tagValue1'},
extra: {extra1: 'extraValue1'},
user: {name: 'Matt'},
whitelistUrls: ['not-a-context-value']
});
assert.deepEqual(Raven._globalContext, {
tags: {tag1: 'tagValue1'},
extra: {extra1: 'extraValue1'},
user: {name: 'Matt'},
});
});

describe('whitelistUrls', function() {
it('should be false if none are passed', function() {
Raven.config('//abc@example.com/2');
Expand Down