[Piwik-hackers] geoip plugin developement guidelines

mikael letang mikael.letang at gmail.com
Sun Jan 13 19:26:23 CET 2008


Here under the main steps I understand to be followed for the geoip plugin
(or any plugin)

1) register data (log)
2) archive
3) display data

1) register data
I understand that for performance matters, all data must be registered
during the loging process. That means that in our case, we need to add
localisation field such as "location_city" in the log table, and populate it
during the logging process. Besides the city, i think it is also interesting
to store the GPS coordinates, which are also provided by the geoip library.
(for later mapping for exemple).
So there are two things to do:
a) create the field(s) in the log_visit table.
This must be done in the Plugin class (Geoip.php), in the function install()
b) populating the added fields during logging (i.e., when the user visit a
page).
This logging logic is achieved in the Plugin class (Geoip.php), with the
help of a hook (which is a notification system). For exemple, in
Provider.php, the function "logProviderInfo" is registered as hook function,
and do the job of extracting the provider (from the ip, provided by the
notification object).

2) archive
During the archiving process, the same system of hook allow to handle the
archiving of the data of our plugin. For exemple in Provider.php,
archiveMonth() and archiveDay() are registered to be called during the
archive process, and do the record creation (I think: data extraction from
log_visit table, in archiveDay(), and data extraction from daily archive, in
archiveMonth().

3) display data
the Plugin/API.php (in our case, Geoip/API.php) is in charge of reading the
archives to be finally displayed. A lot of options in the returned datatable
object allows for modifications (in which i did not dig yet)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.piwik.org/pipermail/piwik-hackers/attachments/20080113/b00cc3bb/attachment.htm 


More information about the Piwik-hackers mailing list