Skip to content

Conversation

@andre-urbani
Copy link
Contributor

What

Implement event tracking on GET endpoints
Jira - https://officefornationalstatistics.atlassian.net/browse/DIS-4411

How to review

To test locally, make a GET request to the endpoints specified in the acceptance criteria, and confirm that events are logged in the dataset_events database in mongodb

Changes make sense, tests pass

Who can review

Anyone

@andre-urbani andre-urbani requested a review from a team as a code owner February 9, 2026 16:45
api/versions.go Outdated
return nil, errs.ErrResourceState
}

if authorised && isStatic {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no requirement to check for static types as part of this work.

}

// ID and Email are the same as auth middleware can only provide userID
if err := api.auditService.RecordVersionAuditEvent(ctx, models.RequestedBy{ID: authEntityData.UserID, Email: authEntityData.UserID}, models.ActionRead, "/datasets/"+datasetID+"/editions/"+editionID, versionToAudit); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be moved to just before the response is returned to the user to ensure all the fields are completed (e.g. those completed via URL re-writing) and the edition model recorded if it is not a static dataset.

}

// ID and Email are the same as auth middleware can only provide userID
if err := api.auditService.RecordVersionAuditEvent(ctx, models.RequestedBy{ID: authEntityData.UserID, Email: authEntityData.UserID}, models.ActionRead, "/datasets/"+datasetID+"/editions/"+edition+"/versions/"+version+"/metadata", versionDoc); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The metadata object should be recorded here instead of versionDoc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants