Skip to content
This repository has been archived by the owner on Feb 17, 2022. It is now read-only.

Commit

Permalink
adding the userId tracking #20
Browse files Browse the repository at this point in the history
  • Loading branch information
rokde committed Nov 18, 2015
1 parent 1a3ccaa commit 9c4f721
Show file tree
Hide file tree
Showing 10 changed files with 1,045 additions and 915 deletions.
23 changes: 13 additions & 10 deletions src/Ipunkt/LaravelAnalytics/AnalyticsFacade.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
<?php namespace Ipunkt\LaravelAnalytics;
<?php

namespace Ipunkt\LaravelAnalytics;

use Illuminate\Support\Facades\Facade;

/**
* Class AnalyticsFacade
*
* @package Ipunkt\LaravelAnalytics
*/
class AnalyticsFacade extends Facade
{
/**
* facade accessor
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'analytics';
}
/**
* facade accessor
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'analytics';
}
}
156 changes: 79 additions & 77 deletions src/Ipunkt/LaravelAnalytics/AnalyticsServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,84 +1,86 @@
<?php namespace Ipunkt\LaravelAnalytics;
<?php

namespace Ipunkt\LaravelAnalytics;

use Config;
use Illuminate\Support\ServiceProvider;

class AnalyticsServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;

/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
if ($this->isLaravel4()) {
$this->package('ipunkt/laravel-analytics');

return;
}

$config = realpath(__DIR__ . '/../../config/analytics.php');

$this->mergeConfigFrom($config, 'analytics');

$this->publishes([
$config => config_path('analytics.php'),
]);
}

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$packageNamespace = $this->isLaravel4() ? 'laravel-analytics::' : '';

$this->app->bind('analytics', function () use ($packageNamespace) {

// get analytics provider name
$provider = Config::get($packageNamespace . 'analytics.provider');

// make it a class
$providerClass = 'Ipunkt\LaravelAnalytics\Providers\\' . $provider;

// getting the config
$providerConfig = [];
if (Config::has($packageNamespace . 'analytics.configurations.' . $provider)) {
$providerConfig = Config::get($packageNamespace . 'analytics.configurations.' . $provider);
}

// return an instance
return new $providerClass($providerConfig);
});
}

/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return array();
}

/**
* are we on laravel 4
*
* @return bool
*/
private function isLaravel4()
{
return version_compare(\Illuminate\Foundation\Application::VERSION, '5', '<');
}
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;

/**
* Bootstrap the application events.
*
* @return void
*/
public function boot()
{
if ($this->isLaravel4()) {
$this->package('ipunkt/laravel-analytics');

return;
}

$config = realpath(__DIR__ . '/../../config/analytics.php');

$this->mergeConfigFrom($config, 'analytics');

$this->publishes([
$config => config_path('analytics.php'),
]);
}

/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$packageNamespace = $this->isLaravel4() ? 'laravel-analytics::' : '';

$this->app->bind('analytics', function () use ($packageNamespace) {

// get analytics provider name
$provider = Config::get($packageNamespace . 'analytics.provider');

// make it a class
$providerClass = 'Ipunkt\LaravelAnalytics\Providers\\' . $provider;

// getting the config
$providerConfig = [];
if (Config::has($packageNamespace . 'analytics.configurations.' . $provider)) {
$providerConfig = Config::get($packageNamespace . 'analytics.configurations.' . $provider);
}

// return an instance
return new $providerClass($providerConfig);
});
}

/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [];
}

/**
* are we on laravel 4
*
* @return bool
*/
private function isLaravel4()
{
return version_compare(\Illuminate\Foundation\Application::VERSION, '5', '<');
}
}
Loading

0 comments on commit 9c4f721

Please sign in to comment.