@krak-stack/registry 0.10.16 → 0.10.18

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @krak-stack/registry
2
2
 
3
+ ## 0.10.18
4
+
5
+ ### Patch Changes
6
+
7
+ - Default browser OpenTelemetry exports and ingestion to `/api/diagnostics/{events,spans,measurements}`. Collector endpoints are unchanged. Use explicit browser `urls` and server `HttpApiOtlp.layerWith` paths to keep a custom deployment or the old `/api/otel/v1/*` routes.
8
+
9
+ ## 0.10.17
10
+
11
+ ### Patch Changes
12
+
13
+ - Export `SupportPage` with a responsive heading and description above the inline support form. It shares localization and submission options with `SupportForm` and `SupportDialog`.
14
+
3
15
  ## 0.10.16
4
16
 
5
17
  ### Patch Changes
@@ -749,6 +749,33 @@ var SupportForm = ({
749
749
  ]
750
750
  });
751
751
  };
752
+ var SupportPage = (props) => {
753
+ const { title, description } = useSupportFormMessages(props.locale, props.messages);
754
+ const titleId = useId();
755
+ return /* @__PURE__ */ jsxs3("section", {
756
+ "aria-labelledby": titleId,
757
+ className: "mx-auto grid w-full max-w-xl gap-8 self-start",
758
+ children: [
759
+ /* @__PURE__ */ jsxs3("header", {
760
+ className: "grid gap-3",
761
+ children: [
762
+ /* @__PURE__ */ jsx9("h1", {
763
+ id: titleId,
764
+ className: "text-3xl font-semibold tracking-tight sm:text-4xl",
765
+ children: title
766
+ }),
767
+ description && /* @__PURE__ */ jsx9("p", {
768
+ className: "text-muted-foreground text-base sm:text-lg",
769
+ children: description
770
+ })
771
+ ]
772
+ }),
773
+ /* @__PURE__ */ jsx9(SupportForm, {
774
+ ...props
775
+ })
776
+ ]
777
+ });
778
+ };
752
779
  var SupportDialog = ({ trigger, ...props }) => {
753
780
  const copy = useSupportFormMessages(props.locale, props.messages);
754
781
  const [open, setOpen] = useState(false);
@@ -847,6 +874,7 @@ export {
847
874
  SupportDialog,
848
875
  SupportForm,
849
876
  SupportMultipartPayload,
877
+ SupportPage,
850
878
  SupportReplyEmail,
851
879
  SupportRequestSchema,
852
880
  readSupportScreenshots
@@ -57,6 +57,7 @@ export type SupportFormProps = {
57
57
  onSubmit: (request: SupportRequest) => void | Promise<void>;
58
58
  };
59
59
  export declare const SupportForm: ({ locale, messages, askForReplyEmail, defaultReplyEmail, supportEmail, errorDetails, onSubmit, }: SupportFormProps) => import("react").JSX.Element;
60
+ export declare const SupportPage: (props: SupportFormProps) => import("react").JSX.Element;
60
61
  export type SupportDialogMessages = SupportFormMessages;
61
62
  export type SupportDialogProps = SupportFormProps & {
62
63
  trigger?: ReactElement;
@@ -749,6 +749,33 @@ var SupportForm = ({
749
749
  ]
750
750
  });
751
751
  };
752
+ var SupportPage = (props) => {
753
+ const { title, description } = useSupportFormMessages(props.locale, props.messages);
754
+ const titleId = useId();
755
+ return /* @__PURE__ */ jsxs3("section", {
756
+ "aria-labelledby": titleId,
757
+ className: "mx-auto grid w-full max-w-xl gap-8 self-start",
758
+ children: [
759
+ /* @__PURE__ */ jsxs3("header", {
760
+ className: "grid gap-3",
761
+ children: [
762
+ /* @__PURE__ */ jsx9("h1", {
763
+ id: titleId,
764
+ className: "text-3xl font-semibold tracking-tight sm:text-4xl",
765
+ children: title
766
+ }),
767
+ description && /* @__PURE__ */ jsx9("p", {
768
+ className: "text-muted-foreground text-base sm:text-lg",
769
+ children: description
770
+ })
771
+ ]
772
+ }),
773
+ /* @__PURE__ */ jsx9(SupportForm, {
774
+ ...props
775
+ })
776
+ ]
777
+ });
778
+ };
752
779
  var SupportDialog = ({ trigger, ...props }) => {
753
780
  const copy = useSupportFormMessages(props.locale, props.messages);
754
781
  const [open, setOpen] = useState(false);
@@ -847,6 +874,7 @@ export {
847
874
  SupportDialog,
848
875
  SupportForm,
849
876
  SupportMultipartPayload,
877
+ SupportPage,
850
878
  SupportReplyEmail,
851
879
  SupportRequestSchema,
852
880
  readSupportScreenshots
@@ -2,6 +2,10 @@ import { Config, Layer } from "effect";
2
2
  import { HttpRouter } from "effect/http";
3
3
  import { Otlp } from "./index.js";
4
4
  export { OtlpLogsProcessor, OtlpProcessingError } from "./processor.js";
5
+ type OtlpSignal = "traces" | "metrics" | "logs";
6
+ type OtlpPaths = Record<OtlpSignal, `/${string}`>;
5
7
  export declare class HttpApiOtlp {
8
+ /** Override the browser-facing paths without changing the collector URLs. */
9
+ static readonly layerWith: (overrides: Partial<OtlpPaths>) => Layer.Layer<import("effect/FileSystem").FileSystem | import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/Path").Path, Config.ConfigError, HttpRouter.HttpRouter | Otlp>;
6
10
  static readonly layer: Layer.Layer<import("effect/FileSystem").FileSystem | import("effect/http/Etag").Generator | import("effect/http/HttpPlatform").HttpPlatform | import("effect/Path").Path, Config.ConfigError, HttpRouter.HttpRouter | Otlp>;
7
11
  }
@@ -194,6 +194,13 @@ class Otlp extends Context2.Service()("krakstack/opentelemetry/Otlp") {
194
194
  static layer = Layer2.mergeAll(Layer2.succeed(this, { resource: OtlpResource2.fromConfig() }), ServerEventsLive).pipe(Layer2.provideMerge(EffectOtlp.layerFromConfig()), Layer2.provideMerge(OtlpExporter2.layerFlusher), Layer2.provide(OtlpSerialization2.layerJson), Layer2.provide(FetchHttpClient.layer));
195
195
  }
196
196
 
197
+ // ../../src/services/opentelemetry/paths.ts
198
+ var defaultTelemetryPaths = {
199
+ logs: "/api/diagnostics/events",
200
+ traces: "/api/diagnostics/spans",
201
+ metrics: "/api/diagnostics/measurements"
202
+ };
203
+
197
204
  // ../../src/services/opentelemetry/processor.ts
198
205
  import { Context as Context3, Schema as Schema4 } from "effect";
199
206
 
@@ -206,11 +213,6 @@ class OtlpLogsProcessor extends Context3.Service()("krakstack/opentelemetry/Otlp
206
213
  }
207
214
 
208
215
  // ../../src/services/opentelemetry/api.ts
209
- var otlpProxyPaths = [
210
- "/api/otel/v1/traces",
211
- "/api/otel/v1/metrics",
212
- "/api/otel/v1/logs"
213
- ];
214
216
  var exporterConfig = (signal) => Config2.Array(Schema5.String, `OTEL_${signal}_EXPORTER`).pipe(Config2.map((exporters) => exporters.map((exporter) => exporter.toLowerCase().trim())), Config2.withDefault([]));
215
217
  var readProcessorBody = Effect4.fnUntraced(function* () {
216
218
  const incoming = yield* HttpServerRequest.HttpServerRequest;
@@ -266,7 +268,7 @@ var proxyOtlp = (baseUrl, signal, processor) => Effect4.gen(function* () {
266
268
  return yield* forward;
267
269
  return yield* forward.pipe(Effect4.timeout("5 seconds"), Effect4.catch((error) => Effect4.logWarning("Collector delivery failed after analytics commit", error).pipe(Effect4.as(HttpServerResponse.jsonUnsafe({})))));
268
270
  }).pipe(Effect4.withTracerEnabled(false), HttpMiddleware.withLoggerDisabled, Effect4.catchTag("OtlpProcessingError", (error) => Effect4.succeed(HttpServerResponse.empty({ status: error.status }))), Effect4.catch((error) => Effect4.logError("Failed to proxy browser telemetry", error).pipe(Effect4.as(HttpServerResponse.empty({ status: 502 })))), Effect4.provide(FetchHttpClient2.layer));
269
- var otlpProxyLayer = Layer3.unwrap(Effect4.gen(function* () {
271
+ var otlpProxyLayer = (paths) => Layer3.unwrap(Effect4.gen(function* () {
270
272
  yield* Otlp;
271
273
  const baseUrl = yield* Config2.URL("OTEL_EXPORTER_OTLP_ENDPOINT");
272
274
  const processor = yield* Effect4.serviceOption(OtlpLogsProcessor);
@@ -275,12 +277,15 @@ var otlpProxyLayer = Layer3.unwrap(Effect4.gen(function* () {
275
277
  metrics: exporterConfig("METRICS"),
276
278
  traces: exporterConfig("TRACES")
277
279
  });
278
- return Layer3.mergeAll(exporters.traces.includes("otlp") ? HttpRouter.add("POST", otlpProxyPaths[0], proxyOtlp(baseUrl, "traces", processor)) : Layer3.empty, exporters.metrics.includes("otlp") ? HttpRouter.add("POST", otlpProxyPaths[1], proxyOtlp(baseUrl, "metrics", processor)) : Layer3.empty, exporters.logs.includes("otlp") ? HttpRouter.add("POST", otlpProxyPaths[2], proxyOtlp(baseUrl, "logs", processor)) : Layer3.empty);
280
+ return Layer3.mergeAll(exporters.traces.includes("otlp") ? HttpRouter.add("POST", paths.traces, proxyOtlp(baseUrl, "traces", processor)) : Layer3.empty, exporters.metrics.includes("otlp") ? HttpRouter.add("POST", paths.metrics, proxyOtlp(baseUrl, "metrics", processor)) : Layer3.empty, exporters.logs.includes("otlp") ? HttpRouter.add("POST", paths.logs, proxyOtlp(baseUrl, "logs", processor)) : Layer3.empty);
279
281
  }));
280
- var serverServices = HttpServer.layerServices.pipe(Layer3.provideMerge(HttpMiddleware.layerTracerDisabledForUrls(otlpProxyPaths)));
281
282
 
282
283
  class HttpApiOtlp {
283
- static layer = Layer3.mergeAll(otlpProxyLayer, serverServices);
284
+ static layerWith = (overrides) => {
285
+ const paths = { ...defaultTelemetryPaths, ...overrides };
286
+ return Layer3.mergeAll(otlpProxyLayer(paths), HttpServer.layerServices.pipe(Layer3.provideMerge(HttpMiddleware.layerTracerDisabledForUrls(Object.values(paths)))));
287
+ };
288
+ static layer = HttpApiOtlp.layerWith({});
284
289
  }
285
290
  export {
286
291
  HttpApiOtlp,
@@ -17,6 +17,8 @@ export interface BrowserOtlpOptions {
17
17
  readonly serviceVersion?: string;
18
18
  readonly attributes?: NonNullable<OtlpOptions["resource"]>["attributes"];
19
19
  readonly baseUrl?: string;
20
+ /** Exact endpoints, overriding the URLs derived from baseUrl. Events use logs. */
21
+ readonly urls?: Partial<Record<"logs" | "metrics" | "traces", string>>;
20
22
  readonly headers?: OtlpOptions["headers"];
21
23
  readonly traces?: false | SignalOptions<Parameters<typeof OtlpTracer.layer>[0]>;
22
24
  readonly metrics?: false | SignalOptions<Parameters<typeof OtlpMetrics.layer>[0]>;
@@ -37,5 +39,5 @@ export declare class BrowserOtlp {
37
39
  readonly [x: string]: string | number | boolean | readonly string[] | readonly number[] | readonly boolean[];
38
40
  } | undefined;
39
41
  } | undefined) => Effect.Effect<void, Schema.SchemaError, OtlpEvents>;
40
- static readonly layer: ({ attributes, baseUrl, logs, events, metrics, serviceName, serviceVersion, traces, headers, }: BrowserOtlpOptions) => Layer.Layer<OtlpExporter.Flusher | OtlpEvents, never, never>;
42
+ static readonly layer: ({ attributes, baseUrl, logs, events, metrics, serviceName, serviceVersion, traces, urls, headers, }: BrowserOtlpOptions) => Layer.Layer<OtlpExporter.Flusher | OtlpEvents, never, never>;
41
43
  }
@@ -152,6 +152,13 @@ var event = Effect.fnUntraced(function* (name, properties, options) {
152
152
  });
153
153
  });
154
154
 
155
+ // ../../src/services/opentelemetry/paths.ts
156
+ var defaultTelemetryPaths = {
157
+ logs: "/api/diagnostics/events",
158
+ traces: "/api/diagnostics/spans",
159
+ metrics: "/api/diagnostics/measurements"
160
+ };
161
+
155
162
  // ../../src/services/opentelemetry/browser.ts
156
163
  class BrowserReportedError extends Schema3.TaggedError()("BrowserReportedError", {
157
164
  type: Schema3.Literals(["window.error", "unhandledrejection"]),
@@ -226,19 +233,20 @@ class BrowserOtlp {
226
233
  static event = event;
227
234
  static layer = ({
228
235
  attributes,
229
- baseUrl = "/api/otel",
236
+ baseUrl,
230
237
  logs = false,
231
238
  events = {},
232
239
  metrics = false,
233
240
  serviceName,
234
241
  serviceVersion,
235
242
  traces = {},
243
+ urls,
236
244
  headers
237
245
  }) => {
238
246
  const eventOptions = events === false ? undefined : events;
239
247
  const resource = { attributes, serviceName, serviceVersion };
240
- const request = HttpClientRequest.get(baseUrl);
241
- const signalUrl = (signal) => HttpClientRequest.appendUrl(request, `/v1/${signal}`).url;
248
+ const request = baseUrl === undefined ? undefined : HttpClientRequest.get(baseUrl);
249
+ const signalUrl = (signal) => urls?.[signal] ?? (request ? HttpClientRequest.appendUrl(request, `/v1/${signal}`).url : defaultTelemetryPaths[signal]);
242
250
  const exporters = Layer2.mergeAll(events !== false ? OtlpEvents.layer({
243
251
  exportInterval: "30 seconds",
244
252
  maxBatchSize: 100,
@@ -0,0 +1,5 @@
1
+ export declare const defaultTelemetryPaths: {
2
+ readonly logs: "/api/diagnostics/events";
3
+ readonly traces: "/api/diagnostics/spans";
4
+ readonly metrics: "/api/diagnostics/measurements";
5
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@krak-stack/registry",
3
- "version": "0.10.16",
3
+ "version": "0.10.18",
4
4
  "description": "Tree-shakable KrakStack components and Effect services.",
5
5
  "license": "MIT",
6
6
  "repository": {