@safaricom-mxl/effect-sdk 0.0.15 → 0.0.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,17 +1,34 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
- import { Config, Effect, Layer, Match, Option, References } from "effect";
3
- import * as Tracer from "effect/Tracer";
4
- import { FetchHttpClient, HttpMiddleware } from "effect/unstable/http";
2
+ import { Cause, Config, Context, Duration, Effect, Layer, ManagedRuntime, Match, Option, References, Schedule, Schema, Semaphore } from "effect";
3
+ import { FetchHttpClient, HttpClient, HttpClientRequest, HttpMiddleware } from "effect/unstable/http";
5
4
  import { Otlp } from "effect/unstable/observability";
5
+ import { AsyncLocalStorageContextManager } from "@opentelemetry/context-async-hooks";
6
6
  import * as Otel from "@opentelemetry/api";
7
7
  import { SpanKind, SpanStatusCode, TraceFlags, context, propagation, trace } from "@opentelemetry/api";
8
+ import * as Tracer from "effect/Tracer";
8
9
  import { v7 } from "uuid";
9
10
  import { platform, provider, runtime } from "std-env";
11
+ import { SchemaJITCompiler } from "effect/unstable/schema";
10
12
  import * as Option$1 from "effect/Option";
11
13
  import * as OtelTracer from "@effect/opentelemetry/OtelTracer";
12
14
  //#region src/server/otel-context-bridge.ts
13
- const OTEL_SPAN_TYPE_ID = "~@effect/opentelemetry/OtelTracer/OtelSpan";
14
15
  const evaluate = "~effect/Effect/evaluate";
