@ovok/native/helpers

Shared helpers: form fields, conditional rendering, formatting utilities, logging and telemetry.

  • Stable unknown
  • Release candidate since 1.16.1-rc.3
  • Development since 1.16.1-dev.2111+9796905

Shared helpers: form fields, conditional rendering, formatting utilities, logging and telemetry.

Import from @ovok/native/helpers.

Components

Conditional

const Conditional: React.FunctionComponent<ConditionalProps>;

Renders its children only when condition is true.


FormDateField

const FormDateField: MemoExoticComponent<(__namedParameters) => Element>;

Formik form field that opens a date, time or date-time picker.


FormField

const FormField: MemoExoticComponent<(__namedParameters) => Element>;

Formik form field that renders a text input with its validation message.


FormSelect

const FormSelect: <T>(props) => ReactElement;

Formik form field that renders a dropdown over options.

Type Parameters

Type Parameter
T extends object

Parameters

ParameterType
propsFormSelectProps<T>

Returns

ReactElement

Functions

addOvokSpanEvent()

function addOvokSpanEvent(
   name,
   attributes?,
   span?
): void;

Adds an event with sanitized attributes to the given or active span; never throws.

Parameters

ParameterType
namestring
attributes?Record<string, unknown>
span?OvokSpan

Returns

void


configureOvokLogger()

function configureOvokLogger(logger?): void;

Configure the SDK logger. The default is the console and OpenTelemetry when present.

Parameters

ParameterType
logger?OvokLogger

Returns

void


configureOvokTelemetry()

function configureOvokTelemetry(options?): void;

Sets the telemetry providers and resets cached instruments.

Parameters

ParameterType
options?OvokTelemetryOptions

Returns

void


emitOvokLog()

function emitOvokLog(
   severityText,
   body,
   attributes?
): void;

Emits a scrubbed log record when a logger is available; never throws.

Parameters

ParameterType
severityTextstring
bodystring
attributes?Record<string, unknown>

Returns

void


ovokLogger()

function ovokLogger(
   type,
   message,
   extra?
): void;

Logs a message through the configured logger and OpenTelemetry; error and fatal levels also count toward the ovok.errors metric.

Parameters

ParameterType
typeOvokLogLevel
messagestring
extra?Record<string, unknown>

Returns

void


parseDatePickerValue()

function parseDatePickerValue(value, fallback): Date;

Parses a YYYY-MM-DD string as a local date, other strings via Date; returns fallback when the value is not a valid date.

Parameters

ParameterType
valuestring
fallbackDate

Returns

Date


recordOvokDuration()

function recordOvokDuration(
   name,
   durationMs,
   attributes?
): void;

Records a duration in milliseconds on the named histogram; never throws.

Parameters

ParameterType
namestring
durationMsnumber
attributes?Record<string, unknown>

Returns

void


recordOvokMetric()

function recordOvokMetric(
   name,
   value,
   attributes?
): void;

Adds a value to the named counter; never throws.

Parameters

ParameterType
namestring
valuenumber
attributes?Record<string, unknown>

Returns

void


sanitizeOvokTelemetryAttributes()

function sanitizeOvokTelemetryAttributes(attributes?): OvokTelemetryAttributes;

Keeps identifiers useful for operations while excluding readings and patient data.

Parameters

ParameterType
attributes?Record<string, unknown>

Returns

OvokTelemetryAttributes


scrubOvokError()

function scrubOvokError(error): object;

Returns error text without the identifiers commonly echoed by the Ovok API.

Parameters

ParameterType
errorunknown

Returns

NameTypeDescription
messagestringError message with ids, emails and numbers replaced by placeholders, capped at 500 characters.
namestringError class name.

slog()

function slog(
   error,
   scope,
   additionalData?,
   level?
): void;

Logs an error with a scope name and extra data through ovokLogger; level defaults to "error".

Parameters

ParameterTypeDefault value
erroranyundefined
scopestringundefined
additionalData?Record<string, any>{}
level?"error" | "warning" | "info" | "debug""error"

Returns

void


startOvokSpan()

function startOvokSpan(name, attributes?): OvokSpan | undefined;

Starts a span with sanitized attributes; returns undefined when no tracer is available.

Parameters

ParameterType
namestring
attributes?Record<string, unknown>

Returns

OvokSpan | undefined


withAnimated()

function withAnimated<T>(WrappedComponent): ComponentType<AnimatedProps<T>>;

Wraps a component in a class so Reanimated can animate it; function components cannot take the ref that animation needs.

Type Parameters

Type Parameter
T extends object

Parameters

ParameterType
WrappedComponentComponentType<T>

Returns

ComponentType<AnimatedProps<T>>


withOvokSpan()

function withOvokSpan<T>(
   name,
   attributes,
   operation
): Promise<T>;

Runs the operation inside a span, recording its outcome and rethrowing any error.

Type Parameters

Type Parameter
T

Parameters

ParameterType
namestring
attributesRecord<string, unknown>
operation() => T | Promise<T>

Returns

Promise<T>

Interfaces

OvokLoggerProvider

Source of loggers, compatible with the OpenTelemetry logger provider.

Properties

PropertyTypeDescription
getLogger(name, version?) => OvokLogEmitterReturns the logger for the given instrumentation name and version.

OvokMeterProvider

Source of meters, compatible with the OpenTelemetry meter provider.

Properties

PropertyTypeDescription
getMeter(name, version?) => OvokMeterReturns the meter for the given instrumentation name and version.

OvokSpan

Minimal OpenTelemetry-compatible span the SDK records to.

Properties

PropertyTypeDescription
addEvent?(name, attributes?) => voidAdds a named event to the span.
end() => voidEnds the span.
recordException?(error) => voidRecords an error on the span.
setAttribute?(name, value) => voidSets one attribute on the span.
setAttributes?(attributes) => voidSets several attributes on the span.
setStatus?(status) => voidSets the span status; code 1 is OK, 2 is an error.

OvokTelemetryOptions

Telemetry providers to use instead of the global OpenTelemetry API.

Properties

PropertyTypeDescription
loggerProvider?OvokLoggerProviderUse this when the app does not register a provider globally.
meterProvider?OvokMeterProviderUse this when the app does not register a provider globally.
tracerProvider?OvokTracerProviderUse this when the app does not register a provider globally.

OvokTracerProvider

Source of tracers, compatible with the OpenTelemetry tracer provider.

Properties

PropertyTypeDescription
getActiveSpan?() => OvokSpan | undefinedReturns the currently active span, if any.
getTracer(name, version?) => OvokTracerReturns the tracer for the given instrumentation name and version.

Type Aliases

OvokTelemetryAttribute

type OvokTelemetryAttribute = string | number | boolean;

A single telemetry attribute value.


OvokTelemetryAttributes

type OvokTelemetryAttributes = Record<string, OvokTelemetryAttribute>;

Telemetry attributes keyed by name.

Last updated on

On this page