Looking Up Users from Tracking Log (Tracking LINE Users)
Overview
This module exposes a single endpoint for finding LINE users by the tracking keys the system records — the log of who tapped what and when. It is used whenever a behaviour needs to be traced back to actual people, answering questions such as "who clicked link X in campaign Y?"
One thing to be aware of: this endpoint is a POST with an untyped body, because the original TypeScript implementation accepted it that way. That choice has consequences for error behaviour, described below.
Business Flow
- cms-web sends
POST /api/tracking-line-userswith a body that must contain atrackingKeysarray. - The service reads
lineOaIdfrom CLS and forwards it to the repository along with the submitted body. - The repository searches
tracking_line_usersfor the given tracking keys and joins back toline_userto retrieve the user records. - The result is returned as a pass-through — no reshaping is applied, matching the legacy implementation.
- A preserved error case — if
trackingKeysis missing or is not an array, the original TypeScript code would read.lengthonundefinedand raise a TypeError. The Go port reproduces this with an error readingCannot read properties of undefined (reading 'length'), and the controller responds with HTTP 500 and theAPP_000code. The controller decodes the body into afindLineUsersPayloadcarrying atrackingKeysUsableflag specifically to detect this case.
Key Files & Functions
The code lives in internal/modules/trackinglineusers/, split across controller.go and
service.go.
| Method | Route | Handler | Policy |
|---|---|---|---|
| POST | /api/tracking-line-users | svc.getListHandler | readAll tracking-log |
The route is registered on the authed group, which enforces JWT, but has no ModuleGate.
The variable governing the error behaviour is errTrackingKeysNotIterable in service.go.
Connections to Other Services
- Permissions — requires the global
JwtAuth, which mandates alineOaId.PolicyModuleTrackingLogis metadata only and is not yet enforced. - Tables —
tracking_line_usersandline_user. - CLS —
lineOaIdfrom the request context scopes the query. - Related modules — Tracking Link, which creates the tracking tokens; Campaign Management, which generates tracking events; and LINE User Management.