16
+ let contextManagerInstalled = false;
17
+ /**
18
+ * Install AsyncLocalStorage so `Otel.context.with` actually propagates.
19
+ * Does not replace a context manager the host app already registered.
20
+ */
21
+ function ensureOtelContextManager() {
22
+ if (contextManagerInstalled) return;
23
+ const manager = new AsyncLocalStorageContextManager();
24
+ manager.enable();
25
+ if (!Otel.context.setGlobalContextManager(manager)) {
26
+ manager.disable();
27
+ contextManagerInstalled = true;
28
+ return;
29
+ }
30
+ contextManagerInstalled = true;
31
+ }
15
32
  function formatTraceparent(span) {
16
33
  const flags = span.sampled ? "01" : "00";
17
34
  return `00-${span.traceId}-${span.spanId}-${flags}`;
@@ -22,9 +39,13 @@ function buildTraceCarrierFromSpan(span, headers) {
22
39
  if (headers?.baggage) carrier.baggage = headers.baggage;
23
40
  return carrier;
24
41
  }
25
- /** Map an Effect span to an OpenTelemetry context with the span active. */
42
+ /**
43
+ * Put Effect span ids on the global OpenTelemetry context.
44
+ *
45
+ * Id-only `setSpanContext`. Live `Otel.Span` objects come from
46
+ * `OtelTracer.currentOtelSpan` in Effect space, not from a private TypeId.
47
+ */
26
48
  function effectSpanToOtelContext(activeContext, span) {
27
- if (typeof span === "object" && span !== null && OTEL_SPAN_TYPE_ID in span && "span" in span) return Otel.trace.setSpan(activeContext, span.span);
28
49
  return Otel.trace.setSpanContext(activeContext, {
29
50
  isRemote: span._tag === "ExternalSpan",
30
51
  spanId: span.spanId,
@@ -32,8 +53,15 @@ function effectSpanToOtelContext(activeContext, span) {
32
53
  traceId: span.traceId
33
54
  });
34
55
  }
35
- /** Wrap a tracer so Effect spans activate global `@opentelemetry/api` context. */
56
+ /**
57
+ * Wrap a tracer so Effect spans activate global `@opentelemetry/api` context.
58
+ *
59
+ * Prefer this over `Otlp.layerJson({ tracerContext })`. That callback receives
60
+ * `(primitive, span)` and must return the evaluation, but `EffectPrimitive`
61
+ * only evaluates with a `fiber`. Keep this wrap until Effect passes fiber.
62
+ */
36
63
  function wrapTracerWithOtelContextBridge(base) {
64
+ ensureOtelContextManager();
37
65
  const existingContext = base.context;
38
66
  return Tracer.make({
39
67
  span(options) {
@@ -54,7 +82,7 @@ function wrapTracerWithOtelContextBridge(base) {
54
82
  /**
55
83
  * Layer that wraps the configured Effect tracer with a global OTel context bridge.
56
84
  *
57
- * Must be merged after `Otlp.layerJson` so queue propagation, log correlation,
85
+ * Must be provided over `Otlp.layerJson` so queue propagation, log correlation,
58
86
  * and outbound W3C headers see the active server span.
59
87
  */
60
88
  const otelGlobalContextBridgeLayer = Layer.effect(Tracer.Tracer, Effect.gen(function* () {
@@ -258,10 +286,10 @@ const getAutoPlatformAttributes = () => {
258
286
  };
259
287
  //#endregion
260
288
  //#region src/server/resource.ts
261
- const stringOrUndefined = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
262
- const DEFAULT_VCS_REPOSITORY_URL = "https://gitlab.safaricom.co.ke/mxl/apm/mxl-node-sdk";
289
+ const stringOrUndefined$1 = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
290
+ const DEFAULT_VCS_REPOSITORY_URL = "https://gitlab.safaricom.co.ke/mxl/apm/mxl-effect-sdk";
263
291
  function resolveCommitRevision() {
264
- return stringOrUndefined(process.env.COMMIT_SHA) ?? stringOrUndefined(process.env.VERCEL_GIT_COMMIT_SHA) ?? stringOrUndefined(process.env.GITHUB_SHA) ?? stringOrUndefined(process.env.RAILWAY_GIT_COMMIT_SHA) ?? stringOrUndefined(process.env.CF_PAGES_COMMIT_SHA) ?? stringOrUndefined(process.env.RENDER_GIT_COMMIT);
292
+ return stringOrUndefined$1(process.env.COMMIT_SHA) ?? stringOrUndefined$1(process.env.VERCEL_GIT_COMMIT_SHA) ?? stringOrUndefined$1(process.env.GITHUB_SHA) ?? stringOrUndefined$1(process.env.RAILWAY_GIT_COMMIT_SHA) ?? stringOrUndefined$1(process.env.CF_PAGES_COMMIT_SHA) ?? stringOrUndefined$1(process.env.RENDER_GIT_COMMIT);
265
293
  }
266
294
  let serviceInstanceId;
267
295
  const getServiceInstanceId = () => serviceInstanceId ??= v7();
@@ -301,7 +329,7 @@ const resolveResource = (config) => Effect.gen(function* () {
301
329
  attributes["deployment.commit_sha"] = commitRevision;
302
330
  attributes["vcs.ref.head.revision"] = commitRevision;
303
331
  }
304
- attributes["vcs.repository.url.full"] = stringOrUndefined(process.env.MXL_VCS_REPOSITORY_URL) ?? DEFAULT_VCS_REPOSITORY_URL;
332
+ attributes["vcs.repository.url.full"] = stringOrUndefined$1(process.env.MXL_VCS_REPOSITORY_URL) ?? DEFAULT_VCS_REPOSITORY_URL;
305
333
  Object.assign(attributes, envResourceAttributes);
306
334
  if (config.attributes) Object.assign(attributes, config.attributes);
307
335
  return {
@@ -317,20 +345,24 @@ const resolveResource = (config) => Effect.gen(function* () {
317
345
  }).pipe(Effect.orDie);
318
346
  //#endregion
319
347
  //#region src/server/layer.ts
320
- var layer_exports = /* @__PURE__ */ __exportAll({ layer: () => layer });
348
+ var layer_exports = /* @__PURE__ */ __exportAll({ layer: () => layer$1 });
321
349
  /**
322
350
  * Create an Effect Layer that provides OpenTelemetry traces, logs, and metrics
323
351
  * configured for MXL's OTLP collector.
324
352
  *
325
353
  * Returns a no-op layer when `OTEL_SDK_DISABLED=true`.
354
+ *
355
+ * Wraps the OTLP tracer with `otelGlobalContextBridgeLayer` via `provideMerge`.
356
+ * `Otlp.layerJson({ tracerContext })` cannot evaluate without a `fiber`, and
357
+ * `Layer.updateService` cannot wrap a Tracer the OTLP layer already provides.
326
358
  */
327
- const layer = (config = {}) => Layer.unwrap(Effect.gen(function* () {
359
+ const layer$1 = (config = {}) => Layer.unwrap(Effect.gen(function* () {
328
360
  const resolved = yield* resolveResource({
329
361
  ...config,
330
362
  sdkType: "server"
331
363
  });
332
364
  if (!resolved.endpoint) return Layer.empty;
333
- return Otlp.layerJson({
365
+ const otlp = Otlp.layerJson({
334
366
  baseUrl: normalizeOtlpBaseUrl(resolved.endpoint),
335
367
  headers: resolved.headers,
336
368
  resource: resolved.resource,
@@ -340,7 +372,189 @@ const layer = (config = {}) => Layer.unwrap(Effect.gen(function* () {
340
372
  tracerExportInterval: config.tracerExportInterval,
341
373
  shutdownTimeout: config.shutdownTimeout
342
374
  }).pipe(Layer.provide(FetchHttpClient.layer));
343
- })).pipe(Layer.updateService(Tracer.Tracer, wrapTracerWithOtelContextBridge));
375
+ return otelGlobalContextBridgeLayer.pipe(Layer.provideMerge(otlp));
376
+ }));
377
+ const RESERVED_EVENT_NAMES = ["session_start", "session_end"];
378
+ const isReservedEventName = (name) => RESERVED_EVENT_NAMES.some((reserved) => reserved === name);
379
+ const coerceTrackProps = (props) => {
380
+ if (props === void 0) return {};
381
+ const attributes = {};
382
+ for (const [key, value] of Object.entries(props)) {
383
+ if (value === void 0) continue;
384
+ attributes[key] = typeof value === "string" ? value : String(value);
385
+ }
386
+ return attributes;
387
+ };
388
+ const toEventTimestamp = (value) => (value instanceof Date ? value : new Date(value ?? Date.now())).toISOString();
389
+ const encodeProductEventLine = (input) => {
390
+ const trimmed = typeof input.name === "string" ? input.name.trim() : "";
391
+ if (trimmed.length === 0 || isReservedEventName(trimmed)) return;
392
+ const options = input.options ?? {};
393
+ return {
394
+ attributes: coerceTrackProps(options.attributes),
395
+ group_id: options.groupId ?? "",
396
+ name: trimmed.slice(0, 80),
397
+ page_path: options.pagePath ?? "",
398
+ service_name: input.serviceName,
399
+ session_id: options.sessionId ?? "",
400
+ source: input.source,
401
+ timestamp: toEventTimestamp(options.timestamp),
402
+ traceparent: options.traceparent,
403
+ url: options.url ?? "",
404
+ user_id: options.userId ?? "",
405
+ visitor_id: options.visitorId ?? ""
406
+ };
407
+ };
408
+ const encodeNdjson = (lines) => `${lines.map((line) => JSON.stringify(line)).join("\n")}\n`;
409
+ //#endregion
410
+ //#region src/version.ts
411
+ const SDK_NAME = "mxl-effect-sdk";
412
+ const SDK_VERSION = "0.0.15";
413
+ //#endregion
414
+ //#region src/server/events.ts
415
+ var events_exports = /* @__PURE__ */ __exportAll({
416
+ MxlEvents: () => MxlEvents,
417
+ ProductEventsPostError: () => ProductEventsPostError,
418
+ layer: () => layer,
419
+ make: () => make$1,
420
+ makeHandle: () => makeHandle
421
+ });
422
+ const DEFAULT_FLUSH_INTERVAL = Duration.seconds(5);
423
+ const DEFAULT_MAX_BATCH_SIZE = 100;
424
+ const MAX_BUFFERED_EVENTS = 1e3;
425
+ const WARN_INTERVAL_MS = 3e4;
426
+ const DEFAULT_BASKET_URL = "http://127.0.0.1:8000";
427
+ var MxlEvents = class extends Context.Service()("@safaricom-mxl/effect-sdk/MxlEvents") {};
428
+ var ProductEventsPostError = class extends Schema.TaggedError()("@safaricom-mxl/effect-sdk/ProductEventsPostError", {
429
+ cause: Schema.optionalKey(Schema.Defect()),
430
+ message: Schema.String,
431
+ status: Schema.optionalKey(Schema.Number)
432
+ }) {};
433
+ SchemaJITCompiler.enable(ProductEventsPostError.ast);
434
+ const stringOrUndefined = (value) => value && value.length > 0 ? value : void 0;
435
+ const resolveEventsConfig = (config) => {
436
+ const endpoint = (config.endpoint ?? process.env.MXL_BASKET_URL ?? DEFAULT_BASKET_URL).replace(/\/$/, "");
437
+ return {
438
+ apiKey: stringOrUndefined(config.apiKey ?? process.env.MXL_API_KEY),
439
+ clientId: stringOrUndefined(config.clientId ?? process.env.MXL_CLIENT_ID),
440
+ serviceName: config.serviceName ?? process.env.OTEL_SERVICE_NAME ?? "unknown",
441
+ url: `${endpoint}${config.eventsPath ?? "/events"}`
442
+ };
443
+ };
444
+ const make$1 = Effect.fn("MxlEvents.make")(function* (config = {}) {
445
+ const resolved = resolveEventsConfig(config);
446
+ const maxBatchSize = Math.max(1, config.maxBatchSize ?? DEFAULT_MAX_BATCH_SIZE);
447
+ const client = (yield* HttpClient.HttpClient).pipe(HttpClient.filterStatusOk);
448
+ const flushing = yield* Semaphore.make(1);
449
+ let buffer = [];
450
+ let warnedAboutName = false;
451
+ let warnedAboutClient = false;
452
+ let lastPostWarnAt = 0;
453
+ const warnPost = (error) => {
454
+ const now = Date.now();
455
+ if (now - lastPostWarnAt < WARN_INTERVAL_MS) return;
456
+ lastPostWarnAt = now;
457
+ console.warn(`[MxlEvents] ${error.message} (dropping batch)`, error.cause ?? "");
458
+ };
459
+ const warnMissingClient = () => {
460
+ if (warnedAboutClient) return;
461
+ warnedAboutClient = true;
462
+ console.warn("[MxlEvents] no client id — set MXL_CLIENT_ID or pass `clientId`; dropping events");
463
+ };
464
+ const warnEmptyName = () => {
465
+ if (warnedAboutName) return;
466
+ warnedAboutName = true;
467
+ console.warn("[MxlEvents] track() needs a non-empty event name; the call was ignored.");
468
+ };
469
+ const post = (lines) => {
470
+ const headers = {
471
+ "mxl-client-id": resolved.clientId ?? "",
472
+ "mxl-sdk-name": SDK_NAME,
473
+ "mxl-sdk-version": SDK_VERSION,
474
+ "user-agent": `${SDK_NAME}-server/${SDK_VERSION}`
475
+ };
476
+ if (resolved.apiKey) headers["mxl-api-key"] = resolved.apiKey;
477
+ return HttpClientRequest.post(resolved.url).pipe(HttpClientRequest.setHeaders(headers), HttpClientRequest.bodyText(encodeNdjson(lines), "application/x-ndjson"), client.execute, Effect.asVoid, Effect.mapError((error) => error.response !== void 0 ? new ProductEventsPostError({
478
+ message: `POST ${resolved.url} → ${error.response.status}`,
479
+ status: error.response.status
480
+ }) : new ProductEventsPostError({
481
+ cause: error,
482
+ message: `POST ${resolved.url} failed: ${error.message}`
483
+ })));
484
+ };
485
+ const flush = flushing.withPermits(1)(Effect.suspend(() => {
486
+ if (buffer.length === 0) return Effect.void;
487
+ const batch = buffer;
488
+ buffer = [];
489
+ if (resolved.clientId === void 0) {
490
+ warnMissingClient();
491
+ return Effect.void;
492
+ }
493
+ return post(batch).pipe(Effect.catchCause((cause) => Effect.sync(() => {
494
+ warnPost(Option.getOrElse(Cause.findErrorOption(cause), () => new ProductEventsPostError({
495
+ cause: Cause.squash(cause),
496
+ message: `POST ${resolved.url} failed`
497
+ })));
498
+ })));
499
+ }));
500
+ const track = (name, options = {}) => Effect.sync(() => {
501
+ const line = encodeProductEventLine({
502
+ name,
503
+ options,
504
+ serviceName: resolved.serviceName,
505
+ source: "server"
506
+ });
507
+ if (line === void 0) {
508
+ warnEmptyName();
509
+ return false;
510
+ }
511
+ buffer.push(line);
512
+ if (buffer.length > MAX_BUFFERED_EVENTS) buffer.splice(0, buffer.length - MAX_BUFFERED_EVENTS);
513
+ return buffer.length >= maxBatchSize;
514
+ }).pipe(Effect.flatMap((full) => full ? Effect.forkDetach(flush) : Effect.void), Effect.asVoid);
515
+ const interval = config.flushInterval ?? DEFAULT_FLUSH_INTERVAL;
516
+ if (Duration.toMillis(interval) > 0) yield* Effect.forkScoped(flush.pipe(Effect.schedule(Schedule.spaced(interval))));
517
+ yield* Effect.addFinalizer(() => flush);
518
+ return {
519
+ flush,
520
+ track
521
+ };
522
+ });
523
+ const layer = (config = {}) => Layer.effect(MxlEvents, make$1(config)).pipe(Layer.provide(FetchHttpClient.layer));
524
+ const makeHandle = (config = {}) => {
525
+ const runtime = ManagedRuntime.make(layer(config));
526
+ const swallow = (promise) => promise.then(() => void 0, () => void 0);
527
+ return {
528
+ dispose: () => swallow(runtime.dispose()),
529
+ flush: () => swallow(runtime.runPromise(Effect.gen(function* () {
530
+ yield* (yield* MxlEvents).flush;
531
+ }))),
532
+ track: (name, options) => {
533
+ swallow(runtime.runPromise(Effect.gen(function* () {
534
+ yield* (yield* MxlEvents).track(name, options);
535
+ })));
536
+ }
537
+ };
538
+ };
539
+ //#endregion
540
+ //#region src/server/flushable.ts
541
+ var flushable_exports = /* @__PURE__ */ __exportAll({ make: () => make });
542
+ const make = (config = {}) => {
543
+ const eventsConfig = {
544
+ apiKey: config.apiKey,
545
+ clientId: config.clientId,
546
+ endpoint: config.ingestUrl,
547
+ flushInterval: config.autoFlushInterval === false ? 0 : config.autoFlushInterval,
548
+ serviceName: config.serviceName
549
+ };
550
+ const handle = makeHandle(eventsConfig);
551
+ return {
552
+ dispose: handle.dispose,
553
+ flush: handle.flush,
554
+ layer: Layer.mergeAll(layer$1(config), layer(eventsConfig)),
555
+ track: handle.track
556
+ };
557
+ };
344
558
  //#endregion
345
559
  //#region src/server/http-middleware.ts
346
560
  function shouldDisableHttpTrace(request) {
@@ -704,7 +918,7 @@ function assignTraceFields(event, traceId, spanId, overwrite) {
704
918
  /**
705
919
  * Enrich evlog wide events with trace/span IDs from OTel global context or W3C headers.
706
920
  *
707
- * Use in the MXL evlog enricher chain alongside `createOtelTraceEnricher`.
921
+ * Use `createEffectTraceEnricher` in the MXL evlog enricher chain.
708
922
  */
709
923
  function createEffectTraceEnricher(options = {}) {
710
924
  const overwrite = options.overwrite ?? false;
@@ -825,6 +1039,6 @@ async function withPromiseDependencySpan(name, attributes, operation, kind = "cl
825
1039
  });
826
1040
  }
827
1041
  //#endregion
828
- export { minimumLogLevelLayer as A, layer_exports as B, withParentFromTraceparent as C, logError as D, logDebug as E, getEffectTraceCorrelation as F, normalizeOtlpBaseUrl as G, getAutoPlatformAttributes as H, parseTraceparent as I, otelGlobalContextBridgeLayer as J, buildTraceCarrierFromSpan as K, traceCorrelationLogAnnotations as L, resolveLogLevelFromEnv as M, serializeLogError as N, logInfo as O, annotateLogsWithActiveSpanCorrelation as P, shouldDisableHttpTrace as R, withParentFromTraceCarrier as S, logAtLevel as T, parseOtelResourceAttributes as U, derivePlatformAttributes as V, parseOtlpHeaders as W, wrapTracerWithOtelContextBridge as Y, logHttpResponse as _, kafkaProducerSpanAttributes as a, spanContextFromTraceparent as b, withDependencySpan as c, jobWithSpanEffect as d, runJobWithSpan as f, logHttpRequestFailure as g, finalizeHttpSpan as h, geoSpanAttributes as i, resolveEffectLogLevelFromHttpStatus as j, logWarning as k, withPromiseDependencySpan as l, buildQueueTraceCarrierEffect as m, bufferSpanAttributes as n, queueConsumerSpanAttributes as o, buildQueueTraceCarrier as p, formatTraceparent as q, dbClientSpanAttributes as r, queueProducerSpanAttributes as s, addSpanLinksFromTraceCarriers as t, createEffectTraceEnricher as u, resolveTraceparentFromHeaders as v, buildHttpStatusLogFields as w, withHttpServerSpan as x, spanContextFromCarrier as y, tracerDisabledWhenLayer as z };
1042
+ export { minimumLogLevelLayer as A, flushable_exports as B, withParentFromTraceparent as C, logError as D, logDebug as E, getEffectTraceCorrelation as F, parseOtelResourceAttributes as G, layer_exports as H, parseTraceparent as I, buildTraceCarrierFromSpan as J, parseOtlpHeaders as K, traceCorrelationLogAnnotations as L, resolveLogLevelFromEnv as M, serializeLogError as N, logInfo as O, annotateLogsWithActiveSpanCorrelation as P, shouldDisableHttpTrace as R, withParentFromTraceCarrier as S, logAtLevel as T, derivePlatformAttributes as U, events_exports as V, getAutoPlatformAttributes as W, otelGlobalContextBridgeLayer as X, formatTraceparent as Y, wrapTracerWithOtelContextBridge as Z, logHttpResponse as _, kafkaProducerSpanAttributes as a, spanContextFromTraceparent as b, withDependencySpan as c, jobWithSpanEffect as d, runJobWithSpan as f, logHttpRequestFailure as g, finalizeHttpSpan as h, geoSpanAttributes as i, resolveEffectLogLevelFromHttpStatus as j, logWarning as k, withPromiseDependencySpan as l, buildQueueTraceCarrierEffect as m, bufferSpanAttributes as n, queueConsumerSpanAttributes as o, buildQueueTraceCarrier as p, normalizeOtlpBaseUrl as q, dbClientSpanAttributes as r, queueProducerSpanAttributes as s, addSpanLinksFromTraceCarriers as t, createEffectTraceEnricher as u, resolveTraceparentFromHeaders as v, buildHttpStatusLogFields as w, withHttpServerSpan as x, spanContextFromCarrier as y, tracerDisabledWhenLayer as z };
829
1043
 
830
- //# sourceMappingURL=server-Dz6g7ADZ.mjs.map
1044
+ //# sourceMappingURL=server-BcUHBdnP.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-BcUHBdnP.mjs","names":["stringOrUndefined","uuidv7","EnvConfig.sdkDisabled","EnvConfig.endpoint","endpoint","EnvConfig.otlpHeaders","EnvConfig.serviceVersion","serviceVersion","EnvConfig.environment","environment","EnvConfig.otelServiceName","EnvConfig.otelResourceAttributes","layer","make","otelLayer","eventsLayer","traceApi","otelContext","Option","headerValue","traceApi","otelContext","Option","traceApi","otelContext"],"sources":["../src/server/otel-context-bridge.ts","../src/server/otlp.ts","../src/server/config.ts","../src/server/platform.ts","../src/server/resource.ts","../src/server/layer.ts","../src/shared/product-event.ts","../src/version.ts","../src/server/events.ts","../src/server/flushable.ts","../src/server/http-middleware.ts","../src/server/trace-correlation.ts","../src/server/logging.ts","../src/server/http-tracing.ts","../src/server/jobs.ts","../src/server/evlog-bridge.ts","../src/shared/dependency-spans.ts"],"sourcesContent":["import { AsyncLocalStorageContextManager } from \"@opentelemetry/context-async-hooks\";\nimport * as Otel from \"@opentelemetry/api\";\nimport { Effect, Layer } from \"effect\";\nimport * as Tracer from \"effect/Tracer\";\n\nconst evaluate = \"~effect/Effect/evaluate\" as const;\n\nlet contextManagerInstalled = false;\n\n/**\n * Install AsyncLocalStorage so `Otel.context.with` actually propagates.\n * Does not replace a context manager the host app already registered.\n */\nexport function ensureOtelContextManager(): void {\n if (contextManagerInstalled) return;\n const manager = new AsyncLocalStorageContextManager();\n manager.enable();\n if (!Otel.context.setGlobalContextManager(manager)) {\n manager.disable();\n contextManagerInstalled = true;\n return;\n }\n contextManagerInstalled = true;\n}\n\nexport function formatTraceparent(span: Tracer.AnySpan): string {\n const flags = span.sampled ? \"01\" : \"00\";\n return `00-${span.traceId}-${span.spanId}-${flags}`;\n}\n\nexport function buildTraceCarrierFromSpan(\n span: Tracer.AnySpan,\n headers?: Record<string, string>\n): Record<string, string> {\n const carrier: Record<string, string> = {\n traceparent: formatTraceparent(span),\n };\n\n if (headers?.tracestate) {\n carrier.tracestate = headers.tracestate;\n }\n if (headers?.baggage) {\n carrier.baggage = headers.baggage;\n }\n\n return carrier;\n}\n\n/**\n * Put Effect span ids on the global OpenTelemetry context.\n *\n * Id-only `setSpanContext`. Live `Otel.Span` objects come from\n * `OtelTracer.currentOtelSpan` in Effect space, not from a private TypeId.\n */\nexport function effectSpanToOtelContext(\n activeContext: Otel.Context,\n span: Tracer.AnySpan\n): Otel.Context {\n return Otel.trace.setSpanContext(activeContext, {\n isRemote: span._tag === \"ExternalSpan\",\n spanId: span.spanId,\n traceFlags: span.sampled ? Otel.TraceFlags.SAMPLED : Otel.TraceFlags.NONE,\n traceId: span.traceId,\n });\n}\n\n/**\n * Wrap a tracer so Effect spans activate global `@opentelemetry/api` context.\n *\n * Prefer this over `Otlp.layerJson({ tracerContext })`. That callback receives\n * `(primitive, span)` and must return the evaluation, but `EffectPrimitive`\n * only evaluates with a `fiber`. Keep this wrap until Effect passes fiber.\n */\nexport function wrapTracerWithOtelContextBridge(\n base: Tracer.Tracer\n): Tracer.Tracer {\n ensureOtelContextManager();\n const existingContext = base.context;\n\n return Tracer.make({\n span(options) {\n return base.span(options);\n },\n context(primitive, fiber) {\n if (fiber.cache.span === undefined) {\n if (existingContext) {\n return existingContext(primitive, fiber);\n }\n return primitive[evaluate](fiber);\n }\n\n return Otel.context.with(\n effectSpanToOtelContext(Otel.context.active(), fiber.cache.span),\n () => {\n if (existingContext) {\n return existingContext(primitive, fiber);\n }\n return primitive[evaluate](fiber);\n }\n );\n },\n });\n}\n\n/**\n * Layer that wraps the configured Effect tracer with a global OTel context bridge.\n *\n * Must be provided over `Otlp.layerJson` so queue propagation, log correlation,\n * and outbound W3C headers see the active server span.\n */\nexport const otelGlobalContextBridgeLayer = Layer.effect(\n Tracer.Tracer,\n Effect.gen(function* () {\n const base = yield* Tracer.Tracer;\n return wrapTracerWithOtelContextBridge(base);\n })\n);\n","export function normalizeOtlpBaseUrl(url: string): string {\n const trimmed = url.replace(/\\/$/, \"\");\n if (trimmed.endsWith(\"/v1/traces\") || trimmed.endsWith(\"/v1/logs\")) {\n return trimmed.replace(/\\/v1\\/(traces|logs|metrics)$/, \"\");\n }\n return trimmed;\n}\n","import { Config, Effect, Option } from \"effect\";\n\nconst DEFAULT_OTLP_ENDPOINT = \"http://127.0.0.1:4318\";\n\n/** Resolve the OTLP exporter endpoint from standard env vars. */\nexport const endpoint = Effect.gen(function* () {\n const otlp = yield* Config.option(\n Config.String(\"OTEL_EXPORTER_OTLP_ENDPOINT\")\n );\n if (Option.isSome(otlp)) return otlp;\n return yield* Config.option(Config.String(\"OTLP_ENDPOINT\"));\n});\n\nexport const defaultOtlpEndpoint = DEFAULT_OTLP_ENDPOINT;\n\nexport const sdkDisabled = Config.Boolean(\"OTEL_SDK_DISABLED\").pipe(\n Config.withDefault(false)\n);\n\n/**\n * Resolve service version / commit SHA from platform-specific env vars.\n *\n * Priority: npm_package_version > COMMIT_SHA > RAILWAY_GIT_COMMIT_SHA >\n * VERCEL_GIT_COMMIT_SHA > CF_PAGES_COMMIT_SHA > RENDER_GIT_COMMIT\n */\nexport const serviceVersion = Config.option(\n Config.String(\"npm_package_version\").pipe(\n Config.orElse(() => Config.String(\"COMMIT_SHA\")),\n Config.orElse(() => Config.String(\"RAILWAY_GIT_COMMIT_SHA\")),\n Config.orElse(() => Config.String(\"VERCEL_GIT_COMMIT_SHA\")),\n Config.orElse(() => Config.String(\"CF_PAGES_COMMIT_SHA\")),\n Config.orElse(() => Config.String(\"RENDER_GIT_COMMIT\"))\n )\n);\n\n/**\n * Resolve deployment environment from env vars.\n *\n * Priority: NODE_ENV > DEPLOYMENT_ENV > \"development\"\n */\nexport const environment = Config.String(\"NODE_ENV\").pipe(\n Config.orElse(() => Config.String(\"DEPLOYMENT_ENV\")),\n Config.withDefault(\"development\")\n);\n\n/** OTel-standard service name override. */\nexport const otelServiceName = Config.option(\n Config.String(\"OTEL_SERVICE_NAME\")\n);\n\n/**\n * Parse the OTel-standard `OTEL_RESOURCE_ATTRIBUTES` env var.\n *\n * Format per the OTel spec: comma-separated `key=value` pairs, values may be\n * URL-encoded.\n */\nexport const parseOtelResourceAttributes = (\n input: string\n): Record<string, string> => {\n const result: Record<string, string> = {};\n for (const pair of input.split(\",\")) {\n const eq = pair.indexOf(\"=\");\n if (eq === -1) continue;\n const key = pair.slice(0, eq).trim();\n if (!key) continue;\n const raw = pair.slice(eq + 1).trim();\n let value = raw;\n try {\n value = decodeURIComponent(raw);\n } catch {\n // Fall back to raw string when decoding fails.\n }\n result[key] = value;\n }\n return result;\n};\n\n/** Resolve and parse `OTEL_RESOURCE_ATTRIBUTES`. */\nexport const otelResourceAttributes = Effect.gen(function* () {\n const raw = yield* Config.option(Config.String(\"OTEL_RESOURCE_ATTRIBUTES\"));\n return Option.match(raw, {\n onNone: () => ({}) as Record<string, string>,\n onSome: (value) => parseOtelResourceAttributes(value),\n });\n});\n\n/**\n * Parse `OTEL_EXPORTER_OTLP_HEADERS` (`key=value,key2=value2`) into a header map.\n */\nexport const parseOtlpHeaders = (input: string): Record<string, string> => {\n const result: Record<string, string> = {};\n for (const pair of input.split(\",\")) {\n const eq = pair.indexOf(\"=\");\n if (eq === -1) continue;\n const key = pair.slice(0, eq).trim();\n if (!key) continue;\n const raw = pair.slice(eq + 1).trim();\n try {\n result[key] = decodeURIComponent(raw);\n } catch {\n result[key] = raw;\n }\n }\n return result;\n};\n\n/** Resolve OTLP export headers from env. */\nexport const otlpHeaders = Effect.gen(function* () {\n const raw = yield* Config.option(Config.String(\"OTEL_EXPORTER_OTLP_HEADERS\"));\n return Option.match(raw, {\n onNone: () => ({}) as Record<string, string>,\n onSome: (value) => parseOtlpHeaders(value),\n });\n});\n","import { Match } from \"effect\";\nimport { platform, provider, runtime } from \"std-env\";\n\nexport interface PlatformInputs {\n readonly runtime: string;\n readonly provider: string;\n readonly platform: string;\n readonly arch: string;\n readonly env: Readonly<Record<string, string | undefined>>;\n}\n\ntype Attrs = Record<string, string>;\nconst empty: Attrs = {};\n\nconst runtimeAttrs = (rt: string): Attrs =>\n Match.value(rt).pipe(\n Match.when(\"node\", () => ({ \"process.runtime.name\": \"nodejs\" })),\n Match.whenOr(\"bun\", \"deno\", \"workerd\", \"edge-light\", \"fastly\", (name) => ({\n \"process.runtime.name\": name,\n })),\n Match.orElse((): Attrs => empty)\n );\n\nconst osAttrs = (plat: string): Attrs =>\n Match.value(plat).pipe(\n Match.when(\"win32\", () => ({ \"os.type\": \"windows\" })),\n Match.whenOr(\"darwin\", \"linux\", \"freebsd\", \"openbsd\", \"netbsd\", (p) => ({\n \"os.type\": p,\n })),\n Match.orElse((): Attrs => empty)\n );\n\nconst archAttrs = (a: string): Attrs =>\n a === \"\"\n ? empty\n : {\n \"host.arch\": Match.value(a).pipe(\n Match.when(\"x64\", () => \"amd64\"),\n Match.when(\"ia32\", () => \"x86\"),\n Match.orElse((other) => other)\n ),\n };\n\nconst lambdaAttrs = (env: PlatformInputs[\"env\"]): Attrs => ({\n \"cloud.provider\": \"aws\",\n \"cloud.platform\": \"aws_lambda\",\n \"faas.name\": env.AWS_LAMBDA_FUNCTION_NAME!,\n ...(env.AWS_LAMBDA_FUNCTION_VERSION && {\n \"faas.version\": env.AWS_LAMBDA_FUNCTION_VERSION,\n }),\n ...(env.AWS_LAMBDA_LOG_STREAM_NAME && {\n \"faas.instance\": env.AWS_LAMBDA_LOG_STREAM_NAME,\n }),\n ...(env.AWS_REGION\n ? { \"cloud.region\": env.AWS_REGION }\n : env.AWS_DEFAULT_REGION\n ? { \"cloud.region\": env.AWS_DEFAULT_REGION }\n : {}),\n});\n\nconst providerAttrs = (prov: string, env: PlatformInputs[\"env\"]): Attrs =>\n Match.value(prov).pipe(\n Match.when(\"cloudflare_workers\", (): Attrs => ({\n \"cloud.provider\": \"cloudflare\",\n \"cloud.platform\": \"cloudflare.workers\",\n })),\n Match.when(\"cloudflare_pages\", (): Attrs => ({\n \"cloud.provider\": \"cloudflare\",\n \"cloud.platform\": \"cloudflare.pages\",\n })),\n Match.when(\"vercel\", (): Attrs => ({\n \"cloud.provider\": \"vercel\",\n \"cloud.platform\": \"vercel\",\n ...(env.VERCEL_REGION && { \"cloud.region\": env.VERCEL_REGION }),\n ...(env.VERCEL_DEPLOYMENT_ID && {\n \"faas.instance\": env.VERCEL_DEPLOYMENT_ID,\n }),\n })),\n Match.when(\"netlify\", (): Attrs => ({\n \"cloud.provider\": \"netlify\",\n \"cloud.platform\": \"netlify\",\n })),\n Match.whenOr(\"google_cloudrun\", \"google_cloudrun_job\", (): Attrs => ({\n \"cloud.provider\": \"gcp\",\n \"cloud.platform\": \"gcp_cloud_run\",\n ...(env.K_SERVICE && { \"faas.name\": env.K_SERVICE }),\n ...(env.K_REVISION && { \"faas.version\": env.K_REVISION }),\n ...(env.CLOUD_RUN_REGION && { \"cloud.region\": env.CLOUD_RUN_REGION }),\n })),\n Match.when(\"firebase_app_hosting\", (): Attrs => ({\n \"cloud.provider\": \"gcp\",\n \"cloud.platform\": \"gcp_firebase_app_hosting\",\n })),\n Match.when(\"aws_amplify\", (): Attrs => ({\n \"cloud.provider\": \"aws\",\n \"cloud.platform\": \"aws_amplify\",\n })),\n Match.when(\"deno-deploy\", (): Attrs => ({\n \"cloud.provider\": \"deno\",\n \"cloud.platform\": \"deno_deploy\",\n ...(env.DENO_REGION && { \"cloud.region\": env.DENO_REGION }),\n ...(env.DENO_DEPLOYMENT_ID && {\n \"faas.instance\": env.DENO_DEPLOYMENT_ID,\n }),\n })),\n Match.when(\"render\", (): Attrs => ({\n \"cloud.provider\": \"render\",\n \"cloud.platform\": \"render\",\n ...(env.RENDER_INSTANCE_ID && {\n \"faas.instance\": env.RENDER_INSTANCE_ID,\n }),\n })),\n Match.when(\"railway\", (): Attrs => ({\n \"cloud.provider\": \"railway\",\n \"cloud.platform\": \"railway\",\n ...(env.RAILWAY_REPLICA_ID && {\n \"faas.instance\": env.RAILWAY_REPLICA_ID,\n }),\n })),\n Match.when(\"edgeone_pages\", (): Attrs => ({\n \"cloud.provider\": \"tencent_cloud\",\n \"cloud.platform\": \"tencent_edgeone_pages\",\n })),\n Match.orElse((): Attrs => empty)\n );\n\nconst workerdFallback = (rt: string, alreadyResolved: boolean): Attrs =>\n rt === \"workerd\" && !alreadyResolved\n ? {\n \"cloud.provider\": \"cloudflare\",\n \"cloud.platform\": \"cloudflare.workers\",\n }\n : empty;\n\nconst vercelEdgeFallback = (\n rt: string,\n alreadyResolved: boolean,\n env: PlatformInputs[\"env\"]\n): Attrs =>\n rt === \"edge-light\" && !alreadyResolved && env.VERCEL\n ? { \"cloud.provider\": \"vercel\", \"cloud.platform\": \"vercel\" }\n : empty;\n\nexport const derivePlatformAttributes = (\n inputs: PlatformInputs\n): PlatformAttributes => {\n const { runtime: rt, provider: prov, platform: plat, arch, env } = inputs;\n\n const cloudAttrs = env.AWS_LAMBDA_FUNCTION_NAME\n ? lambdaAttrs(env)\n : providerAttrs(prov, env);\n const cloudResolved = \"cloud.provider\" in cloudAttrs;\n\n return {\n ...(rt && { \"mxl.runtime\": rt }),\n ...(prov && { \"mxl.provider\": prov }),\n ...runtimeAttrs(rt),\n ...osAttrs(plat),\n ...archAttrs(arch),\n ...cloudAttrs,\n ...workerdFallback(rt, cloudResolved),\n ...vercelEdgeFallback(rt, cloudResolved, env),\n };\n};\n\nexport type PlatformAttributes = Attrs;\n\nconst PLATFORM_ENV_KEYS = [\n \"AWS_LAMBDA_FUNCTION_NAME\",\n \"AWS_LAMBDA_FUNCTION_VERSION\",\n \"AWS_LAMBDA_LOG_STREAM_NAME\",\n \"AWS_REGION\",\n \"AWS_DEFAULT_REGION\",\n \"VERCEL\",\n \"VERCEL_REGION\",\n \"VERCEL_DEPLOYMENT_ID\",\n \"K_SERVICE\",\n \"K_REVISION\",\n \"CLOUD_RUN_REGION\",\n \"DENO_REGION\",\n \"DENO_DEPLOYMENT_ID\",\n \"RENDER_INSTANCE_ID\",\n \"RAILWAY_REPLICA_ID\",\n] as const;\n\nexport const getAutoPlatformAttributes = (): PlatformAttributes => {\n const proc = (\n globalThis as { process?: { env?: Record<string, string>; arch?: string } }\n ).process;\n const procEnv = proc?.env ?? {};\n const env: Record<string, string | undefined> = {};\n for (const key of PLATFORM_ENV_KEYS) env[key] = procEnv[key];\n\n return derivePlatformAttributes({\n runtime: runtime ?? \"\",\n provider: provider ?? \"\",\n platform: platform ?? \"\",\n arch: proc?.arch ?? \"\",\n env,\n });\n};\n","import { v7 as uuidv7 } from \"uuid\";\nimport { Effect, Option } from \"effect\";\n\nimport * as EnvConfig from \"./config.js\";\nimport { getAutoPlatformAttributes } from \"./platform.js\";\n\nconst stringOrUndefined = (value: unknown): string | undefined =>\n typeof value === \"string\" && value.length > 0 ? value : undefined;\n\nconst DEFAULT_VCS_REPOSITORY_URL =\n \"https://gitlab.safaricom.co.ke/mxl/apm/mxl-effect-sdk\";\n\nfunction resolveCommitRevision(): string | undefined {\n return (\n stringOrUndefined(process.env.COMMIT_SHA) ??\n stringOrUndefined(process.env.VERCEL_GIT_COMMIT_SHA) ??\n stringOrUndefined(process.env.GITHUB_SHA) ??\n stringOrUndefined(process.env.RAILWAY_GIT_COMMIT_SHA) ??\n stringOrUndefined(process.env.CF_PAGES_COMMIT_SHA) ??\n stringOrUndefined(process.env.RENDER_GIT_COMMIT)\n );\n}\n\nlet serviceInstanceId: string | undefined;\nconst getServiceInstanceId = (): string => (serviceInstanceId ??= uuidv7());\n\nexport interface ResourceConfigInput {\n readonly serviceName?: string | undefined;\n readonly serviceVersion?: string | undefined;\n readonly environment?: string | undefined;\n readonly endpoint?: string | undefined;\n readonly headers?: Record<string, string> | undefined;\n readonly attributes?: Record<string, string> | undefined;\n readonly sdkType?: \"server\" | undefined;\n}\n\nexport interface ResolvedResource {\n readonly endpoint: string | undefined;\n readonly headers: Record<string, string> | undefined;\n readonly resource: {\n readonly serviceName: string;\n readonly serviceVersion: string | undefined;\n readonly attributes: Record<string, string>;\n };\n readonly environment: string | undefined;\n}\n\nexport const resolveResource = (\n config: ResourceConfigInput\n): Effect.Effect<ResolvedResource> =>\n Effect.gen(function* () {\n const disabled = yield* EnvConfig.sdkDisabled;\n if (disabled) {\n return {\n endpoint: undefined,\n environment: undefined,\n headers: undefined,\n resource: {\n attributes: {},\n serviceName: config.serviceName ?? \"unknown\",\n serviceVersion: undefined,\n },\n } satisfies ResolvedResource;\n }\n\n const envEndpoint = yield* EnvConfig.endpoint;\n const endpoint =\n config.endpoint ??\n Option.getOrUndefined(envEndpoint) ??\n EnvConfig.defaultOtlpEndpoint;\n\n const envHeaders = yield* EnvConfig.otlpHeaders;\n const headers =\n config.headers && Object.keys(config.headers).length > 0\n ? config.headers\n : Object.keys(envHeaders).length > 0\n ? envHeaders\n : undefined;\n\n const envServiceVersion = yield* EnvConfig.serviceVersion;\n const serviceVersion =\n config.serviceVersion ?? Option.getOrUndefined(envServiceVersion);\n\n const envEnvironment = yield* EnvConfig.environment;\n const environment = config.environment ?? envEnvironment;\n\n const envOtelServiceName = yield* EnvConfig.otelServiceName;\n const serviceName =\n config.serviceName ??\n Option.getOrUndefined(envOtelServiceName) ??\n \"unknown\";\n\n const envResourceAttributes = yield* EnvConfig.otelResourceAttributes;\n\n const attributes: Record<string, string> = {};\n Object.assign(attributes, getAutoPlatformAttributes());\n attributes[\"mxl.sdk.type\"] = config.sdkType ?? \"server\";\n attributes[\"service.instance.id\"] = getServiceInstanceId();\n if (environment) {\n attributes[\"deployment.environment\"] = environment;\n attributes[\"deployment.environment.name\"] = environment;\n }\n if (serviceVersion) {\n attributes[\"service.version\"] = serviceVersion;\n }\n const commitRevision = resolveCommitRevision();\n if (commitRevision) {\n attributes[\"deployment.commit_sha\"] = commitRevision;\n attributes[\"vcs.ref.head.revision\"] = commitRevision;\n }\n attributes[\"vcs.repository.url.full\"] =\n stringOrUndefined(process.env.MXL_VCS_REPOSITORY_URL) ??\n DEFAULT_VCS_REPOSITORY_URL;\n Object.assign(attributes, envResourceAttributes);\n if (config.attributes) Object.assign(attributes, config.attributes);\n\n return {\n endpoint,\n environment,\n headers,\n resource: { serviceName, serviceVersion, attributes },\n } satisfies ResolvedResource;\n }).pipe(Effect.orDie);\n","import type { Duration } from \"effect\";\nimport { Effect, Layer } from \"effect\";\nimport { FetchHttpClient } from \"effect/unstable/http\";\nimport { Otlp } from \"effect/unstable/observability\";\n\nimport { otelGlobalContextBridgeLayer } from \"./otel-context-bridge.js\";\nimport { normalizeOtlpBaseUrl } from \"./otlp.js\";\nimport { resolveResource } from \"./resource.js\";\n\nexport interface MxlConfig {\n readonly serviceName?: string | undefined;\n readonly serviceVersion?: string | undefined;\n readonly environment?: string | undefined;\n readonly endpoint?: string | undefined;\n readonly headers?: Record<string, string> | undefined;\n readonly attributes?: Record<string, string> | undefined;\n readonly maxBatchSize?: number | undefined;\n readonly loggerExportInterval?: Duration.Input | undefined;\n readonly metricsExportInterval?: Duration.Input | undefined;\n readonly tracerExportInterval?: Duration.Input | undefined;\n readonly shutdownTimeout?: Duration.Input | undefined;\n}\n\n/**\n * Create an Effect Layer that provides OpenTelemetry traces, logs, and metrics\n * configured for MXL's OTLP collector.\n *\n * Returns a no-op layer when `OTEL_SDK_DISABLED=true`.\n *\n * Wraps the OTLP tracer with `otelGlobalContextBridgeLayer` via `provideMerge`.\n * `Otlp.layerJson({ tracerContext })` cannot evaluate without a `fiber`, and\n * `Layer.updateService` cannot wrap a Tracer the OTLP layer already provides.\n */\nexport const layer = (config: MxlConfig = {}) =>\n Layer.unwrap(\n Effect.gen(function* () {\n const resolved = yield* resolveResource({ ...config, sdkType: \"server\" });\n if (!resolved.endpoint) return Layer.empty;\n\n const otlp = Otlp.layerJson({\n baseUrl: normalizeOtlpBaseUrl(resolved.endpoint),\n headers: resolved.headers,\n resource: resolved.resource,\n maxBatchSize: config.maxBatchSize,\n loggerExportInterval: config.loggerExportInterval,\n metricsExportInterval: config.metricsExportInterval,\n tracerExportInterval: config.tracerExportInterval,\n shutdownTimeout: config.shutdownTimeout,\n }).pipe(Layer.provide(FetchHttpClient.layer));\n\n return otelGlobalContextBridgeLayer.pipe(Layer.provideMerge(otlp));\n })\n );\n","export type ProductEventSource = \"server\" | \"browser\";\n\nexport const MAX_EVENT_NAME_LENGTH = 80;\nexport const RESERVED_EVENT_NAMES = [\"session_start\", \"session_end\"] as const;\n\nexport interface ProductEventLine {\n readonly attributes: Record<string, string>;\n readonly group_id: string;\n readonly name: string;\n readonly page_path: string;\n readonly service_name: string;\n readonly session_id: string;\n readonly source: ProductEventSource;\n readonly timestamp: string;\n readonly traceparent?: string | undefined;\n readonly url: string;\n readonly user_id: string;\n readonly visitor_id: string;\n}\n\nexport interface TrackProps {\n readonly [key: string]: unknown;\n}\n\nexport interface TrackOptions {\n readonly attributes?: TrackProps | undefined;\n readonly groupId?: string | undefined;\n readonly pagePath?: string | undefined;\n readonly sessionId?: string | undefined;\n readonly timestamp?: Date | number | undefined;\n readonly traceparent?: string | undefined;\n readonly url?: string | undefined;\n readonly userId?: string | undefined;\n readonly visitorId?: string | undefined;\n}\n\nconst isReservedEventName = (name: string): boolean =>\n RESERVED_EVENT_NAMES.some((reserved) => reserved === name);\n\nexport const coerceTrackProps = (\n props: TrackProps | undefined\n): Record<string, string> => {\n if (props === undefined) {\n return {};\n }\n const attributes: Record<string, string> = {};\n for (const [key, value] of Object.entries(props)) {\n if (value === undefined) {\n continue;\n }\n attributes[key] = typeof value === \"string\" ? value : String(value);\n }\n return attributes;\n};\n\nexport const toEventTimestamp = (value: Date | number | undefined): string =>\n (value instanceof Date ? value : new Date(value ?? Date.now())).toISOString();\n\nexport const encodeProductEventLine = (input: {\n readonly name: string;\n readonly options?: TrackOptions | undefined;\n readonly serviceName: string;\n readonly source: ProductEventSource;\n}): ProductEventLine | undefined => {\n const trimmed = typeof input.name === \"string\" ? input.name.trim() : \"\";\n if (trimmed.length === 0 || isReservedEventName(trimmed)) {\n return undefined;\n }\n const options = input.options ?? {};\n return {\n attributes: coerceTrackProps(options.attributes),\n group_id: options.groupId ?? \"\",\n name: trimmed.slice(0, MAX_EVENT_NAME_LENGTH),\n page_path: options.pagePath ?? \"\",\n service_name: input.serviceName,\n session_id: options.sessionId ?? \"\",\n source: input.source,\n timestamp: toEventTimestamp(options.timestamp),\n traceparent: options.traceparent,\n url: options.url ?? \"\",\n user_id: options.userId ?? \"\",\n visitor_id: options.visitorId ?? \"\",\n };\n};\n\nexport const encodeNdjson = (lines: ReadonlyArray<ProductEventLine>): string =>\n `${lines.map((line) => JSON.stringify(line)).join(\"\\n\")}\\n`;\n","export const SDK_NAME = \"mxl-effect-sdk\";\nexport const SDK_VERSION = \"0.0.15\";\n","import {\n Cause,\n Context,\n Duration,\n Effect,\n Layer,\n ManagedRuntime,\n Option,\n Schedule,\n Schema,\n Semaphore,\n} from \"effect\";\nimport { FetchHttpClient, HttpClient, HttpClientRequest } from \"effect/unstable/http\";\nimport { SchemaJITCompiler } from \"effect/unstable/schema\";\n\nimport {\n encodeNdjson,\n encodeProductEventLine,\n type ProductEventLine,\n type TrackOptions,\n} from \"../shared/product-event.js\";\nimport { SDK_NAME, SDK_VERSION } from \"../version.js\";\n\nexport type { TrackOptions } from \"../shared/product-event.js\";\n\nconst DEFAULT_FLUSH_INTERVAL = Duration.seconds(5);\nconst DEFAULT_MAX_BATCH_SIZE = 100;\nconst MAX_BUFFERED_EVENTS = 1_000;\nconst WARN_INTERVAL_MS = 30_000;\nconst DEFAULT_BASKET_URL = \"http://127.0.0.1:8000\";\n\nexport interface MxlEventsConfig {\n readonly apiKey?: string | undefined;\n readonly clientId?: string | undefined;\n readonly endpoint?: string | undefined;\n readonly eventsPath?: string | undefined;\n readonly flushInterval?: Duration.Input | undefined;\n readonly maxBatchSize?: number | undefined;\n readonly serviceName?: string | undefined;\n}\n\nexport interface MxlEventsApi {\n readonly flush: Effect.Effect<void>;\n readonly track: (name: string, options?: TrackOptions) => Effect.Effect<void>;\n}\n\nexport class MxlEvents extends Context.Service<MxlEvents, MxlEventsApi>()(\n \"@safaricom-mxl/effect-sdk/MxlEvents\"\n) {}\n\nexport class ProductEventsPostError extends Schema.TaggedError<ProductEventsPostError>()(\n \"@safaricom-mxl/effect-sdk/ProductEventsPostError\",\n {\n cause: Schema.optionalKey(Schema.Defect()),\n message: Schema.String,\n status: Schema.optionalKey(Schema.Number),\n }\n) {}\n\nSchemaJITCompiler.enable(ProductEventsPostError.ast);\nconst stringOrUndefined = (value: string | undefined): string | undefined =>\n value && value.length > 0 ? value : undefined;\n\nconst resolveEventsConfig = (config: MxlEventsConfig) => {\n const endpoint = (\n config.endpoint ??\n process.env.MXL_BASKET_URL ??\n DEFAULT_BASKET_URL\n ).replace(/\\/$/, \"\");\n return {\n apiKey: stringOrUndefined(config.apiKey ?? process.env.MXL_API_KEY),\n clientId: stringOrUndefined(config.clientId ?? process.env.MXL_CLIENT_ID),\n serviceName:\n config.serviceName ?? process.env.OTEL_SERVICE_NAME ?? \"unknown\",\n url: `${endpoint}${config.eventsPath ?? \"/events\"}`,\n };\n};\n\nexport const make = Effect.fn(\"MxlEvents.make\")(function* (\n config: MxlEventsConfig = {}\n) {\n const resolved = resolveEventsConfig(config);\n const maxBatchSize = Math.max(1, config.maxBatchSize ?? DEFAULT_MAX_BATCH_SIZE);\n const client = (yield* HttpClient.HttpClient).pipe(HttpClient.filterStatusOk);\n const flushing = yield* Semaphore.make(1);\n\n let buffer: Array<ProductEventLine> = [];\n let warnedAboutName = false;\n let warnedAboutClient = false;\n let lastPostWarnAt = 0;\n\n const warnPost = (error: ProductEventsPostError): void => {\n const now = Date.now();\n if (now - lastPostWarnAt < WARN_INTERVAL_MS) return;\n lastPostWarnAt = now;\n console.warn(`[MxlEvents] ${error.message} (dropping batch)`, error.cause ?? \"\");\n };\n const warnMissingClient = (): void => {\n if (warnedAboutClient) return;\n warnedAboutClient = true;\n console.warn(\n \"[MxlEvents] no client id — set MXL_CLIENT_ID or pass `clientId`; dropping events\"\n );\n };\n const warnEmptyName = (): void => {\n if (warnedAboutName) return;\n warnedAboutName = true;\n console.warn(\"[MxlEvents] track() needs a non-empty event name; the call was ignored.\");\n };\n\n const post = (lines: ReadonlyArray<ProductEventLine>) => {\n const headers: Record<string, string> = {\n \"mxl-client-id\": resolved.clientId ?? \"\",\n \"mxl-sdk-name\": SDK_NAME,\n \"mxl-sdk-version\": SDK_VERSION,\n \"user-agent\": `${SDK_NAME}-server/${SDK_VERSION}`,\n };\n if (resolved.apiKey) {\n headers[\"mxl-api-key\"] = resolved.apiKey;\n }\n return HttpClientRequest.post(resolved.url).pipe(\n HttpClientRequest.setHeaders(headers),\n HttpClientRequest.bodyText(encodeNdjson(lines), \"application/x-ndjson\"),\n client.execute,\n Effect.asVoid,\n Effect.mapError((error) =>\n error.response !== undefined\n ? new ProductEventsPostError({\n message: `POST ${resolved.url} → ${error.response.status}`,\n status: error.response.status,\n })\n : new ProductEventsPostError({\n cause: error,\n message: `POST ${resolved.url} failed: ${error.message}`,\n })\n )\n );\n };\n\n const flush: Effect.Effect<void> = flushing.withPermits(1)(\n Effect.suspend(() => {\n if (buffer.length === 0) return Effect.void;\n const batch = buffer;\n buffer = [];\n if (resolved.clientId === undefined) {\n warnMissingClient();\n return Effect.void;\n }\n return post(batch).pipe(\n Effect.catchCause((cause) =>\n Effect.sync(() => {\n warnPost(\n Option.getOrElse(Cause.findErrorOption(cause), () =>\n new ProductEventsPostError({\n cause: Cause.squash(cause),\n message: `POST ${resolved.url} failed`,\n })\n )\n );\n })\n )\n );\n })\n );\n\n const track = (name: string, options: TrackOptions = {}): Effect.Effect<void> =>\n Effect.sync(() => {\n const line = encodeProductEventLine({\n name,\n options,\n serviceName: resolved.serviceName,\n source: \"server\",\n });\n if (line === undefined) {\n warnEmptyName();\n return false;\n }\n buffer.push(line);\n if (buffer.length > MAX_BUFFERED_EVENTS) {\n buffer.splice(0, buffer.length - MAX_BUFFERED_EVENTS);\n }\n return buffer.length >= maxBatchSize;\n }).pipe(\n Effect.flatMap((full) => (full ? Effect.forkDetach(flush) : Effect.void)),\n Effect.asVoid\n );\n\n const interval = config.flushInterval ?? DEFAULT_FLUSH_INTERVAL;\n if (Duration.toMillis(interval) > 0) {\n yield* Effect.forkScoped(flush.pipe(Effect.schedule(Schedule.spaced(interval))));\n }\n yield* Effect.addFinalizer(() => flush);\n\n return { flush, track } satisfies MxlEventsApi;\n});\n\nexport const layer = (config: MxlEventsConfig = {}): Layer.Layer<MxlEvents> =>\n Layer.effect(MxlEvents, make(config)).pipe(Layer.provide(FetchHttpClient.layer));\n\nexport interface MxlEventsHandle {\n readonly dispose: () => Promise<void>;\n readonly flush: () => Promise<void>;\n readonly track: (name: string, options?: TrackOptions) => void;\n}\n\nexport const makeHandle = (config: MxlEventsConfig = {}): MxlEventsHandle => {\n const runtime = ManagedRuntime.make(layer(config));\n const swallow = (promise: Promise<unknown>): Promise<void> =>\n promise.then(\n () => undefined,\n () => undefined\n );\n return {\n dispose: () => swallow(runtime.dispose()),\n flush: () =>\n swallow(\n runtime.runPromise(\n Effect.gen(function* () {\n const events = yield* MxlEvents;\n yield* events.flush;\n })\n )\n ),\n track: (name, options) => {\n void swallow(\n runtime.runPromise(\n Effect.gen(function* () {\n const events = yield* MxlEvents;\n yield* events.track(name, options);\n })\n )\n );\n },\n };\n};\n","import { Layer } from \"effect\";\n\nimport {\n type MxlEventsConfig,\n type MxlEventsHandle,\n layer as eventsLayer,\n makeHandle,\n} from \"./events.js\";\nimport type { MxlConfig } from \"./layer.js\";\nimport { layer as otelLayer } from \"./layer.js\";\n\nexport interface MxlFlushableConfig extends MxlConfig {\n readonly apiKey?: string | undefined;\n readonly autoFlushInterval?: number | false | undefined;\n readonly clientId?: string | undefined;\n readonly ingestUrl?: string | undefined;\n}\n\nexport interface FlushableTelemetry extends MxlEventsHandle {\n readonly layer: Layer.Layer<never, never, never>;\n}\n\nexport const make = (config: MxlFlushableConfig = {}): FlushableTelemetry => {\n const eventsConfig: MxlEventsConfig = {\n apiKey: config.apiKey,\n clientId: config.clientId,\n endpoint: config.ingestUrl,\n flushInterval:\n config.autoFlushInterval === false ? 0 : config.autoFlushInterval,\n serviceName: config.serviceName,\n };\n const handle = makeHandle(eventsConfig);\n return {\n dispose: handle.dispose,\n flush: handle.flush,\n layer: Layer.mergeAll(\n otelLayer(config),\n eventsLayer(eventsConfig)\n ) as Layer.Layer<never, never, never>,\n track: handle.track,\n };\n};\n","import { Layer } from \"effect\";\nimport { HttpMiddleware } from \"effect/unstable/http\";\n\nexport function shouldDisableHttpTrace(request: {\n url: string;\n method: string;\n}): boolean {\n return (\n request.method === \"OPTIONS\" ||\n request.url === \"/health\" ||\n request.url === \"/healthcheck\" ||\n request.url.startsWith(\"/healthz\") ||\n request.url === \"/metrics\" ||\n /\\.(png|ico|jpg|jpeg|gif|css|js|svg|webp|woff2?)(\\?.*)?$/i.test(request.url)\n );\n}\n\nexport function tracerDisabledWhenLayer(\n filter: (request: {\n url: string;\n method: string;\n }) => boolean = shouldDisableHttpTrace\n) {\n return Layer.succeed(HttpMiddleware.TracerDisabledWhen, filter);\n}\n","import { context as otelContext, trace as traceApi } from \"@opentelemetry/api\";\nimport { Effect } from \"effect\";\nimport * as Option from \"effect/Option\";\n\nexport interface TraceCorrelation {\n spanId?: string;\n traceId?: string;\n}\n\nexport interface TraceLogAnnotations extends Record<string, string> {}\n\nconst ZERO_TRACE_ID = \"00000000000000000000000000000000\";\nconst ZERO_SPAN_ID = \"0000000000000000\";\n\n/** Parse W3C `traceparent` (`00-{traceId}-{spanId}-{flags}`). */\nexport function parseTraceparent(\n traceparent: string | undefined\n): TraceCorrelation {\n if (!traceparent) return {};\n const parts = traceparent.trim().split(\"-\");\n if (parts.length < 4) return {};\n const traceId = parts[1];\n const spanId = parts[2];\n if (!traceId || !spanId) return {};\n if (traceId.length !== 32 || spanId.length !== 16) return {};\n if (traceId === ZERO_TRACE_ID || spanId === ZERO_SPAN_ID) return {};\n return { spanId, traceId };\n}\n\n/**\n * Resolve trace/span IDs for log correlation.\n *\n * Prefers the active OpenTelemetry span (when a host bridge or queue propagation\n * is active), then falls back to a W3C `traceparent` carrier.\n */\nexport function getEffectTraceCorrelation(options?: {\n traceparent?: string | undefined;\n}): TraceCorrelation {\n const activeSpan = traceApi.getSpan(otelContext.active());\n if (activeSpan) {\n const spanContext = activeSpan.spanContext();\n if (\n spanContext.traceId &&\n spanContext.traceId !== ZERO_TRACE_ID &&\n spanContext.spanId &&\n spanContext.spanId !== ZERO_SPAN_ID\n ) {\n return {\n spanId: spanContext.spanId,\n traceId: spanContext.traceId,\n };\n }\n }\n\n return parseTraceparent(options?.traceparent);\n}\n\n/** Build log annotation fields from active span correlation. */\nexport function traceCorrelationLogAnnotations(\n options?: {\n traceparent?: string | undefined;\n } & Record<string, string>\n): TraceLogAnnotations {\n const { traceparent, ...extra } = options ?? {};\n const correlation = getEffectTraceCorrelation({ traceparent });\n const annotations: TraceLogAnnotations = { ...extra };\n\n if (correlation.traceId) {\n annotations[\"trace.trace_id\"] = correlation.traceId;\n annotations.trace_id = correlation.traceId;\n }\n if (correlation.spanId) {\n annotations[\"trace.span_id\"] = correlation.spanId;\n annotations.span_id = correlation.spanId;\n }\n\n return annotations;\n}\n\n/** Annotate Effect logs with the active span's trace/span IDs. */\nexport function annotateLogsWithActiveSpanCorrelation<A, E, R>(\n program: Effect.Effect<A, E, R>,\n fields?: Record<string, string>\n): Effect.Effect<A, E, R> {\n return Effect.gen(function* () {\n const { traceparent, ...extra } = fields ?? {};\n const annotations: TraceLogAnnotations = { ...extra };\n\n const currentSpan = yield* Effect.currentSpan.pipe(Effect.option);\n if (Option.isSome(currentSpan)) {\n annotations[\"trace.trace_id\"] = currentSpan.value.traceId;\n annotations.trace_id = currentSpan.value.traceId;\n annotations[\"trace.span_id\"] = currentSpan.value.spanId;\n annotations.span_id = currentSpan.value.spanId;\n } else {\n Object.assign(\n annotations,\n traceCorrelationLogAnnotations({\n ...(traceparent !== undefined ? { traceparent } : {}),\n ...extra,\n })\n );\n }\n\n if (Object.keys(annotations).length === 0) {\n return yield* program;\n }\n\n return yield* program.pipe(Effect.annotateLogs(annotations));\n });\n}\n","import { Effect, Layer, References } from \"effect\";\n\nexport type EffectLogLevel = \"Debug\" | \"Info\" | \"Warn\" | \"Error\" | \"Fatal\";\n\nexport interface SerializedLogError {\n readonly message: string;\n readonly name: string;\n readonly stack?: string;\n readonly cause?: SerializedLogError;\n}\n\nconst LOG_LEVEL_BY_ENV: Record<string, EffectLogLevel> = {\n trace: \"Debug\",\n debug: \"Debug\",\n info: \"Info\",\n warn: \"Warn\",\n warning: \"Warn\",\n error: \"Error\",\n fatal: \"Fatal\",\n};\n\nexport function resolveLogLevelFromEnv(\n env: NodeJS.ProcessEnv = process.env\n): EffectLogLevel {\n const raw = env.OTEL_LOG_LEVEL ?? env.LOG_LEVEL ?? \"info\";\n return LOG_LEVEL_BY_ENV[raw.trim().toLowerCase()] ?? \"Info\";\n}\n\nfunction isFiniteHttpStatus(status: number | undefined): status is number {\n return typeof status === \"number\" && Number.isFinite(status) && status >= 0;\n}\n\n/** Map HTTP status to Effect log level for response/failure logs. */\nexport function resolveEffectLogLevelFromHttpStatus(\n status: number | undefined\n): EffectLogLevel {\n if (!isFiniteHttpStatus(status) || status < 400) {\n return \"Info\";\n }\n\n if (status >= 500) {\n return \"Error\";\n }\n\n return \"Warn\";\n}\n\nexport type HttpLogOutcome = \"error\" | \"success\";\n\nexport interface HttpStatusLogFields {\n readonly \"http.response.status_code\": string;\n readonly \"http.status\": string;\n readonly \"log.level\": \"error\" | \"info\" | \"warn\";\n readonly outcome: HttpLogOutcome;\n}\n\n/** Standard log fields for HTTP response correlation in OTEL drains. */\nexport function buildHttpStatusLogFields(\n status: number | undefined\n): Partial<HttpStatusLogFields> {\n const level = resolveEffectLogLevelFromHttpStatus(status);\n const outcome: HttpLogOutcome =\n isFiniteHttpStatus(status) && status >= 400 ? \"error\" : \"success\";\n const logLevel =\n level === \"Error\" ? \"error\" : level === \"Warn\" ? \"warn\" : \"info\";\n\n if (!isFiniteHttpStatus(status)) {\n return {\n \"log.level\": logLevel,\n outcome,\n };\n }\n\n const statusText = String(status);\n return {\n \"http.response.status_code\": statusText,\n \"http.status\": statusText,\n \"log.level\": logLevel,\n outcome,\n };\n}\n\n/** Filter Effect logs below the configured minimum level. */\nexport function minimumLogLevelLayer(\n level: EffectLogLevel = resolveLogLevelFromEnv()\n): Layer.Layer<never> {\n return Layer.succeed(References.MinimumLogLevel, level);\n}\n\nfunction resolveErrorMessage(error: Error): string {\n if (error.message.trim().length > 0) {\n return error.message;\n }\n\n if (error.cause !== undefined) {\n if (error.cause instanceof Error && error.cause.message.trim().length > 0) {\n return error.cause.message;\n }\n\n if (typeof error.cause === \"string\" && error.cause.trim().length > 0) {\n return error.cause;\n }\n }\n\n if (\n \"reason\" in error &&\n typeof error.reason === \"string\" &&\n error.reason.trim().length > 0\n ) {\n return error.reason;\n }\n\n return error.name;\n}\n\nexport function serializeLogError(error: unknown): SerializedLogError {\n if (error instanceof Error) {\n return {\n message: resolveErrorMessage(error),\n name: error.name,\n ...(error.stack ? { stack: error.stack } : {}),\n ...(error.message.trim().length === 0 && error.cause !== undefined\n ? { cause: serializeLogError(error.cause) }\n : {}),\n };\n }\n\n return {\n message: String(error),\n name: \"UnknownError\",\n };\n}\n\nfunction annotateFields(\n fields: Record<string, unknown> | undefined\n): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R> {\n if (!fields || Object.keys(fields).length === 0) {\n return (effect) => effect;\n }\n\n const serialized = Object.fromEntries(\n Object.entries(fields).map(([key, value]) => [\n key,\n value instanceof Error ? serializeLogError(value) : value,\n ])\n );\n\n return (effect) => effect.pipe(Effect.annotateLogs(serialized));\n}\n\nexport function logDebug(\n message: string,\n fields?: Record<string, unknown>\n): Effect.Effect<void> {\n return annotateFields(fields)(Effect.logDebug(message));\n}\n\nexport function logInfo(\n message: string,\n fields?: Record<string, unknown>\n): Effect.Effect<void> {\n return annotateFields(fields)(Effect.logInfo(message));\n}\n\nexport function logWarning(\n message: string,\n fields?: Record<string, unknown>\n): Effect.Effect<void> {\n return annotateFields(fields)(Effect.logWarning(message));\n}\n\nexport function logError(\n message: string,\n fields?: Record<string, unknown>\n): Effect.Effect<void> {\n return annotateFields(fields)(Effect.logError(message));\n}\n\nexport function logAtLevel(\n level: EffectLogLevel,\n message: string,\n fields?: Record<string, unknown>\n): Effect.Effect<void> {\n switch (level) {\n case \"Debug\":\n return logDebug(message, fields);\n case \"Info\":\n return logInfo(message, fields);\n case \"Warn\":\n return logWarning(message, fields);\n case \"Error\":\n case \"Fatal\":\n return logError(message, fields);\n }\n}\n","import * as OtelTracer from \"@effect/opentelemetry/OtelTracer\";\nimport {\n context as otelContext,\n propagation,\n SpanStatusCode,\n trace as traceApi,\n TraceFlags,\n type SpanContext,\n} from \"@opentelemetry/api\";\nimport { Effect } from \"effect\";\nimport * as Option from \"effect/Option\";\n\nimport {\n buildHttpStatusLogFields,\n logAtLevel,\n logError,\n resolveEffectLogLevelFromHttpStatus,\n serializeLogError,\n} from \"./logging.js\";\nimport { buildTraceCarrierFromSpan } from \"./otel-context-bridge.js\";\nimport { annotateLogsWithActiveSpanCorrelation } from \"./trace-correlation.js\";\nimport { parseTraceparent } from \"./trace-correlation.js\";\n\nfunction headerValue(\n value: string | ReadonlyArray<string> | undefined\n): string | undefined {\n if (value === undefined) return undefined;\n return typeof value === \"string\" ? value : value[0];\n}\n\nexport function spanContextFromTraceparent(\n traceparent: string | undefined\n): SpanContext | undefined {\n const { traceId, spanId } = parseTraceparent(traceparent);\n if (!traceId || !spanId) return undefined;\n\n return {\n isRemote: true,\n spanId,\n traceFlags: TraceFlags.SAMPLED,\n traceId,\n };\n}\n\nexport function resolveTraceparentFromHeaders(\n headers: Record<string, string | ReadonlyArray<string> | undefined>\n): string | undefined {\n return headerValue(headers.traceparent ?? headers[\"traceparent\"]);\n}\n\nexport function withParentFromTraceparent<A, E, R>(\n headers: Record<string, string | ReadonlyArray<string> | undefined>,\n program: Effect.Effect<A, E, R>\n): Effect.Effect<A, E, R> {\n const parentSpanContext = spanContextFromTraceparent(\n resolveTraceparentFromHeaders(headers)\n );\n\n if (parentSpanContext === undefined) {\n return program;\n }\n\n return OtelTracer.withSpanContext(program, parentSpanContext);\n}\n\nexport interface HttpSpanAttributes {\n readonly method: string;\n readonly route: string;\n readonly requestId?: string | undefined;\n readonly url?: string | undefined;\n}\n\nexport interface QueueTraceContextCarrier {\n readonly baggage?: string;\n readonly traceparent?: string;\n readonly tracestate?: string;\n}\n\nfunction toSpanAttributes(\n attributes: HttpSpanAttributes\n): Record<string, string> {\n const result: Record<string, string> = {\n \"http.request.method\": attributes.method,\n \"http.route\": attributes.route,\n \"url.path\": attributes.route,\n };\n\n if (attributes.requestId !== undefined) {\n result[\"http.request_id\"] = attributes.requestId;\n result[\"request.id\"] = attributes.requestId;\n }\n\n if (attributes.url !== undefined) {\n result[\"url.full\"] = attributes.url;\n }\n\n return result;\n}\n\nexport function withHttpServerSpan<A, E, R>(\n name: string,\n attributes: HttpSpanAttributes,\n program: Effect.Effect<A, E, R>\n): Effect.Effect<A, E, R> {\n return program.pipe(\n Effect.withSpan(name, {\n attributes: toSpanAttributes(attributes),\n kind: \"server\",\n }),\n Effect.withLogSpan(name)\n );\n}\n\nexport function finalizeHttpSpan(\n status: number,\n route?: string\n): Effect.Effect<void> {\n const annotations: Record<string, string | number> = {\n \"http.response.status_code\": status,\n };\n\n if (route !== undefined) {\n annotations[\"http.route\"] = route;\n annotations[\"url.path\"] = route;\n }\n\n return Effect.sync(() => {\n if (status >= 500) {\n const activeSpan = traceApi.getActiveSpan();\n activeSpan?.setStatus({\n code: SpanStatusCode.ERROR,\n message: String(status),\n });\n }\n }).pipe(Effect.andThen(() => Effect.annotateCurrentSpan(annotations)));\n}\n\nexport interface LogHttpResponseOptions {\n readonly status: number;\n readonly durationMs?: number | undefined;\n readonly method?: string | undefined;\n readonly url?: string | undefined;\n readonly route?: string | undefined;\n readonly error?: unknown;\n readonly traceparent?: string | undefined;\n}\n\nfunction stringifyLogFieldValue(value: unknown): string {\n if (value === undefined) {\n return \"\";\n }\n return String(value);\n}\n\nfunction buildHttpResponseLogFields(\n options: LogHttpResponseOptions\n): Record<string, unknown> {\n const fields: Record<string, unknown> = {\n ...buildHttpStatusLogFields(options.status),\n ...(options.durationMs === undefined\n ? {}\n : { durationMs: options.durationMs }),\n ...(options.method === undefined\n ? {}\n : { \"http.request.method\": options.method }),\n ...(options.url === undefined ? {} : { \"url.full\": options.url }),\n ...(options.route === undefined ? {} : { \"http.route\": options.route }),\n ...(options.route === undefined ? {} : { \"url.path\": options.route }),\n ...(options.traceparent === undefined\n ? {}\n : { traceparent: options.traceparent }),\n };\n\n if (options.error !== undefined) {\n fields.error = serializeLogError(options.error);\n }\n\n return fields;\n}\n\n/** Log an HTTP response at info/warn/error severity based on status code. */\nexport function logHttpResponse(\n message: string,\n options: LogHttpResponseOptions\n): Effect.Effect<void> {\n const level = resolveEffectLogLevelFromHttpStatus(options.status);\n const fields = buildHttpResponseLogFields(options);\n const correlationFields = Object.fromEntries(\n Object.entries(fields)\n .filter(([, value]) => value !== undefined)\n .map(([key, value]) => [key, stringifyLogFieldValue(value)])\n );\n\n return annotateLogsWithActiveSpanCorrelation(\n logAtLevel(level, message, fields),\n correlationFields\n );\n}\n\nexport function logHttpRequestFailure(\n message: string,\n error: unknown,\n fields?: Record<string, unknown>\n): Effect.Effect<void> {\n const logFields: Record<string, string> = {};\n if (fields) {\n for (const [key, value] of Object.entries(fields)) {\n if (value !== undefined) {\n logFields[key] = String(value);\n }\n }\n }\n\n return annotateLogsWithActiveSpanCorrelation(\n logError(message, {\n error: serializeLogError(error),\n ...fields,\n }),\n logFields\n );\n}\n\nfunction normalizeHeaderRecord(\n headers: Record<string, string | ReadonlyArray<string> | undefined>\n): Record<string, string> {\n const normalized: Record<string, string> = {};\n for (const [key, value] of Object.entries(headers)) {\n if (value === undefined) continue;\n normalized[key.toLowerCase()] =\n typeof value === \"string\" ? value : (value[0] ?? \"\");\n }\n return normalized;\n}\n\nfunction normalizeCarrierRecord(\n carrier: QueueTraceContextCarrier | Record<string, string> | undefined\n): Record<string, string> | undefined {\n if (!carrier) return undefined;\n const normalized: Record<string, string> = {};\n for (const [key, value] of Object.entries(carrier)) {\n if (value === undefined || value === \"\") continue;\n normalized[key.toLowerCase()] = value;\n }\n return Object.keys(normalized).length > 0 ? normalized : undefined;\n}\n\n/** Resolve parent span context from a W3C trace carrier. */\nexport function spanContextFromCarrier(\n carrier: QueueTraceContextCarrier | Record<string, string> | undefined\n): SpanContext | undefined {\n const normalized = normalizeCarrierRecord(carrier);\n if (!normalized) return undefined;\n\n const extracted = propagation.extract(otelContext.active(), normalized);\n const spanContext = traceApi.getSpan(extracted)?.spanContext();\n if (\n spanContext?.traceId &&\n spanContext.traceId !== \"00000000000000000000000000000000\" &&\n spanContext.spanId &&\n spanContext.spanId !== \"0000000000000000\"\n ) {\n return spanContext;\n }\n\n return spanContextFromTraceparent(normalized.traceparent);\n}\n\nexport function withParentFromTraceCarrier<A, E, R>(\n carrier: QueueTraceContextCarrier | Record<string, string> | undefined,\n program: Effect.Effect<A, E, R>\n): Effect.Effect<A, E, R> {\n const parentSpanContext = spanContextFromCarrier(carrier);\n if (parentSpanContext === undefined) {\n return program;\n }\n return OtelTracer.withSpanContext(program, parentSpanContext);\n}\n\n/** Build W3C trace carrier for queue/job propagation from request headers + active OTel context. */\nexport function buildQueueTraceCarrier(\n headers?: Record<string, string | ReadonlyArray<string> | undefined>\n): Record<string, string> | undefined {\n const normalized = headers ? normalizeHeaderRecord(headers) : {};\n const parentContext = propagation.extract(otelContext.active(), normalized);\n const carrier: Record<string, string> = {};\n propagation.inject(parentContext, carrier);\n return Object.keys(carrier).length > 0 ? carrier : undefined;\n}\n\n/** Build W3C trace carrier using the active Effect span when available. */\nexport function buildQueueTraceCarrierEffect(\n headers?: Record<string, string | ReadonlyArray<string> | undefined>\n): Effect.Effect<Record<string, string> | undefined> {\n return Effect.gen(function* () {\n const normalized = headers ? normalizeHeaderRecord(headers) : {};\n const currentSpan = yield* Effect.currentSpan.pipe(Effect.option);\n\n if (Option.isSome(currentSpan)) {\n return buildTraceCarrierFromSpan(currentSpan.value, normalized);\n }\n\n return buildQueueTraceCarrier(headers);\n });\n}\n","import * as OtelTracer from \"@effect/opentelemetry/OtelTracer\";\nimport type { SpanContext } from \"@opentelemetry/api\";\nimport { Effect, type ManagedRuntime } from \"effect\";\n\nimport {\n type QueueTraceContextCarrier,\n spanContextFromCarrier,\n} from \"./http-tracing.js\";\nimport { logError, logInfo, serializeLogError } from \"./logging.js\";\nimport { annotateLogsWithActiveSpanCorrelation } from \"./trace-correlation.js\";\n\nexport interface RunJobWithSpanOptions {\n readonly name: string;\n readonly attributes?: Record<string, string> | undefined;\n readonly parentSpanContext?: SpanContext | undefined;\n readonly parentTraceCarrier?:\n | QueueTraceContextCarrier\n | Record<string, string>\n | undefined;\n readonly logAttributes?: Record<string, string> | undefined;\n}\n\nfunction resolveParentSpanContext(\n options: RunJobWithSpanOptions\n): SpanContext | undefined {\n if (options.parentSpanContext !== undefined) {\n return options.parentSpanContext;\n }\n return spanContextFromCarrier(options.parentTraceCarrier);\n}\n\nexport function jobWithSpanEffect<A, E, R>(\n options: RunJobWithSpanOptions,\n program: Effect.Effect<A, E, R>\n): Effect.Effect<A, E, R> {\n const parentSpanContext = resolveParentSpanContext(options);\n const startedAt = Date.now();\n\n let wrapped = program.pipe(\n Effect.tap(() =>\n logInfo(\"Job completed\", {\n durationMs: Date.now() - startedAt,\n \"job.name\": options.name,\n outcome: \"success\",\n ...options.logAttributes,\n })\n ),\n Effect.tapError((error) =>\n logError(\"Job failed\", {\n durationMs: Date.now() - startedAt,\n error: serializeLogError(error),\n \"job.name\": options.name,\n outcome: \"error\",\n ...options.logAttributes,\n })\n ),\n (effect) =>\n annotateLogsWithActiveSpanCorrelation(effect, {\n \"job.name\": options.name,\n ...options.logAttributes,\n }),\n Effect.withLogSpan(options.name),\n Effect.withSpan(options.name, {\n attributes: options.attributes,\n kind: \"consumer\",\n })\n );\n\n if (parentSpanContext !== undefined) {\n wrapped = OtelTracer.withSpanContext(wrapped, parentSpanContext);\n }\n\n return wrapped;\n}\n\nexport function runJobWithSpan<A, E, R>(\n runtime: ManagedRuntime.ManagedRuntime<R, unknown>,\n options: RunJobWithSpanOptions,\n program: Effect.Effect<A, E>\n): Promise<A> {\n return runtime.runPromise(jobWithSpanEffect(options, program));\n}\n","import {\n getEffectTraceCorrelation,\n parseTraceparent,\n} from \"./trace-correlation.js\";\n\n/** Minimal evlog enricher context (compatible with `evlog` EnrichContext). */\nexport interface EffectTraceEnrichContext {\n readonly event: Record<string, unknown>;\n readonly headers?: Record<string, string> | undefined;\n}\n\nexport interface EffectTraceEnricherOptions {\n readonly overwrite?: boolean | undefined;\n}\n\nfunction headerValue(\n headers: Record<string, string> | undefined,\n name: string\n): string | undefined {\n if (!headers) return undefined;\n const direct = headers[name];\n if (direct !== undefined) return direct;\n const lower = headers[name.toLowerCase()];\n if (lower !== undefined) return lower;\n return undefined;\n}\n\nfunction assignTraceFields(\n event: Record<string, unknown>,\n traceId: string,\n spanId: string,\n overwrite: boolean\n): void {\n if (overwrite || event.trace_id === undefined) {\n event.trace_id = traceId;\n }\n if (overwrite || event.span_id === undefined) {\n event.span_id = spanId;\n }\n if (overwrite || event.traceId === undefined) {\n event.traceId = traceId;\n }\n if (overwrite || event.spanId === undefined) {\n event.spanId = spanId;\n }\n\n const trace =\n typeof event.trace === \"object\" && event.trace !== null\n ? (event.trace as Record<string, unknown>)\n : {};\n\n if (overwrite || trace.trace_id === undefined) {\n trace.trace_id = traceId;\n }\n if (overwrite || trace.span_id === undefined) {\n trace.span_id = spanId;\n }\n\n if (Object.keys(trace).length > 0) {\n event.trace = trace;\n }\n}\n\n/**\n * Enrich evlog wide events with trace/span IDs from OTel global context or W3C headers.\n *\n * Use `createEffectTraceEnricher` in the MXL evlog enricher chain.\n */\nexport function createEffectTraceEnricher(\n options: EffectTraceEnricherOptions = {}\n): (ctx: EffectTraceEnrichContext) => void {\n const overwrite = options.overwrite ?? false;\n\n return (ctx) => {\n const traceparent = headerValue(ctx.headers, \"traceparent\");\n const correlation = getEffectTraceCorrelation({ traceparent });\n\n if (correlation.traceId && correlation.spanId) {\n assignTraceFields(\n ctx.event,\n correlation.traceId,\n correlation.spanId,\n overwrite\n );\n return;\n }\n\n const parsed = parseTraceparent(traceparent);\n if (parsed.traceId && parsed.spanId) {\n assignTraceFields(ctx.event, parsed.traceId, parsed.spanId, overwrite);\n }\n };\n}\n","import {\n context as otelContext,\n propagation,\n SpanKind,\n SpanStatusCode,\n trace as traceApi,\n} from \"@opentelemetry/api\";\nimport { Effect } from \"effect\";\n\nexport type DbSystem = \"clickhouse\" | \"postgresql\" | \"redis\";\n\nexport type DependencySpanKind = \"client\" | \"producer\" | \"consumer\";\n\nconst MAX_FLUSH_SPAN_LINKS = 32;\n\nexport interface QueueTraceContextCarrier {\n readonly traceparent?: string | undefined;\n readonly tracestate?: string | undefined;\n readonly baggage?: string | undefined;\n}\n\nexport function dbClientSpanAttributes(\n dbSystem: DbSystem,\n operation?: string\n): Record<string, string> {\n return {\n \"db.system\": dbSystem,\n \"db.system.name\": dbSystem,\n \"peer.service\": dbSystem,\n ...(operation ? { \"db.operation.name\": operation } : {}),\n };\n}\n\nexport function queueProducerSpanAttributes(\n destinationName: string,\n peerService = \"mxl-worker\"\n): Record<string, string> {\n return {\n \"messaging.destination.name\": destinationName,\n \"messaging.system\": \"bullmq\",\n \"peer.service\": peerService,\n };\n}\n\nexport function queueConsumerSpanAttributes(\n destinationName: string\n): Record<string, string> {\n return {\n \"messaging.destination.name\": destinationName,\n \"messaging.system\": \"bullmq\",\n };\n}\n\nexport function kafkaProducerSpanAttributes(\n topic: string,\n peerService = \"kafka\"\n): Record<string, string> {\n return {\n \"messaging.destination.name\": topic,\n \"messaging.system\": \"kafka\",\n \"peer.service\": peerService,\n };\n}\n\nexport function bufferSpanAttributes(\n bufferName: string,\n operation: string\n): Record<string, string> {\n return {\n \"buffer.name\": bufferName,\n \"db.operation.name\": operation,\n \"db.system\": \"redis\",\n \"db.system.name\": \"redis\",\n \"peer.service\": \"redis\",\n };\n}\n\nexport function geoSpanAttributes(): Record<string, string> {\n return {\n \"db.operation.name\": \"resolve\",\n \"db.system\": \"maxmind\",\n \"db.system.name\": \"maxmind\",\n \"peer.service\": \"maxmind\",\n };\n}\n\nexport function addSpanLinksFromTraceCarriers(\n carriers: readonly QueueTraceContextCarrier[]\n): number {\n const span = traceApi.getActiveSpan();\n if (!span) {\n return 0;\n }\n\n const seen = new Set<string>();\n let linked = 0;\n\n for (const carrier of carriers) {\n if (!carrier.traceparent || seen.has(carrier.traceparent)) {\n continue;\n }\n seen.add(carrier.traceparent);\n\n const extracted = propagation.extract(otelContext.active(), carrier);\n const linkedContext = traceApi.getSpanContext(extracted);\n if (!linkedContext) {\n continue;\n }\n\n span.addLink({ context: linkedContext });\n linked += 1;\n\n if (linked >= MAX_FLUSH_SPAN_LINKS) {\n break;\n }\n }\n\n return linked;\n}\n\nexport interface WithDependencySpanOptions {\n readonly attributes?: Record<string, string> | undefined;\n readonly kind?: DependencySpanKind | undefined;\n}\n\nexport function withDependencySpan<A, E, R>(\n name: string,\n attributes: Record<string, string>,\n program: Effect.Effect<A, E, R>\n): Effect.Effect<A, E, R>;\nexport function withDependencySpan<A, E, R>(\n name: string,\n options: WithDependencySpanOptions,\n program: Effect.Effect<A, E, R>\n): Effect.Effect<A, E, R>;\nexport function withDependencySpan<A, E, R>(\n name: string,\n attributesOrOptions: Record<string, string> | WithDependencySpanOptions,\n program: Effect.Effect<A, E, R>\n): Effect.Effect<A, E, R> {\n const options = isWithDependencySpanOptions(attributesOrOptions)\n ? attributesOrOptions\n : { attributes: attributesOrOptions };\n\n const attributes = options.attributes ?? {};\n const kind: DependencySpanKind = options.kind ?? \"client\";\n\n return program.pipe(Effect.withSpan(name, { attributes, kind }));\n}\n\nfunction isWithDependencySpanOptions(\n value: Record<string, string> | WithDependencySpanOptions\n): value is WithDependencySpanOptions {\n return (\n typeof value === \"object\" &&\n (\"kind\" in value ||\n (\"attributes\" in value && typeof value.attributes === \"object\"))\n );\n}\n\n/** Promise-based dependency span for non-Effect code paths. */\nexport async function withPromiseDependencySpan<T>(\n name: string,\n attributes: Record<string, string>,\n operation: () => Promise<T>,\n kind: DependencySpanKind = \"client\"\n): Promise<T> {\n const tracer = traceApi.getTracer(\"mxl-effect-sdk\");\n const spanKind =\n kind === \"producer\"\n ? SpanKind.PRODUCER\n : kind === \"consumer\"\n ? SpanKind.CONSUMER\n : SpanKind.CLIENT;\n return tracer.startActiveSpan(\n name,\n { attributes, kind: spanKind },\n async (span) => {\n try {\n const result = await operation();\n span.end();\n return result;\n } catch (error) {\n if (error instanceof Error) {\n span.recordException(error);\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: error.message,\n });\n } else {\n span.setStatus({\n code: SpanStatusCode.ERROR,\n message: String(error),\n });\n }\n span.end();\n throw error;\n }\n }\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAKA,MAAM,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AAY,MAAM;CAAS,GAC7B,OAAO,SAAS;EACd,IAAI;GACF,MAAM,SAAS,MAAM,UAAU;GAC/B,KAAK,IAAI;GACT,OAAO;EACT,SAAS,OAAO;GACd,IAAI,iBAAiB,OAAO;IAC1B,KAAK,gBAAgB,KAAK;IAC1B,KAAK,UAAU;KACb,MAAM,eAAe;KACrB,SAAS,MAAM;IACjB,CAAC;GACH,OACE,KAAK,UAAU;IACb,MAAM,eAAe;IACrB,SAAS,OAAO,KAAK;GACvB,CAAC;GAEH,KAAK,IAAI;GACT,MAAM;EACR;CACF,CACF;AACF"}
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@safaricom-mxl/effect-sdk",
3
- "version": "0.0.15",
4
- "description": "MXL OpenTelemetry SDK for Effect applications",
5
- "license": "MIT",
3
+ "version": "0.0.17",
4
+ "description": "MXL OpenTelemetry and product-analytics SDK for Effect applications",
5
+ "license": "Apache-2.0",
6
6
  "type": "module",
7
7
  "main": "./dist/index.server.mjs",
8
8
  "module": "./dist/index.server.mjs",
@@ -35,6 +35,16 @@
35
35
  "types": "./dist/browser/index.d.ts",
36
36
  "import": "./dist/browser/index.js",
37
37
  "default": "./dist/browser/index.js"
38
+ },
39
+ "./client": {
40
+ "types": "./dist/browser/index.d.ts",
41
+ "import": "./dist/browser/index.js",
42
+ "default": "./dist/browser/index.js"
43
+ },
44
+ "./cloudflare": {
45
+ "types": "./dist/cloudflare/index.d.ts",
46
+ "import": "./dist/cloudflare/index.js",
47
+ "default": "./dist/cloudflare/index.js"
38
48
  }
39
49
  },
40
50
  "typesVersions": {
@@ -47,6 +57,12 @@
47
57
  ],
48
58
  "browser": [
49
59
  "./dist/browser/index.d.ts"
60
+ ],
61
+ "client": [
62
+ "./dist/browser/index.d.ts"
63
+ ],
64
+ "cloudflare": [
65
+ "./dist/cloudflare/index.d.ts"
50
66
  ]
51
67
  }
52
68
  },
@@ -58,30 +74,28 @@
58
74
  },
59
75
  "dependencies": {
60
76
  "@opentelemetry/api": "^1.9.1",
77
+ "@opentelemetry/context-async-hooks": "^2.11.0",
61
78
  "@opentelemetry/exporter-trace-otlp-http": "^0.222.0",
62
79
  "@opentelemetry/sdk-trace-base": "^2.11.0",
63
- "@opentelemetry/sdk-trace-web": "^2.11.0",
64
80
  "std-env": "^4.2.0",
65
81
  "uuid": "^14.0.2"
66
82
  },
67
83
  "devDependencies": {
68
- "@effect/opentelemetry": "^4.0.0-rc.113",
69
- "@opentelemetry/sdk-trace-base": "^2.11.0",
70
- "@opentelemetry/sdk-trace-web": "^2.11.0",
71
- "@types/node": "^26.4.1",
72
- "effect": "^4.0.0-rc.113",
84
+ "@effect/opentelemetry": "^4.0.0-rc.116",
85
+ "@types/node": "^26.6.2",
86
+ "effect": "^4.0.0-rc.116",
73
87
  "tsdown": "^0.23.0",
74
88
  "typescript": "^7.0.2",
75
- "vitest": "^5.0.0"
89
+ "vitest": "^5.0.1"
76
90
  },
77
91
  "peerDependencies": {
78
- "@effect/opentelemetry": "^4.0.0-rc.113",
79
- "effect": "^4.0.0-rc.113"
92
+ "@effect/opentelemetry": "^4.0.0-rc.116",
93
+ "effect": "^4.0.0-rc.116"
80
94
  },
81
95
  "author": "MXL <ServiceAvailability@Safaricom.co.ke>",
82
96
  "repository": {
83
97
  "type": "git",
84
- "url": "https://gitlab.safaricom.co.ke/mxl/apm/mxl-node-sdk.git",
98
+ "url": "https://gitlab.safaricom.co.ke/mxl/apm/mxl-effect-sdk.git",
85
99
  "directory": "packages/effect-sdk"
86
100
  },
87
101
  "engines": {