Skip to content

Commit

Permalink
Merge branch 'master' into aliu/ingest-feedback-events-config
Browse files Browse the repository at this point in the history
  • Loading branch information
aliu3ntry committed Mar 13, 2024
2 parents b7bc6d0 + 4d7fb4e commit 909bdcc
Show file tree
Hide file tree
Showing 66 changed files with 723 additions and 343 deletions.
1 change: 1 addition & 0 deletions src/sentry/api/endpoints/project_key_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def get(self, request: Request, project, key_id) -> Response:
help_text="The Sentry Javascript SDK version to use. The currently supported options are:",
# Ideally we would call get_browser_sdk_version_choices() here but that requires
# passing in project to this decorator
# todo: v8 add version
choices=[("latest", "Most recent version"), ("7.x", "Version 7 releases")],
required=False,
),
Expand Down
1 change: 1 addition & 0 deletions src/sentry/loader/browsersdkversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def get_highest_browser_sdk_version(versions):


def get_all_browser_sdk_version_versions():
# todo: v8 add version
return ["latest", "7.x", "6.x", "5.x", "4.x"]


Expand Down
2 changes: 0 additions & 2 deletions src/sentry/monitors/endpoints/organization_monitor_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ def map_value_to_constant(constant, value):

DEFAULT_ORDERING = [
MonitorStatus.ERROR,
MonitorStatus.TIMEOUT,
MonitorStatus.MISSED_CHECKIN,
MonitorStatus.OK,
MonitorStatus.ACTIVE,
MonitorStatus.DISABLED,
Expand Down
6 changes: 1 addition & 5 deletions src/sentry/monitors/logic/mark_failed.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,7 @@ def mark_failed_threshold(
)
fingerprint = incident.grouphash

elif monitor_env.status in [
MonitorStatus.ERROR,
MonitorStatus.MISSED_CHECKIN,
MonitorStatus.TIMEOUT,
]:
elif monitor_env.status == MonitorStatus.ERROR:
# if monitor environment has a failed status, use the failed
# check-in and send occurrence
previous_checkins = [
Expand Down
4 changes: 0 additions & 4 deletions src/sentry/monitors/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ class MonitorStatus:

OK = 4
ERROR = 5
MISSED_CHECKIN = 6
TIMEOUT = 7

@classmethod
def as_choices(cls) -> Sequence[tuple[int, str]]:
Expand All @@ -110,8 +108,6 @@ def as_choices(cls) -> Sequence[tuple[int, str]]:
(cls.DELETION_IN_PROGRESS, "deletion_in_progress"),
(cls.OK, "ok"),
(cls.ERROR, "error"),
(cls.MISSED_CHECKIN, "missed_checkin"),
(cls.TIMEOUT, "timeout"),
)


Expand Down
3 changes: 3 additions & 0 deletions src/sentry/monitors/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,9 @@ def detect_broken_monitor_envs():
open_incidents_qs = MonitorIncident.objects.select_related("monitor").filter(
resolving_checkin=None,
starting_timestamp__lte=(current_time - timedelta(days=NUM_DAYS_BROKEN_PERIOD)),
monitor__status=ObjectStatus.ACTIVE,
monitor__is_muted=False,
monitor_environment__is_muted=False,
# TODO(davidenwang): When we want to email users, remove this filter
monitorenvbrokendetection__isnull=True,
)
Expand Down
1 change: 1 addition & 0 deletions src/sentry/projectoptions/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@
)

