unnbound-events 2.0.8 → 2.0.9

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.
@@ -8,6 +8,7 @@ const axios_1 = __importDefault(require("axios"));
8
8
  const types_1 = require("unnbound-logger-sdk/dist/types");
9
9
  const unnbound_logger_sdk_1 = require("unnbound-logger-sdk");
10
10
  const internal_1 = require("unnbound-logger-sdk/dist/internal");
11
+ const storage_1 = require("unnbound-logger-sdk/dist/storage");
11
12
  const getWorkspaceId = (url) => url.replace(/^https?:\/\//, '').replace(/\.unnbound\.ai$/, '');
12
13
  const getEnvironment = (url) => (url.includes('stg.unnbound.ai') ? 'stg' : 'prod');
13
14
  const getWorkflowDomain = (url) => {
@@ -21,11 +22,12 @@ const createEnqueuer = () => {
21
22
  return async (event, metadata) => {
22
23
  if (!event.path.startsWith('/'))
23
24
  throw new Error('Path must be relative.');
25
+ const { traceId, messageId } = storage_1.storage.getStore() ?? {};
24
26
  const config = {
25
27
  headers: {
26
28
  ...event.headers,
27
- [types_1.defaultTraceHeaderKey]: metadata?.traceId ?? event.headers[types_1.defaultTraceHeaderKey],
28
- [types_1.defaultMessageHeaderKey]: metadata?.messageId ?? event.headers[types_1.defaultMessageHeaderKey],
29
+ [types_1.defaultTraceHeaderKey]: metadata?.traceId ?? event.headers?.[types_1.defaultTraceHeaderKey] ?? traceId,
30
+ [types_1.defaultMessageHeaderKey]: metadata?.messageId ?? event.headers?.[types_1.defaultMessageHeaderKey] ?? messageId,
29
31
  },
30
32
  params: event.query,
31
33
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "unnbound-events",
3
3
  "description": "Unified events SDK to handle HTTP routes and queued messages with a single routing API.",
4
- "version": "2.0.8",
4
+ "version": "2.0.9",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "author": "Unnbound Team",