Skip to content

feat(export): OTLP/JSON exporter for OpenTelemetry integration #140

Description

@brucearctor

Summary

Implement an OtlpJsonExporter that sends UserALE logs to any OpenTelemetry Collector via OTLP/HTTP JSON.

Motivation

OpenTelemetry is the de-facto standard for observability. OTLP support lets Flagon users send behavioral data to Grafana, Datadog, Jaeger, and any OTel-compatible backend — without building custom ingestion pipelines.

No competing behavioral analytics library (PostHog, Matomo, Plausible) speaks OTLP. This is a differentiation opportunity.

Design

  • Maps Flagon log fields → OTLP LogRecord attributes using OTel semantic conventions
  • Builds OTLP/JSON payloads using plain objects (zero external dependencies)
  • Ships to standard OTLP HTTP receiver (port 4318, /v1/logs)
  • ~150 lines of code, ~2-3 KB gzipped added to bundle

Attribute Mapping

Flagon Field OTLP Mapping
clientTime timeUnixNano
toolName resource.service.name
useraleVersion resource.telemetry.sdk.version
userId attributes.enduser.id
sessionId attributes.session.id
pageUrl attributes.url.full
target attributes.flagon.dom.target
type attributes.flagon.event_type
logType attributes.flagon.log_type
details body (JSON string)

User Experience

// One config change to enable OTLP
userale.start({
  exporterType: 'otlp',
  otlpEndpoint: 'http://localhost:4318',
});

Depends On

Metadata

Metadata

Assignees

No one assigned

    Labels

    UseralePull requests that update Userale codeenhancement

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions