@taskcast/sentry 0.1.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/dist/hooks.d.ts +20 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +57 -0
- package/dist/hooks.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +35 -0
package/dist/hooks.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { TaskcastHooks } from '@taskcast/core';
|
|
2
|
+
interface SentryLike {
|
|
3
|
+
captureException(err: unknown, opts?: {
|
|
4
|
+
tags?: Record<string, string>;
|
|
5
|
+
extra?: Record<string, unknown>;
|
|
6
|
+
}): void;
|
|
7
|
+
}
|
|
8
|
+
export interface SentryHooksOptions {
|
|
9
|
+
captureTaskFailures?: boolean;
|
|
10
|
+
captureTaskTimeouts?: boolean;
|
|
11
|
+
captureUnhandledErrors?: boolean;
|
|
12
|
+
captureDroppedEvents?: boolean;
|
|
13
|
+
captureStorageErrors?: boolean;
|
|
14
|
+
captureBroadcastErrors?: boolean;
|
|
15
|
+
traceSSEConnections?: boolean;
|
|
16
|
+
traceEventPublish?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare function createSentryHooks(sentry: SentryLike, opts?: SentryHooksOptions): TaskcastHooks;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAA4C,MAAM,gBAAgB,CAAA;AAE7F,UAAU,UAAU;IAClB,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE;QACpC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAC7B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;KAChC,GAAG,IAAI,CAAA;CACT;AAED,MAAM,WAAW,kBAAkB;IACjC,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,oBAAoB,CAAC,EAAE,OAAO,CAAA;IAC9B,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B;AAaD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,UAAU,EAClB,IAAI,GAAE,kBAAuB,GAC5B,aAAa,CA6Cf"}
|
package/dist/hooks.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
const DEFAULT_OPTIONS = {
|
|
2
|
+
captureTaskFailures: true,
|
|
3
|
+
captureTaskTimeouts: true,
|
|
4
|
+
captureUnhandledErrors: true,
|
|
5
|
+
captureDroppedEvents: true,
|
|
6
|
+
captureStorageErrors: true,
|
|
7
|
+
captureBroadcastErrors: true,
|
|
8
|
+
traceSSEConnections: false,
|
|
9
|
+
traceEventPublish: false,
|
|
10
|
+
};
|
|
11
|
+
export function createSentryHooks(sentry, opts = {}) {
|
|
12
|
+
const options = { ...DEFAULT_OPTIONS, ...opts };
|
|
13
|
+
return {
|
|
14
|
+
onTaskFailed(task, error) {
|
|
15
|
+
if (!options.captureTaskFailures)
|
|
16
|
+
return;
|
|
17
|
+
const err = new Error(`Task failed [${task.id}]: ${error.message}`);
|
|
18
|
+
sentry.captureException(err, {
|
|
19
|
+
tags: { taskId: task.id, status: task.status, errorCode: error.code ?? 'unknown' },
|
|
20
|
+
extra: { params: task.params, error: task.error },
|
|
21
|
+
});
|
|
22
|
+
},
|
|
23
|
+
onTaskTimeout(task) {
|
|
24
|
+
if (!options.captureTaskTimeouts)
|
|
25
|
+
return;
|
|
26
|
+
const err = new Error(`Task timed out [${task.id}]`);
|
|
27
|
+
sentry.captureException(err, {
|
|
28
|
+
tags: { taskId: task.id, status: 'timeout' },
|
|
29
|
+
extra: { params: task.params },
|
|
30
|
+
});
|
|
31
|
+
},
|
|
32
|
+
onUnhandledError(err, context) {
|
|
33
|
+
if (!options.captureUnhandledErrors)
|
|
34
|
+
return;
|
|
35
|
+
sentry.captureException(err, {
|
|
36
|
+
tags: { operation: context.operation, ...(context.taskId ? { taskId: context.taskId } : {}) },
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
onEventDropped(event, reason) {
|
|
40
|
+
if (!options.captureDroppedEvents)
|
|
41
|
+
return;
|
|
42
|
+
const err = new Error(`Event dropped [${event.id}]: ${reason}`);
|
|
43
|
+
sentry.captureException(err, {
|
|
44
|
+
tags: { taskId: event.taskId, eventType: event.type },
|
|
45
|
+
extra: { reason, eventId: event.id },
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
onWebhookFailed(config, err) {
|
|
49
|
+
if (!options.captureDroppedEvents)
|
|
50
|
+
return;
|
|
51
|
+
sentry.captureException(err, {
|
|
52
|
+
tags: { webhookUrl: config.url },
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.ts"],"names":[],"mappings":"AAoBA,MAAM,eAAe,GAAiC;IACpD,mBAAmB,EAAE,IAAI;IACzB,mBAAmB,EAAE,IAAI;IACzB,sBAAsB,EAAE,IAAI;IAC5B,oBAAoB,EAAE,IAAI;IAC1B,oBAAoB,EAAE,IAAI;IAC1B,sBAAsB,EAAE,IAAI;IAC5B,mBAAmB,EAAE,KAAK;IAC1B,iBAAiB,E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E,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE;aAC9F,CAAC,CAAA;QACJ,CAAC;QAED,cAAc,CAAC,KAAgB,EAAE,MAAc;YAC7C,IAAI,CAAC,OAAO,CAAC,oBAAoB;gBAAE,OAAM;YACzC,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC,kBAAkB,KAAK,CAAC,EAAE,MAAM,MAAM,EAAE,CAAC,CAAA;YAC/D,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE;gBAC3B,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC,IAAI,EAAE;gBACrD,KAAK,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE,EAAE;aACrC,CAAC,CAAA;QACJ,CAAC;QAED,eAAe,CAAC,MAAM,EAAE,GAAG;YACzB,IAAI,CAAC,OAAO,CAAC,oBAAoB;gBAAE,OAAM;YACzC,MAAM,CAAC,gBAAgB,CAAC,GAAG,EAAE;gBAC3B,IAAI,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC,GAAG,EAAE;aACjC,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AAC9C,YAAY,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@taskcast/sentry",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"files": [
|
|
5
|
+
"dist",
|
|
6
|
+
"LICENSE"
|
|
7
|
+
],
|
|
8
|
+
"type": "module",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"test": "vitest run",
|
|
18
|
+
"test:watch": "vitest"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@taskcast/core": "workspace:*"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@sentry/node": ">=8.0.0"
|
|
25
|
+
},
|
|
26
|
+
"peerDependenciesMeta": {
|
|
27
|
+
"@sentry/node": { "optional": true }
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"typescript": "^5.7.0",
|
|
31
|
+
"vitest": "^2.1.0",
|
|
32
|
+
"@vitest/coverage-v8": "^2.1.0",
|
|
33
|
+
"@sentry/node": "^8.42.0"
|
|
34
|
+
}
|
|
35
|
+
}
|