@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
Parameters
| Parameter | Type |
|---|---|
props | FormSelectProps<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
| Parameter | Type |
|---|---|
name | string |
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
| Parameter | Type |
|---|---|
logger? | OvokLogger |
Returns
void
configureOvokTelemetry()
function configureOvokTelemetry(options?): void;Sets the telemetry providers and resets cached instruments.
Parameters
| Parameter | Type |
|---|---|
options? | OvokTelemetryOptions |
Returns
void
emitOvokLog()
function emitOvokLog(
severityText,
body,
attributes?
): void;Emits a scrubbed log record when a logger is available; never throws.
Parameters
| Parameter | Type |
|---|---|
severityText | string |
body | string |
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
| Parameter | Type |
|---|---|
type | OvokLogLevel |
message | string |
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
| Parameter | Type |
|---|---|
value | string |
fallback | Date |
Returns
Date
recordOvokDuration()
function recordOvokDuration(
name,
durationMs,
attributes?
): void;Records a duration in milliseconds on the named histogram; never throws.
Parameters
| Parameter | Type |
|---|---|
name | string |
durationMs | number |
attributes? | Record<string, unknown> |
Returns
void
recordOvokMetric()
function recordOvokMetric(
name,
value,
attributes?
): void;Adds a value to the named counter; never throws.
Parameters
| Parameter | Type |
|---|---|
name | string |
value | number |
attributes? | Record<string, unknown> |
Returns
void
sanitizeOvokTelemetryAttributes()
function sanitizeOvokTelemetryAttributes(attributes?): OvokTelemetryAttributes;Keeps identifiers useful for operations while excluding readings and patient data.
Parameters
| Parameter | Type |
|---|---|
attributes? | Record<string, unknown> |
Returns
scrubOvokError()
function scrubOvokError(error): object;Returns error text without the identifiers commonly echoed by the Ovok API.
Parameters
| Parameter | Type |
|---|---|
error | unknown |
Returns
| Name | Type | Description |
|---|---|---|
message | string | Error message with ids, emails and numbers replaced by placeholders, capped at 500 characters. |
name | string | Error 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
| Parameter | Type | Default value |
|---|---|---|
error | any | undefined |
scope | string | undefined |
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
| Parameter | Type |
|---|---|
name | string |
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
Parameters
| Parameter | Type |
|---|---|
WrappedComponent | ComponentType<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
Parameters
| Parameter | Type |
|---|---|
name | string |
attributes | Record<string, unknown> |
operation | () => T | Promise<T> |
Returns
Promise<T>
Interfaces
OvokLoggerProvider
Source of loggers, compatible with the OpenTelemetry logger provider.
Properties
| Property | Type | Description |
|---|---|---|
getLogger | (name, version?) => OvokLogEmitter | Returns the logger for the given instrumentation name and version. |
OvokMeterProvider
Source of meters, compatible with the OpenTelemetry meter provider.
Properties
| Property | Type | Description |
|---|---|---|
getMeter | (name, version?) => OvokMeter | Returns the meter for the given instrumentation name and version. |
OvokSpan
Minimal OpenTelemetry-compatible span the SDK records to.
Properties
OvokTelemetryOptions
Telemetry providers to use instead of the global OpenTelemetry API.
Properties
| Property | Type | Description |
|---|---|---|
loggerProvider? | OvokLoggerProvider | Use this when the app does not register a provider globally. |
meterProvider? | OvokMeterProvider | Use this when the app does not register a provider globally. |
tracerProvider? | OvokTracerProvider | Use this when the app does not register a provider globally. |
OvokTracerProvider
Source of tracers, compatible with the OpenTelemetry tracer provider.
Properties
| Property | Type | Description |
|---|---|---|
getActiveSpan? | () => OvokSpan | undefined | Returns the currently active span, if any. |
getTracer | (name, version?) => OvokTracer | Returns 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