Skip to content

Commit faafbec

Browse files
committed
feat: additional fields for project keys
1 parent b83a4d2 commit faafbec

File tree

2 files changed

+164
-56
lines changed

2 files changed

+164
-56
lines changed

sentry/project_keys.go

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,33 @@ type ProjectKeyDSN struct {
2020
CSP string `json:"csp"`
2121
Security string `json:"security"`
2222
Minidump string `json:"minidump"`
23+
NEL string `json:"nel"`
24+
Unreal string `json:"unreal"`
2325
CDN string `json:"cdn"`
26+
Crons string `json:"crons"`
27+
}
28+
29+
type ProjectKeyDynamicSDKLoaderOptions struct {
30+
HasReplay bool `json:"hasReplay"`
31+
HasPerformance bool `json:"hasPerformance"`
32+
HasDebugFiles bool `json:"hasDebug"`
2433
}
2534

2635
// ProjectKey represents a client key bound to a project.
2736
// https://github.com/getsentry/sentry/blob/9.0.0/src/sentry/api/serializers/models/project_key.py
2837
type ProjectKey struct {
29-
ID string `json:"id"`
30-
Name string `json:"name"`
31-
Label string `json:"label"`
32-
Public string `json:"public"`
33-
Secret string `json:"secret"`
34-
ProjectID json.Number `json:"projectId"`
35-
IsActive bool `json:"isActive"`
36-
RateLimit *ProjectKeyRateLimit `json:"rateLimit"`
37-
DSN ProjectKeyDSN `json:"dsn"`
38-
DateCreated time.Time `json:"dateCreated"`
38+
ID string `json:"id"`
39+
Name string `json:"name"`
40+
Label string `json:"label"`
41+
Public string `json:"public"`
42+
Secret string `json:"secret"`
43+
ProjectID json.Number `json:"projectId"`
44+
IsActive bool `json:"isActive"`
45+
RateLimit *ProjectKeyRateLimit `json:"rateLimit"`
46+
DSN ProjectKeyDSN `json:"dsn"`
47+
BrowserSDKVersion string `json:"browserSdkVersion"`
48+
DateCreated time.Time `json:"dateCreated"`
49+
DynamicSDKLoaderOptions ProjectKeyDynamicSDKLoaderOptions `json:"dynamicSdkLoaderOptions"`
3950
}
4051

4152
// ProjectKeysService provides methods for accessing Sentry project

sentry/project_keys_test.go

