Skip to content

Commit

Permalink
chore: make homepage visit events more obvious, trim preceding slash,…
Browse files Browse the repository at this point in the history
… dont change pageNameSuffix in journey id mware (#347)
  • Loading branch information
ReedSoftware authored Nov 29, 2024
1 parent f791f61 commit 9036047
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 6 additions & 0 deletions server/middleware/auditPageViewMiddleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ export const auditPageViewMiddleware = (auditService: AuditService): RequestHand
if (hasCsipId) {
pageNameSuffix = `${splitUrl[1]}_${splitUrl.slice(3)}`
}
if (pageNameSuffix[0] === '/') {
pageNameSuffix = pageNameSuffix.slice(1)
}
if (pageNameSuffix.length === 0) {
pageNameSuffix = 'HOMEPAGE'
}
res.locals.auditEvent = {
pageNameSuffix: pageNameSuffix.replace('/', '_').replace('-', '_'),
who: res.locals.user.username,
Expand Down
3 changes: 0 additions & 3 deletions server/middleware/insertJourneyIdentifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ export default function insertJourneyIdentifier() {
if (!validate(uuid)) {
return res.redirect(`${req.baseUrl}/${uuidV4()}${req.url}`)
}
if (res.locals.auditEvent) {
res.locals.auditEvent.pageNameSuffix = `${req.url.split('/')[1]}/${req.url.replace(/\?.*/, '').split('/').slice(2).join('/')}` // JOURNEYID_PAGE
}
return next()
}
}

0 comments on commit 9036047

Please sign in to comment.