What Does TraceWatch Do?
As a visitor visits your website and hits a page it actually makes a request to the web server on which your website resides. The web server has some information about any particular request made like IP address, User Agent string, Referrer, etc... which we call Request Data. There are two serious problem with this data. Firstly they are very raw, open your web server's log file (where it stores all this data) and try to understand what's actually happening and you'll know what I mean! Secondly visitor's connection to the web server is stateless which means every request is like an island, we don't know which request and data belongs to which visitor.
TraceWatch tries to collect these data, figure out the relationship between them and analyze them in real-time and present them to you in a natural and meaningful way so that you can understand what's happening on your website and what exactly are visitors doing.
How Does TraceWatch Do That?
When you put TraceWatch's code on a page on your website whenever a visitor request's that page twatchLogRequest() function gets called. In twatchLogRequest() first TraceWatch tries to collect Request Data for that particular request from the server with various techniques.
Second step is to convert these data to TraceWatch Entities. Entity is TraceWatch's format for storing and addressing Request Data, it helps TraceWatch to treat various data which might be very different in nature (take an IP address and a Refferer for instance) in a uniform way, this gives TraceWatch a lot of flexibility. Any data should be converted to an Entity before it can be used by TraceWatch.
Then tracewatch uses these entities to trigger counters, store information about latest visitors do path-analysis as shown in figure below.
How are data stored as Entities
Each Entity has one Entity Value for any particular request. For example value of 'IP Entity' can be '22.214.171.124' or '126.96.36.199', etc... or value of 'Page Entity' may be '/' or '/products/' or '/about.php', etc...
Entity Values for any particular Entity can only be selected from a finite set of known values.
For example value of "Hour Entity" can only be one of the numbers between 0 and 23, "Weekday Entity" can be any of the seven weekdays, or any boolean entity can either be "true" or "false".
But many of the data we have are not known and finite in nature, like a referrer which can be anything or the user-agent string, here is where dictionaries are used, any new value we see for such entities is stored in a dictionary and is given a unique id.
both an Entity and an Entity Value are represented by a unique integer number internally.