Lines changed: 143 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,91 @@ func TestProjectKeysService_List(t *testing.T) {
1818
assertMethod(t, "GET", r)
1919
w.Header().Set("Content-Type", "application/json")
2020
w.Header().Set("Link", "</api/0/projects/the-interstellar-jurisdiction/pump-station/keys/?&cursor=0:0:1>; rel=\"previous\"; results=\"true\"; cursor=\"0:0:1\", </api/0/projects/the-interstellar-jurisdiction/pump-station/keys/?&cursor=1584513610301:0:1>; rel=\"next\"; results=\"false\"; cursor=\"1584513610301:0:1\"")
21-
fmt.Fprint(w, `[{
22-
"browserSdk": {
23-
"choices": [
24-
[
25-
"latest",
26-
"latest"
27-
],
28-
[
29-
"4.x",
30-
"4.x"
21+
fmt.Fprint(w, `[
22+
{
23+
"id": "60120449b6b1d5e45f75561e6dabd80b",
24+
"name": "Liked Pegasus",
25+
"label": "Liked Pegasus",
26+
"public": "60120449b6b1d5e45f75561e6dabd80b",
27+
"secret": "189485c3b8ccf582bf5e12c530ef8858",
28+
"projectId": 4505281256090153,
29+
"isActive": true,
30+
"rateLimit": {
31+
"window": 7200,
32+
"count": 1000
33+
},
34+
"dsn": {
35+
"secret": "https://a785682ddda742d7a8a4088810e67701:bcd99b3790b3441c85ce4b1eaa854f66@o4504765715316736.ingest.sentry.io/4505281256090153",
36+
"public": "https://a785682ddda742d7a8a4088810e67791@o4504765715316736.ingest.sentry.io/4505281256090153",
37+
"csp": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/csp-report/?sentry_key=a785682ddda719b7a8a4011110d75598",
38+
"security": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/security/?sentry_key=a785682ddda719b7a8a4011110d75598",
39+
"minidump": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/minidump/?sentry_key=a785682ddda719b7a8a4011110d75598",
40+
"nel": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/nel/?sentry_key=a785682ddda719b7a8a4011110d75598",
41+
"unreal": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/unreal/a785682ddda719b7a8a4011110d75598/",
42+
"cdn": "https://js.sentry-cdn.com/a785682ddda719b7a8a4011110d75598.min.js",
43+
"crons": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/crons/___MONITOR_SLUG___/a785682ddda719b7a8a4011110d75598/"
44+
},
45+
"browserSdkVersion": "7.x",
46+
"browserSdk": {
47+
"choices": [
48+
[
49+
"latest",
50+
"latest"
51+
],
52+
[
53+
"7.x",
54+
"7.x"
55+
]
3156
]
32-
]
57+
},
58+
"dateCreated": "2023-06-21T19:50:26.036254Z",
59+
"dynamicSdkLoaderOptions": {
60+
"hasReplay": true,
61+
"hasPerformance": true,
62+
"hasDebug": true
63+
}
3364
},
34-
"browserSdkVersion": "4.x",
35-
"dateCreated": "2018-09-20T15:48:07.397Z",
36-
"dsn": {
37-
"cdn": "https://sentry.io/js-sdk-loader/cfc7b0341c6e4f6ea1a9d256a30dba00.min.js",
38-
"csp": "https://sentry.io/api/2/csp-report/?sentry_key=cfc7b0341c6e4f6ea1a9d256a30dba00",
39-
"minidump": "https://sentry.io/api/2/minidump/?sentry_key=cfc7b0341c6e4f6ea1a9d256a30dba00",
40-
"public": "https://[email protected]/2",
41-
"secret": "https://cfc7b0341c6e4f6ea1a9d256a30dba00:[email protected]/2",
42-
"security": "https://sentry.io/api/2/security/?sentry_key=cfc7b0341c6e4f6ea1a9d256a30dba00"
43-
},
44-
"id": "cfc7b0341c6e4f6ea1a9d256a30dba00",
45-
"isActive": true,
46-
"label": "Fabulous Key",
47-
"name": "Fabulous Key",
48-
"projectId": 2,
49-
"public": "cfc7b0341c6e4f6ea1a9d256a30dba00",
50-
"rateLimit": null,
51-
"secret": "a07dcd97aa56481f82aeabaed43ca448"
52-
}]`)
65+
{
66+
"id": "da8d69cb17e80677b76e08fde4656b93",
67+
"name": "Bold Oarfish",
68+
"label": "Bold Oarfish",
69+
"public": "da8d69cb17e80677b76e08fde4656b93",
70+
"secret": "5c241ebc42ccfbec281cbefbedc7ab96",
71+
"projectId": 4505281256090153,
72+
"isActive": true,
73+
"rateLimit": null,
74+
"dsn": {
75+
"secret": "https://a785682ddda742d7a8a4088810e67701:bcd99b3790b3441c85ce4b1eaa854f66@o4504765715316736.ingest.sentry.io/4505281256090153",
76+
"public": "https://a785682ddda742d7a8a4088810e67791@o4504765715316736.ingest.sentry.io/4505281256090153",
77+
"csp": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/csp-report/?sentry_key=a785682ddda719b7a8a4011110d75598",
78+
"security": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/security/?sentry_key=a785682ddda719b7a8a4011110d75598",
79+
"minidump": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/minidump/?sentry_key=a785682ddda719b7a8a4011110d75598",
80+
"nel": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/nel/?sentry_key=a785682ddda719b7a8a4011110d75598",
81+
"unreal": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/unreal/a785682ddda719b7a8a4011110d75598/",
82+
"cdn": "https://js.sentry-cdn.com/a785682ddda719b7a8a4011110d75598.min.js",
83+
"crons": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/crons/___MONITOR_SLUG___/a785682ddda719b7a8a4011110d75598/"
84+
},
85+
"browserSdkVersion": "7.x",
86+
"browserSdk": {
87+
"choices": [
88+
[
89+
"latest",
90+
"latest"
91+
],
92+
[
93+
"7.x",
94+
"7.x"
95+
]
96+
]
97+
},
98+
"dateCreated": "2023-06-21T19:50:26.036254Z",
99+
"dynamicSdkLoaderOptions": {
100+
"hasReplay": true,
101+
"hasPerformance": true,
102+
"hasDebug": true
103+
}
104+
}
105+
]`)
53106
})
54107

