@ttt-productions/monitoring-core 0.13.2 → 0.13.4

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 +1 @@
1
- {"version":3,"file":"sentry-node.d.ts","sourceRoot":"","sources":["../../src/adapters/sentry-node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AA0BvD,eAAO,MAAM,iBAAiB,EAAE,iBAgI/B,CAAC"}
1
+ {"version":3,"file":"sentry-node.d.ts","sourceRoot":"","sources":["../../src/adapters/sentry-node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AA2BvD,eAAO,MAAM,iBAAiB,EAAE,iBA4H/B,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { applyCaptureContext } from "../capture-context.js";
1
2
  let sentryNodePromise = null;
2
3
  let sentryNodeInstance = null;
3
4
  function getSentryNode() {
@@ -28,10 +29,7 @@ export const SentryNodeAdapter = {
28
29
  if (sentryNodeInstance) {
29
30
  if (context) {
30
31
  sentryNodeInstance.withScope((scope) => {
31
- for (const [k, v] of Object.entries(context)) {
32
- if (typeof scope?.setExtra === "function")
33
- scope.setExtra(k, v);
34
- }
32
+ applyCaptureContext(scope, context);
35
33
  sentryNodeInstance.captureException(error);
36
34
  });
37
35
  return;
@@ -43,10 +41,7 @@ export const SentryNodeAdapter = {
43
41
  const S = await getSentryNode();
44
42
  if (context) {
45
43
  S.withScope((scope) => {
46
- for (const [k, v] of Object.entries(context)) {
47
- if (typeof scope?.setExtra === "function")
48
- scope.setExtra(k, v);
49
- }
44
+ applyCaptureContext(scope, context);
50
45
  S.captureException(error);
51
46
  });
52
47
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"sentry-node.js","sourceRoot":"","sources":["../../src/adapters/sentry-node.ts"],"names":[],"mappings":"AAaA,IAAI,iBAAiB,GAAmC,IAAI,CAAC;A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AAU,EAAE,GAAG,EAAE,GAAE,CAAC;SACrB,CAAC;QAEF,KAAK,CAAC,KAAK,IAAI,EAAE;YACf,MAAM,CAAC,GAAG,MAAM,aAAa,EAAE,CAAC;YAChC,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,KAAY,CAAC,CAAC,CAAC;QAC3C,CAAC,CAAC,EAAE,CAAC;QAEL,OAAO,EAAE,CAAC,YAAY,CAAC,CAAC;IAC1B,CAAC;IAED,aAAa,CAAC,UAKb;QACC,IAAI,kBAAkB,EAAE,CAAC;YACvB,kBAAkB,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YAC7C,OAAO;QACT,CAAC;QACD,KAAK,CAAC,KAAK,IAAI,EAAE;YACf,MAAM,CAAC,GAAG,MAAM,aAAa,EAAE,CAAC;YAChC,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QAC9B,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;CACF,CAAC","sourcesContent":["import type { MonitoringAdapter } from \"../adapter.js\";\nimport type { MonitoringInitOptions, MonitoringUser, ScopeLike } from \"../types.js\";\n\ntype SentryNodeLike = {\n init: (opts: any) => void;\n captureException: (e: unknown, hint?: any) => void;\n captureMessage: (m: string, level?: any) => void;\n setUser: (u: any) => void;\n setTag: (k: string, v: string) => void;\n withScope: (fn: (scope: any) => void) => void;\n addBreadcrumb: (breadcrumb: any) => void;\n};\n\nlet sentryNodePromise: Promise<SentryNodeLike> | null = null;\nlet sentryNodeInstance: SentryNodeLike | null = null;\n\nfunction getSentryNode(): Promise<SentryNodeLike> {\n if (!sentryNodePromise) {\n sentryNodePromise = import(\"@sentry/node\").then((m) => {\n sentryNodeInstance = m as any;\n return sentryNodeInstance!;\n });\n }\n return sentryNodePromise;\n}\n\nexport const SentryNodeAdapter: MonitoringAdapter = {\n async init(options: MonitoringInitOptions) {\n const enabled = options.enabled ?? true;\n if (!enabled || !options.dsn) return;\n\n const S = await getSentryNode();\n S.init({\n dsn: options.dsn,\n environment: options.environment,\n enabled: true,\n release: options.release,\n ...(options.tracesSampleRate !== undefined ? { tracesSampleRate: options.tracesSampleRate } : {}),\n ...(options.integrations !== undefined ? { integrations: options.integrations } : {}),\n });\n },\n\n captureException(error: unknown, context?: Record<string, unknown>) {\n if (sentryNodeInstance) {\n if (context) {\n sentryNodeInstance.withScope((scope) => {\n for (const [k, v] of Object.entries(context)) {\n if (typeof scope?.setExtra === \"function\") scope.setExtra(k, v);\n }\n sentryNodeInstance!.captureException(error);\n });\n return;\n }\n sentryNodeInstance.captureException(error);\n return;\n }\n\n void (async () => {\n const S = await getSentryNode();\n\n if (context) {\n S.withScope((scope) => {\n for (const [k, v] of Object.entries(context)) {\n if (typeof scope?.setExtra === \"function\") scope.setExtra(k, v);\n }\n S.captureException(error);\n });\n return;\n }\n\n S.captureException(error);\n })();\n },\n\n captureMessage(message: string, level?: any) {\n if (sentryNodeInstance) {\n sentryNodeInstance.captureMessage(message, level);\n return;\n }\n void (async () => {\n const S = await getSentryNode();\n S.captureMessage(message, level);\n })();\n },\n\n setUser(user: MonitoringUser | null) {\n if (sentryNodeInstance) {\n sentryNodeInstance.setUser(user as any);\n return;\n }\n void (async () => {\n const S = await getSentryNode();\n S.setUser(user as any);\n })();\n },\n\n setTag(key: string, value: string) {\n if (sentryNodeInstance) {\n sentryNodeInstance.setTag(key, value);\n return;\n }\n void (async () => {\n const S = await getSentryNode();\n S.setTag(key, value);\n })();\n },\n\n // NOTE: withScope calls `fn` exactly once. When Sentry is already loaded\n // (the expected steady state — `init()` awaits the dynamic import, and\n // callers must await `initMonitoring()` before serving traffic), it runs\n // synchronously through the real Sentry scope. Only during the narrow\n // pre-load race window (a call that races the very first `getSentryNode()`\n // resolution) does it fall back to a synchronous no-op-scope call plus an\n // async replay against the real scope — mirroring the browser adapter's\n // same accepted tradeoff for that same race window.\n withScope<T>(fn: (scope: ScopeLike) => T): T {\n if (sentryNodeInstance) {\n let result: T;\n sentryNodeInstance.withScope((scope) => {\n result = fn(scope as any);\n });\n return result!;\n }\n\n const minimalScope: ScopeLike = {\n setTag: () => {},\n setUser: () => {},\n setExtra: () => {},\n setContext: () => {},\n };\n\n void (async () => {\n const S = await getSentryNode();\n S.withScope((scope) => fn(scope as any));\n })();\n\n return fn(minimalScope);\n },\n\n addBreadcrumb(breadcrumb: {\n category?: string;\n message?: string;\n level?: \"fatal\" | \"error\" | \"warning\" | \"info\" | \"debug\";\n data?: Record<string, unknown>;\n }) {\n if (sentryNodeInstance) {\n sentryNodeInstance.addBreadcrumb(breadcrumb);\n return;\n }\n void (async () => {\n const S = await getSentryNode();\n S.addBreadcrumb(breadcrumb);\n })();\n },\n};"]}
1
+ {"version":3,"file":"sentry-node.js","sourceRoot":"","sources":["../../src/adapters/sentry-node.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAY5D,IAAI,iBAAiB,GAAmC,IAAI,CAAC;AAC7D,IAAI,kBAAkB,GAA0B,IAAI,CAAC;AAErD,SAAS,aAAa;IACpB,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACvB,iBAAiB,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;YACpD,kBAAkB,GAAG,CAAQ,CAAC;YAC9B,OAAO,kBAAmB,CAAC;QAC7B,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,iBAAiB,CAAC;AAC3B,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAsB;IAClD,KAAK,CAAC,IAAI,CAAC,OAA8B;QACvC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC;QACxC,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG;YAAE,OAAO;QAErC,MAAM,CAAC,GAAG,MAAM,aAAa,EAAE,CAAC;QAChC,CAAC,CAAC,IAAI,CAAC;YACL,GAAG,EAAE,OAAO,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AAG,EAAE,CAAC,KAAY,CAAC,CAAC;YAC5B,CAAC,CAAC,CAAC;YACH,OAAO,MAAO,CAAC;QACjB,CAAC;QAED,MAAM,YAAY,GAAc;YAC9B,MAAM,EAAE,GAAG,EAAE,GAAE,CAAC;YAChB,OAAO,EAAE,GAAG,EAAE,GAAE,CAAC;YACjB,QAAQ,EAAE,GAAG,EAAE,GAAE,CAAC;YAClB,UAAU,EAAE,GAAG,EAAE,GAAE,CAAC;SACrB,CAAC;QAEF,KAAK,CAAC,KAAK,IAAI,EAAE;YACf,MAAM,CAAC,GAAG,MAAM,aAAa,EAAE,CAAC;YAChC,CAAC,CAAC,SAAS,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,KAAY,CAAC,CAAC,CAAC;QAC3C,CAAC,CAAC,EAAE,CAAC;QAEL,OAAO,EAAE,CAAC,YAAY,CAAC,CAAC;IAC1B,CAAC;IAED,aAAa,CAAC,UAKb;QACC,IAAI,kBAAkB,EAAE,CAAC;YACvB,kBAAkB,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YAC7C,OAAO;QACT,CAAC;QACD,KAAK,CAAC,KAAK,IAAI,EAAE;YACf,MAAM,CAAC,GAAG,MAAM,aAAa,EAAE,CAAC;YAChC,CAAC,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;QAC9B,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;CACF,CAAC","sourcesContent":["import type { MonitoringAdapter } from \"../adapter.js\";\nimport type { MonitoringInitOptions, MonitoringUser, ScopeLike } from \"../types.js\";\nimport { applyCaptureContext } from \"../capture-context.js\";\n\ntype SentryNodeLike = {\n init: (opts: any) => void;\n captureException: (e: unknown, hint?: any) => void;\n captureMessage: (m: string, level?: any) => void;\n setUser: (u: any) => void;\n setTag: (k: string, v: string) => void;\n withScope: (fn: (scope: any) => void) => void;\n addBreadcrumb: (breadcrumb: any) => void;\n};\n\nlet sentryNodePromise: Promise<SentryNodeLike> | null = null;\nlet sentryNodeInstance: SentryNodeLike | null = null;\n\nfunction getSentryNode(): Promise<SentryNodeLike> {\n if (!sentryNodePromise) {\n sentryNodePromise = import(\"@sentry/node\").then((m) => {\n sentryNodeInstance = m as any;\n return sentryNodeInstance!;\n });\n }\n return sentryNodePromise;\n}\n\nexport const SentryNodeAdapter: MonitoringAdapter = {\n async init(options: MonitoringInitOptions) {\n const enabled = options.enabled ?? true;\n if (!enabled || !options.dsn) return;\n\n const S = await getSentryNode();\n S.init({\n dsn: options.dsn,\n environment: options.environment,\n enabled: true,\n release: options.release,\n ...(options.tracesSampleRate !== undefined ? { tracesSampleRate: options.tracesSampleRate } : {}),\n ...(options.integrations !== undefined ? { integrations: options.integrations } : {}),\n });\n },\n\n captureException(error: unknown, context?: Record<string, unknown>) {\n if (sentryNodeInstance) {\n if (context) {\n sentryNodeInstance.withScope((scope) => {\n applyCaptureContext(scope, context);\n sentryNodeInstance!.captureException(error);\n });\n return;\n }\n sentryNodeInstance.captureException(error);\n return;\n }\n\n void (async () => {\n const S = await getSentryNode();\n\n if (context) {\n S.withScope((scope) => {\n applyCaptureContext(scope, context);\n S.captureException(error);\n });\n return;\n }\n\n S.captureException(error);\n })();\n },\n\n captureMessage(message: string, level?: any) {\n if (sentryNodeInstance) {\n sentryNodeInstance.captureMessage(message, level);\n return;\n }\n void (async () => {\n const S = await getSentryNode();\n S.captureMessage(message, level);\n })();\n },\n\n setUser(user: MonitoringUser | null) {\n if (sentryNodeInstance) {\n sentryNodeInstance.setUser(user as any);\n return;\n }\n void (async () => {\n const S = await getSentryNode();\n S.setUser(user as any);\n })();\n },\n\n setTag(key: string, value: string) {\n if (sentryNodeInstance) {\n sentryNodeInstance.setTag(key, value);\n return;\n }\n void (async () => {\n const S = await getSentryNode();\n S.setTag(key, value);\n })();\n },\n\n // NOTE: withScope calls `fn` exactly once. When Sentry is already loaded\n // (the expected steady state — `init()` awaits the dynamic import, and\n // callers must await `initMonitoring()` before serving traffic), it runs\n // synchronously through the real Sentry scope. Only during the narrow\n // pre-load race window (a call that races the very first `getSentryNode()`\n // resolution) does it fall back to a synchronous no-op-scope call plus an\n // async replay against the real scope — mirroring the browser adapter's\n // same accepted tradeoff for that same race window.\n withScope<T>(fn: (scope: ScopeLike) => T): T {\n if (sentryNodeInstance) {\n let result: T;\n sentryNodeInstance.withScope((scope) => {\n result = fn(scope as any);\n });\n return result!;\n }\n\n const minimalScope: ScopeLike = {\n setTag: () => {},\n setUser: () => {},\n setExtra: () => {},\n setContext: () => {},\n };\n\n void (async () => {\n const S = await getSentryNode();\n S.withScope((scope) => fn(scope as any));\n })();\n\n return fn(minimalScope);\n },\n\n addBreadcrumb(breadcrumb: {\n category?: string;\n message?: string;\n level?: \"fatal\" | \"error\" | \"warning\" | \"info\" | \"debug\";\n data?: Record<string, unknown>;\n }) {\n if (sentryNodeInstance) {\n sentryNodeInstance.addBreadcrumb(breadcrumb);\n return;\n }\n void (async () => {\n const S = await getSentryNode();\n S.addBreadcrumb(breadcrumb);\n })();\n },\n};"]}
@@ -1 +1 @@
1
- {"version":3,"file":"sentry.d.ts","sourceRoot":"","sources":["../../src/adapters/sentry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AA0BvD,eAAO,MAAM,aAAa,EAAE,iBA8H3B,CAAC"}
1
+ {"version":3,"file":"sentry.d.ts","sourceRoot":"","sources":["../../src/adapters/sentry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AA2BvD,eAAO,MAAM,aAAa,EAAE,iBA0H3B,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { applyCaptureContext } from "../capture-context.js";
1
2
  let sentryPromise = null;
2
3
  let sentryInstance = null;
3
4
  function getSentry() {
@@ -28,10 +29,7 @@ export const SentryAdapter = {
28
29
  if (sentryInstance) {
29
30
  if (context && sentryInstance.withScope) {
30
31
  sentryInstance.withScope((scope) => {
31
- for (const [k, v] of Object.entries(context)) {
32
- if (typeof scope?.setExtra === "function")
33
- scope.setExtra(k, v);
34
- }
32
+ applyCaptureContext(scope, context);
35
33
  sentryInstance.captureException(error);
36
34
  });
37
35
  return;
@@ -43,10 +41,7 @@ export const SentryAdapter = {
43
41
  const S = await getSentry();
44
42
  if (context && S.withScope) {
45
43
  S.withScope((scope) => {
46
- for (const [k, v] of Object.entries(context)) {
47
- if (typeof scope?.setExtra === "function")
48
- scope.setExtra(k, v);
49
- }
44
+ applyCaptureContext(scope, context);
50
45
  S.captureException(error);
51
46
  });
52
47
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"sentry.js","sourceRoot":"","sources":["../../src/adapters/sentry.ts"],"names":[],"mappings":"AAaA,IAAI,aAAa,GAA+B,IAAI,CAAC;AACrD,IAAI,cAAc,GAAsB,IAAI,CAAC;AAE7C,SAAS,SAAS;IAChB,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;YAClD,cAAc,GAAG,CAAQ,CAAC;YAC1B,OAAO,cAAe,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAsB;IAC9C,KAAK,CAAC,IAAI,CAAC,OAA8B;QACvC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC;QACxC,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG;YAAE,OAAO;QAErC,MAAM,CAAC,GAAG,MAAM,SAAS,EAAE,CAAC;QAC5B,CAAC,CAAC,IAAI,CAAC;YACL,GAAG,EAAE,OAAO,CAAC,GAAG;YAChB,WAAW,EAAE,OAAO,CAAC,WAAW;YAChC,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,GAAG,CAAC,OAAO,CAAC,gBAAgB,KA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{ MonitoringInitOptions, MonitoringUser, ScopeLike } from \"../types.js\";\n\ntype SentryLike = {\n init: (opts: any) => void;\n captureException: (e: unknown) => void;\n captureMessage: (m: string, level?: any) => void;\n setUser: (u: any) => void;\n setTag: (k: string, v: string) => void;\n withScope?: (fn: (scope: any) => void) => void;\n addBreadcrumb?: (breadcrumb: any) => void;\n};\n\nlet sentryPromise: Promise<SentryLike> | null = null;\nlet sentryInstance: SentryLike | null = null;\n\nfunction getSentry(): Promise<SentryLike> {\n if (!sentryPromise) {\n sentryPromise = import(\"@sentry/nextjs\").then((m) => {\n sentryInstance = m as any;\n return sentryInstance!;\n });\n }\n return sentryPromise;\n}\n\nexport const SentryAdapter: MonitoringAdapter = {\n async init(options: MonitoringInitOptions) {\n const enabled = options.enabled ?? true;\n if (!enabled || !options.dsn) return;\n\n const S = await getSentry();\n S.init({\n dsn: options.dsn,\n environment: options.environment,\n enabled: true,\n release: options.release,\n ...(options.tracesSampleRate !== undefined ? { tracesSampleRate: options.tracesSampleRate } : {}),\n ...(options.integrations !== undefined ? { integrations: options.integrations } : {}),\n });\n },\n\n captureException(error: unknown, context?: Record<string, unknown>) {\n if (sentryInstance) {\n if (context && sentryInstance.withScope) {\n sentryInstance.withScope((scope) => {\n for (const [k, v] of Object.entries(context)) {\n if (typeof scope?.setExtra === \"function\") scope.setExtra(k, v);\n }\n sentryInstance!.captureException(error);\n });\n return;\n }\n sentryInstance.captureException(error);\n return;\n }\n\n void (async () => {\n const S = await getSentry();\n\n if (context && S.withScope) {\n S.withScope((scope) => {\n for (const [k, v] of Object.entries(context)) {\n if (typeof scope?.setExtra === \"function\") scope.setExtra(k, v);\n }\n S.captureException(error);\n });\n return;\n }\n\n S.captureException(error);\n })();\n },\n\n captureMessage(message: string, level?: any) {\n if (sentryInstance) {\n sentryInstance.captureMessage(message, level);\n return;\n }\n void (async () => {\n const S = await getSentry();\n S.captureMessage(message, level);\n })();\n },\n\n setUser(user: MonitoringUser | null) {\n if (sentryInstance) {\n sentryInstance.setUser(user as any);\n return;\n }\n void (async () => {\n const S = await getSentry();\n S.setUser(user as any);\n })();\n },\n\n setTag(key: string, value: string) {\n if (sentryInstance) {\n sentryInstance.setTag(key, value);\n return;\n }\n void (async () => {\n const S = await getSentry();\n S.setTag(key, value);\n })();\n },\n\n withScope<T>(fn: (scope: ScopeLike) => T): T {\n if (sentryInstance && sentryInstance.withScope) {\n let result: T;\n sentryInstance.withScope((scope) => {\n result = fn(scope as any);\n });\n return result!;\n }\n\n // Sentry not loaded yet — run with no-op scope, then replay async\n const minimalScope: ScopeLike = {\n setTag: () => {},\n setUser: () => {},\n setExtra: () => {},\n setContext: () => {},\n };\n\n void (async () => {\n const S = await getSentry();\n if (!S.withScope) return;\n S.withScope((scope) => fn(scope as any));\n })();\n\n return fn(minimalScope);\n },\n\n addBreadcrumb(breadcrumb: {\n category?: string;\n message?: string;\n level?: \"fatal\" | \"error\" | \"warning\" | \"info\" | \"debug\";\n data?: Record<string, unknown>;\n }) {\n if (sentryInstance) {\n if (sentryInstance.addBreadcrumb) {\n sentryInstance.addBreadcrumb(breadcrumb);\n }\n return;\n }\n void (async () => {\n const S = await getSentry();\n if (S.addBreadcrumb) {\n S.addBreadcrumb(breadcrumb);\n }\n })();\n },\n};"]}
1
+ {"version":3,"file":"sentry.js","sourceRoot":"","sources":["../../src/adapters/sentry.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAY5D,IAAI,aAAa,GAA+B,IAAI,CAAC;AACrD,IAAI,cAAc,GAAsB,IAAI,CAAC;AAE7C,SAAS,SAAS;IAChB,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;YAClD,cAAc,GAAG,CAAQ,CAAC;YAC1B,OAAO,cAAe,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC;IACD,OAAO,aAAa,C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AC;YAC9B,CAAC;QACH,CAAC,CAAC,EAAE,CAAC;IACP,CAAC;CACF,CAAC","sourcesContent":["import type { MonitoringAdapter } from \"../adapter.js\";\nimport type { MonitoringInitOptions, MonitoringUser, ScopeLike } from \"../types.js\";\nimport { applyCaptureContext } from \"../capture-context.js\";\n\ntype SentryLike = {\n init: (opts: any) => void;\n captureException: (e: unknown) => void;\n captureMessage: (m: string, level?: any) => void;\n setUser: (u: any) => void;\n setTag: (k: string, v: string) => void;\n withScope?: (fn: (scope: any) => void) => void;\n addBreadcrumb?: (breadcrumb: any) => void;\n};\n\nlet sentryPromise: Promise<SentryLike> | null = null;\nlet sentryInstance: SentryLike | null = null;\n\nfunction getSentry(): Promise<SentryLike> {\n if (!sentryPromise) {\n sentryPromise = import(\"@sentry/nextjs\").then((m) => {\n sentryInstance = m as any;\n return sentryInstance!;\n });\n }\n return sentryPromise;\n}\n\nexport const SentryAdapter: MonitoringAdapter = {\n async init(options: MonitoringInitOptions) {\n const enabled = options.enabled ?? true;\n if (!enabled || !options.dsn) return;\n\n const S = await getSentry();\n S.init({\n dsn: options.dsn,\n environment: options.environment,\n enabled: true,\n release: options.release,\n ...(options.tracesSampleRate !== undefined ? { tracesSampleRate: options.tracesSampleRate } : {}),\n ...(options.integrations !== undefined ? { integrations: options.integrations } : {}),\n });\n },\n\n captureException(error: unknown, context?: Record<string, unknown>) {\n if (sentryInstance) {\n if (context && sentryInstance.withScope) {\n sentryInstance.withScope((scope) => {\n applyCaptureContext(scope, context);\n sentryInstance!.captureException(error);\n });\n return;\n }\n sentryInstance.captureException(error);\n return;\n }\n\n void (async () => {\n const S = await getSentry();\n\n if (context && S.withScope) {\n S.withScope((scope) => {\n applyCaptureContext(scope, context);\n S.captureException(error);\n });\n return;\n }\n\n S.captureException(error);\n })();\n },\n\n captureMessage(message: string, level?: any) {\n if (sentryInstance) {\n sentryInstance.captureMessage(message, level);\n return;\n }\n void (async () => {\n const S = await getSentry();\n S.captureMessage(message, level);\n })();\n },\n\n setUser(user: MonitoringUser | null) {\n if (sentryInstance) {\n sentryInstance.setUser(user as any);\n return;\n }\n void (async () => {\n const S = await getSentry();\n S.setUser(user as any);\n })();\n },\n\n setTag(key: string, value: string) {\n if (sentryInstance) {\n sentryInstance.setTag(key, value);\n return;\n }\n void (async () => {\n const S = await getSentry();\n S.setTag(key, value);\n })();\n },\n\n withScope<T>(fn: (scope: ScopeLike) => T): T {\n if (sentryInstance && sentryInstance.withScope) {\n let result: T;\n sentryInstance.withScope((scope) => {\n result = fn(scope as any);\n });\n return result!;\n }\n\n // Sentry not loaded yet — run with no-op scope, then replay async\n const minimalScope: ScopeLike = {\n setTag: () => {},\n setUser: () => {},\n setExtra: () => {},\n setContext: () => {},\n };\n\n void (async () => {\n const S = await getSentry();\n if (!S.withScope) return;\n S.withScope((scope) => fn(scope as any));\n })();\n\n return fn(minimalScope);\n },\n\n addBreadcrumb(breadcrumb: {\n category?: string;\n message?: string;\n level?: \"fatal\" | \"error\" | \"warning\" | \"info\" | \"debug\";\n data?: Record<string, unknown>;\n }) {\n if (sentryInstance) {\n if (sentryInstance.addBreadcrumb) {\n sentryInstance.addBreadcrumb(breadcrumb);\n }\n return;\n }\n void (async () => {\n const S = await getSentry();\n if (S.addBreadcrumb) {\n S.addBreadcrumb(breadcrumb);\n }\n })();\n },\n};"]}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Capture-context application — the one place that decides how a capture's
3
+ * context argument lands on a Sentry scope.
4
+ *
5
+ * Context keys become EXTRAS, with two exceptions — the keys call sites pass
6
+ * meaning a FIRST-CLASS Sentry field rather than a free-form attachment:
7
+ *
8
+ * - `tags`, a flat string map, is applied as REAL Sentry tags
9
+ * (`scope.setTag`), so those values are searchable, filterable, and
10
+ * alert-routable;
11
+ * - `level`, one of the severity names, is applied as the capture's REAL
12
+ * severity (`scope.setLevel`), so a call site asking for `warning` is not
13
+ * reported as an error.
14
+ *
15
+ * Both are all-or-nothing: a value that does not fit the shape (a `tags` map
16
+ * with a non-string value, an unrecognized `level`) stays an ordinary extra, so
17
+ * nothing is ever dropped. A scope that cannot honour the field (no `setLevel`)
18
+ * also falls back to the extra.
19
+ */
20
+ import type { MonitoringLevel } from "./types.js";
21
+ /**
22
+ * Narrow an arbitrary value to a flat `Record<string, string>`, or `null` when
23
+ * it is not one. An empty object qualifies (it carries no tags and no
24
+ * information, so it yields neither a tag nor an extra).
25
+ */
26
+ export declare function asFlatStringTagMap(value: unknown): Record<string, string> | null;
27
+ /** Narrow a value to a monitoring severity name, or `null` when it is not one. */
28
+ export declare function asMonitoringLevel(value: unknown): MonitoringLevel | null;
29
+ /**
30
+ * Apply a capture context to a scope: real tags for a flat-string-map `tags`
31
+ * entry, the real severity for a recognized `level`, extras for everything else.
32
+ * Tolerates a scope missing any of the methods.
33
+ */
34
+ export declare function applyCaptureContext(scope: unknown, context: Record<string, unknown>): void;
35
+ //# sourceMappingURL=capture-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capture-context.d.ts","sourceRoot":"","sources":["../src/capture-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAa,MAAM,YAAY,CAAC;AAE7D;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAShF;AAID,kFAAkF;AAClF,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,IAAI,CAExE;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CA0B1F"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Capture-context application — the one place that decides how a capture's
3
+ * context argument lands on a Sentry scope.
4
+ *
5
+ * Context keys become EXTRAS, with two exceptions — the keys call sites pass
6
+ * meaning a FIRST-CLASS Sentry field rather than a free-form attachment:
7
+ *
8
+ * - `tags`, a flat string map, is applied as REAL Sentry tags
9
+ * (`scope.setTag`), so those values are searchable, filterable, and
10
+ * alert-routable;
11
+ * - `level`, one of the severity names, is applied as the capture's REAL
12
+ * severity (`scope.setLevel`), so a call site asking for `warning` is not
13
+ * reported as an error.
14
+ *
15
+ * Both are all-or-nothing: a value that does not fit the shape (a `tags` map
16
+ * with a non-string value, an unrecognized `level`) stays an ordinary extra, so
17
+ * nothing is ever dropped. A scope that cannot honour the field (no `setLevel`)
18
+ * also falls back to the extra.
19
+ */
20
+ /**
21
+ * Narrow an arbitrary value to a flat `Record<string, string>`, or `null` when
22
+ * it is not one. An empty object qualifies (it carries no tags and no
23
+ * information, so it yields neither a tag nor an extra).
24
+ */
25
+ export function asFlatStringTagMap(value) {
26
+ if (value === null || typeof value !== "object" || Array.isArray(value))
27
+ return null;
28
+ const out = {};
29
+ for (const [key, entry] of Object.entries(value)) {
30
+ if (typeof entry !== "string")
31
+ return null;
32
+ out[key] = entry;
33
+ }
34
+ return out;
35
+ }
36
+ const MONITORING_LEVELS = ["fatal", "error", "warning", "info", "debug"];
37
+ /** Narrow a value to a monitoring severity name, or `null` when it is not one. */
38
+ export function asMonitoringLevel(value) {
39
+ return typeof value === "string" && MONITORING_LEVELS.includes(value) ? value : null;
40
+ }
41
+ /**
42
+ * Apply a capture context to a scope: real tags for a flat-string-map `tags`
43
+ * entry, the real severity for a recognized `level`, extras for everything else.
44
+ * Tolerates a scope missing any of the methods.
45
+ */
46
+ export function applyCaptureContext(scope, context) {
47
+ const target = scope;
48
+ for (const [key, value] of Object.entries(context)) {
49
+ if (key === "tags") {
50
+ const tagMap = asFlatStringTagMap(value);
51
+ if (tagMap) {
52
+ if (typeof target?.setTag === "function") {
53
+ for (const [tagKey, tagValue] of Object.entries(tagMap)) {
54
+ target.setTag(tagKey, tagValue);
55
+ }
56
+ }
57
+ continue;
58
+ }
59
+ }
60
+ if (key === "level") {
61
+ const level = asMonitoringLevel(value);
62
+ if (level && typeof target?.setLevel === "function") {
63
+ target.setLevel(level);
64
+ continue;
65
+ }
66
+ }
67
+ if (typeof target?.setExtra === "function")
68
+ target.setExtra(key, value);
69
+ }
70
+ }
71
+ //# sourceMappingURL=capture-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capture-context.js","sourceRoot":"","sources":["../src/capture-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAErF,MAAM,GAAG,GAA2B,EAAE,CAAC;IACvC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,EAAE,CAAC;QAC5E,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;QAC3C,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACnB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,iBAAiB,GAAsB,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5F,kFAAkF;AAClF,MAAM,UAAU,iBAAiB,CAAC,KAAc;IAC9C,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,iBAAiB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAE,KAAyB,CAAC,CAAC,CAAC,IAAI,CAAC;AAC5G,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAc,EAAE,OAAgC;IAClF,MAAM,MAAM,GAAG,KAA8C,CAAC;IAE9D,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,IAAI,GAAG,KAAK,MAAM,EAAE,CAAC;YACnB,MAAM,MAAM,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;YACzC,IAAI,MAAM,EAAE,CAAC;gBACX,IAAI,OAAO,MAAM,EAAE,MAAM,KAAK,UAAU,EAAE,CAAC;oBACzC,KAAK,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;wBACxD,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;oBAClC,CAAC;gBACH,CAAC;gBACD,SAAS;YACX,CAAC;QACH,CAAC;QAED,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;YACpB,MAAM,KAAK,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;YACvC,IAAI,KAAK,IAAI,OAAO,MAAM,EAAE,QAAQ,KAAK,UAAU,EAAE,CAAC;gBACpD,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;gBACvB,SAAS;YACX,CAAC;QACH,CAAC;QAED,IAAI,OAAO,MAAM,EAAE,QAAQ,KAAK,UAAU;YAAE,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC1E,CAAC;AACH,CAAC","sourcesContent":["/**\n * Capture-context application — the one place that decides how a capture's\n * context argument lands on a Sentry scope.\n *\n * Context keys become EXTRAS, with two exceptions — the keys call sites pass\n * meaning a FIRST-CLASS Sentry field rather than a free-form attachment:\n *\n * - `tags`, a flat string map, is applied as REAL Sentry tags\n * (`scope.setTag`), so those values are searchable, filterable, and\n * alert-routable;\n * - `level`, one of the severity names, is applied as the capture's REAL\n * severity (`scope.setLevel`), so a call site asking for `warning` is not\n * reported as an error.\n *\n * Both are all-or-nothing: a value that does not fit the shape (a `tags` map\n * with a non-string value, an unrecognized `level`) stays an ordinary extra, so\n * nothing is ever dropped. A scope that cannot honour the field (no `setLevel`)\n * also falls back to the extra.\n */\n\nimport type { MonitoringLevel, ScopeLike } from \"./types.js\";\n\n/**\n * Narrow an arbitrary value to a flat `Record<string, string>`, or `null` when\n * it is not one. An empty object qualifies (it carries no tags and no\n * information, so it yields neither a tag nor an extra).\n */\nexport function asFlatStringTagMap(value: unknown): Record<string, string> | null {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) return null;\n\n const out: Record<string, string> = {};\n for (const [key, entry] of Object.entries(value as Record<string, unknown>)) {\n if (typeof entry !== \"string\") return null;\n out[key] = entry;\n }\n return out;\n}\n\nconst MONITORING_LEVELS: readonly string[] = [\"fatal\", \"error\", \"warning\", \"info\", \"debug\"];\n\n/** Narrow a value to a monitoring severity name, or `null` when it is not one. */\nexport function asMonitoringLevel(value: unknown): MonitoringLevel | null {\n return typeof value === \"string\" && MONITORING_LEVELS.includes(value) ? (value as MonitoringLevel) : null;\n}\n\n/**\n * Apply a capture context to a scope: real tags for a flat-string-map `tags`\n * entry, the real severity for a recognized `level`, extras for everything else.\n * Tolerates a scope missing any of the methods.\n */\nexport function applyCaptureContext(scope: unknown, context: Record<string, unknown>): void {\n const target = scope as Partial<ScopeLike> | null | undefined;\n\n for (const [key, value] of Object.entries(context)) {\n if (key === \"tags\") {\n const tagMap = asFlatStringTagMap(value);\n if (tagMap) {\n if (typeof target?.setTag === \"function\") {\n for (const [tagKey, tagValue] of Object.entries(tagMap)) {\n target.setTag(tagKey, tagValue);\n }\n }\n continue;\n }\n }\n\n if (key === \"level\") {\n const level = asMonitoringLevel(value);\n if (level && typeof target?.setLevel === \"function\") {\n target.setLevel(level);\n continue;\n }\n }\n\n if (typeof target?.setExtra === \"function\") target.setExtra(key, value);\n }\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type { MonitoringInitOptions, MonitoringUser, MonitoringProvider, ScopeLike } from "./types.js";
1
+ export type { MonitoringInitOptions, MonitoringUser, MonitoringProvider, MonitoringLevel, ScopeLike } from "./types.js";
2
2
  export type { MonitoringAdapter } from "./adapter.js";
3
3
  export { initMonitoring, getMonitoringAdapter, setMonitoringAdapter, resetMonitoringAdapter } from "./init.js";
4
4
  export { captureException, captureMessage, setUser, setTag, withScope, addBreadcrumb } from "./api.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,qBAAqB,EAAE,cAAc,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvG,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAC/G,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEvG,YAAY,EACV,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,wBAAwB,EACxB,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,YAAY,EACZ,WAAW,EACX,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,mBAAmB,EACnB,SAAS,EACT,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,qBAAqB,EAAE,cAAc,EAAE,kBAAkB,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACxH,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAC/G,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEvG,YAAY,EACV,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,wBAAwB,EACxB,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,YAAY,EACZ,WAAW,EACX,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAEvB,YAAY,EACV,mBAAmB,EACnB,SAAS,EACT,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAC/G,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AASvG,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,YAAY,EACZ,WAAW,EACX,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAOvB,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["export type { MonitoringInitOptions, MonitoringUser, MonitoringProvider, ScopeLike } from \"./types.js\";\nexport type { MonitoringAdapter } from \"./adapter.js\";\n\nexport { initMonitoring, getMonitoringAdapter, setMonitoringAdapter, resetMonitoringAdapter } from \"./init.js\";\nexport { captureException, captureMessage, setUser, setTag, withScope, addBreadcrumb } from \"./api.js\";\n\nexport type {\n ForbiddenPattern,\n RedactStringOptions,\n ScrubbableEvent,\n TelemetryScrubberOptions,\n BeforeSendHook,\n} from \"./scrubber.js\";\nexport {\n REDACTION_PLACEHOLDER,\n DEFAULT_FORBIDDEN_PATTERNS,\n redactString,\n redactEvent,\n createTelemetryScrubber,\n} from \"./scrubber.js\";\n\nexport type {\n DefaultSafeEventKey,\n SafeEvent,\n BuildSafeEventOptions,\n} from \"./safe-event.js\";\nexport { DEFAULT_SAFE_EVENT_KEYS, buildSafeEvent } from \"./safe-event.js\";"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAC/G,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AASvG,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,YAAY,EACZ,WAAW,EACX,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAOvB,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC","sourcesContent":["export type { MonitoringInitOptions, MonitoringUser, MonitoringProvider, MonitoringLevel, ScopeLike } from \"./types.js\";\nexport type { MonitoringAdapter } from \"./adapter.js\";\n\nexport { initMonitoring, getMonitoringAdapter, setMonitoringAdapter, resetMonitoringAdapter } from \"./init.js\";\nexport { captureException, captureMessage, setUser, setTag, withScope, addBreadcrumb } from \"./api.js\";\n\nexport type {\n ForbiddenPattern,\n RedactStringOptions,\n ScrubbableEvent,\n TelemetryScrubberOptions,\n BeforeSendHook,\n} from \"./scrubber.js\";\nexport {\n REDACTION_PLACEHOLDER,\n DEFAULT_FORBIDDEN_PATTERNS,\n redactString,\n redactEvent,\n createTelemetryScrubber,\n} from \"./scrubber.js\";\n\nexport type {\n DefaultSafeEventKey,\n SafeEvent,\n BuildSafeEventOptions,\n} from \"./safe-event.js\";\nexport { DEFAULT_SAFE_EVENT_KEYS, buildSafeEvent } from \"./safe-event.js\";"]}
package/dist/types.d.ts CHANGED
@@ -19,10 +19,15 @@ export type MonitoringUser = {
19
19
  username?: string;
20
20
  ip_address?: string;
21
21
  };
22
+ /** The severity names every provider in this package understands. */
23
+ export type MonitoringLevel = "fatal" | "error" | "warning" | "info" | "debug";
22
24
  export type ScopeLike = {
23
25
  setTag: (key: string, value: string) => void;
24
26
  setUser: (user: MonitoringUser | null) => void;
25
27
  setExtra: (key: string, value: unknown) => void;
26
28
  setContext: (key: string, context: Record<string, unknown>) => void;
29
+ /** Optional: real Sentry scopes have it, the noop/minimal scopes may not. A capture
30
+ * context's `level` is applied through this when present (see capture-context.ts). */
31
+ setLevel?: (level: MonitoringLevel) => void;
27
32
  };
28
33
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,aAAa,GAAG,MAAM,CAAC;AAEnE,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;4CACwC;IACxC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;iGAE6F;IAC7F,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF,MAAM,MAA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AAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,OAAO,EAAE,CAAC,IAAI,EAAE,cAAc,GAAG,IAAI,KAAK,IAAI,CAAC;IAC/C,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAChD,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;IACpE;2FACuF;IACvF,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;CAC7C,CAAC"}
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["export type MonitoringProvider = \"sentry\" | \"sentry-node\" | \"noop\";\n\nexport type MonitoringInitOptions = {\n provider: MonitoringProvider;\n dsn?: string;\n environment?: string;\n enabled?: boolean; // default true\n release?: string;\n /** Performance-trace sample rate (0–1), passed through to the provider's init.\n * Omit to use the provider default. */\n tracesSampleRate?: number;\n /** Provider integrations passed through to the SDK init — e.g. `[]` to disable the\n * default auto-integrations and keep init lightweight (the consuming app's Cloud\n * Functions bootstrap does this). Typed loosely: it is a provider-specific pass-through. */\n integrations?: unknown[];\n};\n\nexport type MonitoringUser = {\n id?: string;\n email?: string;\n username?: string;\n ip_address?: string;\n};\n\nexport type ScopeLike = {\n setTag: (key: string, value: string) => void;\n setUser: (user: MonitoringUser | null) => void;\n setExtra: (key: string, value: unknown) => void;\n setContext: (key: string, context: Record<string, unknown>) => void;\n};"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["export type MonitoringProvider = \"sentry\" | \"sentry-node\" | \"noop\";\n\nexport type MonitoringInitOptions = {\n provider: MonitoringProvider;\n dsn?: string;\n environment?: string;\n enabled?: boolean; // default true\n release?: string;\n /** Performance-trace sample rate (0–1), passed through to the provider's init.\n * Omit to use the provider default. */\n tracesSampleRate?: number;\n /** Provider integrations passed through to the SDK init — e.g. `[]` to disable the\n * default auto-integrations and keep init lightweight (the consuming app's Cloud\n * Functions bootstrap does this). Typed loosely: it is a provider-specific pass-through. */\n integrations?: unknown[];\n};\n\nexport type MonitoringUser = {\n id?: string;\n email?: string;\n username?: string;\n ip_address?: string;\n};\n\n/** The severity names every provider in this package understands. */\nexport type MonitoringLevel = \"fatal\" | \"error\" | \"warning\" | \"info\" | \"debug\";\n\nexport type ScopeLike = {\n setTag: (key: string, value: string) => void;\n setUser: (user: MonitoringUser | null) => void;\n setExtra: (key: string, value: unknown) => void;\n setContext: (key: string, context: Record<string, unknown>) => void;\n /** Optional: real Sentry scopes have it, the noop/minimal scopes may not. A capture\n * context's `level` is applied through this when present (see capture-context.ts). */\n setLevel?: (level: MonitoringLevel) => void;\n};"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttt-productions/monitoring-core",
3
- "version": "0.13.2",
3
+ "version": "0.13.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/ttt-productions/ttt-packages.git",