-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Feat/mark sentry app installed put route #14060
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
src/sentry/analytics/events/sentry_app_installation_updated.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| from __future__ import absolute_import | ||
|
|
||
| from sentry import analytics | ||
|
|
||
|
|
||
| class SentryAppInstallationUpdatedEvent(analytics.Event): | ||
| type = 'sentry_app_installation.updated' | ||
|
|
||
| attributes = ( | ||
| analytics.Attribute('sentry_app_installation_id'), | ||
| analytics.Attribute('sentry_app_id'), | ||
| analytics.Attribute('organization_id'), | ||
| ) | ||
|
|
||
|
|
||
| analytics.register(SentryAppInstallationUpdatedEvent) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/sentry/api/serializers/rest_framework/sentry_app_installation.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| from __future__ import absolute_import | ||
|
|
||
|
|
||
| from rest_framework import serializers | ||
| from rest_framework.serializers import Serializer, ValidationError | ||
| from sentry.constants import SentryAppInstallationStatus | ||
|
|
||
|
|
||
| class SentryAppInstallationSerializer(Serializer): | ||
| status = serializers.CharField() | ||
|
|
||
| def validate_status(self, new_status): | ||
| # can only set status to installed | ||
| if new_status != SentryAppInstallationStatus.INSTALLED_STR: | ||
| raise ValidationError( | ||
| u"Invalid value '{}' for status. Valid values: '{}'".format( | ||
| new_status, SentryAppInstallationStatus.INSTALLED_STR)) | ||
|
|
||
| return new_status |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| from __future__ import absolute_import | ||
|
|
||
| import six | ||
|
|
||
|
|
||
| from sentry import analytics | ||
| from sentry.constants import SentryAppInstallationStatus | ||
| from sentry.mediators import Mediator, Param | ||
| from sentry.mediators.param import if_param | ||
|
|
||
|
|
||
| class Updater(Mediator): | ||
| sentry_app_installation = Param('sentry.models.SentryAppInstallation') | ||
| status = Param(six.string_types, required=False) | ||
|
|
||
| def call(self): | ||
| self._update_status() | ||
| self.sentry_app_installation.save() | ||
| return self.sentry_app_installation | ||
|
|
||
| @if_param('status') | ||
| def _update_status(self): | ||
| # convert from string to integer | ||
| if self.status == SentryAppInstallationStatus.INSTALLED_STR: | ||
| self.sentry_app_installation.status = SentryAppInstallationStatus.INSTALLED | ||
|
|
||
| def record_analytics(self): | ||
| # TODO: Add analytics | ||
| analytics.record( | ||
| 'sentry_app_installation.updated', | ||
| sentry_app_installation_id=self.sentry_app_installation.id, | ||
| sentry_app_id=self.sentry_app_installation.sentry_app.id, | ||
| organization_id=self.sentry_app_installation.organization.id | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need the
partial=Truehere since we expect the status to be in therequest.dataand that's the only thing you are validatingThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be good to keep it, though. Updating is almost always going to allow only a portion of the required data (opposed to requiring all fields).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put it back