Anonymous Segment.com tracking. Closes #91.

This commit is contained in:
James Brooks
2015-01-23 17:24:34 +00:00
committed by Joseph Cohen
parent a63c65a6c3
commit 5c391cc888
23 changed files with 523 additions and 8 deletions

View File

@@ -109,6 +109,11 @@ class DashComponentController extends Controller
$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',
@@ -118,6 +123,11 @@ class DashComponentController extends Controller
->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);
@@ -168,6 +178,11 @@ class DashComponentController extends Controller
$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',
@@ -177,6 +192,11 @@ class DashComponentController extends Controller
->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);
@@ -207,6 +227,10 @@ class DashComponentController extends Controller
*/
public function deleteComponentAction(Component $component)
{
segment_track('Dashboard', [
'event' => 'Deleted Component',
]);
$component->delete();
return Redirect::back();
@@ -221,6 +245,10 @@ class DashComponentController extends Controller
*/
public function deleteComponentGroupAction(ComponentGroup $group)
{
segment_track('Dashboard', [
'event' => 'Deleted Component Group',
]);
$group->delete();
return Redirect::back();
@@ -248,6 +276,11 @@ class DashComponentController extends Controller
$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',
@@ -257,6 +290,11 @@ class DashComponentController extends Controller
->with('errors', $group->getErrors());
}
segment_track('Dashboard', [
'event' => 'Created Component Group',
'success' => true,
]);
$successMsg = sprintf(
'<strong>%s</strong> %s',
trans('dashboard.notifications.awesome'),

View File

@@ -66,6 +66,11 @@ class DashIncidentController extends Controller
$incident = Incident::create($incidentData);
if (! $incident->isValid()) {
segment_track('Dashboard', [
'event' => 'Created Incident',
'success' => false,
]);
return Redirect::back()->withInput(Binput::all())
->with('title', sprintf(
'<strong>%s</strong> %s',
@@ -82,6 +87,11 @@ class DashIncidentController extends Controller
]);
}
segment_track('Dashboard', [
'event' => 'Created Incident',
'success' => true,
]);
$successMsg = sprintf(
'<strong>%s</strong> %s',
trans('dashboard.notifications.awesome'),
@@ -127,6 +137,10 @@ class DashIncidentController extends Controller
*/
public function deleteTemplateAction(IncidentTemplate $template)
{
segment_track('Dashboard', [
'event' => 'Deleted Incident Template',
]);
$template->delete();
return Redirect::back();
@@ -143,6 +157,11 @@ class DashIncidentController extends Controller
$template = IncidentTemplate::create($_template);
if (! $template->isValid()) {
segment_track('Dashboard', [
'event' => 'Created Incident Template',
'success' => false,
]);
return Redirect::back()->withInput(Binput::all())
->with('title', sprintf(
'<strong>%s</strong> %s',
@@ -152,6 +171,11 @@ class DashIncidentController extends Controller
->with('errors', $template->getErrors());
}
segment_track('Dashboard', [
'event' => 'Created Incident Template',
'success' => true,
]);
$successMsg = sprintf(
'<strong>%s</strong> %s',
trans('dashboard.notifications.awesome'),
@@ -170,6 +194,10 @@ class DashIncidentController extends Controller
*/
public function deleteIncidentAction(Incident $incident)
{
segment_track('Dashboard', [
'event' => 'Deleted Incident',
]);
$incident->delete();
return Redirect::back();
@@ -204,6 +232,11 @@ class DashIncidentController extends Controller
$incident->update($_incident);
if (! $incident->isValid()) {
segment_track('Dashboard', [
'event' => 'Edited Incident',
'success' => false,
]);
return Redirect::back()->withInput(Binput::all())
->with('title', sprintf(
'<strong>%s</strong> %s',
@@ -213,6 +246,11 @@ class DashIncidentController extends Controller
->with('errors', $incident->getErrors());
}
segment_track('Dashboard', [
'event' => 'Edited Incident',
'success' => true,
]);
$successMsg = sprintf(
'<strong>%s</strong> %s',
trans('dashboard.notifications.awesome'),
@@ -231,6 +269,10 @@ class DashIncidentController extends Controller
*/
public function editTemplateAction(IncidentTemplate $template)
{
segment_track('Dashboard', [
'event' => 'Edited Incident Template',
]);
$template->update(Binput::get('template'));
return Redirect::back()->with('updatedTemplate', $template);

View File

@@ -60,6 +60,11 @@ class DashTeamController extends Controller
$user = User::create(Binput::all());
if (! $user->isValid()) {
segment_track('Dashboard', [
'event' => 'Added User',
'success' => false,
]);
return Redirect::back()->withInput(Binput::except('password'))
->with('title', sprintf(
'<strong>%s</strong> %s',
@@ -69,6 +74,11 @@ class DashTeamController extends Controller
->with('errors', $user->getErrors());
}
segment_track('Dashboard', [
'event' => 'Added User',
'success' => true,
]);
$successMsg = sprintf(
'<strong>%s</strong> %s',
trans('dashboard.notifications.awesome'),
@@ -98,6 +108,11 @@ class DashTeamController extends Controller
$user->update($items);
if (! $user->isValid()) {
segment_track('Dashboard', [
'event' => 'Updated User',
'success' => false,
]);
return Redirect::back()->withInput(Binput::except('password'))
->with('title', sprintf(
'<strong>%s</strong> %s',
@@ -107,6 +122,11 @@ class DashTeamController extends Controller
->with('errors', $user->getErrors());
}
segment_track('Dashboard', [
'event' => 'Updated User',
'success' => true,
]);
$successMsg = sprintf(
'<strong>%s</strong> %s',
trans('dashboard.notifications.awesome'),

View File

@@ -39,8 +39,18 @@ class DashUserController extends Controller
// Let's enable/disable auth
if ($enable2FA && ! Auth::user()->hasTwoFactor) {
$items['google_2fa_secret'] = Google2FA::generateSecretKey();
segment_track('User Management', [
'event' => 'enabled_two_factor',
'value' => true,
]);
} elseif (! $enable2FA) {
$items['google_2fa_secret'] = '';
segment_track('User Management', [
'event' => 'enabled_two_factor',
'value' => false,
]);
}
if (trim($passwordChange) === '') {
@@ -76,6 +86,10 @@ class DashUserController extends Controller
*/
public function regenerateApiKey(User $user)
{
segment_track('User Management', [
'event' => 'regenrated_api_token'
]);
$user->api_key = User::generateApiKey();
$user->save();

View File

@@ -22,6 +22,10 @@ class HomeController extends Controller
*/
public function showIndex()
{
segment_track('Status Page', [
'event' => 'Landed',
]);
$components = Component::orderBy('order')->orderBy('created_at')->get();
$allIncidents = [];
@@ -38,6 +42,21 @@ class HomeController extends Controller
try {
// If date provided is valid
$oldDate = Date::createFromFormat('Y-m-d', Binput::get('start_date'));
segment_track('Status Page', [
'start_date' => $oldDate->format('Y-m-d'),
]);
if (Setting::get('app_tracking')) {
Segment::track([
'userId' => Config::get('app.key'),
'event' => 'Home Page',
'properties' => [
'start_date' => $oldDate,
],
]);
}
// If trying to get a future date fallback to today
if ($today->gt($oldDate)) {
$startDate = $oldDate;

View File

@@ -47,6 +47,10 @@ class SetupController extends Controller
{
$postData = Binput::all();
segment_track('Setup', [
'step' => '1',
]);
$v = Validator::make($postData, [
'settings.app_name' => 'required',
'settings.app_domain' => 'required',
@@ -72,6 +76,10 @@ class SetupController extends Controller
{
$postData = Binput::all();
segment_track('Setup', [
'step' => '2',
]);
$v = Validator::make($postData, [
'settings.app_name' => 'required',
'settings.app_domain' => 'required',