coldfusionapplication.cfcfw1

Location for Traffic tracking on an FW/1 site


I am currenting using FW/1 and tracking traffic via the following function call

this.wsTraffic.add(action =
        {
        SubSystem   = getSubSystem(),
        Section     = getSection(),
        Item        = rc.slug != "" ? rc.slug : getItem()
        },  
        isPost      = (cgi.request_method == "POST" ? 1 : 0),

        http_user_agent         = cgi.http_user_agent,
        Remote_addr             = cgi.remote_addr,
        http_referer            = cgi.http_referer,
        http_accept_language    = cgi.http_accept_language,
        url_vars                = Duplicate(url)
        );

Currently it is ran on setupRequest() in application.cfc. I have two subsystems: home and admin. home will always have it traffic tracked. Admin will never have its traffic tracked.

I am considering moving the function call to home/layouts/default.cfm because only the home subsystem is tracked. I don't want to move the traffic tracker there because this has nothing to do with layouts.

Where should traffic logging be done on an FW/1 site?


Solution

  • It would be done in setupRequest, (where you are currently doing it).

    To avoid it occurring for the Admin subsystem, wrap it in a conditional check for getSubSystem() NEQ 'admin' before running it.


    Alternatively, if you forsee adding multiple subsystems with different statuses, you could implement it instead by creating a TrackedSubsystems (or UntrackedSubsystems) item in Variables.Framework, with a list of subsystem names, then check for:

    ListFind( Variables.Framework.TrackedSubSystems , getSubSystem() )