Raxol.Privacy (Raxol v2.6.0)

View Source

Privacy and GDPR compliance utilities for Raxol.

Provides functions for user data management in compliance with privacy regulations like GDPR.

Example

# Anonymize user data
Raxol.Privacy.anonymize_user(user_id)

# Export all user data (GDPR data portability)
{:ok, data} = Raxol.Privacy.export_user_data(user_id)

# Delete all user data (GDPR right to erasure)
:ok = Raxol.Privacy.delete_user_data(user_id)

Summary

Functions

Anonymize a user's personally identifiable information.

Check consent status for a user.

Delete all data associated with a user.

Export all data associated with a user.

Get data retention policy.

Types

user_export()

@type user_export() :: %{
  user_id: String.t(),
  exported_at: DateTime.t(),
  format: atom(),
  data: map()
}

Functions

anonymize_user(user_id)

@spec anonymize_user(String.t()) :: :ok

Anonymize a user's personally identifiable information.

Replaces PII with anonymized placeholders while preserving data structure for analytics.

Example

:ok = Raxol.Privacy.anonymize_user(user_id)

check_consent(user_id, consent_type)

@spec check_consent(String.t(), atom()) :: {:ok, boolean()}

Check consent status for a user.

Example

case Raxol.Privacy.check_consent(user_id, :analytics) do
  {:ok, true} -> track_analytics()
  {:ok, false} -> skip_analytics()
end

delete_user_data(user_id, opts \\ [])

@spec delete_user_data(
  String.t(),
  keyword()
) :: :ok

Delete all data associated with a user.

Implements GDPR right to erasure (right to be forgotten).

Options

  • :soft_delete - Mark as deleted instead of removing (default: false)
  • :retain_audit - Keep anonymized audit logs (default: true)

Example

:ok = Raxol.Privacy.delete_user_data(user_id)

export_user_data(user_id, opts \\ [])

@spec export_user_data(
  String.t(),
  keyword()
) :: {:ok, user_export()}

Export all data associated with a user.

Returns a structured export of all user data for GDPR data portability compliance.

Options

  • :format - Export format (:json, :csv) (default: :json)
  • :include - List of data types to include (default: all)

Example

{:ok, data} = Raxol.Privacy.export_user_data(user_id)

record_consent(user_id, consent_type, granted)

@spec record_consent(String.t(), atom(), boolean()) :: :ok

Record user consent.

Example

:ok = Raxol.Privacy.record_consent(user_id, :analytics, true)

retention_policy(data_type)

@spec retention_policy(atom()) :: map()

Get data retention policy.

Example

policy = Raxol.Privacy.retention_policy(:audit_logs)
# => %{retention_days: 90, anonymize_after: 30}