Skip to content
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

Sync with upstream #7

Merged
merged 42 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
ea2d744
Export sentry.ParseRate. Remove client-wide rate settings
jianyuan Jul 19, 2022
7f04ca7
Add in Project Filter Service (#62)
taj-p Jul 20, 2022
ddbf69c
chore(deps): update module go to 1.19 (#63)
renovate[bot] Aug 2, 2022
3710411
Feature: Organization repository code mapping (#64)
danielpoonwj Aug 23, 2022
250257c
fix: use string array for scopes type (#66)
taj-p Oct 5, 2022
ce7d9ba
fix(deps): update module github.com/peterhellberg/link to v1.2.0 (#68)
renovate[bot] Nov 6, 2022
42e3d51
fix(deps): update module github.com/stretchr/testify to v1.8.1 (#67)
renovate[bot] Nov 6, 2022
54108e4
feat: Available set eventTypes when create alerts. (#69)
eugeniykurasov Nov 29, 2022
805b3a9
Switch endpoint (#71)
jianyuan Dec 12, 2022
8f147c7
Run go fmt
jianyuan Dec 12, 2022
9a37263
fix(#72): Async metric create. (#73)
eugeniykurasov Jan 3, 2023
966077d
Add support for creating new release deployments (#74)
mvantellingen Jan 20, 2023
0932fda
fix(deps): update module github.com/stretchr/testify to v1.8.2 (#75)
renovate[bot] Feb 25, 2023
3850087
chore(deps): update actions/setup-go action to v4 (#77)
renovate[bot] Mar 15, 2023
97df7c9
add fingerprinting rules (#76)
mtanda Mar 21, 2023
7a0b01c
Add methods to get and update organization integration configData (#80)
sbrudz Apr 14, 2023
861f4c0
chore(deps): update actions/checkout action to v4 (#82)
renovate[bot] Oct 30, 2023
adc51b1
fix: add support for default_rules to create project (#85)
merrington Nov 30, 2023
5beaa3f
chore(deps): update actions/setup-go action to v5 (#86)
renovate[bot] Dec 6, 2023
c7b30d0
feat: add/remove organization member to/from a team (#87)
jianyuan Dec 6, 2023
24b9e99
fix(deps): update module github.com/stretchr/testify to v1.8.4 (#81)
renovate[bot] Dec 7, 2023
d6f394e
ref: fix casing in memberID
jianyuan Dec 7, 2023
d91bffa
feat: Add/delete/change roles to organization members- Including Team…
jianyuan Dec 7, 2023
449195c
feat: Allow projects to update inbound data filters (#89)
jianyuan Dec 7, 2023
9f4943b
feat: Enable/disable spike protection (#90)
jianyuan Dec 7, 2023
e63a506
feat: Update team member
jianyuan Dec 9, 2023
0c7dd3e
ref: org/team role list
jianyuan Dec 9, 2023
881b50c
feat: project inbound data filters service
jianyuan Dec 9, 2023
5fe6715
feat: notification actions
jianyuan Dec 9, 2023
6da456e
feat: add list params to list projects endpoint
jianyuan Dec 11, 2023
621cfd2
ref: alias UpdateNotificationActionParams
jianyuan Dec 11, 2023
7710695
feat: project symbol source
jianyuan Dec 11, 2023
b3fa073
ref: convert project id into json.Number
jianyuan Dec 13, 2023
ce941c8
ref: convert issue alert frequency to json number
jianyuan Dec 13, 2023
288c5a2
ref: issue alert conditions, filters, actions use map[string]interface{}
jianyuan Dec 14, 2023
87a3266
fix: targetIdentifier can be an integer
jianyuan Dec 16, 2023
a0eb7e6
fix: authassignment is now a string
jianyuan Dec 16, 2023
6789d91
define custom marshaller
jianyuan Dec 16, 2023
01d0536
feat: add cursor pagination to list teams endpoint
jianyuan Dec 16, 2023
0f22970
ref: org role list and team role list
jianyuan Jan 12, 2024
039d045
Merge remote-tracking branch 'upstream/main' into foadnh-sync-upstream
foadnh Mar 21, 2024
50b9617
Sync with upstream
foadnh Mar 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 12 additions & 14 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,24 @@ name: Go
on: push

jobs:

build:
runs-on: ubuntu-latest
strategy:
matrix:
go:
- "1.15"
- "1.16"
- "1.17"
- "1.18"
- "1.19"
- "1.20"
- "1.21"
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go }}
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}

- name: Build
run: go build -v ./...
- name: Build
run: go build -v ./...

- name: Test
run: make test
- name: Test
run: make test
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module github.com/canva/go-sentry

go 1.18
go 1.19

require (
github.com/google/go-querystring v1.1.0
github.com/peterhellberg/link v1.1.0
github.com/stretchr/testify v1.8.0
github.com/peterhellberg/link v1.2.0
github.com/stretchr/testify v1.8.4
)

require (
Expand Down
19 changes: 4 additions & 15 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,28 +1,17 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/google/go-cmp v0.5.2 h1:X2ev0eStA3AbceY54o37/0PQ/UWqKEiiO2dKL5OPaFM=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/peterhellberg/link v1.1.0 h1:s2+RH8EGuI/mI4QwrWGSYQCRz7uNgip9BaM04HKu5kc=
github.com/peterhellberg/link v1.1.0/go.mod h1:gtSlOT4jmkY8P47hbTc8PTgiDDWpdPbFYl75keYyBB8=
github.com/peterhellberg/link v1.2.0 h1:UA5pg3Gp/E0F2WdX7GERiNrPQrM1K6CVJUUWfHa4t6c=
github.com/peterhellberg/link v1.2.0/go.mod h1:gYfAh+oJgQu2SrZHg5hROVRQe1ICoK0/HHJTcE0edxc=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.2 h1:4jaiDzPyXQvSd7D0EjG45355tLlV3VOECpq10pLC+8s=
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
github.com/stretchr/testify v1.7.4 h1:wZRexSlwd7ZXfKINDLsO4r7WBt3gTKONc6K/VesHvHM=
github.com/stretchr/testify v1.7.4/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.7.5 h1:s5PTfem8p8EbKQOctVV53k6jCJt3UX4IEJzwh+C324Q=
github.com/stretchr/testify v1.7.5/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
7 changes: 3 additions & 4 deletions sentry/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ import (
// APIError represents a Sentry API Error response.
// Should look like:
//
// type apiError struct {
// Detail string `json:"detail"`
// }
//
// type apiError struct {
// Detail string `json:"detail"`
// }
type APIError struct {
f interface{} // unknown
}
Expand Down
38 changes: 15 additions & 23 deletions sentry/issue_alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package sentry

import (
"context"
"encoding/json"
"errors"
"fmt"
"time"
Expand All @@ -10,20 +11,20 @@ import (
// IssueAlert represents an issue alert configured for this project.
// https://github.com/getsentry/sentry/blob/22.5.0/src/sentry/api/serializers/models/rule.py#L131-L155
type IssueAlert struct {
ID *string `json:"id,omitempty"`
Conditions []*IssueAlertCondition `json:"conditions,omitempty"`
Filters []*IssueAlertFilter `json:"filters,omitempty"`
Actions []*IssueAlertAction `json:"actions,omitempty"`
ActionMatch *string `json:"actionMatch,omitempty"`
FilterMatch *string `json:"filterMatch,omitempty"`
Frequency *int `json:"frequency,omitempty"`
Name *string `json:"name,omitempty"`
DateCreated *time.Time `json:"dateCreated,omitempty"`
Owner *string `json:"owner,omitempty"`
CreatedBy *IssueAlertCreatedBy `json:"createdBy,omitempty"`
Environment *string `json:"environment,omitempty"`
Projects []string `json:"projects,omitempty"`
TaskUUID *string `json:"uuid,omitempty"` // This is actually the UUID of the async task that can be spawned to create the rule
ID *string `json:"id,omitempty"`
Conditions []map[string]interface{} `json:"conditions,omitempty"`
Filters []map[string]interface{} `json:"filters,omitempty"`
Actions []map[string]interface{} `json:"actions,omitempty"`
ActionMatch *string `json:"actionMatch,omitempty"`
FilterMatch *string `json:"filterMatch,omitempty"`
Frequency *json.Number `json:"frequency,omitempty"`
Name *string `json:"name,omitempty"`
DateCreated *time.Time `json:"dateCreated,omitempty"`
Owner *string `json:"owner,omitempty"`
CreatedBy *IssueAlertCreatedBy `json:"createdBy,omitempty"`
Environment *string `json:"environment,omitempty"`
Projects []string `json:"projects,omitempty"`
TaskUUID *string `json:"uuid,omitempty"` // This is actually the UUID of the async task that can be spawned to create the rule
}

// IssueAlertCreatedBy for defining the rule creator.
Expand All @@ -33,15 +34,6 @@ type IssueAlertCreatedBy struct {
Email *string `json:"email,omitempty"`
}

// IssueAlertCondition for defining conditions.
type IssueAlertCondition map[string]interface{}

// IssueAlertAction for defining actions.
type IssueAlertAction map[string]interface{}

// IssueAlertFilter for defining actions.
type IssueAlertFilter map[string]interface{}

// IssueAlertTaskDetail represents the inline struct Sentry defines for task details
// https://github.com/getsentry/sentry/blob/22.5.0/src/sentry/api/endpoints/project_rule_task_details.py#L29
type IssueAlertTaskDetail struct {
Expand Down
52 changes: 26 additions & 26 deletions sentry/issue_alerts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ func TestIssueAlertsService_List(t *testing.T) {
ID: String("12345"),
ActionMatch: String("any"),
Environment: String("production"),
Frequency: Int(30),
Frequency: JsonNumber(json.Number("30")),
Name: String("Notify errors"),
Conditions: []*IssueAlertCondition{
Conditions: []map[string]interface{}{
{
"id": "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition",
"name": "An issue is first seen",
"value": json.Number("500"),
"interval": "1h",
},
},
Actions: []*IssueAlertAction{
Actions: []map[string]interface{}{
{
"id": "sentry.integrations.slack.notify_action.SlackNotifyServiceAction",
"name": "Send a notification to the Dummy Slack workspace to #dummy-channel and show tags [environment] in notification",
Expand Down Expand Up @@ -221,7 +221,7 @@ func TestIssueAlertsService_Get(t *testing.T) {

expected := &IssueAlert{
ID: String("11185158"),
Conditions: []*IssueAlertCondition{
Conditions: []map[string]interface{}{
{
"id": "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition",
"name": "A new issue is created",
Expand Down Expand Up @@ -256,7 +256,7 @@ func TestIssueAlertsService_Get(t *testing.T) {
"name": "The issue affects more than 100.0 percent of sessions in 1h",
},
},
Filters: []*IssueAlertFilter{
Filters: []map[string]interface{}{
{
"comparison_type": "older",
"time": "minute",
Expand Down Expand Up @@ -300,7 +300,7 @@ func TestIssueAlertsService_Get(t *testing.T) {
"name": "The event's level is equal to fatal",
},
},
Actions: []*IssueAlertAction{
Actions: []map[string]interface{}{
{
"targetType": "IssueOwners",
"id": "sentry.mail.actions.NotifyEmailAction",
Expand All @@ -326,7 +326,7 @@ func TestIssueAlertsService_Get(t *testing.T) {
},
ActionMatch: String("any"),
FilterMatch: String("any"),
Frequency: Int(30),
Frequency: JsonNumber(json.Number("30")),
Name: String("My Rule Name"),
DateCreated: Time(mustParseTime("2022-05-23T19:54:30.860115Z")),
Owner: String("team:1322366"),
Expand Down Expand Up @@ -404,17 +404,17 @@ func TestIssueAlertsService_Create(t *testing.T) {
params := &IssueAlert{
ActionMatch: String("all"),
Environment: String("production"),
Frequency: Int(30),
Frequency: JsonNumber(json.Number("30")),
Name: String("Notify errors"),
Conditions: []*IssueAlertCondition{
Conditions: []map[string]interface{}{
{
"interval": "1h",
"name": "The issue is seen more than 10 times in 1h",
"value": json.Number("10"),
"id": "sentry.rules.conditions.event_frequency.EventFrequencyCondition",
},
},
Actions: []*IssueAlertAction{
Actions: []map[string]interface{}{
{
"id": "sentry.integrations.slack.notify_action.SlackNotifyServiceAction",
"name": "Send a notification to the Dummy Slack workspace to #dummy-channel and show tags [environment] in notification",
Expand All @@ -433,17 +433,17 @@ func TestIssueAlertsService_Create(t *testing.T) {
ID: String("123456"),
ActionMatch: String("all"),
Environment: String("production"),
Frequency: Int(30),
Frequency: JsonNumber(json.Number("30")),
Name: String("Notify errors"),
Conditions: []*IssueAlertCondition{
Conditions: []map[string]interface{}{
{
"interval": "1h",
"name": "The issue is seen more than 10 times in 1h",
"value": json.Number("10"),
"id": "sentry.rules.conditions.event_frequency.EventFrequencyCondition",
},
},
Actions: []*IssueAlertAction{
Actions: []map[string]interface{}{
{
"id": "sentry.integrations.slack.notify_action.SlackNotifyServiceAction",
"name": "Send a notification to the Dummy Slack workspace to #dummy-channel and show tags [environment] in notification",
Expand Down Expand Up @@ -532,17 +532,17 @@ func TestIssueAlertsService_CreateWithAsyncTask(t *testing.T) {
params := &IssueAlert{
ActionMatch: String("all"),
Environment: String("production"),
Frequency: Int(30),
Frequency: JsonNumber(json.Number("30")),
Name: String("Notify errors"),
Conditions: []*IssueAlertCondition{
Conditions: []map[string]interface{}{
{
"interval": "1h",
"name": "The issue is seen more than 10 times in 1h",
"value": json.Number("10"),
"id": "sentry.rules.conditions.event_frequency.EventFrequencyCondition",
},
},
Actions: []*IssueAlertAction{
Actions: []map[string]interface{}{
{
"id": "sentry.integrations.slack.notify_action.SlackNotifyServiceAction",
"name": "Send a notification to the Dummy Slack workspace to #dummy-channel and show tags [environment] in notification",
Expand All @@ -561,17 +561,17 @@ func TestIssueAlertsService_CreateWithAsyncTask(t *testing.T) {
ID: String("123456"),
ActionMatch: String("all"),
Environment: String("production"),
Frequency: Int(30),
Frequency: JsonNumber(json.Number("30")),
Name: String("Notify errors"),
Conditions: []*IssueAlertCondition{
Conditions: []map[string]interface{}{
{
"interval": "1h",
"name": "The issue is seen more than 10 times in 1h",
"value": json.Number("10"),
"id": "sentry.rules.conditions.event_frequency.EventFrequencyCondition",
},
},
Actions: []*IssueAlertAction{
Actions: []map[string]interface{}{
{
"id": "sentry.integrations.slack.notify_action.SlackNotifyServiceAction",
"name": "Send a notification to the Dummy Slack workspace to #dummy-channel and show tags [environment] in notification",
Expand All @@ -596,16 +596,16 @@ func TestIssueAlertsService_Update(t *testing.T) {
ActionMatch: String("all"),
FilterMatch: String("any"),
Environment: String("staging"),
Frequency: Int(30),
Frequency: JsonNumber(json.Number("30")),
Name: String("Notify errors"),
Conditions: []*IssueAlertCondition{
Conditions: []map[string]interface{}{
{
"id": "sentry.rules.conditions.event_frequency.EventFrequencyCondition",
"value": 500,
"interval": "1h",
},
},
Actions: []*IssueAlertAction{
Actions: []map[string]interface{}{
{
"id": "sentry.integrations.slack.notify_action.SlackNotifyServiceAction",
"name": "Send a notification to the Dummy Slack workspace to #dummy-channel and show tags [environment] in notification",
Expand All @@ -615,7 +615,7 @@ func TestIssueAlertsService_Update(t *testing.T) {
"workspace": "1234",
},
},
Filters: []*IssueAlertFilter{
Filters: []map[string]interface{}{
{
"id": "sentry.rules.filters.issue_occurrences.IssueOccurrencesFilter",
"name": "The issue has happened at least 4 times",
Expand Down Expand Up @@ -709,15 +709,15 @@ func TestIssueAlertsService_Update(t *testing.T) {
ID: String("12345"),
ActionMatch: String("any"),
Environment: String("staging"),
Frequency: Int(30),
Frequency: JsonNumber(json.Number("30")),
Name: String("Notify errors"),
Conditions: []*IssueAlertCondition{
Conditions: []map[string]interface{}{
{
"id": "sentry.rules.conditions.first_seen_event.FirstSeenEventCondition",
"name": "An issue is first seen",
},
},
Actions: []*IssueAlertAction{
Actions: []map[string]interface{}{
{
"id": "sentry.integrations.slack.notify_action.SlackNotifyServiceAction",
"name": "Send a notification to the Dummy Slack workspace to #dummy-channel and show tags [environment] in notification",
Expand Down
Loading