Skip to content

Commit

Permalink
feat(sentry): set user id (installation ID) and username (repository …
Browse files Browse the repository at this point in the history
…owner login) if present (#13)
  • Loading branch information
gr2m authored Sep 6, 2020
1 parent 8c851f6 commit 5e1d16f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,23 @@ function getTransformStream() {
scope.setExtra(extra, data[extra]);
}

// set user id and username when available
if (data.event && data.event.installation) {
const user = { id: data.event.installation.id };

/* istanbul ignore if */
if (data.event.organization) {
user.username = data.event.organization.user.login;
}

/* istanbul ignore if */
if (data.event.repository) {
user.username = data.event.repository.owner.login;
}

scope.setUser(user);
}

Sentry.captureException(toSentryError(data));
});
}
Expand Down

0 comments on commit 5e1d16f

Please sign in to comment.