Added support for analytics

This commit is contained in:
Hillel Coren 2017-06-05 16:31:28 +03:00
parent ebfb76bfac
commit 7723d86c1d
7 changed files with 46 additions and 20 deletions

View File

@ -1006,6 +1006,10 @@ class AccountController extends BaseController
$user->notify_approved = Input::get('notify_approved');
$user->save();
$account = $user->account;
$account->fill(request()->all());
$account->save();
Session::flash('message', trans('texts.updated_settings'));
return Redirect::to('settings/'.ACCOUNT_NOTIFICATIONS);

View File

@ -15,19 +15,26 @@ class AnalyticsListener
*/
public function trackRevenue(PaymentWasCreated $event)
{
if (! Utils::isNinja() || ! env('ANALYTICS_KEY')) {
return;
}
$payment = $event->payment;
$invoice = $payment->invoice;
$account = $payment->account;
if (! $account->isNinjaAccount() && $account->account_key != NINJA_LICENSE_ACCOUNT_KEY) {
$analyticsId = false;
if ($account->isNinjaAccount() || $account->account_key == NINJA_LICENSE_ACCOUNT_KEY) {
$analyticsId = env('ANALYTICS_KEY');
} else {
if (Utils::isNinja()) {
$analyticsId = $account->analytics_key;
} else {
$analyticsId = $account->analytics_key ?: env('ANALYTICS_KEY');
}
}
if (! $analyticsId) {
return;
}
$analyticsId = env('ANALYTICS_KEY');
$client = $payment->client;
$amount = $payment->amount;
$item = $invoice->invoice_items->last()->product_key;

View File

@ -170,6 +170,7 @@ class Account extends Eloquent
'custom_contact_label1',
'custom_contact_label2',
'domain_id',
'analytics_key',
];
/**

View File

@ -69,6 +69,7 @@ class AddDefaultNoteToClient extends Migration
$table->renameColumn('custom_design', 'custom_design1');
$table->mediumText('custom_design2')->nullable();
$table->mediumText('custom_design3')->nullable();
$table->string('analytics_key')->nullable();
});
DB::statement('update accounts
@ -100,6 +101,10 @@ class AddDefaultNoteToClient extends Migration
});
Schema::table('accounts', function ($table) {
$table->renameColumn('custom_design1', 'custom_design');
$table->dropColumn('custom_design2');
$table->dropColumn('custom_design3');
$table->dropColumn('analytics_key');
$table->dropColumn('tax_name1');
$table->dropColumn('tax_rate1');
$table->dropColumn('tax_name2');
@ -112,12 +117,5 @@ class AddDefaultNoteToClient extends Migration
$table->dropColumn('tax_name2');
$table->dropColumn('tax_rate2');
});
Schema::table('accounts', function ($table) {
$table->renameColumn('custom_design1', 'custom_design');
$table->dropColumn('custom_design2');
$table->dropColumn('custom_design3');
});
}
}

File diff suppressed because one or more lines are too long

View File

@ -81,7 +81,7 @@ $LANG = array(
'guest' => 'Guest',
'company_details' => 'Company Details',
'online_payments' => 'Online Payments',
'notifications' => 'Email Notifications',
'notifications' => 'Notifications',
'import_export' => 'Import | Export',
'done' => 'Done',
'save' => 'Save',
@ -2263,6 +2263,9 @@ $LANG = array(
'load_design' => 'Load Design',
'accepted_card_logos' => 'Accepted Card Logos',
'phantomjs_local_and_cloud' => 'Using local PhantomJS, falling back to phantomjscloud.com',
'google_analytics' => 'Google Analytics',
'analytics_key' => 'Analytics Key',
'analytics_key_help' => 'Track payments using :link',
);

View File

@ -10,6 +10,18 @@
@include('accounts.partials.notifications')
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{!! trans('texts.google_analytics') !!}</h3>
</div>
<div class="panel-body">
{!! Former::text('analytics_key')
->help(trans('texts.analytics_key_help', ['link' => link_to('https://support.google.com/analytics/answer/1037249?hl=en', 'Google Analytics Ecommerce', ['target' => '_blank'])])) !!}
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">{!! trans('texts.facebook_and_twitter') !!}</h3>