Skip to content

Make user type more flexible #1187

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 3 commits into from
Jan 12, 2018
Merged

Conversation

ForbesLindesay
Copy link
Contributor

The API seems to accept any JSON Object for setUserContext. By making it one method instead of two separate methods, we can also make it more flexible. Where before a wrapper would need to do:

function setUser(user?: User) {
  if (user) {
    Raven.setUserContext(user);
  } else {
    Raven.setUserContext();
  }
}

This type definition allows for:

function setUser(user?: User) {
  Raven.setUserContext(user);
}

Before submitting a pull request, please verify the following:

  • If you've added code that should be tested, please add tests.
  • If you've modified the API (e.g. added a new config or public method), update the docs and TypeScript declaration file.
  • Ensure your code lints and the test suite passes (npm test).

The API seems to accept any JSON Object for `setUserContext`.  By making it one method instead of two separate methods, we can also make it more flexible.  Where before a wrapper would need to do:

```typescript
function setUser(user?: User) {
  if (user) {
    Raven.setUserContext(user);
  } else {
    Raven.setUserContext();
  }
}
```

This type definition allows for:


```typescript
function setUser(user?: User) {
  Raven.setUserContext(user);
}
```
id?: string;
username?: string;
email?: string;
setUserContext(user?: {
Copy link
Contributor

@kamilogorek kamilogorek Jan 9, 2018

Choose a reason for hiding this comment

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

Isn't this the same as just setUserContext(user?: Object)? I'm not very familiar with TS.

@kamilogorek
Copy link
Contributor

Could you also please rebase your changes?

@kamilogorek kamilogorek merged commit 50583ff into getsentry:master Jan 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants