Skip to content

Commit 456f733

Browse files
author
mmoreram
committed
Small refactor on Metrics
* Changed a little bit how metrics works in its internals * Changed api and JS script * Removed all metrics-related from template, and placed everything in the base file * Changed dependencies * CHanged how metrics are shown in Admin panel * Fixed behat scenario * Updated readme * Added php7 ind hhvm n travis matrix (7.0 allowed for failures)
1 parent 321f5d4 commit 456f733

File tree

56 files changed

+1744
-302
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1744
-302
lines changed

.travis.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
language: php
22

33
php:
4-
- 5.4
5-
- 5.5
6-
- 5.6
4+
- 5.4
5+
- 5.5
6+
- 5.6
7+
- hhvm
8+
- 7.0
9+
10+
matrix:
11+
fast_finish: true
12+
allow_failures:
13+
- php: 7.0
714

815
before_install:
916
- /home/travis/.phpenv/versions/$(phpenv version-name)/bin/composer self-update

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ Bamboo uses redis to make the app lighter and to minimize the response time.
3232
For more info just visit their
3333
[installation page](http://redis.io/topics/quickstart)
3434

35+
In order to use the last Redis features, like the `HyperLogLog` commands, be
36+
sure your Redis version is at least `v2.8.9`.
37+
3538
### Imagick
3639
The images are a really important part of an store. Bamboo uses Imagick to
3740
resize and optimize all the product images

app/AppKernel.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function registerBundles()
5252
new \PaymentSuite\PaypalWebCheckoutBundle\PaypalWebCheckoutBundle(),
5353
new \PaymentSuite\PaymillBundle\PaymillBundle(),
5454
new \HWI\Bundle\OAuthBundle\HWIOAuthBundle(),
55-
new Snc\RedisBundle\SncRedisBundle(),
55+
new \Snc\RedisBundle\SncRedisBundle(),
5656

5757
/**
5858
* Elcodi core bundles
@@ -98,6 +98,7 @@ public function registerBundles()
9898
new \Elcodi\Store\CartCouponBundle\StoreCartCouponBundle(),
9999
new \Elcodi\Store\ConnectBundle\StoreConnectBundle(),
100100
new \Elcodi\Store\PaymentBridgeBundle\PaymentBridgeBundle(),
101+
new \Elcodi\Store\MetricBundle\StoreMetricBundle(),
101102

102103
/**
103104
* Elcodi admin bundles

app/Resources/views/_base.html.twig

Lines changed: 65 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,78 @@
4343
</head>
4444

4545
<body {% block body_id "" %} {% block body_class "" %}>
46-
4746
{{ elcodi_hook("store.body_top") }}
4847

4948
<!--[if lt IE 8]>
5049
<!-- should warn for outdated browser -->
5150
<![endif]-->
5251
{% block body "" %}
5352
{% block pixels "" %}
54-
{% block view_pixel %}
55-
<script>
56-
_etc.push(["{{ store_tracker }}", 'page_view']);
57-
</script>
58-
{% endblock %}
53+
54+
{% set current_user_id = app.session.id|sha1 %}
55+
{% set current_route_name = app.request.get('_route') %}
56+
57+
<script>
58+
59+
var isMobile = {
60+
Android: function() {
61+
return navigator.userAgent.match(/Android/i);
62+
},
63+
BlackBerry: function() {
64+
return navigator.userAgent.match(/BlackBerry/i);
65+
},
66+
iOS: function() {
67+
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
68+
},
69+
Opera: function() {
70+
return navigator.userAgent.match(/Opera Mini/i);
71+
},
72+
Windows: function() {
73+
return navigator.userAgent.match(/IEMobile/i);
74+
},
75+
any: function() {
76+
return ( isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows());
77+
}
78+
};
79+
80+
/**
81+
* Page view beacons
82+
*/
83+
_etc.push(["{{ store_tracker }}", 'pv', '{{ current_user_id }}', '3']);
84+
_etc.push(["{{ store_tracker }}", 'pv_{{ current_route_name }}', '{{ current_user_id }}', '3']);
85+
86+
/**
87+
* Specific product view beacon
88+
*/
89+
{% if current_route_name == 'store_product_view' %}
90+
_etc.push(["{{ store_tracker }}", 'pv_store_product_view_{{ product.id }}', '{{ current_user_id }}', '3']);
91+
{% endif %}
92+
93+
/**
94+
* Add mobile beacon
95+
*/
96+
if (isMobile.any()) {
97+
_etc.push(["{{ store_tracker }}", 'mob', '', '1']);
98+
} else {
99+
_etc.push(["{{ store_tracker }}", 'no_mob', '', '1']);
100+
}
101+
102+
/**
103+
* Add search engine beacon
104+
*/
105+
var referrer = "{{ referrer_domain() }}";
106+
var referrerIsSearchEngine = {{ referrer_is_search_engine() }};
107+
if (referrerIsSearchEngine) {
108+
_etc.push(["{{ store_tracker }}", 'source_se', '', '1']);
109+
_etc.push(["{{ store_tracker }}", 'rf', referrer, '8'])
110+
} else if (referrer != false) {
111+
_etc.push(["{{ store_tracker }}", 'source_ref', '', '1']);
112+
_etc.push(["{{ store_tracker }}", 'rf', referrer, '8'])
113+
} else {
114+
_etc.push(["{{ store_tracker }}", 'source_dir', '', '1'])
115+
}
116+
</script>
117+
59118
{% block foot_script "" %}
60119

61120
{{ elcodi_hook("store.body_bottom") }}

app/config/accessControl.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ security:
33

44
# admin
55
login_area:
6-
path: ^/admin/login
6+
path: ^/%bamboo_admin_prefix%/login
77
roles: IS_AUTHENTICATED_ANONYMOUSLY
88

99
password_area:
10-
path: ^/admin/password
10+
path: ^/%bamboo_admin_prefix%/password
1111
roles: IS_AUTHENTICATED_ANONYMOUSLY
1212

1313
admin_area:
14-
path: ^/admin/
14+
path: ^/%bamboo_admin_prefix%/
1515
roles: ROLE_ADMIN
1616

1717
# store

app/config/firewalls.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ security:
3333
default_target_path: admin_homepage
3434
logout:
3535
path: admin_logout
36-
target: admin_homepage
36+
target: admin_login
3737
invalidate_session: false
3838

3939
store_area:

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@
7171
"paymentsuite/paypal-web-checkout-bundle": "~1.5.0",
7272
"incenteev/composer-parameter-handler": "~2.0",
7373
"hwi/oauth-bundle": "0.4.*@dev",
74-
"snc/redis-bundle": "~1.1",
74+
"snc/redis-bundle": "~1.1, >=1.1.8",
75+
"predis/predis": "0.8.7",
7576

7677
"elcodi/bamboo-bundle": "~0.4.0",
7778
"elcodi/attribute-bundle": "~0.4.0",

features/admin.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ Feature: admin
1515
| elcodi_admin_user_form_type_login_email | admin@admin.com |
1616
| elcodi_admin_user_form_type_login_password | 1234 |
1717
And I press "Log In"
18-
Then I should be on "/admin/"
18+
Then I should be on "/admin/plugin/setup-wizard/store-setup-wizard"
1919
And I should see "Elcodi Admin"

src/Elcodi/Admin/CoreBundle/AdminCoreBundle.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ class AdminCoreBundle extends Bundle
3131
*/
3232
public function getContainerExtension()
3333
{
34-
return null;
34+
return;
3535
}
3636
}

