@sentry/junior-sentry 0.265.0 → 0.267.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/{chunk-KK3VWIJ2.js → chunk-6QQNR5HC.js} +179 -66
- package/dist/events/issue.d.ts +14 -1
- package/dist/events/metric-alert.d.ts +15 -1
- package/dist/events/scope.d.ts +17 -0
- package/dist/index.js +22 -5
- package/dist/testing.js +1 -1
- package/dist/webhooks/events.d.ts +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -52,6 +52,8 @@ Junior verifies `Sentry-Hook-Signature`, reads the org slug from the signed payl
|
|
|
52
52
|
- `issue.created` for `org/project#issueId` and `org/project`.
|
|
53
53
|
- `metric_alert.critical`, `metric_alert.warning`, and `metric_alert.resolved` for `metric-alert:org/alertRuleId` and for `org/project` of each project on the alert rule.
|
|
54
54
|
|
|
55
|
+
Each event has trusted data from Sentry. Issue events have `issueId`, `level`, `priority`, `issueCategory`, `issueType`, and `url` when Sentry sends them. Metric alert events have `alertRuleId`, `incidentId`, and `url`. On `org/project`, watches and event automations can filter issue events on `level`, `priority`, and `issueCategory`, and metric alert events on `alertRuleId`. The issue title, culprit, and alert description stay untrusted text.
|
|
56
|
+
|
|
55
57
|
Create watches/event automations before the webhook arrives; unmatched deliveries are not replayed.
|
|
56
58
|
|
|
57
59
|
Full guide: https://junior.sentry.dev/extend/sentry-plugin/
|
|
@@ -1,5 +1,61 @@
|
|
|
1
|
+
// src/events/issue.ts
|
|
2
|
+
import {
|
|
3
|
+
eventMatchFieldsSchema as eventMatchFieldsSchema2
|
|
4
|
+
} from "@sentry/junior-plugin-api";
|
|
5
|
+
|
|
6
|
+
// src/events/scope.ts
|
|
7
|
+
import {
|
|
8
|
+
eventMatchFieldsSchema
|
|
9
|
+
} from "@sentry/junior-plugin-api";
|
|
10
|
+
import { z } from "zod";
|
|
11
|
+
var sentrySlugDataSchema = z.string().min(1).toLowerCase();
|
|
12
|
+
function sentryProjectsMatchFields(events) {
|
|
13
|
+
return eventMatchFieldsSchema.parse({
|
|
14
|
+
projects: {
|
|
15
|
+
kind: "string",
|
|
16
|
+
case: "lower",
|
|
17
|
+
list: true,
|
|
18
|
+
description: "lowercase Sentry project slugs, such as junior; an issue has one, a metric alert has the projects of its rule",
|
|
19
|
+
events
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
1
24
|
// src/events/issue.ts
|
|
2
25
|
var SENTRY_ISSUE_EVENTS = ["issue.created"];
|
|
26
|
+
var SENTRY_ISSUE_LEVELS = [
|
|
27
|
+
"fatal",
|
|
28
|
+
"error",
|
|
29
|
+
"warning",
|
|
30
|
+
"info",
|
|
31
|
+
"debug"
|
|
32
|
+
];
|
|
33
|
+
var SENTRY_ISSUE_PRIORITIES = ["high", "medium", "low"];
|
|
34
|
+
var SENTRY_ISSUE_MATCH_FIELDS = eventMatchFieldsSchema2.parse({
|
|
35
|
+
...sentryProjectsMatchFields(SENTRY_ISSUE_EVENTS),
|
|
36
|
+
issueId: {
|
|
37
|
+
kind: "string",
|
|
38
|
+
description: "numeric Sentry issue id as text, such as 7513266773",
|
|
39
|
+
events: [...SENTRY_ISSUE_EVENTS]
|
|
40
|
+
},
|
|
41
|
+
level: {
|
|
42
|
+
kind: "string",
|
|
43
|
+
description: "issue level: fatal, error, warning, info, or debug",
|
|
44
|
+
enum: [...SENTRY_ISSUE_LEVELS],
|
|
45
|
+
events: [...SENTRY_ISSUE_EVENTS]
|
|
46
|
+
},
|
|
47
|
+
priority: {
|
|
48
|
+
kind: "string",
|
|
49
|
+
description: "issue priority: high, medium, or low",
|
|
50
|
+
enum: [...SENTRY_ISSUE_PRIORITIES],
|
|
51
|
+
events: [...SENTRY_ISSUE_EVENTS]
|
|
52
|
+
},
|
|
53
|
+
issueCategory: {
|
|
54
|
+
kind: "string",
|
|
55
|
+
description: "kind of problem, such as error, performance, cron, or feedback",
|
|
56
|
+
events: [...SENTRY_ISSUE_EVENTS]
|
|
57
|
+
}
|
|
58
|
+
});
|
|
3
59
|
function sentryIssueResource(input) {
|
|
4
60
|
return {
|
|
5
61
|
identifier: `${input.org}/${input.project}#${input.issueId}`,
|
|
@@ -16,6 +72,14 @@ function sentryProjectResource(input) {
|
|
|
16
72
|
}
|
|
17
73
|
|
|
18
74
|
// src/events/metric-alert.ts
|
|
75
|
+
import {
|
|
76
|
+
eventMatchFieldsSchema as eventMatchFieldsSchema3
|
|
77
|
+
} from "@sentry/junior-plugin-api";
|
|
78
|
+
var SENTRY_METRIC_ALERT_ACTIONS = [
|
|
79
|
+
"critical",
|
|
80
|
+
"warning",
|
|
81
|
+
"resolved"
|
|
82
|
+
];
|
|
19
83
|
var SENTRY_METRIC_ALERT_EVENTS = [
|
|
20
84
|
"metric_alert.critical",
|
|
21
85
|
"metric_alert.warning",
|
|
@@ -25,6 +89,14 @@ var SENTRY_METRIC_ALERT_SUGGESTED_EVENTS = [
|
|
|
25
89
|
"metric_alert.critical",
|
|
26
90
|
"metric_alert.warning"
|
|
27
91
|
];
|
|
92
|
+
var SENTRY_METRIC_ALERT_MATCH_FIELDS = eventMatchFieldsSchema3.parse({
|
|
93
|
+
...sentryProjectsMatchFields(SENTRY_METRIC_ALERT_EVENTS),
|
|
94
|
+
alertRuleId: {
|
|
95
|
+
kind: "string",
|
|
96
|
+
description: "id of the Sentry metric alert rule, such as 7",
|
|
97
|
+
events: [...SENTRY_METRIC_ALERT_EVENTS]
|
|
98
|
+
}
|
|
99
|
+
});
|
|
28
100
|
var SENTRY_METRIC_ALERT_IDENTIFIER = {
|
|
29
101
|
format: "metric-alert:org/alertRuleId",
|
|
30
102
|
pattern: String.raw`^metric-alert:[^\s/:#]+\/\d+$`
|
|
@@ -38,52 +110,55 @@ function sentryMetricAlertResource(input) {
|
|
|
38
110
|
}
|
|
39
111
|
|
|
40
112
|
// src/webhooks/events.ts
|
|
41
|
-
import {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
113
|
+
import {
|
|
114
|
+
eventDataSchema
|
|
115
|
+
} from "@sentry/junior-plugin-api";
|
|
116
|
+
import { z as z2 } from "zod";
|
|
117
|
+
var issueLevelSchema = z2.enum(SENTRY_ISSUE_LEVELS).optional().catch(void 0);
|
|
118
|
+
var issuePrioritySchema = z2.enum(SENTRY_ISSUE_PRIORITIES).optional().catch(void 0);
|
|
119
|
+
var issueWebhookSchema = z2.object({
|
|
120
|
+
action: z2.literal("created"),
|
|
121
|
+
data: z2.object({
|
|
122
|
+
issue: z2.object({
|
|
123
|
+
culprit: z2.string().optional(),
|
|
124
|
+
firstSeen: z2.string().optional(),
|
|
125
|
+
id: z2.string().min(1),
|
|
126
|
+
issueCategory: z2.string().optional(),
|
|
127
|
+
issueType: z2.string().optional(),
|
|
128
|
+
level: issueLevelSchema,
|
|
129
|
+
priority: issuePrioritySchema,
|
|
130
|
+
project: z2.object({ slug: z2.string().min(1) }).passthrough(),
|
|
131
|
+
title: z2.string().optional(),
|
|
132
|
+
url: z2.string().url(),
|
|
133
|
+
web_url: z2.string().url().optional()
|
|
59
134
|
}).passthrough()
|
|
60
135
|
}),
|
|
61
|
-
installation:
|
|
136
|
+
installation: z2.object({ uuid: z2.string().min(1) }).passthrough()
|
|
62
137
|
}).passthrough();
|
|
63
|
-
var metricAlertWebhookSchema =
|
|
64
|
-
action:
|
|
65
|
-
data:
|
|
66
|
-
description_text:
|
|
67
|
-
description_title:
|
|
68
|
-
metric_alert:
|
|
69
|
-
alert_rule:
|
|
70
|
-
id:
|
|
71
|
-
projects:
|
|
138
|
+
var metricAlertWebhookSchema = z2.object({
|
|
139
|
+
action: z2.enum(SENTRY_METRIC_ALERT_ACTIONS),
|
|
140
|
+
data: z2.object({
|
|
141
|
+
description_text: z2.string().optional(),
|
|
142
|
+
description_title: z2.string().optional(),
|
|
143
|
+
metric_alert: z2.object({
|
|
144
|
+
alert_rule: z2.object({
|
|
145
|
+
id: z2.coerce.string().min(1),
|
|
146
|
+
projects: z2.array(z2.string().min(1)).optional()
|
|
72
147
|
}).passthrough(),
|
|
73
|
-
id:
|
|
148
|
+
id: z2.coerce.string().min(1)
|
|
74
149
|
}).passthrough(),
|
|
75
|
-
web_url:
|
|
150
|
+
web_url: z2.string().url()
|
|
76
151
|
}),
|
|
77
|
-
installation:
|
|
152
|
+
installation: z2.object({ uuid: z2.string().min(1) }).passthrough()
|
|
78
153
|
}).passthrough();
|
|
79
|
-
function organizationSlug(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
154
|
+
function organizationSlug(url) {
|
|
155
|
+
const parsed = z2.url().safeParse(url);
|
|
156
|
+
if (!parsed.success) return void 0;
|
|
157
|
+
const { hostname, pathname } = new URL(parsed.data);
|
|
158
|
+
const segments = pathname.split("/").filter(Boolean);
|
|
159
|
+
const index = segments.indexOf("organizations");
|
|
160
|
+
const slug = index >= 0 ? segments[index + 1] : hostname.split(".").length >= 3 ? hostname.split(".")[0] : void 0;
|
|
161
|
+
return slug?.toLowerCase() || void 0;
|
|
87
162
|
}
|
|
88
163
|
function providerTime(value) {
|
|
89
164
|
if (!value) return void 0;
|
|
@@ -97,28 +172,59 @@ function providerTime(value) {
|
|
|
97
172
|
function issueText(issue) {
|
|
98
173
|
const parts = [
|
|
99
174
|
issue.title ? `Title: ${issue.title}` : void 0,
|
|
100
|
-
issue.culprit ? `Culprit: ${issue.culprit}` : void 0
|
|
101
|
-
issue.level ? `Level: ${issue.level}` : void 0,
|
|
102
|
-
issue.priority ? `Priority: ${issue.priority}` : void 0,
|
|
103
|
-
issue.issueCategory ? `Category: ${issue.issueCategory}` : void 0,
|
|
104
|
-
issue.issueType ? `Type: ${issue.issueType}` : void 0,
|
|
105
|
-
issue.status ? `Status: ${issue.status}` : void 0,
|
|
106
|
-
issue.substatus ? `Substatus: ${issue.substatus}` : void 0,
|
|
107
|
-
issue.web_url ? `URL: ${issue.web_url}` : void 0
|
|
175
|
+
issue.culprit ? `Culprit: ${issue.culprit}` : void 0
|
|
108
176
|
].filter((part) => part !== void 0);
|
|
109
177
|
return parts.length > 0 ? parts.join("\n") : void 0;
|
|
110
178
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
179
|
+
var issueEventDataSchema = z2.object({
|
|
180
|
+
projects: z2.array(sentrySlugDataSchema).length(1),
|
|
181
|
+
issueId: z2.string().min(1),
|
|
182
|
+
level: z2.enum(SENTRY_ISSUE_LEVELS).optional(),
|
|
183
|
+
priority: z2.enum(SENTRY_ISSUE_PRIORITIES).optional(),
|
|
184
|
+
issueCategory: z2.string().min(1).optional(),
|
|
185
|
+
issueType: z2.string().min(1).optional(),
|
|
186
|
+
url: z2.string().url().optional()
|
|
187
|
+
}).strict();
|
|
188
|
+
function issueData(issue) {
|
|
189
|
+
return issueEventDataSchema.parse(
|
|
190
|
+
definedValues({
|
|
191
|
+
projects: [issue.project.slug],
|
|
192
|
+
issueId: issue.id,
|
|
193
|
+
level: issue.level,
|
|
194
|
+
priority: issue.priority,
|
|
195
|
+
issueCategory: issue.issueCategory || void 0,
|
|
196
|
+
issueType: issue.issueType || void 0,
|
|
197
|
+
url: issue.web_url
|
|
198
|
+
})
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
var metricAlertEventDataSchema = z2.object({
|
|
202
|
+
projects: z2.array(sentrySlugDataSchema).min(1).optional(),
|
|
203
|
+
alertRuleId: z2.string().min(1),
|
|
204
|
+
incidentId: z2.string().min(1),
|
|
205
|
+
url: z2.string().url()
|
|
206
|
+
}).strict();
|
|
207
|
+
function definedValues(data) {
|
|
208
|
+
return Object.fromEntries(
|
|
209
|
+
Object.entries(data).filter(([, value]) => value !== void 0)
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
function metricAlertData(input, projects) {
|
|
213
|
+
const data = metricAlertEventDataSchema.parse(
|
|
214
|
+
definedValues({
|
|
215
|
+
...input,
|
|
216
|
+
projects: projects.length > 0 ? projects : void 0
|
|
217
|
+
})
|
|
218
|
+
);
|
|
219
|
+
if (eventDataSchema.safeParse(data).success) return data;
|
|
220
|
+
const { projects: _projects, ...rest } = data;
|
|
221
|
+
return rest;
|
|
116
222
|
}
|
|
117
223
|
function normalizeIssueEvents(input) {
|
|
118
224
|
const parsed = issueWebhookSchema.safeParse(input.body);
|
|
119
|
-
if (!parsed.success
|
|
225
|
+
if (!parsed.success) return [];
|
|
120
226
|
const issue = parsed.data.data.issue;
|
|
121
|
-
const org = organizationSlug(issue.url)
|
|
227
|
+
const org = organizationSlug(issue.url);
|
|
122
228
|
if (!org) return [];
|
|
123
229
|
const issueResource = sentryIssueResource({
|
|
124
230
|
issueId: issue.id,
|
|
@@ -137,8 +243,10 @@ function normalizeIssueEvents(input) {
|
|
|
137
243
|
// idempotency across repeated deliveries of the same lifecycle event.
|
|
138
244
|
eventKey: `sentry:${issueResource.identifier}:${eventType}`,
|
|
139
245
|
eventType,
|
|
246
|
+
objectType: "task",
|
|
140
247
|
occurredAtMs,
|
|
141
248
|
trustedSummary: `${issueResource.label} was created.`,
|
|
249
|
+
data: issueData(issue),
|
|
142
250
|
...untrustedText ? { untrustedText } : void 0
|
|
143
251
|
};
|
|
144
252
|
return [
|
|
@@ -150,30 +258,33 @@ function normalizeMetricAlertEvents(input) {
|
|
|
150
258
|
const parsed = metricAlertWebhookSchema.safeParse(input.body);
|
|
151
259
|
if (!parsed.success) return [];
|
|
152
260
|
const eventType = `metric_alert.${parsed.data.action}`;
|
|
153
|
-
if (!SENTRY_METRIC_ALERT_EVENTS.includes(eventType)) {
|
|
154
|
-
return [];
|
|
155
|
-
}
|
|
156
261
|
const { data } = parsed.data;
|
|
157
|
-
const org =
|
|
262
|
+
const org = organizationSlug(data.web_url);
|
|
158
263
|
if (!org) return [];
|
|
159
264
|
const alertRuleId = data.metric_alert.alert_rule.id;
|
|
160
265
|
const incidentId = data.metric_alert.id;
|
|
161
266
|
const resource = sentryMetricAlertResource({ alertRuleId, org });
|
|
162
|
-
const untrustedText = [
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
267
|
+
const untrustedText = [data.description_title, data.description_text].filter((part) => Boolean(part)).join("\n");
|
|
268
|
+
const projects = [
|
|
269
|
+
...new Set(
|
|
270
|
+
(data.metric_alert.alert_rule.projects ?? []).map(
|
|
271
|
+
(project) => project.toLowerCase()
|
|
272
|
+
)
|
|
273
|
+
)
|
|
274
|
+
];
|
|
167
275
|
const event = {
|
|
168
276
|
// One event per incident state. Sentry retries get new Request-IDs.
|
|
169
277
|
eventKey: `sentry:${resource.identifier}:${incidentId}:${eventType}`,
|
|
170
278
|
eventType,
|
|
279
|
+
objectType: "item",
|
|
171
280
|
occurredAtMs: providerTime(input.hookTimestamp) ?? Date.now(),
|
|
172
281
|
trustedSummary: `${resource.label} is ${parsed.data.action}.`,
|
|
173
|
-
data:
|
|
174
|
-
|
|
282
|
+
data: metricAlertData(
|
|
283
|
+
{ alertRuleId, incidentId, url: data.web_url },
|
|
284
|
+
projects
|
|
285
|
+
),
|
|
286
|
+
...untrustedText ? { untrustedText } : void 0
|
|
175
287
|
};
|
|
176
|
-
const projects = [...new Set(data.metric_alert.alert_rule.projects ?? [])];
|
|
177
288
|
return [
|
|
178
289
|
{ ...event, identifier: resource.identifier },
|
|
179
290
|
...projects.map((project) => ({
|
|
@@ -253,10 +364,12 @@ function sentryWebhookSecret() {
|
|
|
253
364
|
|
|
254
365
|
export {
|
|
255
366
|
SENTRY_ISSUE_EVENTS,
|
|
367
|
+
SENTRY_ISSUE_MATCH_FIELDS,
|
|
256
368
|
sentryIssueResource,
|
|
257
369
|
sentryProjectResource,
|
|
258
370
|
SENTRY_METRIC_ALERT_EVENTS,
|
|
259
371
|
SENTRY_METRIC_ALERT_SUGGESTED_EVENTS,
|
|
372
|
+
SENTRY_METRIC_ALERT_MATCH_FIELDS,
|
|
260
373
|
SENTRY_METRIC_ALERT_IDENTIFIER,
|
|
261
374
|
normalizeSentryEvents,
|
|
262
375
|
createSentryWebhookRoute,
|
package/dist/events/issue.d.ts
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type SubscribableResource } from "@sentry/junior-plugin-api";
|
|
2
2
|
export declare const SENTRY_ISSUE_EVENTS: readonly ["issue.created"];
|
|
3
|
+
/** Issue levels that Sentry sets, from most to least severe. */
|
|
4
|
+
export declare const SENTRY_ISSUE_LEVELS: readonly ["fatal", "error", "warning", "info", "debug"];
|
|
5
|
+
/** Issue priorities that Sentry sets. */
|
|
6
|
+
export declare const SENTRY_ISSUE_PRIORITIES: readonly ["high", "medium", "low"];
|
|
7
|
+
/** Trusted values that Sentry issue events set, when the webhook has them. */
|
|
8
|
+
export declare const SENTRY_ISSUE_MATCH_FIELDS: Record<string, {
|
|
9
|
+
kind: "boolean" | "number" | "string";
|
|
10
|
+
description: string;
|
|
11
|
+
enum?: string[] | undefined;
|
|
12
|
+
list?: true | undefined;
|
|
13
|
+
case?: "lower" | "upper" | undefined;
|
|
14
|
+
events?: string[] | undefined;
|
|
15
|
+
}>;
|
|
3
16
|
/** Build the stable Sentry issue identity shared by tools and webhooks. */
|
|
4
17
|
export declare function sentryIssueResource(input: {
|
|
5
18
|
issueId: string;
|
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type SubscribableResource } from "@sentry/junior-plugin-api";
|
|
2
|
+
/** The `action` values of Sentry metric alert webhooks. */
|
|
3
|
+
export declare const SENTRY_METRIC_ALERT_ACTIONS: readonly ["critical", "warning", "resolved"];
|
|
2
4
|
/** Metric alert states, named after Sentry's `metric_alert.<action>` webhooks. */
|
|
3
5
|
export declare const SENTRY_METRIC_ALERT_EVENTS: readonly ["metric_alert.critical", "metric_alert.warning", "metric_alert.resolved"];
|
|
4
6
|
export declare const SENTRY_METRIC_ALERT_SUGGESTED_EVENTS: string[];
|
|
7
|
+
/**
|
|
8
|
+
* Trusted values that Sentry metric alert events set. `projects` is missing
|
|
9
|
+
* when the rule lists no projects or too many to fit in event data.
|
|
10
|
+
*/
|
|
11
|
+
export declare const SENTRY_METRIC_ALERT_MATCH_FIELDS: Record<string, {
|
|
12
|
+
kind: "boolean" | "number" | "string";
|
|
13
|
+
description: string;
|
|
14
|
+
enum?: string[] | undefined;
|
|
15
|
+
list?: true | undefined;
|
|
16
|
+
case?: "lower" | "upper" | undefined;
|
|
17
|
+
events?: string[] | undefined;
|
|
18
|
+
}>;
|
|
5
19
|
/** The identifier shape that `sentryMetricAlertResource` builds. */
|
|
6
20
|
export declare const SENTRY_METRIC_ALERT_IDENTIFIER: {
|
|
7
21
|
format: string;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type EventMatchFields } from "@sentry/junior-plugin-api";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/**
|
|
4
|
+
* A project slug in event data. It is lowercase, the same form as
|
|
5
|
+
* identifiers, because the plugin lowercases every identifier.
|
|
6
|
+
*/
|
|
7
|
+
export declare const sentrySlugDataSchema: z.ZodString;
|
|
8
|
+
/**
|
|
9
|
+
* Filter on the projects of a Sentry event. `projects` is a list on every
|
|
10
|
+
* event, so one filter fits an issue, which has one project, and a metric
|
|
11
|
+
* alert, whose rule can cover several projects.
|
|
12
|
+
*
|
|
13
|
+
* There is no `org` filter. One Sentry integration belongs to one org, and
|
|
14
|
+
* its webhook secret scopes every delivery to that org. So `org` is the same
|
|
15
|
+
* on every event of an install, and a filter on it cannot narrow anything.
|
|
16
|
+
*/
|
|
17
|
+
export declare function sentryProjectsMatchFields(events: readonly string[]): EventMatchFields;
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
SENTRY_ISSUE_EVENTS,
|
|
3
|
+
SENTRY_ISSUE_MATCH_FIELDS,
|
|
3
4
|
SENTRY_METRIC_ALERT_EVENTS,
|
|
4
5
|
SENTRY_METRIC_ALERT_IDENTIFIER,
|
|
6
|
+
SENTRY_METRIC_ALERT_MATCH_FIELDS,
|
|
5
7
|
SENTRY_METRIC_ALERT_SUGGESTED_EVENTS,
|
|
6
8
|
createSentryWebhookRoute,
|
|
7
9
|
sentryWebhookSecret
|
|
8
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-6QQNR5HC.js";
|
|
9
11
|
|
|
10
12
|
// src/index.ts
|
|
11
13
|
import {
|
|
12
|
-
defineJuniorPlugin
|
|
14
|
+
defineJuniorPlugin,
|
|
15
|
+
mergeEventMatchFields
|
|
13
16
|
} from "@sentry/junior-plugin-api";
|
|
14
17
|
|
|
15
18
|
// src/org-read.ts
|
|
@@ -101,7 +104,8 @@ function sentryPlugin() {
|
|
|
101
104
|
{
|
|
102
105
|
type: "issue",
|
|
103
106
|
supportedEvents: [...SENTRY_ISSUE_EVENTS],
|
|
104
|
-
suggestedEvents: [...SENTRY_ISSUE_EVENTS]
|
|
107
|
+
suggestedEvents: [...SENTRY_ISSUE_EVENTS],
|
|
108
|
+
matchFields: SENTRY_ISSUE_MATCH_FIELDS
|
|
105
109
|
},
|
|
106
110
|
{
|
|
107
111
|
type: "project",
|
|
@@ -112,15 +116,28 @@ function sentryPlugin() {
|
|
|
112
116
|
suggestedEvents: [
|
|
113
117
|
...SENTRY_ISSUE_EVENTS,
|
|
114
118
|
...SENTRY_METRIC_ALERT_SUGGESTED_EVENTS
|
|
115
|
-
]
|
|
119
|
+
],
|
|
120
|
+
matchFields: mergeEventMatchFields(
|
|
121
|
+
SENTRY_ISSUE_MATCH_FIELDS,
|
|
122
|
+
SENTRY_METRIC_ALERT_MATCH_FIELDS
|
|
123
|
+
)
|
|
116
124
|
},
|
|
117
125
|
{
|
|
118
126
|
type: "metric_alert",
|
|
119
127
|
identifier: SENTRY_METRIC_ALERT_IDENTIFIER,
|
|
120
128
|
supportedEvents: [...SENTRY_METRIC_ALERT_EVENTS],
|
|
121
|
-
suggestedEvents: SENTRY_METRIC_ALERT_SUGGESTED_EVENTS
|
|
129
|
+
suggestedEvents: SENTRY_METRIC_ALERT_SUGGESTED_EVENTS,
|
|
130
|
+
matchFields: SENTRY_METRIC_ALERT_MATCH_FIELDS
|
|
122
131
|
}
|
|
123
132
|
],
|
|
133
|
+
// One install is one Sentry org. Issue and metric alert events carry
|
|
134
|
+
// alert facts, and Junior adds nothing to Sentry, so they can run for
|
|
135
|
+
// every project. Use the `projects` filter to narrow them.
|
|
136
|
+
events: Object.fromEntries(
|
|
137
|
+
[...SENTRY_ISSUE_EVENTS, ...SENTRY_METRIC_ALERT_EVENTS].map(
|
|
138
|
+
(eventType) => [eventType, { reach: "all" }]
|
|
139
|
+
)
|
|
140
|
+
),
|
|
124
141
|
isEnabled: () => Boolean(sentryWebhookSecret()),
|
|
125
142
|
normalizeIdentifier: (identifier) => identifier.toLowerCase()
|
|
126
143
|
},
|
package/dist/testing.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-sentry",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.267.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"zod": "^4.5.4",
|
|
30
|
-
"@sentry/junior-plugin-api": "0.
|
|
30
|
+
"@sentry/junior-plugin-api": "0.267.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@oxlint/plugins": "1.79.0",
|
|
@@ -35,7 +35,8 @@
|
|
|
35
35
|
"oxlint": "^1.79.0",
|
|
36
36
|
"tsup": "^8.5.1",
|
|
37
37
|
"typescript": "^7.0.2",
|
|
38
|
-
"vitest": "^4.1.12"
|
|
38
|
+
"vitest": "^4.1.12",
|
|
39
|
+
"@sentry/junior-testing": "0.0.0"
|
|
39
40
|
},
|
|
40
41
|
"scripts": {
|
|
41
42
|
"build": "tsup && tsc -p tsconfig.build.json --emitDeclarationOnly",
|