Skip to content

Commit

Permalink
Anonymous Segment.com tracking. Closes #91.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrooksuk committed Jan 27, 2015
1 parent 5b618c0 commit 66374c5
Show file tree
Hide file tree
Showing 18 changed files with 355 additions and 8 deletions.
11 changes: 6 additions & 5 deletions app/config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,18 @@
/*
* Packages Service Providers...
*/
'CachetHQ\Segment\SegmentServiceProvider',
'Dingo\Api\Provider\ApiServiceProvider',
'GrahamCampbell\Security\SecurityServiceProvider',
'Fideloper\Proxy\ProxyServiceProvider',
'GrahamCampbell\Binput\BinputServiceProvider',
'GrahamCampbell\Throttle\ThrottleServiceProvider',
'GrahamCampbell\Markdown\MarkdownServiceProvider',
'Roumen\Feed\FeedServiceProvider',
'Thujohn\Rss\RssServiceProvider',
'GrahamCampbell\Security\SecurityServiceProvider',
'GrahamCampbell\Throttle\ThrottleServiceProvider',
'Jenssegers\Date\DateServiceProvider',
'McCool\LaravelAutoPresenter\LaravelAutoPresenterServiceProvider',
'PragmaRX\Google2FA\Vendor\Laravel\ServiceProvider',
'Fideloper\Proxy\ProxyServiceProvider',
'Roumen\Feed\FeedServiceProvider',
'Thujohn\Rss\RssServiceProvider',

/*
* Application Service Providers...
Expand Down
9 changes: 9 additions & 0 deletions app/config/packages/cachethq/segment/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

return [
'write_key' => 'AdcpUouGjiShPkxoZWxhMUDWAT6tsvbY',
'consumer' => 'socket',
'debug' => false,
'ssl' => true,
'error_handler' => null,
];
1 change: 1 addition & 0 deletions app/lang/de/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
'complete_setup' => 'Setup abschließen',
'completed' => 'Cachet wurde erfolgreich eingerichtet!',
'finish_setup' => 'Zum Dashboard',
'allow_tracking' => 'Allow anonymous usage tracking?',
];
1 change: 1 addition & 0 deletions app/lang/en/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
'complete_setup' => 'Complete Setup',
'completed' => 'Cachet has been configured successfully!',
'finish_setup' => 'Go to dashboard',
'allow_tracking' => 'Allow anonymous usage tracking?',
];
1 change: 1 addition & 0 deletions app/lang/fr/setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
'complete_setup' => 'Terminer l\'installation',
'completed' => 'Cachet a été configuré avec succès !',
'finish_setup' => 'Aller au tableau de bord',
'allow_tracking' => 'Allow anonymous usage tracking?',
];
2 changes: 2 additions & 0 deletions app/start/global.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php

use CachetHQ\Segment\Facades\Segment;
use Dingo\Api\Facade\API;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Log;

/*
Expand Down
9 changes: 9 additions & 0 deletions app/views/dashboard/settings/app-setup.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="form-group">
<label>{{ trans('setup.allow_tracking') }}</label>
<input type="hidden" value="0" name="app_track">
<input type="checkbox" value="1" name="app_track" class="form-control" {{ Setting::get('app_track') ? 'checked' : null }}>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12">
<div class="form-group">
Expand Down
6 changes: 6 additions & 0 deletions app/views/setup.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@
{{ trans("setup.show_support") }}
</label>
</div>
<div class="form-group">
<label>
<input type="checkbox" name="settings[app_track]" value="1" checked >
{{ trans("setup.allow_tracking") }}
</label>
</div>
<hr>
<div class="form-group text-center">
<span class="wizard-next btn btn-success" data-current-block="1" data-next-block="2" data-loading-text="<i class='icon ion-load-c'></i>">
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"ext-mcrypt": "*",
"ext-openssl": "*",
"laravel/framework": "4.2.*",
"cachethq/segment": "1.0.*@dev",
"dingo/api": "0.8.*",
"doctrine/dbal": "2.5.*",
"graham-campbell/binput": "2.1.*",
Expand Down
106 changes: 104 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/Console/Commands/OneClickDeployCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ public function __construct($migrate)
public function fire()
{
if ($this->migrate) {
return $this->runMigrations();
$migrations = $this->runMigrations();

segment_track('Installation', [
'event' => 'Heroku Deployment',
]);

return $migrations;
}

$this->info('Please run "php artisan migrate" to finish the installation.');
Expand Down
38 changes: 38 additions & 0 deletions src/Http/Controllers/DashComponentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ public function updateComponentAction(Component $component)
$component->update($_component);

if (! $component->isValid()) {
segment_track('Dashboard', [
'event' => 'Edit Component',
'success' => false,
]);

return Redirect::back()->withInput(Binput::all())
->with('title', sprintf(
'<strong>%s</strong> %s',
Expand All @@ -118,6 +123,11 @@ public function updateComponentAction(Component $component)
->with('errors', $component->getErrors());
}

segment_track('Dashboard', [
'event' => 'Edit Component',
'success' => true,
]);

// The component was added successfully, so now let's deal with the tags.
$tags = preg_split('/ ?, ?/', $tags);

Expand Down Expand Up @@ -168,6 +178,11 @@ public function createComponentAction()
$component = Component::create($_component);

if (! $component->isValid()) {
segment_track('Dashboard', [
'event' => 'Created Component',
'success' => false,
]);

return Redirect::back()->withInput(Binput::all())
->with('title', sprintf(
'<strong>%s</strong> %s',
Expand All @@ -177,6 +192,11 @@ public function createComponentAction()
->with('errors', $component->getErrors());
}

segment_track('Dashboard', [
'event' => 'Created Component',
'success' => true,
]);

// The component was added successfully, so now let's deal with the tags.
$tags = preg_split('/ ?, ?/', $tags);

Expand Down Expand Up @@ -207,6 +227,10 @@ public function createComponentAction()
*/
public function deleteComponentAction(Component $component)
{
segment_track('Dashboard', [
'event' => 'Deleted Component',
]);

$component->delete();

return Redirect::back();
Expand All @@ -221,6 +245,10 @@ public function deleteComponentAction(Component $component)
*/
public function deleteComponentGroupAction(ComponentGroup $group)
{
segment_track('Dashboard', [
'event' => 'Deleted Component Group',
]);

$group->delete();

return Redirect::back();
Expand Down Expand Up @@ -248,6 +276,11 @@ public function postAddComponentGroup()
$group = ComponentGroup::create(Binput::get('group'));

if (! $group->isValid()) {
segment_track('Dashboard', [
'event' => 'Created Component Group',
'success' => false,
]);

return Redirect::back()->withInput(Binput::all())
->with('title', sprintf(
'<strong>%s</strong> %s',
Expand All @@ -257,6 +290,11 @@ public function postAddComponentGroup()
->with('errors', $group->getErrors());
}

segment_track('Dashboard', [
'event' => 'Created Component Group',
'success' => true,
]);

$successMsg = sprintf(
'<strong>%s</strong> %s',
trans('dashboard.notifications.awesome'),
Expand Down
Loading

0 comments on commit 66374c5

Please sign in to comment.