Jim James
unread,May 4, 2008, 8:40:57 PM5/4/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to MOle Plugin
Have I mentioned I love the MOle?
In the absence of getting snitch to work for the plugin, I needed to
add my own snitch-like feature. Unlike most who use MOle to privately
view users' activity on an application, I actually want my clients to
view their customer's activities. I have an application for tour
operators to supply their travelers with online scrapbooks of their
escorted tours overseas. We build the scrapbooks automatically based
on the tour they are booked on. Travelers can leave it as-is (looks
great!) or they can treat it like a blog and upload personal pics,
etc. Typically they invite friends, family and co-workers to view
their scrapbook (because they are all ridiculously excited about their
upcoming trips).
As a courtesy to my clients, the tour operators, I want them to be
able to view activity on the site as it happens. A previous
implementation of this was a line in each controller's main methods to
write a line of text to a log file, and tail the log in a view.
Worked. Until I moved to morph (MorphExchange.com) - a hosting
provider that automatically pushes your rails app to Anazon EC2
instances and automates scaling (love morph, too). Using log files
doesn't work with a cluster and was a stop-gap anyway.
Enter MOle. Now all user activities of interest are written to the db
using nice feature procs. Still need a way to display a description of
what the users are doing. I added a new column to mole_features called
"narrative", and modified DbMole#mole_it and DbMole#find_feature to
write the narrative template to the mole_features table. Then, in
mole.conf, I added the narrative template string to each feature like
this:
ItinerariesController.after(:feature => :journal) do |context,
feature, ret_val, *args|
narrative = "%user is viewing the journal of %traveler on the
%tour_name trip with %tour_operator booked by %travel_agency."
Mole::DbMole.mole_it( context,
feature,
narrative,
context.session[:user],
:tour_operator =>
context.session[:tour_operator_name],
:travel_agency =>
context.session[:travel_agency_name],
:traveler => context.session[:traveler],
:tour_code_id =>
context.session[:tour_code_id] )
end
A little multi-pass regex converts the narrative string in the view to
lines like this:
Guest is viewing the journal of Traveler Candi on the Introduction to
Ireland trip with Globus booked by themselves.
Guest is viewing the journal of Jane Doe on the Castles and Vineyards
trip with Dream Italia booked by Affordable Tours.
Jane Doe is viewing the journal of Jane Doe on the Castles and
Vineyards trip with Dream Italia booked by Affordable Tours.
and it supports some pre-processing of the params values (like using
"themselves" if the travel_agency is nil, doing lookups of the tour
name from its id, etc). Very nice for my clients to read. Each MOled
feature has its own narrative template sentence.
Just thought I'd share. Jim.
PS. The next thing is to generate user stories - click on a row to get
a display of what that user did in the application during that
session. Did they jump around a lot? Did they seem purposeful in what
they were doing? Did they seem to get lost? Are they looking at other
users' journals...?
Has anyone done that?