Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Dependency List
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
197
Issues
197
List
Boards
Labels
Service Desk
Milestones
Merge Requests
27
Merge Requests
27
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
List
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Minds
Minds Backend - Engine
Commits
dffd0a4e
Commit
dffd0a4e
authored
1 hour ago
by
Mark Harding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(feat): introduce new mwa endpoint for pageview recording
parent
07015d77
master
No related merge requests found
Pipeline
#74187732
waiting for manual action with stages
in 11 minutes and 25 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
80 additions
and
0 deletions
+80
-0
pv.php
Controllers/api/v2/mwa/pv.php
+80
-0
No files found.
Controllers/api/v2/mwa/pv.php
0 → 100644
View file @
dffd0a4e
<?php
/**
* Pageview analytics
*/
namespace
Minds\Controllers\api\v2\mwa
;
use
Minds\Api\Factory
;
use
Minds\Core
;
use
Minds\Core\Di\Di
;
use
Minds\Common\Cookie
;
use
Minds\Entities
;
use
Minds\Helpers\Counters
;
use
Minds\Interfaces
;
class
pv
implements
Interfaces\Api
,
Interfaces\ApiIgnorePam
{
public
function
get
(
$pages
)
{
return
Factory
::
response
([]);
}
public
function
post
(
$pages
)
{
if
(
!
isset
(
$_POST
[
'url'
]))
{
return
Factory
::
response
([
'status'
=>
'error'
,
'message'
=>
'You must provide a url'
]);
}
if
(
!
isset
(
$_COOKIE
[
'mwa'
]))
{
//@TODO make this more unique
$id
=
uniqid
(
true
);
$cookie
=
new
Cookie
();
$cookie
->
setName
(
'mwa'
)
->
setValue
(
$id
)
->
setExpire
(
time
()
+
(
60
*
60
*
24
*
30
*
12
))
->
setPath
(
'/'
)
->
create
();
$_COOKIE
[
'mwa'
]
=
$id
;
}
$url
=
strtok
(
$_POST
[
'url'
],
'?'
);
$event
=
new
Core\Analytics\Metrics\Event
();
$event
->
setType
(
'action'
)
->
setProduct
(
'platform'
)
->
setAction
(
'pageview'
)
->
setRouteUri
(
$url
)
->
setUserAgent
(
$_SERVER
[
'HTTP_USER_AGENT'
])
->
setCookieId
(
$_COOKIE
[
'mwa'
]);
if
(
isset
(
$_POST
[
'referrer'
])
&&
$_POST
[
'referrer'
])
{
$event
->
setReferrerUri
((
string
)
$_POST
[
'referrer'
]);
}
if
(
Core\Session
::
isLoggedIn
())
{
$event
->
setLoggedIn
(
true
);
}
$event
->
push
();
return
Factory
::
response
([]);
}
public
function
put
(
$pages
)
{
return
Factory
::
response
([]);
}
public
function
delete
(
$pages
)
{
return
Factory
::
response
([]);
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment