dt-common-device 13.4.16 → 13.4.17

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.
@@ -1,4 +1,9 @@
1
1
  import { IAuditProperties } from "./IAuditProperties";
2
+ /**
3
+ * Publishes an audit event. Failures are logged and swallowed so callers can
4
+ * fire-and-forget without causing unhandled promise rejections when the audit
5
+ * pipeline returns 5xx or times out (see e.g. Sentry DT-PMS-C).
6
+ */
2
7
  export declare function pushAudit(data: {
3
8
  auditType: string;
4
9
  auditData: IAuditProperties;
@@ -5,16 +5,31 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.pushAudit = pushAudit;
7
7
  const dt_audit_library_1 = require("dt-audit-library");
8
+ const config_1 = require("../config/config");
8
9
  const AuditUtils_1 = require("./AuditUtils");
9
10
  const typedi_1 = __importDefault(require("typedi"));
11
+ /**
12
+ * Publishes an audit event. Failures are logged and swallowed so callers can
13
+ * fire-and-forget without causing unhandled promise rejections when the audit
14
+ * pipeline returns 5xx or times out (see e.g. Sentry DT-PMS-C).
15
+ */
10
16
  async function pushAudit(data) {
11
- const audit = await typedi_1.default.get(AuditUtils_1.AuditUtils).buildAuditProperties(data.auditData);
12
- await (0, dt_audit_library_1.publishAudit)({
13
- eventType: data.auditType,
14
- properties: {
15
- ...audit,
16
- timestamp: new Date().toISOString(),
17
- env_type: process.env.NODE_ENV,
18
- },
19
- });
17
+ try {
18
+ const audit = await typedi_1.default.get(AuditUtils_1.AuditUtils).buildAuditProperties(data.auditData);
19
+ await (0, dt_audit_library_1.publishAudit)({
20
+ eventType: data.auditType,
21
+ properties: {
22
+ ...audit,
23
+ timestamp: new Date().toISOString(),
24
+ env_type: process.env.NODE_ENV,
25
+ },
26
+ });
27
+ }
28
+ catch (err) {
29
+ const status = err?.response?.status;
30
+ const code = err?.code;
31
+ (0, config_1.getLogger)().error(`pushAudit failed for ${data.auditType}: ${err?.message ?? err}`, status != null || code != null
32
+ ? { auditType: data.auditType, status, code }
33
+ : { auditType: data.auditType });
34
+ }
20
35
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dt-common-device",
3
- "version": "13.4.16",
3
+ "version": "13.4.17",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [