diff --git a/src/sentry/sentry_apps/api/endpoints/sentry_app_stats_details.py b/src/sentry/sentry_apps/api/endpoints/sentry_app_stats_details.py index 34dc8f7fb9ce7d..269cd5a4e74671 100644 --- a/src/sentry/sentry_apps/api/endpoints/sentry_app_stats_details.py +++ b/src/sentry/sentry_apps/api/endpoints/sentry_app_stats_details.py @@ -34,18 +34,20 @@ def get(self, request: Request, sentry_app) -> Response: sentry_app_id=sentry_app.id, date_deleted__isnull=False ).count() - rollup, series = tsdb.get_optimal_rollup_series(query_args["start"], query_args["end"]) + rollup, series = tsdb.backend.get_optimal_rollup_series( + query_args["start"], query_args["end"] + ) install_stats = dict.fromkeys(series, 0) uninstall_stats = dict.fromkeys(series, 0) for date_added, date_deleted, organization_id in installations: - install_norm_epoch = tsdb.normalize_to_epoch(date_added, rollup) + install_norm_epoch = tsdb.backend.normalize_to_epoch(date_added, rollup) if install_norm_epoch in install_stats: install_stats[install_norm_epoch] += 1 if date_deleted is not None: - uninstall_norm_epoch = tsdb.normalize_to_epoch(date_deleted, rollup) + uninstall_norm_epoch = tsdb.backend.normalize_to_epoch(date_deleted, rollup) if uninstall_norm_epoch in uninstall_stats: uninstall_stats[uninstall_norm_epoch] += 1 diff --git a/src/sentry/sentry_apps/api/endpoints/sentry_internal_app_tokens.py b/src/sentry/sentry_apps/api/endpoints/sentry_internal_app_tokens.py index 0999cf93d6cc35..525809d539b8c4 100644 --- a/src/sentry/sentry_apps/api/endpoints/sentry_internal_app_tokens.py +++ b/src/sentry/sentry_apps/api/endpoints/sentry_internal_app_tokens.py @@ -12,10 +12,12 @@ ) from sentry.api.serializers.models.apitoken import ApiTokenSerializer from sentry.exceptions import ApiTokenLimitError +from sentry.interfaces.user import User from sentry.models.apitoken import ApiToken from sentry.sentry_apps.installations import SentryAppInstallationTokenCreator from sentry.sentry_apps.models.sentry_app import MASKED_VALUE from sentry.sentry_apps.models.sentry_app_installation import SentryAppInstallation +from sentry.users.services.user.model import RpcUser @control_silo_endpoint @@ -61,6 +63,9 @@ def post(self, request: Request, sentry_app) -> Response: ) sentry_app_installation = SentryAppInstallation.objects.get(sentry_app_id=sentry_app.id) try: + assert isinstance(request.user, User) or isinstance( + request.user, RpcUser + ), "User must be authenticated to install a sentry app" api_token = SentryAppInstallationTokenCreator( sentry_app_installation=sentry_app_installation ).run(request=request, user=request.user)