@spfn/monitor 0.1.0-beta.14 → 0.1.0-beta.16
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/dist/server.js +31 -21
- package/dist/server.js.map +1 -1
- package/package.json +4 -4
package/dist/server.js
CHANGED
|
@@ -3045,26 +3045,30 @@ async function trackError(err, ctx, metadata) {
|
|
|
3045
3045
|
firstSeenAt: now,
|
|
3046
3046
|
lastSeenAt: now
|
|
3047
3047
|
});
|
|
3048
|
-
const event = await
|
|
3048
|
+
const event = await safeCreateEvent(group.id, err, ctx, metadata);
|
|
3049
3049
|
logger2.info("New error group tracked", { fingerprint, groupId: group.id });
|
|
3050
|
-
|
|
3050
|
+
if (event) {
|
|
3051
|
+
notifyErrorToSlack(group, event, "new", ctx.environment).catch((e) => logger2.warn("Slack notification failed", e));
|
|
3052
|
+
}
|
|
3051
3053
|
return;
|
|
3052
3054
|
}
|
|
3053
3055
|
if (existing.status === "resolved") {
|
|
3054
3056
|
await errorGroupsRepository.updateStatus(existing.id, "active");
|
|
3055
3057
|
await errorGroupsRepository.incrementCount(existing.id);
|
|
3056
|
-
const event = await
|
|
3058
|
+
const event = await safeCreateEvent(existing.id, err, ctx, metadata);
|
|
3057
3059
|
logger2.info("Error group reopened", { fingerprint, groupId: existing.id });
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3060
|
+
if (event) {
|
|
3061
|
+
notifyErrorToSlack(
|
|
3062
|
+
{ ...existing, status: "active", count: existing.count + 1 },
|
|
3063
|
+
event,
|
|
3064
|
+
"reopened",
|
|
3065
|
+
ctx.environment
|
|
3066
|
+
).catch((e) => logger2.warn("Slack notification failed", e));
|
|
3067
|
+
}
|
|
3064
3068
|
return;
|
|
3065
3069
|
}
|
|
3066
3070
|
await errorGroupsRepository.incrementCount(existing.id);
|
|
3067
|
-
await
|
|
3071
|
+
await safeCreateEvent(existing.id, err, ctx, metadata);
|
|
3068
3072
|
}
|
|
3069
3073
|
async function updateErrorGroupStatus(groupId, newStatus) {
|
|
3070
3074
|
const group = await errorGroupsRepository.findById(groupId);
|
|
@@ -3082,17 +3086,23 @@ async function updateErrorGroupStatus(groupId, newStatus) {
|
|
|
3082
3086
|
});
|
|
3083
3087
|
return updated;
|
|
3084
3088
|
}
|
|
3085
|
-
async function
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3089
|
+
async function safeCreateEvent(groupId, err, ctx, metadata) {
|
|
3090
|
+
try {
|
|
3091
|
+
return await errorEventsRepository.create({
|
|
3092
|
+
groupId,
|
|
3093
|
+
requestId: ctx.requestId,
|
|
3094
|
+
userId: ctx.userId,
|
|
3095
|
+
statusCode: ctx.statusCode,
|
|
3096
|
+
headers: ctx.headers,
|
|
3097
|
+
query: ctx.query,
|
|
3098
|
+
stackTrace: err.stack,
|
|
3099
|
+
metadata
|
|
3100
|
+
});
|
|
3101
|
+
} catch (e) {
|
|
3102
|
+
const cause = e instanceof Error && e.cause instanceof Error ? e.cause : e;
|
|
3103
|
+
logger2.warn("Failed to create error event", cause, { groupId });
|
|
3104
|
+
return null;
|
|
3105
|
+
}
|
|
3096
3106
|
}
|
|
3097
3107
|
|
|
3098
3108
|
// src/server/services/log.service.ts
|