55108
ctx := context.Background()
@@ -58,22 +111,63 @@ func TestProjectKeysService_List(t *testing.T) {
58111

59112
expected := []*ProjectKey{
60113
{
61-
ID: "cfc7b0341c6e4f6ea1a9d256a30dba00",
62-
Name: "Fabulous Key",
63-
Label: "Fabulous Key",
64-
Public: "cfc7b0341c6e4f6ea1a9d256a30dba00",
65-
Secret: "a07dcd97aa56481f82aeabaed43ca448",
66-
ProjectID: json.Number("2"),
114+
ID: "60120449b6b1d5e45f75561e6dabd80b",
115+
Name: "Liked Pegasus",
116+
Label: "Liked Pegasus",
117+
Public: "60120449b6b1d5e45f75561e6dabd80b",
118+
Secret: "189485c3b8ccf582bf5e12c530ef8858",
119+
ProjectID: json.Number("4505281256090153"),
67120
IsActive: true,
121+
RateLimit: &ProjectKeyRateLimit{
122+
Window: 7200,
123+
Count: 1000,
124+
},
68125
DSN: ProjectKeyDSN{
69-
Secret: "https://cfc7b0341c6e4f6ea1a9d256a30dba00:[email protected]/2",
70-
Public: "https://[email protected]/2",
71-
CSP: "https://sentry.io/api/2/csp-report/?sentry_key=cfc7b0341c6e4f6ea1a9d256a30dba00",
72-
Security: "https://sentry.io/api/2/security/?sentry_key=cfc7b0341c6e4f6ea1a9d256a30dba00",
73-
Minidump: "https://sentry.io/api/2/minidump/?sentry_key=cfc7b0341c6e4f6ea1a9d256a30dba00",
74-
CDN: "https://sentry.io/js-sdk-loader/cfc7b0341c6e4f6ea1a9d256a30dba00.min.js",
126+
Secret: "https://a785682ddda742d7a8a4088810e67701:bcd99b3790b3441c85ce4b1eaa854f66@o4504765715316736.ingest.sentry.io/4505281256090153",
127+
Public: "https://a785682ddda742d7a8a4088810e67791@o4504765715316736.ingest.sentry.io/4505281256090153",
128+
CSP: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/csp-report/?sentry_key=a785682ddda719b7a8a4011110d75598",
129+
Security: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/security/?sentry_key=a785682ddda719b7a8a4011110d75598",
130+
Minidump: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/minidump/?sentry_key=a785682ddda719b7a8a4011110d75598",
131+
NEL: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/nel/?sentry_key=a785682ddda719b7a8a4011110d75598",
132+
Unreal: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/unreal/a785682ddda719b7a8a4011110d75598/",
133+
CDN: "https://js.sentry-cdn.com/a785682ddda719b7a8a4011110d75598.min.js",
134+
Crons: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/crons/___MONITOR_SLUG___/a785682ddda719b7a8a4011110d75598/",
135+
},
136+
BrowserSDKVersion: "7.x",
137+
DateCreated: mustParseTime("2023-06-21T19:50:26.036254Z"),
138+
DynamicSDKLoaderOptions: ProjectKeyDynamicSDKLoaderOptions{
139+
HasReplay: true,
140+
HasPerformance: true,
141+
HasDebugFiles: true,
142+
},
143+
},
144+
{
145+
ID: "da8d69cb17e80677b76e08fde4656b93",
146+
Name: "Bold Oarfish",
147+
Label: "Bold Oarfish",
148+
Public: "da8d69cb17e80677b76e08fde4656b93",
149+
Secret: "5c241ebc42ccfbec281cbefbedc7ab96",
150+
ProjectID: json.Number("4505281256090153"),
151+
IsActive: true,
152+
RateLimit: nil,
153+
DSN: ProjectKeyDSN{
154+
Secret: "https://a785682ddda742d7a8a4088810e67701:bcd99b3790b3441c85ce4b1eaa854f66@o4504765715316736.ingest.sentry.io/4505281256090153",
155+
Public: "https://a785682ddda742d7a8a4088810e67791@o4504765715316736.ingest.sentry.io/4505281256090153",
156+
CSP: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/csp-report/?sentry_key=a785682ddda719b7a8a4011110d75598",
157+
Security: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/security/?sentry_key=a785682ddda719b7a8a4011110d75598",
158+
Minidump: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/minidump/?sentry_key=a785682ddda719b7a8a4011110d75598",
159+
NEL: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/nel/?sentry_key=a785682ddda719b7a8a4011110d75598",
160+
Unreal: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/unreal/a785682ddda719b7a8a4011110d75598/",
161+
CDN: "https://js.sentry-cdn.com/a785682ddda719b7a8a4011110d75598.min.js",
162+
Crons: "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/crons/___MONITOR_SLUG___/a785682ddda719b7a8a4011110d75598/",
163+
},
164+
BrowserSDKVersion: "7.x",
165+
DateCreated: mustParseTime("2023-06-21T19:50:26.036254Z"),
166+
DynamicSDKLoaderOptions: ProjectKeyDynamicSDKLoaderOptions{
167+
HasReplay: true,
168+
HasPerformance: true,
169+
HasDebugFiles: true,
75170
},
76-
DateCreated: mustParseTime("2018-09-20T15:48:07.397Z"),
77171
},
78172
}
79173
assert.Equal(t, expected, projectKeys)
@@ -145,7 +239,8 @@ func TestProjectKeysService_Create(t *testing.T) {
145239
Minidump: "https://sentry.io/api/2/minidump/?sentry_key=cfc7b0341c6e4f6ea1a9d256a30dba00",
146240
CDN: "https://sentry.io/js-sdk-loader/cfc7b0341c6e4f6ea1a9d256a30dba00.min.js",
147241
},
148-
DateCreated: mustParseTime("2018-09-20T15:48:07.397Z"),
242+
BrowserSDKVersion: "4.x",
243+
DateCreated: mustParseTime("2018-09-20T15:48:07.397Z"),
149244
}
150245
assert.Equal(t, expected, projectKey)
151246
}
@@ -216,7 +311,8 @@ func TestProjectKeysService_Update(t *testing.T) {
216311
Minidump: "https://sentry.io/api/2/minidump/?sentry_key=cfc7b0341c6e4f6ea1a9d256a30dba00",
217312
CDN: "https://sentry.io/js-sdk-loader/cfc7b0341c6e4f6ea1a9d256a30dba00.min.js",
218313
},
219-
DateCreated: mustParseTime("2018-09-20T15:48:07.397Z"),
314+
BrowserSDKVersion: "4.x",
315+
DateCreated: mustParseTime("2018-09-20T15:48:07.397Z"),
220316
}
221317
assert.Equal(t, expected, projectKey)
222318
}
@@ -300,7 +396,8 @@ func TestProjectKeysService_Update_RateLimit(t *testing.T) {
300396
Minidump: "https://sentry.io/api/2/minidump/?sentry_key=cfc7b0341c6e4f6ea1a9d256a30dba00",
301397
CDN: "https://sentry.io/js-sdk-loader/cfc7b0341c6e4f6ea1a9d256a30dba00.min.js",
302398
},
303-
DateCreated: mustParseTime("2018-09-20T15:48:07.397Z"),
399+
BrowserSDKVersion: "4.x",
400+
DateCreated: mustParseTime("2018-09-20T15:48:07.397Z"),
304401
}
305402
assert.Equal(t, expected, projectKey)
306403
}

0 commit comments

Comments
 (0)