Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
visitors
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
visitors
Commits
006ee433
Commit
006ee433
authored
4 months ago
by
Steven Ayers
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3496400
: Optional: Device Detect
parent
ba1b1a51
Branches
Branches containing commit
No related tags found
1 merge request
!201
Issue #3496400 by bluegeek9: Optional: Device Detect
Pipeline
#380850
failed
4 months ago
Stage: build
Stage: validate
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Controller/Visitors.php
+17
-1
17 additions, 1 deletion
src/Controller/Visitors.php
tests/src/Unit/Controller/VisitorsControllerTest.php
+1
-0
1 addition, 0 deletions
tests/src/Unit/Controller/VisitorsControllerTest.php
with
18 additions
and
1 deletion
src/Controller/Visitors.php
+
17
−
1
View file @
006ee433
...
...
@@ -159,7 +159,7 @@ final class Visitors extends ControllerBase {
$server
=
$request
->
server
;
$query
=
$request
->
query
->
all
();
$fields
=
[]
;
$fields
=
$this
->
getDefaultFields
()
;
$ip
=
$request
->
getClientIp
();
$fields
[
'visitors_ip'
]
=
$ip
;
...
...
@@ -200,6 +200,18 @@ final class Visitors extends ControllerBase {
return
$response
;
}
/**
* Get the default fields.
*
* @return array
* The default fields.
*/
protected
function
getDefaultFields
():
array
{
return
[
'bot'
=>
0
,
];
}
/**
* Detects the visitor url.
*
...
...
@@ -248,6 +260,10 @@ final class Visitors extends ControllerBase {
* The server array.
*/
protected
function
doDeviceDetect
(
array
&
$fields
,
ServerBag
$server
)
{
if
(
!
class_exists
(
'DeviceDetector\ClientHints'
))
{
return
NULL
;
}
$user_agent
=
$server
->
get
(
'HTTP_USER_AGENT'
,
''
);
$dd
=
$this
->
device
->
getDeviceDetector
(
$user_agent
,
$server
->
all
());
...
...
This diff is collapsed.
Click to expand it.
tests/src/Unit/Controller/VisitorsControllerTest.php
+
1
−
0
View file @
006ee433
...
...
@@ -177,6 +177,7 @@ class VisitorsControllerTest extends UnitTestCase {
* @covers ::doTime
* @covers ::doLanguage
* @covers ::doLocation
* @covers ::getDefaultFields
*/
public
function
testTrack
()
{
$request
=
$this
->
createMock
(
'\Symfony\Component\HttpFoundation\Request'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment