Open-Web-Analytics/owa-php-sdk

Initial Commit ideas

padams opened this issue · 9 comments

Here's a list of things that need to happen to get to a work able first commit:

  • extract client.php from open-web-analytics
  • extract state.php from open web analytics
  • re-factor client.php to use it's own local config. $this->conf maybe?
  • re-factor client to use state directly instead of going through coreAPI.
  • re-factor client logEvent to send events to OWA over HTTP. maybe keep the current functionality to send events via direct method call (if OWA is present on the same server) as an option too.
  • Setup composer
  • install guzzle via composer

This should be really straight forward @Maaiins . 95% of the php tracker is contained in client.php.

re-factor client.php to use it's own local config. $this->conf maybe

I think the config should be request from the owa api instance and cached locally. I don't like the idea to have multiple configurations. I think you should only store the api endpoint.

I’m really only talking about certain config values specific to the tracker such as the names of cookies etc.

What config values would you want to fetch from the server?

Exactly this settings, we can get them from owa or am i wrong?

Take a look at the code. The settings needed are are minor and not shared or used anywhere else in OWA as far as I can tell.

Also the JavaScript tracker doesn’t need to fetch and cache any settings. They are all local as well.

Ok sorry thought there are set in the base settings

JS no. php tracker yes but don’t need to be is what I’m saying. 😉

I've pushed an initial commit to master that moves and renovates all the relevant files and sets up the sdk framework.

Usage is:

ini_set('display_errors', 1);
require_once('owa-php-sdk/owa-autoloader.php');

$config = [];
$sdk = new OwaSdk\sdk($config);
$tracker = $sdk->createTracker();

//$tracker->setCookieDomain('openwebanalytics.com');
$tracker->setPageTitle('Standalone PHP Test Page3');
$tracker->setSiteId('__your_site_id__');
$tracker->setCustomVar(2, 'foo2', 'bar2', 'page');
$tracker->deleteCustomVar(3, 'foo', 'bar', 'visitor');
$tracker->trackPageView();	

The logEvent method is stubbed out right now so this won't track anything as is but it just an error free base to build on.

Closing as this is now working. It does however require the latest code in master from OWA core to work properly.