Skip to contents

Unified writer for engagement-related outputs with privacy enforcement. Parent directories are created if they do not exist.

Usage

write_metrics(
  data = NULL,
  what = c("engagement", "summary", "session_summary"),
  path,
  comments_format = NULL,
  privacy_level = getOption("engager.privacy_level", "mask"),
  comments_policy = c("auto", "omit", "count", "text")
)

Arguments

data

A tibble containing the data to write

what

Type of output: "engagement", "summary", or "session_summary" (default: "engagement")

path

Explicit file path where the output will be written. No default path is used.

comments_format

Deprecated alias for comments_policy. Use comments_policy = "count" or comments_policy = "text" instead. Retained before privacy_level to preserve positional compatibility.

privacy_level

Privacy level for data export (default: from global option)

comments_policy

Export policy for the comments column: "auto", "omit", "count", or "text" (default: "auto"). "auto" resolves to "omit" so raw transcript text is never exported accidentally. "text" is allowed only with privacy_level = "none" and emits a warning.

Value

Invisibly returns the exported tibble after privacy and export policies are applied.

Details

write_metrics() is the privacy-safe CSV export path. It applies structured identifier masking with ensure_privacy() and then omits raw free-text comments by default. ensure_privacy() does not redact identifiers embedded inside comment text.