mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-16 21:18:19 +01:00
Removed tracking
This commit is contained in:
parent
2425682381
commit
fb127fb861
@ -120,11 +120,6 @@ class ComponentController extends AbstractController
|
||||
$component->update($_component);
|
||||
|
||||
if (!$component->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Edit Component',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
@ -134,11 +129,6 @@ class ComponentController extends AbstractController
|
||||
->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);
|
||||
|
||||
@ -189,11 +179,6 @@ class ComponentController extends AbstractController
|
||||
$component = Component::create($_component);
|
||||
|
||||
if (!$component->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Created Component',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
@ -203,11 +188,6 @@ class ComponentController extends AbstractController
|
||||
->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);
|
||||
|
||||
@ -238,10 +218,6 @@ class ComponentController extends AbstractController
|
||||
*/
|
||||
public function deleteComponentAction(Component $component)
|
||||
{
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Deleted Component',
|
||||
]);
|
||||
|
||||
$component->delete();
|
||||
|
||||
return Redirect::back();
|
||||
@ -256,10 +232,6 @@ class ComponentController extends AbstractController
|
||||
*/
|
||||
public function deleteComponentGroupAction(ComponentGroup $group)
|
||||
{
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Deleted Component Group',
|
||||
]);
|
||||
|
||||
$group->components->map(function ($component) {
|
||||
$component->update([
|
||||
'group_id' => 0,
|
||||
@ -308,11 +280,6 @@ class ComponentController extends AbstractController
|
||||
$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(
|
||||
'%s %s',
|
||||
@ -322,11 +289,6 @@ class ComponentController extends AbstractController
|
||||
->with('errors', $group->getErrors());
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Created Component Group',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
@ -349,11 +311,6 @@ class ComponentController extends AbstractController
|
||||
$group->update($groupData);
|
||||
|
||||
if (!$group->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Edit Component Group',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
@ -363,11 +320,6 @@ class ComponentController extends AbstractController
|
||||
->with('errors', $group->getErrors());
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Edit Component Group',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
|
@ -26,8 +26,6 @@ class DashboardController extends AbstractController
|
||||
{
|
||||
$components = Component::orderBy('order')->get();
|
||||
|
||||
segment_page('Dashboard');
|
||||
|
||||
return View::make('dashboard.index')->with([
|
||||
'components' => $components,
|
||||
]);
|
||||
|
@ -126,11 +126,6 @@ class IncidentController extends AbstractController
|
||||
$incident = Incident::create($incidentData);
|
||||
|
||||
if (!$incident->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Created Incident',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
@ -147,11 +142,6 @@ class IncidentController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Created Incident',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
@ -206,10 +196,6 @@ class IncidentController extends AbstractController
|
||||
*/
|
||||
public function deleteTemplateAction(IncidentTemplate $template)
|
||||
{
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Deleted Incident Template',
|
||||
]);
|
||||
|
||||
$template->delete();
|
||||
|
||||
return Redirect::back();
|
||||
@ -226,11 +212,6 @@ class IncidentController extends AbstractController
|
||||
$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(
|
||||
'%s %s',
|
||||
@ -240,11 +221,6 @@ class IncidentController extends AbstractController
|
||||
->with('errors', $template->getErrors());
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Created Incident Template',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
@ -263,10 +239,6 @@ class IncidentController extends AbstractController
|
||||
*/
|
||||
public function deleteIncidentAction(Incident $incident)
|
||||
{
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Deleted Incident',
|
||||
]);
|
||||
|
||||
$incident->delete();
|
||||
|
||||
return Redirect::back();
|
||||
@ -314,11 +286,6 @@ class IncidentController extends AbstractController
|
||||
$incident->update($incidentData);
|
||||
|
||||
if (!$incident->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Edited Incident',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
@ -335,11 +302,6 @@ class IncidentController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Edited Incident',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
@ -358,10 +320,6 @@ class IncidentController extends AbstractController
|
||||
*/
|
||||
public function editTemplateAction(IncidentTemplate $template)
|
||||
{
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Edited Incident Template',
|
||||
]);
|
||||
|
||||
$template->update(Binput::get('template'));
|
||||
|
||||
return Redirect::back()->with('updatedTemplate', $template);
|
||||
|
@ -72,11 +72,6 @@ class MetricController extends AbstractController
|
||||
$metric = Metric::create($metricData);
|
||||
|
||||
if (!$metric->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Created Metric',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
@ -86,11 +81,6 @@ class MetricController extends AbstractController
|
||||
->with('errors', $metric->getErrors());
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Created Metric',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
@ -183,11 +173,6 @@ class MetricController extends AbstractController
|
||||
$metric->update($metricData);
|
||||
|
||||
if (!$metric->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Edited Metric',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'<strong>%s</strong>',
|
||||
@ -196,11 +181,6 @@ class MetricController extends AbstractController
|
||||
->with('errors', $metric->getErrors());
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Edited Metric',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
|
@ -113,11 +113,6 @@ class ScheduleController extends AbstractController
|
||||
$incident = Incident::create($scheduleData);
|
||||
|
||||
if (!$incident->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Created Scheduled Maintenance',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('success', sprintf(
|
||||
'%s %s',
|
||||
@ -127,11 +122,6 @@ class ScheduleController extends AbstractController
|
||||
->with('errors', $incident->getErrors());
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Created Scheduled Maintenance',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
@ -197,11 +187,6 @@ class ScheduleController extends AbstractController
|
||||
$schedule->update($scheduleData);
|
||||
|
||||
if (!$schedule->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Edited Schedule',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
@ -211,11 +196,6 @@ class ScheduleController extends AbstractController
|
||||
->with('errors', $schedule->getErrors());
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Edited Schedule',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
@ -234,10 +214,6 @@ class ScheduleController extends AbstractController
|
||||
*/
|
||||
public function deleteScheduleAction(Incident $schedule)
|
||||
{
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Deleted Schedule',
|
||||
]);
|
||||
|
||||
$schedule->delete();
|
||||
|
||||
return Redirect::back()->with('warning', sprintf(
|
||||
|
@ -64,11 +64,6 @@ class SubscriberController extends AbstractController
|
||||
]);
|
||||
|
||||
if (!$subscriber->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Created Subscriber',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()
|
||||
->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
@ -79,11 +74,6 @@ class SubscriberController extends AbstractController
|
||||
->with('errors', $subscriber->getErrors());
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Created Subscriber',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
@ -107,10 +97,6 @@ class SubscriberController extends AbstractController
|
||||
*/
|
||||
public function deleteSubscriberAction(Subscriber $subscriber)
|
||||
{
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Deleted Subscriber',
|
||||
]);
|
||||
|
||||
$subscriber->delete();
|
||||
|
||||
return Redirect::back();
|
||||
|
@ -69,11 +69,6 @@ class TeamController extends AbstractController
|
||||
$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(
|
||||
'%s %s',
|
||||
@ -83,11 +78,6 @@ class TeamController extends AbstractController
|
||||
->with('errors', $user->getErrors());
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Added User',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
@ -117,11 +107,6 @@ class TeamController extends AbstractController
|
||||
$user->update($items);
|
||||
|
||||
if (!$user->isValid()) {
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Updated User',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::except('password'))
|
||||
->with('title', sprintf(
|
||||
'%s %s',
|
||||
@ -131,11 +116,6 @@ class TeamController extends AbstractController
|
||||
->with('errors', $user->getErrors());
|
||||
}
|
||||
|
||||
segment_track('Dashboard', [
|
||||
'event' => 'Updated User',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'%s %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
|
@ -48,18 +48,8 @@ class UserController extends AbstractController
|
||||
// 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) === '') {
|
||||
@ -95,10 +85,6 @@ class UserController extends AbstractController
|
||||
*/
|
||||
public function regenerateApiKey(User $user)
|
||||
{
|
||||
segment_track('User Management', [
|
||||
'event' => 'regenrated_api_token',
|
||||
]);
|
||||
|
||||
$user->api_key = User::generateApiKey();
|
||||
$user->save();
|
||||
|
||||
|
@ -57,11 +57,9 @@ class AuthController extends AbstractController
|
||||
return Redirect::route('two-factor');
|
||||
}
|
||||
|
||||
// We probably wan't to add support for "Remember me" here.
|
||||
// We probably want to add support for "Remember me" here.
|
||||
Auth::attempt(Binput::only(['email', 'password']));
|
||||
|
||||
segment_track('Logged In');
|
||||
|
||||
return Redirect::intended('dashboard');
|
||||
}
|
||||
|
||||
@ -122,8 +120,6 @@ class AuthController extends AbstractController
|
||||
{
|
||||
Auth::logout();
|
||||
|
||||
segment_track('Logged Out');
|
||||
|
||||
return Redirect::to('/');
|
||||
}
|
||||
}
|
||||
|
@ -35,18 +35,12 @@ class HomeController extends AbstractController
|
||||
$today = Date::now();
|
||||
$startDate = Date::now();
|
||||
|
||||
segment_page('Status Page');
|
||||
|
||||
// Check if we have another starting date
|
||||
if (Binput::has('start_date')) {
|
||||
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 trying to get a future date fallback to today
|
||||
if ($today->gt($oldDate)) {
|
||||
$startDate = $oldDate;
|
||||
|
@ -54,9 +54,7 @@ class SetupController extends AbstractController
|
||||
*/
|
||||
public function getIndex()
|
||||
{
|
||||
segment_page('Setup');
|
||||
|
||||
// If we've copied the .env.example file, then we should try and reset it ready for Segment to kick in.
|
||||
// If we've copied the .env.example file, then we should try and reset it.
|
||||
if (getenv('APP_KEY') === 'SomeRandomString') {
|
||||
$this->keyGenerate();
|
||||
}
|
||||
@ -83,19 +81,8 @@ class SetupController extends AbstractController
|
||||
]);
|
||||
|
||||
if ($v->passes()) {
|
||||
segment_track('Setup', [
|
||||
'event' => 'Step 1',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
return Response::json(['status' => 1]);
|
||||
} else {
|
||||
// No good, let's try that again.
|
||||
segment_track('Setup', [
|
||||
'event' => 'Step 1',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Response::json(['errors' => $v->messages()], 400);
|
||||
}
|
||||
}
|
||||
@ -120,19 +107,8 @@ class SetupController extends AbstractController
|
||||
]);
|
||||
|
||||
if ($v->passes()) {
|
||||
segment_track('Setup', [
|
||||
'event' => 'Step 2',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
return Response::json(['status' => 1]);
|
||||
} else {
|
||||
// No good, let's try that again.
|
||||
segment_track('Setup', [
|
||||
'event' => 'Step 2',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Response::json(['errors' => $v->messages()], 400);
|
||||
}
|
||||
}
|
||||
@ -190,25 +166,12 @@ class SetupController extends AbstractController
|
||||
|
||||
Session::flash('setup.done', true);
|
||||
|
||||
segment_track('Setup', [
|
||||
'event' => 'Step 3',
|
||||
'success' => true,
|
||||
'cache_driver' => $envData['cache_driver'],
|
||||
'session_driver' => $envData['session_driver'],
|
||||
]);
|
||||
|
||||
if (Request::ajax()) {
|
||||
return Response::json(['status' => 1]);
|
||||
}
|
||||
|
||||
return Redirect::to('dashboard');
|
||||
} else {
|
||||
segment_track('Setup', [
|
||||
'event' => 'Step 3',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
// No good, let's try that again.
|
||||
if (Request::ajax()) {
|
||||
return Response::json(['errors' => $v->messages()], 400);
|
||||
}
|
||||
|
@ -46,11 +46,6 @@ class SubscribeController extends AbstractController
|
||||
$subscriber = Subscriber::create(['email' => Binput::get('email')]);
|
||||
|
||||
if (!$subscriber->isValid()) {
|
||||
segment_track('Subscribers', [
|
||||
'event' => 'Customer Subscribed',
|
||||
'success' => false,
|
||||
]);
|
||||
|
||||
return Redirect::back()->withInput(Binput::all())
|
||||
->with('title', sprintf(
|
||||
'<strong>%s</strong> %s',
|
||||
@ -60,11 +55,6 @@ class SubscribeController extends AbstractController
|
||||
->with('errors', $subscriber->getErrors());
|
||||
}
|
||||
|
||||
segment_track('Subscribers', [
|
||||
'event' => 'Customer Subscribed',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'<strong>%s</strong> %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
@ -98,11 +88,6 @@ class SubscribeController extends AbstractController
|
||||
$subscriber->verified_at = Carbon::now();
|
||||
$subscriber->save();
|
||||
|
||||
segment_track('Subscribers', [
|
||||
'event' => 'Customer Email Verified',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'<strong>%s</strong> %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
@ -133,11 +118,6 @@ class SubscribeController extends AbstractController
|
||||
|
||||
$subscriber->delete();
|
||||
|
||||
segment_track('Subscribers', [
|
||||
'event' => 'Customer Unsubscribed',
|
||||
'success' => true,
|
||||
]);
|
||||
|
||||
$successMsg = sprintf(
|
||||
'<strong>%s</strong> %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
|
@ -36,106 +36,6 @@ if (!function_exists('set_active')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('segment_identify')) {
|
||||
/**
|
||||
* Identifies the user for Segment.com.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function segment_identify()
|
||||
{
|
||||
if (Config::get('segment.write_key')) {
|
||||
try {
|
||||
if (Setting::get('app_track')) {
|
||||
return Segment::identify([
|
||||
'anonymousId' => Config::get('app.key'),
|
||||
'context' => [
|
||||
'locale' => Config::get('app.locale'),
|
||||
'timezone' => Setting::get('app_timezone'),
|
||||
'DB_DRIVER' => getenv('DB_DRIVER'),
|
||||
'CACHE_DRIVER' => getenv('CACHE_DRIVER'),
|
||||
'SESSION_DRIVER' => getenv('SESSION_DRIVER'),
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('segment_track')) {
|
||||
/**
|
||||
* Tracks events in Segment.com.
|
||||
*
|
||||
* @param string $event
|
||||
* @param array $properties
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function segment_track($event, array $properties = [])
|
||||
{
|
||||
if (Config::get('segment.write_key')) {
|
||||
try {
|
||||
if (Setting::get('app_track')) {
|
||||
return Segment::track([
|
||||
'anonymousId' => Config::get('app.key'),
|
||||
'event' => $event,
|
||||
'properties' => $properties,
|
||||
'context' => [
|
||||
'locale' => Config::get('app.locale'),
|
||||
'timezone' => Setting::get('app_timezone'),
|
||||
'DB_DRIVER' => getenv('DB_DRIVER'),
|
||||
'CACHE_DRIVER' => getenv('CACHE_DRIVER'),
|
||||
'SESSION_DRIVER' => getenv('SESSION_DRIVER'),
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('segment_page')) {
|
||||
/**
|
||||
* Tracks pages in Segment.com.
|
||||
*
|
||||
* @param string $page
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function segment_page($page)
|
||||
{
|
||||
if (Config::get('segment.write_key')) {
|
||||
try {
|
||||
if (Setting::get('app_track')) {
|
||||
return Segment::page([
|
||||
'anonymousId' => Config::get('app.key'),
|
||||
'name' => $page,
|
||||
'context' => [
|
||||
'locale' => Config::get('app.locale'),
|
||||
'timezone' => Setting::get('app_timezone'),
|
||||
'DB_DRIVER' => getenv('DB_DRIVER'),
|
||||
'CACHE_DRIVER' => getenv('CACHE_DRIVER'),
|
||||
'SESSION_DRIVER' => getenv('SESSION_DRIVER'),
|
||||
],
|
||||
]);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('formatted_date')) {
|
||||
/**
|
||||
|
@ -31,12 +31,6 @@ class ConfigServiceProvider extends ServiceProvider
|
||||
$appDomain = Setting::get('app_domain');
|
||||
$appLocale = Setting::get('app_locale');
|
||||
|
||||
// Set the Segment.com settings.
|
||||
if (Setting::get('app_track')) {
|
||||
$segmentRepository = $this->app->make('CachetHQ\Cachet\Segment\RepositoryInterface');
|
||||
$this->app->config->set('segment.write_key', $segmentRepository->fetch());
|
||||
}
|
||||
|
||||
// Setup Cors.
|
||||
$allowedOrigins = $this->app->config->get('cors.defaults.allowedOrigins');
|
||||
$allowedOrigins[] = Setting::get('app_domain');
|
||||
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Providers;
|
||||
|
||||
use CachetHQ\Cachet\Segment\CacheRepository;
|
||||
use CachetHQ\Cachet\Segment\HttpRepository;
|
||||
use GuzzleHttp\Client;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class SegmentServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Register the service provider.
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->singleton('CachetHQ\Cachet\Segment\RepositoryInterface', function () {
|
||||
$url = 'https://gist.githubusercontent.com/jbrooksuk/5de24bc1cf90fb1a3d57/raw/cachet.json';
|
||||
$guzzleClient = new Client();
|
||||
$client = new HttpRepository($guzzleClient, $url);
|
||||
|
||||
return new CacheRepository($client);
|
||||
});
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Segment;
|
||||
|
||||
use CachetHQ\Cachet\Facades\Setting;
|
||||
use CachetHQ\Cachet\Models\Setting as SettingModel;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Database\QueryException;
|
||||
|
||||
class CacheRepository implements RepositoryInterface
|
||||
{
|
||||
/**
|
||||
* The underlying segment repository instance.
|
||||
*
|
||||
* @var \CachetHQ\Cachet\Segment\RepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* Create a new segment cache repository instance.
|
||||
*
|
||||
* @param \CachetHQ\Cachet\Segment\RepositoryInterface $repository
|
||||
*/
|
||||
public function __construct(RepositoryInterface $repository)
|
||||
{
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the segment write key.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fetch()
|
||||
{
|
||||
$writeKey = null;
|
||||
|
||||
try {
|
||||
// Firstly, does the setting exist?
|
||||
if (null === ($writeKey = Setting::get('segment_write_key'))) {
|
||||
// No, let's go fetch it.
|
||||
$writeKey = $this->repository->fetch();
|
||||
Setting::set('segment_write_key', $writeKey);
|
||||
} else {
|
||||
// It does, but how old is it?
|
||||
$setting = SettingModel::where('name', 'segment_write_key')->first();
|
||||
|
||||
// It's older than an hour, let's refresh
|
||||
if ($setting->updated_at->lt(Carbon::now()->subHour())) {
|
||||
$writeKey = $this->repository->fetch();
|
||||
|
||||
// Update the setting. This is done manual to make sure updated_at is overwritten.
|
||||
$setting->value = $writeKey;
|
||||
$setting->updated_at = Carbon::now();
|
||||
$setting->save();
|
||||
}
|
||||
}
|
||||
} catch (QueryException $e) {
|
||||
// Just return it until we're setup.
|
||||
$writeKey = $this->repository->fetch();
|
||||
}
|
||||
|
||||
return $writeKey;
|
||||
}
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Segment;
|
||||
|
||||
use GuzzleHttp\ClientInterface;
|
||||
|
||||
class HttpRepository implements RepositoryInterface
|
||||
{
|
||||
/**
|
||||
* The guzzle client instance.
|
||||
*
|
||||
* @var \GuzzleHttp\ClientInterface
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* The url to use.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $url;
|
||||
|
||||
/**
|
||||
* Create a new segment http repository instance.
|
||||
*
|
||||
* @param \GuzzleHttp\ClientInterface $client
|
||||
* @param string $url
|
||||
*/
|
||||
public function __construct(ClientInterface $client, $url)
|
||||
{
|
||||
$this->client = $client;
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the segment write key.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fetch()
|
||||
{
|
||||
$response = $this->client->get($this->url);
|
||||
|
||||
$body = json_decode($response->getBody());
|
||||
|
||||
return $body->segment_write_key;
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace CachetHQ\Cachet\Segment;
|
||||
|
||||
interface RepositoryInterface
|
||||
{
|
||||
/**
|
||||
* Returns the segment write key.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function fetch();
|
||||
}
|
@ -22,7 +22,6 @@
|
||||
"php": "^5.5.9",
|
||||
"laravel/framework": "~5.1.6",
|
||||
"alt-three/emoji": "^1.0",
|
||||
"alt-three/segment": "^1.0",
|
||||
"barryvdh/laravel-cors": "^0.5",
|
||||
"doctrine/dbal": "^2.5",
|
||||
"fideloper/proxy": "^3.0",
|
||||
|
@ -150,7 +150,6 @@ return [
|
||||
* Packages Service Providers...
|
||||
*/
|
||||
'AltThree\Emoji\EmojiServiceProvider',
|
||||
'AltThree\Segment\SegmentServiceProvider',
|
||||
'Barryvdh\Cors\CorsServiceProvider',
|
||||
'Fideloper\Proxy\TrustedProxyServiceProvider',
|
||||
'GrahamCampbell\Binput\BinputServiceProvider',
|
||||
@ -173,7 +172,6 @@ return [
|
||||
'CachetHQ\Cachet\Providers\ConsoleServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\EventServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\RouteServiceProvider',
|
||||
'CachetHQ\Cachet\Providers\SegmentServiceProvider',
|
||||
|
||||
],
|
||||
|
||||
|
@ -1,27 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Cachet.
|
||||
*
|
||||
* (c) Alt Three Services Limited
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Segment Write Key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This option specifies key which enables you to write to Segment's API.
|
||||
|
|
||||
| Default: ''
|
||||
|
|
||||
*/
|
||||
|
||||
'write_key' => '',
|
||||
|
||||
];
|
@ -40,10 +40,6 @@ class SettingsTableSeeder extends Seeder
|
||||
'name' => 'app_timezone',
|
||||
'value' => 'Europe/London',
|
||||
],
|
||||
[
|
||||
'name' => 'app_track',
|
||||
'value' => '1',
|
||||
],
|
||||
[
|
||||
'name' => 'app_incident_days',
|
||||
'value' => '7',
|
||||
|
@ -19,5 +19,4 @@ return [
|
||||
'complete_setup' => 'Setup abschließen',
|
||||
'completed' => 'Cachet wurde erfolgreich eingerichtet!',
|
||||
'finish_setup' => 'Zum Dashboard',
|
||||
'allow_tracking' => 'Allow anonymous usage tracking?',
|
||||
];
|
||||
|
@ -20,5 +20,4 @@ return [
|
||||
'complete_setup' => 'crwdns264:0crwdne264:0',
|
||||
'completed' => 'crwdns291:0crwdne291:0',
|
||||
'finish_setup' => 'crwdns292:0crwdne292:0',
|
||||
'allow_tracking' => 'crwdns437:0crwdne437:0',
|
||||
];
|
||||
|
@ -20,5 +20,4 @@ return [
|
||||
'complete_setup' => 'Complete Setup',
|
||||
'completed' => 'Cachet has been configured successfully!',
|
||||
'finish_setup' => 'Go to dashboard',
|
||||
'allow_tracking' => 'Allow anonymous usage tracking?',
|
||||
];
|
||||
|
@ -19,5 +19,4 @@ return [
|
||||
'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?',
|
||||
];
|
||||
|
@ -19,5 +19,4 @@ return [
|
||||
'complete_setup' => 'Selesaikan Instalasi',
|
||||
'completed' => 'Cachet berhasil dikonfigurasi!',
|
||||
'finish_setup' => 'Ke dashboard',
|
||||
'allow_tracking' => 'Aktifkan tracking penggunaan anonim?',
|
||||
];
|
||||
|
@ -20,5 +20,4 @@ return [
|
||||
'complete_setup' => '설치 완료',
|
||||
'completed' => 'Cachet 이 성공적으로 설정되었습니다.',
|
||||
'finish_setup' => '대시보드로 이동',
|
||||
'allow_tracking' => '익명 사용 추적 허용',
|
||||
];
|
||||
|
@ -19,5 +19,4 @@ return [
|
||||
'complete_setup' => 'Installatie voltooien',
|
||||
'completed' => 'Cachet is met succes geconfigureerd!',
|
||||
'finish_setup' => 'Ga naar dashboard',
|
||||
'allow_tracking' => 'Anoniem gebruik tracken toestaan?',
|
||||
];
|
||||
|
@ -19,5 +19,4 @@ return [
|
||||
'complete_setup' => 'Konfiguracja zakończona',
|
||||
'completed' => 'Cachet został skonfigurowany pomyślnie!',
|
||||
'finish_setup' => 'Przejdź do panelu',
|
||||
'allow_tracking' => 'Zezwolić na anonimowe śledzenie wykorzystania?',
|
||||
];
|
||||
|
@ -19,5 +19,4 @@ return [
|
||||
'complete_setup' => 'Configuração completa',
|
||||
'completed' => 'Cachet foi configurado com sucesso!',
|
||||
'finish_setup' => 'Ir para o painel de controle',
|
||||
'allow_tracking' => 'Permite rastreamento de uso anônimo?',
|
||||
];
|
||||
|
@ -20,5 +20,4 @@ return [
|
||||
'complete_setup' => 'Завершить установку',
|
||||
'completed' => 'Вы успешно установили Cachet!',
|
||||
'finish_setup' => 'Перейти в панель управления',
|
||||
'allow_tracking' => 'Разрешить отправку анонимной статистики использования?',
|
||||
];
|
||||
|
@ -20,5 +20,4 @@ return [
|
||||
'complete_setup' => '设置完成',
|
||||
'completed' => 'Cachet已成功配置!',
|
||||
'finish_setup' => '前往控制面板',
|
||||
'allow_tracking' => '允许匿名用量跟踪吗?',
|
||||
];
|
||||
|
@ -20,5 +20,4 @@ return [
|
||||
'complete_setup' => '完成安裝',
|
||||
'completed' => '成功安裝 Cachet !',
|
||||
'finish_setup' => '前往儀表板',
|
||||
'allow_tracking' => '允許匿名統計?',
|
||||
];
|
||||
|
@ -166,15 +166,6 @@
|
||||
</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">
|
||||
|
@ -116,12 +116,6 @@
|
||||
{{ 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-info" data-current-block="2" data-next-block="1">
|
||||
|
Loading…
x
Reference in New Issue
Block a user