Add Activity Target consistently
Overview
When creating related activities for other entities (e.g. Contribution, Participant (event registration), Membership) source and target contact IDs holds different contacts and have different meanings if a logged-in user added the entity or an anonymous user (through an online form).
This creates inconsistency and makes any downstream processing harder: searching, creating extensions & automations based on these activities.
Example use-case
If a contact get registered for an event by a logged-in user (someone showed interest in email and a backoffice user adding the registration to Civi) "Event Registration" activity's source (Added by) would be the CRM user and target (With) is the contact who wants to attend the event. This makes sense and the roles match the label: registration was added by the user and the target is the contact. Also works well as audit trails. However, if the contact is using the online registration form source will be the contact and target will be empty.
Proposed behaviour
In my opinion best case would be: if there's no logged in user then source is the system user and target is the contact. This presents exactly what happened: a contact has registered and registration was added by the system, not by a real user manually.
If that's too much of a change or system user determination is hard across all CMS then just add contact to target (in this case source and target would be the same contact_id). This way also has the benefits of the same results for consumers.
In the latter case the downside is there would be redundancy in civicrm_activity_contact
table (#2450 (comment 55527)). Regarding this, I argue that consistency worths more than disk space.
Comments
I've found some issues that mention this, but not as the main topic (#2450 (closed)) or hasn't any progress (#2669 (closed)). As it would be nice to change this through all of Civi.