src/Elcodi/Admin/CoreBundle/Controller/HomeController.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@
2323

2424
/**
2525
* Class IndexController
26-
*
27-
* @Route(
28-
* path = "/",
29-
* )
3026
*/
3127
class HomeController extends Controller
3228
{

src/Elcodi/Admin/CoreBundle/Resources/public/twig/commentForm.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
<div class="balloon balloon-left balloon-background d-ib va-m mb-n w-80">
44
{{ comment }}
55
</div>
6-
</div>
6+
</div>

src/Elcodi/Admin/CoreBundle/Resources/public/twig/commentItem.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
<p class="fz-s mb-n">{{ commentDate|date("d/m/Y") }}</p>
1818
</div>
1919
{% endif %}
20-
</div>
20+
</div>

src/Elcodi/Admin/CoreBundle/Resources/public/twig/commentNew.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
<p class="fz-s mb-n">{{ authorName }}</p>
1616
</div>
1717
{% endif %}
18-
</div>
18+
</div>

src/Elcodi/Admin/CoreBundle/Resources/public/twig/commentWrapper.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
<div class="bxp-responses"></div>
55
<div id="boxpopuli-response-{{ commentId }}" class="bxp-new-response"></div>
66
</div>
7-
</div>
7+
</div>

src/Elcodi/Admin/CoreBundle/Resources/views/Home/index.html.twig

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66

77
{% block content %}
88

9-
{{ render(url('admin_metric_last_24_hours', {
10-
'tracker': store_tracker,
11-
'event': 'page_view'
12-
})) }}
9+
{% render(controller("AdminMetricBundle:Panel:metricPanelToday")) %}
1310

1411
{% endblock content %}

src/Elcodi/Admin/CoreBundle/Resources/views/Navs/side.html.twig

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<div class="sidebar-user tablet desktop">
22
<div class="ta-c">
3-
43
<a href="#sidebar-user-dropdown" data-tc-modules="toggle" class="c-foreground-light">
54
<span class=" tablet va-m">
65
<img src="{{ gravatar(app.user.email, 40) }}" alt="Avatar" class="image-circle">
@@ -14,7 +13,7 @@
1413
<nav id="sidebar-user-dropdown" class="navigation navigation-vertical sidebar-user-dropdown hidden">
1514
<ul>
1615
<li>
17-
<a href="{{ url('admin_admin_user_edit', {id: app.security.getToken().getUser().getId() }) }}">
16+
<a href="{{ url('admin_admin_user_edit', {id: app.user.id }) }}">
1817
<span class="mobile tablet">
1918
<i class="icon-user fz-xl"></i> {{ 'Profile'|trans }}
2019
</span>
@@ -40,23 +39,23 @@
4039
<ul>
4140
{% for menu_item in menu_items %}
4241

43-
{% if menu_item.code != 'separator' %}
44-
<li class="{% if menu_item.active %}active{% endif %}{% if menu_item.subnodes|length %}parent{% endif %}">
45-
{% if generate_url(menu_item.url) != '' %}
46-
<a href="{{ generate_url(menu_item.url) }}">
42+
{% if menu_item.code != 'separator' %}
43+
<li class="{% if menu_item.active %}active{% endif %}{% if menu_item.subnodes|length %}parent{% endif %}">
44+
{% if generate_url(menu_item.url) != '' %}
45+
<a href="{{ generate_url(menu_item.url) }}">
4746
{% else %}
48-
<a href="#{{ menu_item.id }}" data-tc-modules="toggle">
49-
<i class="icon-caret-down fl-r"></i>
50-
{% endif %}
51-
<span class="mobile tablet">
52-
<i class="icon-{{ menu_item.code|default("folder") }} fz-xl va-m mr-s"></i>
53-
<span class="c-foreground-light">{{ menu_item.name|trans }}</span>
54-
</span>
55-
<span class="desktop">
56-
<i class="icon-{{ menu_item.code|default("folder") }} mr-m"></i>
57-
{{ menu_item.name|trans }}
58-
</span>
59-
</a>
47+
<a href="#{{ menu_item.id }}" data-tc-modules="toggle">
48+
<i class="icon-caret-down fl-r"></i>
49+
{% endif %}
50+
<span class="mobile tablet">
51+
<i class="icon-{{ menu_item.code|default("folder") }} fz-xl va-m mr-s"></i>
52+
<span class="c-foreground-light">{{ menu_item.name|trans }}</span>
53+
</span>
54+
<span class="desktop">
55+
<i class="icon-{{ menu_item.code|default("folder") }} mr-m"></i>
56+
{{ menu_item.name|trans }}
57+
</span>
58+
</a>
6059
{% for submenu_item in menu_item.subnodes %}
6160
{% if loop.first %}
6261
<ul id="{{ menu_item.id }}" {% if not menu_item.active %}class="hidden"{% endif %}>
@@ -68,12 +67,12 @@
6867
</ul>
6968
{% endif %}
7069
{% endfor %}
71-
</li>
72-
{% else %}
73-
<li class="pt-s">
74-
<hr class="rule" />
75-
</li>
76-
{% endif %}
70+
</li>
71+
{% else %}
72+
<li class="pt-s">
73+
<hr class="rule" />
74+
</li>
75+
{% endif %}
7776
{% endfor %}
7877
</ul>
7978
</nav>

src/Elcodi/Admin/CoreBundle/Resources/views/footscript.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
}
1616
</script>
1717
<script type="text/javascript" src="{{ asset('bundles/admincore/components/twig.js/twig.js') }}"></script>
18-
<script type="text/javascript" src="{{ asset('bundles/admincore/components/frontendcore-js/core.js') }}"></script>
18+
<script type="text/javascript" src="{{ asset('bundles/admincore/components/frontendcore-js/core.js') }}"></script>

src/Elcodi/Admin/MediaBundle/DependencyInjection/AdminMediaExtension.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ public function getConfigFiles(array $config)
5959
return [
6060
'classes',
6161
'formTypes',
62-
'paginationFields',
6362
];
6463
}
6564

src/Elcodi/Admin/MediaBundle/Resources/config/paginationFields.yml

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/Elcodi/Admin/MetricBundle/AdminMetricBundle.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@
1717

1818
namespace Elcodi\Admin\MetricBundle;
1919

20+
use Symfony\Component\CssSelector\XPath\Extension\ExtensionInterface;
2021
use Symfony\Component\HttpKernel\Bundle\Bundle;
2122

23+
use Elcodi\Admin\MetricBundle\DependencyInjection\AdminMetricExtension;
24+
2225
/**
2326
* Class AdminMetricBundle
2427
*/
@@ -27,10 +30,10 @@ class AdminMetricBundle extends Bundle
2730
/**
2831
* Returns the bundle's container extension.
2932
*
30-
* @return null
33+
* @return ExtensionInterface The container extension
3134
*/
3235
public function getContainerExtension()
3336
{
34-
return;
37+
return new AdminMetricExtension();
3538
}
3639
}

0 commit comments

Comments
 (0)