# The available loader SDK versions
# todo: v8 add version
register(
key="sentry:loader_available_sdk_versions",
epoch_defaults={1: ["7.x", "6.x", "5.x", "4.x"], 11: ["7.x"]},
Expand Down
1 change: 1 addition & 0 deletions src/sentry/replays/lib/new_query/conditions.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Every condition visitor must define a method for every operator supported by the caller. A full
list of supported operations can be found in the "GenericBase" visitor.
"""

from __future__ import annotations

from typing import Any, NoReturn, TypeVar
Expand Down
8 changes: 5 additions & 3 deletions src/sentry/replays/lib/new_query/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
filtered in that way. The field's job is to translate the display format to the expression
format.
"""

from __future__ import annotations

import datetime
Expand All @@ -26,6 +27,7 @@

from sentry.api.event_search import SearchFilter
from sentry.replays.lib.new_query.conditions import GenericBase, T
from sentry.replays.lib.new_query.errors import OperatorNotSupported


class FieldProtocol(Protocol):
Expand Down Expand Up @@ -54,7 +56,7 @@ def _apply_wildcard(self, expression: Expression, operator: str, value: T) -> Co
elif operator == "!=":
visitor = self.query.visit_not_match
else:
raise Exception(f"Unsupported wildcard search operator: '{operator}'")
raise OperatorNotSupported(f"Unsupported wildcard search operator: '{operator}'")

return visitor(expression, value)

Expand All @@ -64,7 +66,7 @@ def _apply_composite(self, expression: Expression, operator: str, value: list[T]
elif operator == "NOT IN":
visitor = self.query.visit_not_in
else:
raise Exception(f"Unsupported composite search operator: '{operator}'")
raise OperatorNotSupported(f"Unsupported composite search operator: '{operator}'")

return visitor(expression, value)

Expand All @@ -82,7 +84,7 @@ def _apply_scalar(self, expression: Expression, operator: str, value: T) -> Cond
elif operator == "<=":
visitor = self.query.visit_lte
else:
raise Exception(f"Unsupported search operator: '{operator}'")
raise OperatorNotSupported(f"Unsupported search operator: '{operator}'")

return visitor(expression, value)

Expand Down
10 changes: 5 additions & 5 deletions src/sentry/replays/usecases/ingest/dom_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,11 @@ def _handle_resource_metric_event(event: dict[str, Any]) -> None:

def _handle_options_logging_event(project_id: int, replay_id: str, event: dict[str, Any]) -> None:
# log the SDK options sent from the SDK 1/500 times
if random.randint(0, 499) < 1:
log = event["data"].get("payload", {}).copy()
log["project_id"] = project_id
log["replay_id"] = replay_id
logger.info("SDK Options:", extra=log)
log = event["data"].get("payload", {}).copy()
log["project_id"] = project_id
log["replay_id"] = replay_id
# Log to "slow_click" because its the only bigtable sink
logger.info("sentry.replays.slow_click", extra=log)


def _handle_mutations_event(project_id: int, replay_id: str, event: dict[str, Any]) -> None:
Expand Down
13 changes: 7 additions & 6 deletions src/sentry/replays/usecases/query/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from snuba_sdk import Condition

from sentry.api.event_search import SearchFilter
from sentry.replays.lib.new_query.errors import OperatorNotSupported
from sentry.replays.lib.new_query.parsers import parse_str
from sentry.replays.usecases.query.conditions import SumOfTagScalar
from sentry.replays.usecases.query.conditions.base import ComputedBase
Expand Down Expand Up @@ -55,7 +56,7 @@ def _apply_wildcard(self, operator: str, value: T) -> Condition:
elif operator == "!=":
visitor = self.query.visit_not_match
else:
raise Exception(f"Unsupported wildcard search operator: '{operator}'")
raise OperatorNotSupported(f"Unsupported wildcard search operator: '{operator}'")

return visitor(value)

Expand All @@ -65,7 +66,7 @@ def _apply_composite(self, operator: str, value: list[T]) -> Condition:
elif operator == "NOT IN":
visitor = self.query.visit_not_in
else:
raise Exception(f"Unsupported composite search operator: '{operator}'")
raise OperatorNotSupported(f"Unsupported composite search operator: '{operator}'")

return visitor(value)

Expand All @@ -83,7 +84,7 @@ def _apply_scalar(self, operator: str, value: T) -> Condition:
elif operator == "<=":
visitor = self.query.visit_lte
else:
raise Exception(f"Unsupported search operator: '{operator}'")
raise OperatorNotSupported(f"Unsupported search operator: '{operator}'")

return visitor(value)

Expand Down Expand Up @@ -129,7 +130,7 @@ def _apply_wildcard(self, key: str, operator: str, value: str) -> Condition:
elif operator == "!=":
visitor = self.query.visit_not_match
else:
raise Exception(f"Unsupported wildcard search operator: '{operator}'")
raise OperatorNotSupported(f"Unsupported wildcard search operator: '{operator}'")

return visitor(key, value)

Expand All @@ -139,7 +140,7 @@ def _apply_composite(self, key: str, operator: str, value: list[str]) -> Conditi
elif operator == "NOT IN":
visitor = self.query.visit_not_in
else:
raise Exception(f"Unsupported composite search operator: '{operator}'")
raise OperatorNotSupported(f"Unsupported composite search operator: '{operator}'")

return visitor(key, value)

Expand All @@ -149,6 +150,6 @@ def _apply_scalar(self, key: str, operator: str, value: str) -> Condition:
elif operator == "!=":
visitor = self.query.visit_neq
else:
raise Exception(f"Unsupported search operator: '{operator}'")
raise OperatorNotSupported(f"Unsupported search operator: '{operator}'")

return visitor(key, value)
2 changes: 2 additions & 0 deletions src/sentry/sentry_metrics/indexer/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@
"is_application": PREFIX + 269,
"platform": PREFIX + 270,
"os.version": PREFIX + 271,
# Performance Score
"sentry.score_profile_version": PREFIX + 272,
# GENERAL/MISC (don't have a category)
"": PREFIX + 1000,
}
Expand Down
5 changes: 0 additions & 5 deletions src/sentry/services/hybrid_cloud/rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,11 +585,6 @@ def _fire_request(self, headers: MutableMapping[str, str], data: bytes) -> reque
# TODO: Performance considerations (persistent connections, pooling, etc.)?
url = self.address + self.path

# Add tracing continuation headers as the SDK doesn't monkeypatch requests.
if traceparent := sentry_sdk.get_traceparent():
headers["Sentry-Trace"] = traceparent
if baggage := sentry_sdk.get_baggage():
headers["Baggage"] = baggage
try:
return http.post(url, headers=headers, data=data, timeout=settings.RPC_TIMEOUT)
except requests.exceptions.ConnectionError as e:
Expand Down
5 changes: 3 additions & 2 deletions src/sentry/tasks/assemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,14 @@ def assemble_file(task, org_or_project, name, checksum, chunks, file_type) -> As

# Reject all files that exceed the maximum allowed size for this organization.
file_size = sum(x[2] for x in file_blobs)
if file_size > get_max_file_size(organization):
max_file_size = get_max_file_size(organization)
if file_size > max_file_size:
set_assemble_status(
task,
org_or_project.id,
checksum,
ChunkFileState.ERROR,
detail="File exceeds maximum size",
detail=f"File {name} exceeds maximum size ({file_size} > {max_file_size})",
)

return None
Expand Down
3 changes: 2 additions & 1 deletion src/sentry/templates/sentry/emails/auth-link-identity.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{% extends "sentry/emails/base.html" %}

{% load i18n %}
{% load sentry_helpers %}

{% block main %}
<h3>{{ provider.name }} SSO Enabled</h3>

<p>
<strong>{{ provider.name }}</strong> Single Sign-On has been configured for the
<strong>{{ organization.name }}</strong> organization. Link your Sentry account to enable
<strong>{{ organization.name|sanitize_periods }}</strong> organization. Link your Sentry account to enable
signing on with your <strong>{{ provider.name }}</strong> account.
</p>

Expand Down
3 changes: 2 additions & 1 deletion src/sentry/templates/sentry/emails/auth-sso-disabled.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{% extends "sentry/emails/base.html" %}

{% load i18n %}
{% load sentry_helpers %}

{% block main %}
<h3>Single Sign-On disabled</h3>

<p>
<strong>{{ provider.name }}</strong> Single Sign-On has been disabled for the
<strong>{{ organization.name }}</strong> organization.
<strong>{{ organization.name|sanitize_periods }}</strong> organization.
</p>

{% if has_password %}
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/templates/sentry/emails/member-invite.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

{% block main %}
<h3>You've been invited to Sentry</h3>
<p>Your teammates at <strong>{{ organization.name }}</strong> are using Sentry to track and debug software errors.</p>
<p>Your teammates at <strong>{{ organization.name|sanitize_periods }}</strong> are using Sentry to track and debug software errors.</p>

<p><a href="{{ url }}" class="btn">Join your team</a></p>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

{% block main %}
<h3>Security Notice</h3>
<p>User {{ actor.email }} has created a new Organization Auth Token "{{ token_name }}" for your Sentry organization {{ organization.name }}.</p>
<p>User {{ actor.email }} has created a new Organization Auth Token "{{ token_name }}" for your Sentry organization {{ organization.name|sanitize_periods }}.</p>
<table>
<tr>
<td style="width:36px;vertical-align:top;padding-right:15px;">
Expand Down
3 changes: 2 additions & 1 deletion src/sentry/templates/sentry/emails/org_delete_confirm.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{% extends "sentry/emails/base.html" %}

{% load i18n %}
{% load sentry_helpers %}

{% block main %}
<h3>Organization Queued for Deletion</h3>
<p>The <strong>{{ organization.name }}</strong> organization has been scheduled for deletion by:</p>
<p>The <strong>{{ organization.name|sanitize_periods }}</strong> organization has been scheduled for deletion by:</p>
<p><pre>User: {{ username }}
IP: {{ user_ip_address }}
Date: {{ deletion_datetime }}</pre></p>
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/templates/sentry/emails/reports/body.html
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ <h1>
</h1>
</td>
<td class="align-right">
<strong>Weekly Update for {{ organization.name }}</strong><br />
<strong>Weekly Update for {{ organization.name|sanitize_periods }}</strong><br />
{{ start }} &ndash; {{ end }}
</td>
</tr>
Expand Down
3 changes: 2 additions & 1 deletion src/sentry/templates/sentry/emails/setup_2fa.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{% extends "sentry/emails/base.html" %}

{% load i18n %}
{% load sentry_helpers %}

{% block main %}
<h3>Setup Two-Factor Authentication</h3>
<p>
The {{ organization.name|title }} organization now requires all members to enable
The {{ organization.name|sanitize_periods|title }} organization now requires all members to enable
two-factor authentication. Effective immediately, you will be unable to access
this organization or receive its notifications until you enable at least
one form of 2FA.
Expand Down
3 changes: 2 additions & 1 deletion src/sentry/templates/sentry/emails/setup_email.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{% extends "sentry/emails/base.html" %}

{% load i18n %}
{% load sentry_helpers %}

{% block main %}
<h3>Confirm Email</h3>
<p>
The {{ organization.name|title }} organization now requires all members to confirm
The {{ organization.name|sanitize_periods|title }} organization now requires all members to confirm
their primary email address. Effective immediately, you will be unable to access
this organization or receive its notifications until you confirm this email
address.
Expand Down
2 changes: 1 addition & 1 deletion src/sentry/templates/sentry/emails/slack-migration.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

{% block main %}
<h3>You're All Upgraded</h3>
Well, you're looking fresh. Your organization <strong>{{organization.name}}</strong>'s Sentry-Slack Integration for your workspace
Well, you're looking fresh. Your organization <strong>{{organization.name|sanitize_periods}}</strong>'s Sentry-Slack Integration for your workspace
<strong>{{integration.name}}</strong> is all up to date and ready to report errors. If you're confused, curious, or just looking
for some light reading, see <a href="{{ doc_link }}">our docs</a>.
<br />
Expand Down
14 changes: 14 additions & 0 deletions src/sentry/templatetags/sentry_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,17 @@ def random_int(a, b=None):
@register.filter
def get_item(dictionary, key):
return dictionary.get(key, "")


@register.filter
@stringfilter
def sanitize_periods(value):
"""
Primarily used in email templates when a field may contain a domain name to prevent
email clients from creating a clickable link to the domain.
"""
word_joiner = "\u2060"

# Adding the Unicode character before every period
output_string = value.replace(".", word_joiner + ".")
return output_string
8 changes: 8 additions & 0 deletions src/sentry/web/frontend/auth_organization_login.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging

from django.contrib import messages
from django.http.response import HttpResponseBase
from django.urls import reverse
Expand All @@ -12,6 +14,8 @@
from sentry.utils.auth import initiate_login
from sentry.web.frontend.auth_login import AuthLoginView

logger = logging.getLogger("sentry.saml_setup_error")


class AuthOrganizationLoginView(AuthLoginView):
def respond_login(self, request: Request, context, *args, **kwargs) -> HttpResponseBase:
Expand All @@ -32,6 +36,10 @@ def handle_sso(self, request: Request, organization: RpcOrganization, auth_provi
helper.initialize()

if not helper.is_valid():
logger.info(
"AuthOrganizationLoginView",
extra=helper.state.get_state(),
)
return helper.error("Something unexpected happened during authentication.")

return helper.current_step()
Expand Down

0 comments on commit 909bdcc

Please sign in to comment.