[Piwik-hackers] geoip plugin developement guidelines

mikael letang mikael.letang at gmail.com
Thu Jan 17 10:39:16 CET 2008


Hi,

I could not spend as much time as I wanted into Piwik; but still i
progressed a little bit.

I have a question regarding the unit tests:
Is there any kind of framework for testing the API? As of now, the testcases
in the "tests" folder don't cover them. Is it on purpose; or it is simply
not there yet for lack of time?
For my testing purpose I created a "plugins" folder within the tests folder
to test the logic of my API; don't know if it is the right way to do it?

Mikael

2008/1/13, Matthieu Aubry <matthieu.aubry at gmail.com>:
>
>
>
> mikael letang wrote:
> > 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).
> exactly
> >
> > 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().
> yes computing the statistics for a given field of the table log_visit is
> automatically handled with the helper function
> Piwik_ArchiveProcessing_Day::getDataTableInterestForLabel()
> in your case it will compute the statistics (nb of visits, nb of
> actions, bounce rate, etc.) for any distinct value of the  location_city
> field automatically.
>
> >
> > 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)
> yes.
> currently the APIs are called withing the "Home" controller which
> displays all the reports in one page. You can see the calling code in
> /trunk/plugins/Home/Controller.php
> But it will change very soon as we are working on a widget architecture
> for displaying all the data.
>
> You've understood the global process perfectly. good luck with the plugin!
> _______________________________________________
> Piwik-hackers mailing list
> Piwik-hackers at piwik.org
> http://lists.piwik.org/cgi-bin/mailman/listinfo/piwik-hackers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.piwik.org/pipermail/piwik-hackers/attachments/20080117/c9af8693/attachment.htm 


More information about the Piwik-hackers mailing list