# `MishkaDocument.Resources.Changes.SetEventMetadata`
[🔗](https://github.com/mishka-group/mishka_document/blob/v0.0.1/lib/mishka_document/resources/__changes/set_event_metadata.ex#L5)

Sets event metadata for activity log tracking.

This change adds workspace_id, workspace_version_id, section_id, and other
relevant metadata to the changeset context for AshEvents tracking.

## Options

  * `:resource_type` - The type of resource (required):
    - `:section` - workspace_version_id is on the record
    - `:note` - section_id is on the record, traces through section
    - `:section_draft` - workspace_version_id on record, uses source_section_id
    - `:note_draft` - workspace_version_id and section_id on record

  * `:for_action` - The action type (optional, defaults to `:update`):
    - `:create` - Uses changeset attributes
    - `:update` / `:destroy` - Uses changeset.data

## Usage

    change {MishkaDocument.Resources.Changes.SetEventMetadata,
            resource_type: :section, for_action: :create}

    change {MishkaDocument.Resources.Changes.SetEventMetadata,
            resource_type: :note, for_action: :update}

---

*Consult [api-reference.md](api-reference.md) for complete listing*
