diff options
author | Kate Butler <kate@innocraft.com> | 2019-04-02 00:56:57 +0300 |
---|---|---|
committer | diosmosis <diosmosis@users.noreply.github.com> | 2019-04-02 00:56:57 +0300 |
commit | 0df4c84a15de3dfb0ef4247c15a1dce97347976a (patch) | |
tree | 021a260dd71bcfba7519f1dc2e7849d399d95975 /plugins/Live | |
parent | fdc3483a7243137fcc70421f2a2696c3b0f7958d (diff) |
New dimension for segmenting visitors by fingerprint (#14184)
* Add new dimension for segmenting by visitor fingerprint; expose fingerprint in getLastVisitsDetails API response
* Add new dimension for segmenting by visitor fingerprint
* Add new fingerprint field to API system test reference files
* System test fixes for visitor fingerprint
* System test fixes for visitor fingerprint
* System test changes for new fingerprint dimension
* Auto-suggest for new fingerprint segment
* Fix unit test
* Revert whitespace changes
* Fix metricId for new visitor fingerprint dimension
Diffstat (limited to 'plugins/Live')
7 files changed, 66 insertions, 10 deletions
diff --git a/plugins/Live/Visitor.php b/plugins/Live/Visitor.php index 4a2cd2dc41..c58d1466e4 100644 --- a/plugins/Live/Visitor.php +++ b/plugins/Live/Visitor.php @@ -146,23 +146,26 @@ class Visitor implements VisitorInterface } /** - * Removes fields that are not meant to be displayed (md5 config hash) - * Or that the user should only access if they are Super User or admin (cookie, IP) + * Removes fields that the user should only access if they are Super User or admin (cookie, IP, + * md5 config "fingerprint" hash) * * @param array $visitorDetails * @return array */ public static function cleanVisitorDetails($visitorDetails) { - $toUnset = array('config_id'); if (Piwik::isUserIsAnonymous()) { - $toUnset[] = 'idvisitor'; - $toUnset[] = 'user_id'; - $toUnset[] = 'location_ip'; - } - foreach ($toUnset as $keyName) { - if (isset($visitorDetails[$keyName])) { - unset($visitorDetails[$keyName]); + $toUnset = array( + 'idvisitor', + 'user_id', + 'location_ip', + 'config_id' + ); + + foreach ($toUnset as $keyName) { + if (isset($visitorDetails[$keyName])) { + unset($visitorDetails[$keyName]); + } } } diff --git a/plugins/Live/VisitorDetails.php b/plugins/Live/VisitorDetails.php index 376186ac08..bd60d886a0 100644 --- a/plugins/Live/VisitorDetails.php +++ b/plugins/Live/VisitorDetails.php @@ -35,6 +35,7 @@ class VisitorDetails extends VisitorDetailsAbstract 'idVisit' => $this->getIdVisit(), 'visitIp' => $this->getIp(), 'visitorId' => $this->getVisitorId(), + 'fingerprint' => $this->getFingerprint(), // => false are placeholders to be filled in API later 'actionDetails' => false, @@ -153,6 +154,14 @@ class VisitorDetails extends VisitorDetailsAbstract return $this->details['idsite']; } + function getFingerprint() + { + if (isset($this->details['config_id'])) { + return bin2hex($this->details['config_id']); + } + return false; + } + function getTimestampLastAction() { return strtotime($this->details['visit_last_action_time']); diff --git a/plugins/Live/tests/System/expected/test___Live.getVisitorProfile.xml b/plugins/Live/tests/System/expected/test___Live.getVisitorProfile.xml index 9d3f255754..ca134105c7 100644 --- a/plugins/Live/tests/System/expected/test___Live.getVisitorProfile.xml +++ b/plugins/Live/tests/System/expected/test___Live.getVisitorProfile.xml @@ -25,6 +25,7 @@ <idVisit>32</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -146,6 +147,7 @@ <idVisit>31</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -267,6 +269,7 @@ <idVisit>30</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -388,6 +391,7 @@ <idVisit>29</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -509,6 +513,7 @@ <idVisit>28</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -630,6 +635,7 @@ <idVisit>27</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -751,6 +757,7 @@ <idVisit>26</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -872,6 +879,7 @@ <idVisit>25</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -993,6 +1001,7 @@ <idVisit>24</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -1114,6 +1123,7 @@ <idVisit>23</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> diff --git a/plugins/Live/tests/System/expected/test_allSites__Live.getLastVisitsDetails_day.xml b/plugins/Live/tests/System/expected/test_allSites__Live.getLastVisitsDetails_day.xml index 9fa47144a6..fcb420cd50 100644 --- a/plugins/Live/tests/System/expected/test_allSites__Live.getLastVisitsDetails_day.xml +++ b/plugins/Live/tests/System/expected/test_allSites__Live.getLastVisitsDetails_day.xml @@ -5,6 +5,7 @@ <idVisit>1</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>d58a483a3cfef87b</fingerprint> <actionDetails> <row> <type>action</type> @@ -126,6 +127,7 @@ <idVisit>2</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>e16cf2bbaeea2c88</fingerprint> <actionDetails> <row> <type>action</type> diff --git a/plugins/Live/tests/System/expected/test_higherLimit__Live.getVisitorProfile.xml b/plugins/Live/tests/System/expected/test_higherLimit__Live.getVisitorProfile.xml index 5368d0509d..1bbb29ca03 100644 --- a/plugins/Live/tests/System/expected/test_higherLimit__Live.getVisitorProfile.xml +++ b/plugins/Live/tests/System/expected/test_higherLimit__Live.getVisitorProfile.xml @@ -25,6 +25,7 @@ <idVisit>32</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -146,6 +147,7 @@ <idVisit>31</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -267,6 +269,7 @@ <idVisit>30</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -388,6 +391,7 @@ <idVisit>29</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -509,6 +513,7 @@ <idVisit>28</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -630,6 +635,7 @@ <idVisit>27</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -751,6 +757,7 @@ <idVisit>26</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -872,6 +879,7 @@ <idVisit>25</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -993,6 +1001,7 @@ <idVisit>24</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -1114,6 +1123,7 @@ <idVisit>23</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -1235,6 +1245,7 @@ <idVisit>22</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -1356,6 +1367,7 @@ <idVisit>21</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -1477,6 +1489,7 @@ <idVisit>20</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -1598,6 +1611,7 @@ <idVisit>19</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -1719,6 +1733,7 @@ <idVisit>18</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -1840,6 +1855,7 @@ <idVisit>17</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -1961,6 +1977,7 @@ <idVisit>16</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -2082,6 +2099,7 @@ <idVisit>15</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -2203,6 +2221,7 @@ <idVisit>14</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -2324,6 +2343,7 @@ <idVisit>13</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> diff --git a/plugins/Live/tests/System/expected/test_maxVisitLimit__Live.getVisitorProfile.xml b/plugins/Live/tests/System/expected/test_maxVisitLimit__Live.getVisitorProfile.xml index 9e7801b307..c670a5b3be 100644 --- a/plugins/Live/tests/System/expected/test_maxVisitLimit__Live.getVisitorProfile.xml +++ b/plugins/Live/tests/System/expected/test_maxVisitLimit__Live.getVisitorProfile.xml @@ -25,6 +25,7 @@ <idVisit>32</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -146,6 +147,7 @@ <idVisit>31</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -267,6 +269,7 @@ <idVisit>30</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -388,6 +391,7 @@ <idVisit>29</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -509,6 +513,7 @@ <idVisit>28</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -630,6 +635,7 @@ <idVisit>27</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -751,6 +757,7 @@ <idVisit>26</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -872,6 +879,7 @@ <idVisit>25</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -993,6 +1001,7 @@ <idVisit>24</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> @@ -1114,6 +1123,7 @@ <idVisit>23</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>5041e282fc23fef1</fingerprint> <actionDetails> <row> <type>action</type> diff --git a/plugins/Live/tests/System/expected/test_multiSites__Live.getLastVisitsDetails_day.xml b/plugins/Live/tests/System/expected/test_multiSites__Live.getLastVisitsDetails_day.xml index 9fa47144a6..fcb420cd50 100644 --- a/plugins/Live/tests/System/expected/test_multiSites__Live.getLastVisitsDetails_day.xml +++ b/plugins/Live/tests/System/expected/test_multiSites__Live.getLastVisitsDetails_day.xml @@ -5,6 +5,7 @@ <idVisit>1</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>d58a483a3cfef87b</fingerprint> <actionDetails> <row> <type>action</type> @@ -126,6 +127,7 @@ <idVisit>2</idVisit> <visitIp>156.5.3.2</visitIp> + <fingerprint>e16cf2bbaeea2c88</fingerprint> <actionDetails> <row> <type>action</type> |