@krak-stack/registry 0.1.33 → 0.1.35
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/components/ui/code-block.d.ts +1 -1
- package/dist/components/ui/code-block.js +6 -2
- package/dist/components/ui/copy-button.d.ts +1 -1
- package/dist/components/ui/copy-button.js +3 -1
- package/dist/components/ui/data-table.js +21 -12
- package/dist/components/ui/editing-locale-switcher.d.ts +1 -1
- package/dist/components/ui/editing-locale-switcher.js +8 -2
- package/dist/components/ui/effect-form.js +51 -35
- package/dist/components/ui/error-component.d.ts +1 -1
- package/dist/components/ui/error-component.js +6 -2
- package/dist/components/ui/file-picker.d.ts +1 -1
- package/dist/components/ui/file-picker.js +3 -1
- package/dist/components/ui/form.d.ts +12 -12
- package/dist/components/ui/form.js +25 -13
- package/dist/components/ui/google-map.d.ts +1 -1
- package/dist/components/ui/google-map.js +3 -1
- package/dist/components/ui/icon-input.d.ts +1 -1
- package/dist/components/ui/icon-input.js +9 -3
- package/dist/components/ui/krakstack-provider.d.ts +9 -0
- package/dist/components/ui/krakstack-provider.js +28 -0
- package/dist/components/ui/loading.d.ts +1 -1
- package/dist/components/ui/loading.js +3 -1
- package/dist/components/ui/locale-switcher.d.ts +2 -2
- package/dist/components/ui/locale-switcher.js +8 -2
- package/dist/components/ui/pagination.d.ts +1 -1
- package/dist/components/ui/pagination.js +3 -1
- package/dist/components/ui/search-menu.d.ts +1 -1
- package/dist/components/ui/search-menu.js +3 -1
- package/dist/components/ui/theme-switcher.d.ts +1 -1
- package/dist/components/ui/theme-switcher.js +3 -1
- package/dist/components/ui/virtualized-combobox.js +6 -2
- package/dist/lib/docs.js +10 -4
- package/dist/lib/docs.server.js +5 -0
- package/dist/lib/documentation-toolkit.js +5 -0
- package/dist/services/agent/client/index.js +10 -4
- package/dist/services/agent/client/widget.d.ts +1 -1
- package/dist/services/notification/client/index.js +5 -2
- package/dist/services/notification/client/notification-menu.d.ts +2 -2
- package/dist/services/notification/public.js +5 -2
- package/dist/services/opentelemetry/api.js +11 -2
- package/dist/services/opentelemetry/browser.d.ts +15 -7
- package/dist/services/opentelemetry/browser.js +62 -13
- package/package.json +5 -1
package/dist/lib/docs.server.js
CHANGED
|
@@ -75,12 +75,14 @@ var buttonVariants = cva2("group/button inline-flex shrink-0 items-center justif
|
|
|
75
75
|
// ../../src/components/ui/copy-button.tsx
|
|
76
76
|
import { Check, Copy, TriangleAlert } from "lucide-react";
|
|
77
77
|
import { useEffect, useRef, useState } from "react";
|
|
78
|
+
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
|
|
78
79
|
|
|
79
80
|
// ../../src/components/ui/code-block.tsx
|
|
80
81
|
import { highlight } from "@tanstack/highlight";
|
|
81
82
|
import { createThemeCss } from "@tanstack/highlight/theme";
|
|
82
83
|
import { githubDarkTheme } from "@tanstack/highlight/themes/github-dark";
|
|
83
84
|
import { githubLightTheme } from "@tanstack/highlight/themes/github-light";
|
|
85
|
+
import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/krakstack-provider";
|
|
84
86
|
var themeCss = `${createThemeCss({
|
|
85
87
|
light: githubLightTheme,
|
|
86
88
|
dark: githubDarkTheme,
|
|
@@ -113,6 +115,9 @@ import { SearchIcon } from "lucide-react";
|
|
|
113
115
|
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
|
|
114
116
|
import { XIcon } from "lucide-react";
|
|
115
117
|
|
|
118
|
+
// ../../src/components/ui/search-menu.tsx
|
|
119
|
+
import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/krakstack-provider";
|
|
120
|
+
|
|
116
121
|
// ../../src/components/ui/sidebar-layout.tsx
|
|
117
122
|
import { Link as Link2, Outlet, useRouterState } from "@tanstack/react-router";
|
|
118
123
|
import { Option, Schema as Schema2 } from "effect";
|
|
@@ -75,12 +75,14 @@ var buttonVariants = cva2("group/button inline-flex shrink-0 items-center justif
|
|
|
75
75
|
// ../../src/components/ui/copy-button.tsx
|
|
76
76
|
import { Check, Copy, TriangleAlert } from "lucide-react";
|
|
77
77
|
import { useEffect, useRef, useState } from "react";
|
|
78
|
+
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
|
|
78
79
|
|
|
79
80
|
// ../../src/components/ui/code-block.tsx
|
|
80
81
|
import { highlight } from "@tanstack/highlight";
|
|
81
82
|
import { createThemeCss } from "@tanstack/highlight/theme";
|
|
82
83
|
import { githubDarkTheme } from "@tanstack/highlight/themes/github-dark";
|
|
83
84
|
import { githubLightTheme } from "@tanstack/highlight/themes/github-light";
|
|
85
|
+
import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/krakstack-provider";
|
|
84
86
|
var themeCss = `${createThemeCss({
|
|
85
87
|
light: githubLightTheme,
|
|
86
88
|
dark: githubDarkTheme,
|
|
@@ -113,6 +115,9 @@ import { SearchIcon } from "lucide-react";
|
|
|
113
115
|
import { Dialog as DialogPrimitive } from "@base-ui/react/dialog";
|
|
114
116
|
import { XIcon } from "lucide-react";
|
|
115
117
|
|
|
118
|
+
// ../../src/components/ui/search-menu.tsx
|
|
119
|
+
import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/krakstack-provider";
|
|
120
|
+
|
|
116
121
|
// ../../src/components/ui/sidebar-layout.tsx
|
|
117
122
|
import { Link as Link2, Outlet, useRouterState } from "@tanstack/react-router";
|
|
118
123
|
import { Option, Schema as Schema2 } from "effect";
|
|
@@ -211,6 +211,7 @@ function Button({
|
|
|
211
211
|
// ../../src/components/ui/copy-button.tsx
|
|
212
212
|
import { Check, Copy, TriangleAlert } from "lucide-react";
|
|
213
213
|
import { useEffect, useRef, useState } from "react";
|
|
214
|
+
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
|
|
214
215
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
215
216
|
var messages = {
|
|
216
217
|
en: { copy: "Copy", copied: "Copied", copyFailed: "Copy failed" },
|
|
@@ -225,7 +226,7 @@ function CopyButton({
|
|
|
225
226
|
value,
|
|
226
227
|
valueDescription,
|
|
227
228
|
copyVariant = "default",
|
|
228
|
-
locale
|
|
229
|
+
locale: localeOverride,
|
|
229
230
|
messages: messages2,
|
|
230
231
|
onCopied,
|
|
231
232
|
onCopyError,
|
|
@@ -235,6 +236,7 @@ function CopyButton({
|
|
|
235
236
|
"aria-label": ariaLabel,
|
|
236
237
|
...props
|
|
237
238
|
}) {
|
|
239
|
+
const locale = useKrakstackLocale(localeOverride);
|
|
238
240
|
const [copyState, setCopyState] = useState("idle");
|
|
239
241
|
const copyTimeout = useRef(undefined);
|
|
240
242
|
const labels = copyButtonMessages(locale, messages2);
|
|
@@ -298,6 +300,7 @@ import { highlight } from "@tanstack/highlight";
|
|
|
298
300
|
import { createThemeCss } from "@tanstack/highlight/theme";
|
|
299
301
|
import { githubDarkTheme } from "@tanstack/highlight/themes/github-dark";
|
|
300
302
|
import { githubLightTheme } from "@tanstack/highlight/themes/github-light";
|
|
303
|
+
import { useKrakstackLocale as useKrakstackLocale2 } from "@krak-stack/registry/krakstack-provider";
|
|
301
304
|
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
302
305
|
var themeCss = `${createThemeCss({
|
|
303
306
|
light: githubLightTheme,
|
|
@@ -337,9 +340,10 @@ var codeBlockMessages = (locale = "en", translations) => ({
|
|
|
337
340
|
function CodeBlock({
|
|
338
341
|
code,
|
|
339
342
|
language = "text",
|
|
340
|
-
locale
|
|
343
|
+
locale: localeOverride,
|
|
341
344
|
messages: messages3
|
|
342
345
|
}) {
|
|
346
|
+
const locale = useKrakstackLocale2(localeOverride);
|
|
343
347
|
const normalizedLanguage = language.toLowerCase() || "text";
|
|
344
348
|
const highlighted = highlight(code, { lang: normalizedLanguage });
|
|
345
349
|
const labels = codeBlockMessages(locale, messages3);
|
|
@@ -380,7 +384,7 @@ var MarkdownContent = ({
|
|
|
380
384
|
className,
|
|
381
385
|
codeBlocks,
|
|
382
386
|
html,
|
|
383
|
-
locale
|
|
387
|
+
locale,
|
|
384
388
|
messages: messages3
|
|
385
389
|
}) => {
|
|
386
390
|
const content = [];
|
|
@@ -1208,6 +1212,7 @@ var AgentStreamError = Schema2.Struct({
|
|
|
1208
1212
|
});
|
|
1209
1213
|
|
|
1210
1214
|
// ../../src/services/agent/client/widget.tsx
|
|
1215
|
+
import { useKrakstackLocale as useKrakstackLocale3 } from "@krak-stack/registry/krakstack-provider";
|
|
1211
1216
|
import { jsx as jsx19, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1212
1217
|
var messages3 = {
|
|
1213
1218
|
en: {
|
|
@@ -1667,7 +1672,7 @@ function AgentMessageRow({
|
|
|
1667
1672
|
function AgentWidget({
|
|
1668
1673
|
availableReferences = [],
|
|
1669
1674
|
context,
|
|
1670
|
-
locale
|
|
1675
|
+
locale: localeOverride,
|
|
1671
1676
|
messages: messageOverrides,
|
|
1672
1677
|
onInterrupt,
|
|
1673
1678
|
onRemoveContext,
|
|
@@ -1675,6 +1680,7 @@ function AgentWidget({
|
|
|
1675
1680
|
onSubmit,
|
|
1676
1681
|
state
|
|
1677
1682
|
}) {
|
|
1683
|
+
const locale = useKrakstackLocale3(localeOverride);
|
|
1678
1684
|
const labels = agentWidgetMessages(locale, messageOverrides);
|
|
1679
1685
|
const referenceInputId = useId();
|
|
1680
1686
|
const referenceListId = `${referenceInputId}-list`;
|
|
@@ -41,7 +41,7 @@ export type AgentWidgetMessages = {
|
|
|
41
41
|
};
|
|
42
42
|
export type AgentWidgetMessageTranslations = Partial<Record<string, Partial<AgentWidgetMessages>>>;
|
|
43
43
|
export declare const agentWidgetMessages: (locale?: string, translations?: AgentWidgetMessageTranslations) => AgentWidgetMessages;
|
|
44
|
-
export declare function AgentWidget<Resource = never>({ availableReferences, context, locale, messages: messageOverrides, onInterrupt, onRemoveContext, onReset, onSubmit, state, }: {
|
|
44
|
+
export declare function AgentWidget<Resource = never>({ availableReferences, context, locale: localeOverride, messages: messageOverrides, onInterrupt, onRemoveContext, onReset, onSubmit, state, }: {
|
|
45
45
|
readonly availableReferences?: ReadonlyArray<AgentWidgetReference<Resource>>;
|
|
46
46
|
readonly context?: AgentWidgetReference<Resource>;
|
|
47
47
|
readonly locale?: string;
|
|
@@ -303,6 +303,7 @@ function TabsTrigger({ className, ...props }) {
|
|
|
303
303
|
}
|
|
304
304
|
|
|
305
305
|
// ../../src/services/notification/client/notification-menu.tsx
|
|
306
|
+
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
|
|
306
307
|
import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
307
308
|
var defaultMessages = {
|
|
308
309
|
en: {
|
|
@@ -348,7 +349,7 @@ function NotificationMenu({
|
|
|
348
349
|
defaultOpen = false,
|
|
349
350
|
error = false,
|
|
350
351
|
isLoading = false,
|
|
351
|
-
locale
|
|
352
|
+
locale: localeOverride,
|
|
352
353
|
markReadOnOpen = true,
|
|
353
354
|
messages: messageOverrides,
|
|
354
355
|
notifications,
|
|
@@ -360,6 +361,7 @@ function NotificationMenu({
|
|
|
360
361
|
renderItem,
|
|
361
362
|
renderTrigger
|
|
362
363
|
}) {
|
|
364
|
+
const locale = useKrakstackLocale(localeOverride);
|
|
363
365
|
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
|
|
364
366
|
const [tab, setTab] = useState("inbox");
|
|
365
367
|
const open = controlledOpen ?? uncontrolledOpen;
|
|
@@ -462,10 +464,11 @@ function NotificationMenu({
|
|
|
462
464
|
}
|
|
463
465
|
function NotificationMenuTrigger({
|
|
464
466
|
labels: providedLabels,
|
|
465
|
-
locale
|
|
467
|
+
locale: localeOverride,
|
|
466
468
|
messages,
|
|
467
469
|
unreadCount
|
|
468
470
|
}) {
|
|
471
|
+
const locale = useKrakstackLocale(localeOverride);
|
|
469
472
|
const labels = providedLabels ?? notificationMenuMessages(locale, messages);
|
|
470
473
|
return /* @__PURE__ */ jsxs2(PopoverTrigger, {
|
|
471
474
|
"aria-label": unreadCount > 0 ? `${labels.notifications}, ${labels.unread(unreadCount)}` : labels.notifications,
|
|
@@ -51,8 +51,8 @@ export type NotificationMenuProps<ActionResult = ErrorOptions["cause"]> = {
|
|
|
51
51
|
renderItem?: ((notification: NotificationItem) => ReactNode) | undefined;
|
|
52
52
|
renderTrigger?: ((state: NotificationMenuState) => ReactElement) | undefined;
|
|
53
53
|
};
|
|
54
|
-
export declare function NotificationMenu<ActionResult = ErrorOptions["cause"]>({ className, defaultOpen, error, isLoading, locale, markReadOnOpen, messages: messageOverrides, notifications, onArchive, onMarkRead, onNavigate, onOpenChange, open: controlledOpen, renderItem, renderTrigger, }: NotificationMenuProps<ActionResult>): import("react").JSX.Element;
|
|
55
|
-
export declare function NotificationMenuTrigger({ labels: providedLabels, locale, messages, unreadCount, }: {
|
|
54
|
+
export declare function NotificationMenu<ActionResult = ErrorOptions["cause"]>({ className, defaultOpen, error, isLoading, locale: localeOverride, markReadOnOpen, messages: messageOverrides, notifications, onArchive, onMarkRead, onNavigate, onOpenChange, open: controlledOpen, renderItem, renderTrigger, }: NotificationMenuProps<ActionResult>): import("react").JSX.Element;
|
|
55
|
+
export declare function NotificationMenuTrigger({ labels: providedLabels, locale: localeOverride, messages, unreadCount, }: {
|
|
56
56
|
labels?: NotificationMenuMessages | undefined;
|
|
57
57
|
locale?: string | undefined;
|
|
58
58
|
messages?: NotificationMenuMessageTranslations | undefined;
|
|
@@ -396,6 +396,7 @@ function TabsTrigger({ className, ...props }) {
|
|
|
396
396
|
}
|
|
397
397
|
|
|
398
398
|
// ../../src/services/notification/client/notification-menu.tsx
|
|
399
|
+
import { useKrakstackLocale } from "@krak-stack/registry/krakstack-provider";
|
|
399
400
|
import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
400
401
|
var defaultMessages = {
|
|
401
402
|
en: {
|
|
@@ -441,7 +442,7 @@ function NotificationMenu({
|
|
|
441
442
|
defaultOpen = false,
|
|
442
443
|
error = false,
|
|
443
444
|
isLoading = false,
|
|
444
|
-
locale
|
|
445
|
+
locale: localeOverride,
|
|
445
446
|
markReadOnOpen = true,
|
|
446
447
|
messages: messageOverrides,
|
|
447
448
|
notifications,
|
|
@@ -453,6 +454,7 @@ function NotificationMenu({
|
|
|
453
454
|
renderItem,
|
|
454
455
|
renderTrigger
|
|
455
456
|
}) {
|
|
457
|
+
const locale = useKrakstackLocale(localeOverride);
|
|
456
458
|
const [uncontrolledOpen, setUncontrolledOpen] = useState(defaultOpen);
|
|
457
459
|
const [tab, setTab] = useState("inbox");
|
|
458
460
|
const open = controlledOpen ?? uncontrolledOpen;
|
|
@@ -555,10 +557,11 @@ function NotificationMenu({
|
|
|
555
557
|
}
|
|
556
558
|
function NotificationMenuTrigger({
|
|
557
559
|
labels: providedLabels,
|
|
558
|
-
locale
|
|
560
|
+
locale: localeOverride,
|
|
559
561
|
messages,
|
|
560
562
|
unreadCount
|
|
561
563
|
}) {
|
|
564
|
+
const locale = useKrakstackLocale(localeOverride);
|
|
562
565
|
const labels = providedLabels ?? notificationMenuMessages(locale, messages);
|
|
563
566
|
return /* @__PURE__ */ jsxs2(PopoverTrigger, {
|
|
564
567
|
"aria-label": unreadCount > 0 ? `${labels.notifications}, ${labels.unread(unreadCount)}` : labels.notifications,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// ../../src/services/opentelemetry/api.ts
|
|
2
|
-
import { Config, Effect, Layer } from "effect";
|
|
2
|
+
import { Config, Effect, Layer, Schema } from "effect";
|
|
3
3
|
import {
|
|
4
4
|
FetchHttpClient,
|
|
5
5
|
HttpClient,
|
|
@@ -17,6 +17,7 @@ var otlpProxyPaths = [
|
|
|
17
17
|
"/api/otel/v1/metrics",
|
|
18
18
|
"/api/otel/v1/logs"
|
|
19
19
|
];
|
|
20
|
+
var exporterConfig = (signal) => Config.schema(Config.Array(Schema.String), `OTEL_${signal}_EXPORTER`).pipe(Config.map((exporters) => exporters.map((exporter) => exporter.toLowerCase().trim())), Config.withDefault([]));
|
|
20
21
|
var proxyOtlp = (baseUrl, signal) => Effect.gen(function* () {
|
|
21
22
|
const incoming = yield* HttpServerRequest.HttpServerRequest;
|
|
22
23
|
const client = yield* HttpClient.HttpClient;
|
|
@@ -33,7 +34,15 @@ var proxyOtlp = (baseUrl, signal) => Effect.gen(function* () {
|
|
|
33
34
|
}
|
|
34
35
|
});
|
|
35
36
|
}).pipe(Effect.withTracerEnabled(false), HttpMiddleware.withLoggerDisabled, Effect.catch((error) => Effect.logError("Failed to proxy browser telemetry", error).pipe(Effect.as(HttpServerResponse.empty({ status: 502 })))), Effect.provide(FetchHttpClient.layer));
|
|
36
|
-
var otlpProxyLayer = Layer.unwrap(Effect.
|
|
37
|
+
var otlpProxyLayer = Layer.unwrap(Effect.gen(function* () {
|
|
38
|
+
const baseUrl = yield* Config.url("OTEL_EXPORTER_OTLP_ENDPOINT");
|
|
39
|
+
const exporters = yield* Config.all({
|
|
40
|
+
logs: exporterConfig("LOGS"),
|
|
41
|
+
metrics: exporterConfig("METRICS"),
|
|
42
|
+
traces: exporterConfig("TRACES")
|
|
43
|
+
});
|
|
44
|
+
return Layer.mergeAll(exporters.traces.includes("otlp") ? HttpRouter.add("POST", otlpProxyPaths[0], proxyOtlp(baseUrl, "traces")) : Layer.empty, exporters.metrics.includes("otlp") ? HttpRouter.add("POST", otlpProxyPaths[1], proxyOtlp(baseUrl, "metrics")) : Layer.empty, exporters.logs.includes("otlp") ? HttpRouter.add("POST", otlpProxyPaths[2], proxyOtlp(baseUrl, "logs")) : Layer.empty);
|
|
45
|
+
}));
|
|
37
46
|
var serverServices = HttpServer.layerServices.pipe(Layer.provideMerge(HttpMiddleware.layerTracerDisabledForUrls(otlpProxyPaths)));
|
|
38
47
|
|
|
39
48
|
class HttpApiOtlp {
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { Layer } from "effect";
|
|
2
|
-
import { Otlp } from "effect/unstable/observability";
|
|
2
|
+
import { type Otlp, OtlpExporter, OtlpLogger, OtlpMetrics, OtlpTracer } from "effect/unstable/observability";
|
|
3
|
+
type OtlpOptions = Parameters<typeof Otlp.layerJson>[0];
|
|
4
|
+
type SignalOptions<Options> = Omit<Options, "url" | "resource" | "headers">;
|
|
5
|
+
export interface BrowserOtlpOptions {
|
|
6
|
+
readonly serviceName: string;
|
|
7
|
+
readonly serviceVersion?: string;
|
|
8
|
+
readonly attributes?: NonNullable<OtlpOptions["resource"]>["attributes"];
|
|
9
|
+
readonly baseUrl?: string;
|
|
10
|
+
readonly headers?: OtlpOptions["headers"];
|
|
11
|
+
readonly traces?: false | SignalOptions<Parameters<typeof OtlpTracer.layer>[0]>;
|
|
12
|
+
readonly metrics?: false | SignalOptions<Parameters<typeof OtlpMetrics.layer>[0]>;
|
|
13
|
+
readonly logs?: false | SignalOptions<Parameters<typeof OtlpLogger.layer>[0]>;
|
|
14
|
+
}
|
|
3
15
|
export declare class BrowserOtlp {
|
|
4
|
-
static readonly layer: ({ attributes, baseUrl, serviceName, serviceVersion,
|
|
5
|
-
readonly serviceName: string;
|
|
6
|
-
readonly serviceVersion?: string;
|
|
7
|
-
readonly attributes?: NonNullable<Parameters<typeof Otlp.layerJson>[0]["resource"]>["attributes"];
|
|
8
|
-
readonly baseUrl?: string;
|
|
9
|
-
}) => Layer.Layer<never, never, never>;
|
|
16
|
+
static readonly layer: ({ attributes, baseUrl, logs, metrics, serviceName, serviceVersion, traces, headers, }: BrowserOtlpOptions) => Layer.Layer<OtlpExporter.Flusher, never, never>;
|
|
10
17
|
}
|
|
18
|
+
export {};
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
// ../../src/services/opentelemetry/browser.ts
|
|
2
|
-
import { Effect, Layer, Predicate, Schema, Stream } from "effect";
|
|
3
|
-
import { FetchHttpClient } from "effect/unstable/http";
|
|
4
|
-
import {
|
|
2
|
+
import { Effect, FiberSet, Layer, Predicate, Schema, Stream } from "effect";
|
|
3
|
+
import { FetchHttpClient, HttpClientRequest } from "effect/unstable/http";
|
|
4
|
+
import {
|
|
5
|
+
OtlpExporter,
|
|
6
|
+
OtlpLogger,
|
|
7
|
+
OtlpMetrics,
|
|
8
|
+
OtlpSerialization,
|
|
9
|
+
OtlpTracer
|
|
10
|
+
} from "effect/unstable/observability";
|
|
5
11
|
|
|
6
12
|
class BrowserReportedError extends Schema.TaggedError()("BrowserReportedError", {
|
|
7
13
|
type: Schema.Literals(["window.error", "unhandledrejection"]),
|
|
@@ -10,6 +16,8 @@ class BrowserReportedError extends Schema.TaggedError()("BrowserReportedError",
|
|
|
10
16
|
}) {
|
|
11
17
|
}
|
|
12
18
|
var reportBrowserException = (exception) => Effect.fail(exception).pipe(Effect.withSpan("browser.exception", {
|
|
19
|
+
root: true,
|
|
20
|
+
sampled: true,
|
|
13
21
|
attributes: {
|
|
14
22
|
"exception.type": exception.type,
|
|
15
23
|
"exception.message": exception.message,
|
|
@@ -36,23 +44,64 @@ var BrowserExceptionTrackingLive = Layer.effectDiscard(Stream.merge(Stream.fromE
|
|
|
36
44
|
message: "Unhandled promise rejection"
|
|
37
45
|
});
|
|
38
46
|
}))).pipe(Stream.runForEach(reportBrowserException), Effect.forkScoped));
|
|
47
|
+
var BrowserLifecycleFlushingLive = Layer.effectDiscard(Effect.gen(function* () {
|
|
48
|
+
const flusher = yield* OtlpExporter.Flusher;
|
|
49
|
+
const fibers = yield* FiberSet.make();
|
|
50
|
+
const run = yield* FiberSet.runtime(fibers)();
|
|
51
|
+
const flush = () => {
|
|
52
|
+
run(flusher.flush.pipe(Effect.provideService(FetchHttpClient.RequestInit, {
|
|
53
|
+
keepalive: true
|
|
54
|
+
})));
|
|
55
|
+
};
|
|
56
|
+
const onVisibilityChange = () => {
|
|
57
|
+
if (document.visibilityState === "hidden")
|
|
58
|
+
flush();
|
|
59
|
+
};
|
|
60
|
+
yield* Effect.acquireRelease(Effect.sync(() => {
|
|
61
|
+
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
62
|
+
globalThis.addEventListener("pagehide", flush);
|
|
63
|
+
}), () => Effect.sync(() => {
|
|
64
|
+
document.removeEventListener("visibilitychange", onVisibilityChange);
|
|
65
|
+
globalThis.removeEventListener("pagehide", flush);
|
|
66
|
+
}));
|
|
67
|
+
}));
|
|
39
68
|
|
|
40
69
|
class BrowserOtlp {
|
|
41
70
|
static layer = ({
|
|
42
71
|
attributes,
|
|
43
72
|
baseUrl = "/api/otel",
|
|
73
|
+
logs = false,
|
|
74
|
+
metrics = false,
|
|
44
75
|
serviceName,
|
|
45
76
|
serviceVersion,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
77
|
+
traces = {},
|
|
78
|
+
headers
|
|
79
|
+
}) => {
|
|
80
|
+
const resource = { attributes, serviceName, serviceVersion };
|
|
81
|
+
const request = HttpClientRequest.get(baseUrl);
|
|
82
|
+
const signalUrl = (signal) => HttpClientRequest.appendUrl(request, `/v1/${signal}`).url;
|
|
83
|
+
const exporters = Layer.mergeAll(OtlpExporter.layerFlusher, traces !== false ? OtlpTracer.layer({
|
|
84
|
+
exportInterval: "30 seconds",
|
|
85
|
+
...traces,
|
|
86
|
+
url: signalUrl("traces"),
|
|
87
|
+
resource,
|
|
88
|
+
headers
|
|
89
|
+
}) : Layer.empty, metrics !== false ? OtlpMetrics.layer({
|
|
90
|
+
exportInterval: "60 seconds",
|
|
91
|
+
...metrics,
|
|
92
|
+
url: signalUrl("metrics"),
|
|
93
|
+
resource,
|
|
94
|
+
headers
|
|
95
|
+
}) : Layer.empty, logs !== false ? OtlpLogger.layer({
|
|
96
|
+
excludeLogSpans: true,
|
|
97
|
+
mergeWithExisting: true,
|
|
98
|
+
...logs,
|
|
99
|
+
url: signalUrl("logs"),
|
|
100
|
+
resource,
|
|
101
|
+
headers
|
|
102
|
+
}) : Layer.empty).pipe(Layer.provide(OtlpSerialization.layerJson), Layer.provide(FetchHttpClient.layer));
|
|
103
|
+
return Layer.mergeAll(BrowserLifecycleFlushingLive, traces !== false ? BrowserExceptionTrackingLive : Layer.empty).pipe(Layer.provideMerge(exporters));
|
|
104
|
+
};
|
|
56
105
|
}
|
|
57
106
|
export {
|
|
58
107
|
BrowserOtlp
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krak-stack/registry",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.35",
|
|
4
4
|
"description": "Tree-shakable KrakStack components and Effect services.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -127,6 +127,10 @@
|
|
|
127
127
|
"types": "./dist/components/ui/icon-input.d.ts",
|
|
128
128
|
"import": "./dist/components/ui/icon-input.js"
|
|
129
129
|
},
|
|
130
|
+
"./krakstack-provider": {
|
|
131
|
+
"types": "./dist/components/ui/krakstack-provider.d.ts",
|
|
132
|
+
"import": "./dist/components/ui/krakstack-provider.js"
|
|
133
|
+
},
|
|
130
134
|
"./loading": {
|
|
131
135
|
"types": "./dist/components/ui/loading.d.ts",
|
|
132
136
|
"import": "./dist/components/ui/loading.js"
|