diff --git a/sentry/project_keys.go b/sentry/project_keys.go index 09839c0..0c3a24b 100644 --- a/sentry/project_keys.go +++ b/sentry/project_keys.go @@ -20,22 +20,33 @@ type ProjectKeyDSN struct { CSP string `json:"csp"` Security string `json:"security"` Minidump string `json:"minidump"` + NEL string `json:"nel"` + Unreal string `json:"unreal"` CDN string `json:"cdn"` + Crons string `json:"crons"` +} + +type ProjectKeyDynamicSDKLoaderOptions struct { + HasReplay bool `json:"hasReplay"` + HasPerformance bool `json:"hasPerformance"` + HasDebugFiles bool `json:"hasDebug"` } // ProjectKey represents a client key bound to a project. // https://github.com/getsentry/sentry/blob/9.0.0/src/sentry/api/serializers/models/project_key.py type ProjectKey struct { - ID string `json:"id"` - Name string `json:"name"` - Label string `json:"label"` - Public string `json:"public"` - Secret string `json:"secret"` - ProjectID json.Number `json:"projectId"` - IsActive bool `json:"isActive"` - RateLimit *ProjectKeyRateLimit `json:"rateLimit"` - DSN ProjectKeyDSN `json:"dsn"` - DateCreated time.Time `json:"dateCreated"` + ID string `json:"id"` + Name string `json:"name"` + Label string `json:"label"` + Public string `json:"public"` + Secret string `json:"secret"` + ProjectID json.Number `json:"projectId"` + IsActive bool `json:"isActive"` + RateLimit *ProjectKeyRateLimit `json:"rateLimit"` + DSN ProjectKeyDSN `json:"dsn"` + BrowserSDKVersion string `json:"browserSdkVersion"` + DateCreated time.Time `json:"dateCreated"` + DynamicSDKLoaderOptions ProjectKeyDynamicSDKLoaderOptions `json:"dynamicSdkLoaderOptions"` } // ProjectKeysService provides methods for accessing Sentry project diff --git a/sentry/project_keys_test.go b/sentry/project_keys_test.go index e87a881..f6687a9 100644 --- a/sentry/project_keys_test.go +++ b/sentry/project_keys_test.go @@ -18,38 +18,91 @@ func TestProjectKeysService_List(t *testing.T) { assertMethod(t, "GET", r) w.Header().Set("Content-Type", "application/json") w.Header().Set("Link", "; rel=\"previous\"; results=\"true\"; cursor=\"0:0:1\", ; rel=\"next\"; results=\"false\"; cursor=\"1584513610301:0:1\"") - fmt.Fprint(w, `[{ - "browserSdk": { - "choices": [ - [ - "latest", - "latest" - ], - [ - "4.x", - "4.x" + fmt.Fprint(w, `[ + { + "id": "60120449b6b1d5e45f75561e6dabd80b", + "name": "Liked Pegasus", + "label": "Liked Pegasus", + "public": "60120449b6b1d5e45f75561e6dabd80b", + "secret": "189485c3b8ccf582bf5e12c530ef8858", + "projectId": 4505281256090153, + "isActive": true, + "rateLimit": { + "window": 7200, + "count": 1000 + }, + "dsn": { + "secret": "https://a785682ddda742d7a8a4088810e67701:bcd99b3790b3441c85ce4b1eaa854f66@o4504765715316736.ingest.sentry.io/4505281256090153", + "public": "https://a785682ddda742d7a8a4088810e67791@o4504765715316736.ingest.sentry.io/4505281256090153", + "csp": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/csp-report/?sentry_key=a785682ddda719b7a8a4011110d75598", + "security": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/security/?sentry_key=a785682ddda719b7a8a4011110d75598", + "minidump": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/minidump/?sentry_key=a785682ddda719b7a8a4011110d75598", + "nel": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/nel/?sentry_key=a785682ddda719b7a8a4011110d75598", + "unreal": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/unreal/a785682ddda719b7a8a4011110d75598/", + "cdn": "https://js.sentry-cdn.com/a785682ddda719b7a8a4011110d75598.min.js", + "crons": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/crons/___MONITOR_SLUG___/a785682ddda719b7a8a4011110d75598/" + }, + "browserSdkVersion": "7.x", + "browserSdk": { + "choices": [ + [ + "latest", + "latest" + ], + [ + "7.x", + "7.x" + ] ] - ] + }, + "dateCreated": "2023-06-21T19:50:26.036254Z", + "dynamicSdkLoaderOptions": { + "hasReplay": true, + "hasPerformance": true, + "hasDebug": true + } }, - "browserSdkVersion": "4.x", - "dateCreated": "2018-09-20T15:48:07.397Z", - "dsn": { - "cdn": "https://sentry.io/js-sdk-loader/cfc7b0341c6e4f6ea1a9d256a30dba00.min.js", - "csp": "https://sentry.io/api/2/csp-report/?sentry_key=cfc7b0341c6e4f6ea1a9d256a30dba00", - "minidump": "https://sentry.io/api/2/minidump/?sentry_key=cfc7b0341c6e4f6ea1a9d256a30dba00", - "public": "https://cfc7b0341c6e4f6ea1a9d256a30dba00@sentry.io/2", - "secret": "https://cfc7b0341c6e4f6ea1a9d256a30dba00:a07dcd97aa56481f82aeabaed43ca448@sentry.io/2", - "security": "https://sentry.io/api/2/security/?sentry_key=cfc7b0341c6e4f6ea1a9d256a30dba00" - }, - "id": "cfc7b0341c6e4f6ea1a9d256a30dba00", - "isActive": true, - "label": "Fabulous Key", - "name": "Fabulous Key", - "projectId": 2, - "public": "cfc7b0341c6e4f6ea1a9d256a30dba00", - "rateLimit": null, - "secret": "a07dcd97aa56481f82aeabaed43ca448" - }]`) + { + "id": "da8d69cb17e80677b76e08fde4656b93", + "name": "Bold Oarfish", + "label": "Bold Oarfish", + "public": "da8d69cb17e80677b76e08fde4656b93", + "secret": "5c241ebc42ccfbec281cbefbedc7ab96", + "projectId": 4505281256090153, + "isActive": true, + "rateLimit": null, + "dsn": { + "secret": "https://a785682ddda742d7a8a4088810e67701:bcd99b3790b3441c85ce4b1eaa854f66@o4504765715316736.ingest.sentry.io/4505281256090153", + "public": "https://a785682ddda742d7a8a4088810e67791@o4504765715316736.ingest.sentry.io/4505281256090153", + "csp": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/csp-report/?sentry_key=a785682ddda719b7a8a4011110d75598", + "security": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/security/?sentry_key=a785682ddda719b7a8a4011110d75598", + "minidump": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/minidump/?sentry_key=a785682ddda719b7a8a4011110d75598", + "nel": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/nel/?sentry_key=a785682ddda719b7a8a4011110d75598", + "unreal": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/unreal/a785682ddda719b7a8a4011110d75598/", + "cdn": "https://js.sentry-cdn.com/a785682ddda719b7a8a4011110d75598.min.js", + "crons": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/crons/___MONITOR_SLUG___/a785682ddda719b7a8a4011110d75598/" + }, + "browserSdkVersion": "7.x", + "browserSdk": { + "choices": [ + [ + "latest", + "latest" + ], + [ + "7.x", + "7.x" + ] + ] + }, + "dateCreated": "2023-06-21T19:50:26.036254Z", + "dynamicSdkLoaderOptions": { + "hasReplay": true, + "hasPerformance": true, + "hasDebug": true + } + } + ]`) }) ctx := context.Background() @@ -58,22 +111,63 @@ func TestProjectKeysService_List(t *testing.T) { expected := []*ProjectKey{ { - ID: "cfc7b0341c6e4f6ea1a9d256a30dba00", - Name: "Fabulous Key", - Label: "Fabulous Key", - Public: "cfc7b0341c6e4f6ea1a9d256a30dba00", - Secret: "a07dcd97aa56481f82aeabaed43ca448", - ProjectID: json.Number("2"), + ID: "60120449b6b1d5e45f75561e6dabd80b", + Name: "Liked Pegasus", + Label: "Liked Pegasus", + Public: "60120449b6b1d5e45f75561e6dabd80b", + Secret: "189485c3b8ccf582bf5e12c530ef8858", + ProjectID: json.Number("4505281256090153"), IsActive: true, + RateLimit: &ProjectKeyRateLimit{ + Window: 7200, + Count: 1000, + }, DSN: ProjectKeyDSN{ - Secret: "https://cfc7b0341c6e4f6ea1a9d256a30dba00:a07dcd97aa56481f82aeabaed43ca448@sentry.io/2", - Public: "https://cfc7b0341c6e4f6ea1a9d256a30dba00@sentry.io/2", - CSP: "https://sentry.io/api/2/csp-report/?sentry_key=cfc7b0341c6e4f6ea1a9d256a30dba00", - Security: "https://sentry.io/api/2/security/?sentry_key=cfc7b0341c6e4f6ea1a9d256a30dba00", - Minidump: "https://sentry.io/api/2/minidump/?sentry_key=cfc7b0341c6e4f6ea1a9d256a30dba00", - CDN: "https://sentry.io/js-sdk-loader/cfc7b0341c6e4f6ea1a9d256a30dba00.min.js", + Secret: "https://a785682ddda742d7a8a4088810e67701:bcd99b3790b3441c85ce4b1eaa854f66@o4504765715316736.ingest.sentry.io/4505281256090153", + Public: "https://a785682ddda742d7a8a4088810e67791@o4504765715316736.ingest.sentry.io/4505281256090153", + CSP: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/csp-report/?sentry_key=a785682ddda719b7a8a4011110d75598", + Security: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/security/?sentry_key=a785682ddda719b7a8a4011110d75598", + Minidump: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/minidump/?sentry_key=a785682ddda719b7a8a4011110d75598", + NEL: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/nel/?sentry_key=a785682ddda719b7a8a4011110d75598", + Unreal: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/unreal/a785682ddda719b7a8a4011110d75598/", + CDN: "https://js.sentry-cdn.com/a785682ddda719b7a8a4011110d75598.min.js", + Crons: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/crons/___MONITOR_SLUG___/a785682ddda719b7a8a4011110d75598/", + }, + BrowserSDKVersion: "7.x", + DateCreated: mustParseTime("2023-06-21T19:50:26.036254Z"), + DynamicSDKLoaderOptions: ProjectKeyDynamicSDKLoaderOptions{ + HasReplay: true, + HasPerformance: true, + HasDebugFiles: true, + }, + }, + { + ID: "da8d69cb17e80677b76e08fde4656b93", + Name: "Bold Oarfish", + Label: "Bold Oarfish", + Public: "da8d69cb17e80677b76e08fde4656b93", + Secret: "5c241ebc42ccfbec281cbefbedc7ab96", + ProjectID: json.Number("4505281256090153"), + IsActive: true, + RateLimit: nil, + DSN: ProjectKeyDSN{ + Secret: "https://a785682ddda742d7a8a4088810e67701:bcd99b3790b3441c85ce4b1eaa854f66@o4504765715316736.ingest.sentry.io/4505281256090153", + Public: "https://a785682ddda742d7a8a4088810e67791@o4504765715316736.ingest.sentry.io/4505281256090153", + CSP: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/csp-report/?sentry_key=a785682ddda719b7a8a4011110d75598", + Security: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/security/?sentry_key=a785682ddda719b7a8a4011110d75598", + Minidump: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/minidump/?sentry_key=a785682ddda719b7a8a4011110d75598", + NEL: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/nel/?sentry_key=a785682ddda719b7a8a4011110d75598", + Unreal: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/unreal/a785682ddda719b7a8a4011110d75598/", + CDN: "https://js.sentry-cdn.com/a785682ddda719b7a8a4011110d75598.min.js", + Crons: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/crons/___MONITOR_SLUG___/a785682ddda719b7a8a4011110d75598/", + }, + BrowserSDKVersion: "7.x", + DateCreated: mustParseTime("2023-06-21T19:50:26.036254Z"), + DynamicSDKLoaderOptions: ProjectKeyDynamicSDKLoaderOptions{ + HasReplay: true, + HasPerformance: true, + HasDebugFiles: true, }, - DateCreated: mustParseTime("2018-09-20T15:48:07.397Z"), }, } assert.Equal(t, expected, projectKeys) @@ -145,7 +239,8 @@ func TestProjectKeysService_Create(t *testing.T) { Minidump: "https://sentry.io/api/2/minidump/?sentry_key=cfc7b0341c6e4f6ea1a9d256a30dba00", CDN: "https://sentry.io/js-sdk-loader/cfc7b0341c6e4f6ea1a9d256a30dba00.min.js", }, - DateCreated: mustParseTime("2018-09-20T15:48:07.397Z"), + BrowserSDKVersion: "4.x", + DateCreated: mustParseTime("2018-09-20T15:48:07.397Z"), } assert.Equal(t, expected, projectKey) } @@ -216,7 +311,8 @@ func TestProjectKeysService_Update(t *testing.T) { Minidump: "https://sentry.io/api/2/minidump/?sentry_key=cfc7b0341c6e4f6ea1a9d256a30dba00", CDN: "https://sentry.io/js-sdk-loader/cfc7b0341c6e4f6ea1a9d256a30dba00.min.js", }, - DateCreated: mustParseTime("2018-09-20T15:48:07.397Z"), + BrowserSDKVersion: "4.x", + DateCreated: mustParseTime("2018-09-20T15:48:07.397Z"), } assert.Equal(t, expected, projectKey) } @@ -300,7 +396,8 @@ func TestProjectKeysService_Update_RateLimit(t *testing.T) { Minidump: "https://sentry.io/api/2/minidump/?sentry_key=cfc7b0341c6e4f6ea1a9d256a30dba00", CDN: "https://sentry.io/js-sdk-loader/cfc7b0341c6e4f6ea1a9d256a30dba00.min.js", }, - DateCreated: mustParseTime("2018-09-20T15:48:07.397Z"), + BrowserSDKVersion: "4.x", + DateCreated: mustParseTime("2018-09-20T15:48:07.397Z"), } assert.Equal(t, expected, projectKey) }