Skip to content
Next
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Minds Backend - Engine
Project
Project
Details
Activity
Releases
Cycle Analytics
Insights
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
276
Issues
276
List
Boards
Labels
Service Desk
Milestones
Merge Requests
46
Merge Requests
46
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Security & Compliance
Security & Compliance
Dependency List
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
80522e2f
Commit
80522e2f
authored
3 hours ago
by
Marcelo Rivera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(feat): add new MetricsDelegate that pushes the new delete analytics event
parent
4ea10248
feat/new-delete-event-32
1 merge request
!380
Implement new delete for channel delete to record delete event in elasticsearch
Pipeline
#90213920
passed with stages
in 11 minutes and 23 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
0 deletions
+40
-0
Core/Channels/Delegates/MetricsDelegate.php
Core/Channels/Delegates/MetricsDelegate.php
+23
-0
Core/Channels/Manager.php
Core/Channels/Manager.php
+8
-0
Spec/Core/Channels/ManagerSpec.php
Spec/Core/Channels/ManagerSpec.php
+9
-0
No files found.
Core/Channels/Delegates/MetricsDelegate.php
0 → 100644
View file @
80522e2f
<?php
/**
* @author: eiennohi.
*/
namespace
Minds\Core\Channels\Delegates
;
use
Minds\Core\Analytics\Metrics\Event
;
use
Minds\Entities\User
;
class
MetricsDelegate
{
public
function
onDelete
(
User
$user
)
{
$event
=
new
Event
();
$event
->
setType
(
'action'
)
->
setAction
(
'delete'
)
->
setProduct
(
'platform'
)
->
setUserGuid
((
string
)
$user
->
guid
)
->
setUserPhoneNumberHash
(
$user
->
getPhoneNumberHash
())
->
push
();
}
}
This diff is collapsed.
Click to expand it.
Core/Channels/Manager.php
View file @
80522e2f
...
...
@@ -5,6 +5,7 @@
namespace
Minds\Core\Channels
;
use
Minds\Core\Channels\Delegates\MetricsDelegate
;
use
Minds\Core\Di\Di
;
use
Minds\Core\Queue\Interfaces\QueueClient
;
use
Minds\Entities\User
;
...
...
@@ -30,6 +31,9 @@ class Manager
/** @var Delegates\Artifacts\Factory */
protected
$artifactsDelegatesFactory
;
/** @var MetricsDelegate */
protected
$metricsDelegate
;
/** @var Delegates\Logout */
protected
$logoutDelegate
;
...
...
@@ -44,10 +48,12 @@ class Manager
*/
public
function
__construct
(
$artifactsDelegatesFactory
=
null
,
$metricsDelegate
=
null
,
$logoutDelegate
=
null
,
$queueClient
=
null
)
{
$this
->
artifactsDelegatesFactory
=
$artifactsDelegatesFactory
?:
new
Delegates\Artifacts\Factory
();
$this
->
metricsDelegate
=
$metricsDelegate
?:
new
MetricsDelegate
();
$this
->
logoutDelegate
=
$logoutDelegate
?:
new
Delegates\Logout
();
$this
->
queueClient
=
$queueClient
?:
Di
::
_
()
->
get
(
'Queue'
);
}
...
...
@@ -132,6 +138,8 @@ class Manager
if
(
!
$done
)
{
throw
new
\Exception
(
"
{
$delegateClassName
}
deletion failed for
{
$userGuid
}
"
);
}
$this
->
metricsDelegate
->
onDelete
(
$this
->
user
);
}
catch
(
\Exception
$e
)
{
// TODO: Fail?
error_log
((
string
)
$e
);
...
...
This diff is collapsed.
Click to expand it.
Spec/Core/Channels/ManagerSpec.php
View file @
80522e2f
...
...
@@ -20,6 +20,9 @@ class ManagerSpec extends ObjectBehavior
/** @var Delegates\Artifacts\Factory */
protected
$artifactsDelegatesFactory
;
/** @var Delegates\MetricsDelegate */
protected
$metricsDelegate
;
/** @var Delegates\Logout */
protected
$logoutDelegate
;
...
...
@@ -28,16 +31,19 @@ class ManagerSpec extends ObjectBehavior
public
function
let
(
Delegates\Artifacts\Factory
$artifactsDelegatesFactory
,
Delegates\MetricsDelegate
$metricsDelegate
,
Delegates\Logout
$logoutDelegate
,
QueueClient
$queueClient
)
{
$this
->
beConstructedWith
(
$artifactsDelegatesFactory
,
$metricsDelegate
,
$logoutDelegate
,
$queueClient
);
$this
->
artifactsDelegatesFactory
=
$artifactsDelegatesFactory
;
$this
->
metricsDelegate
=
$metricsDelegate
;
$this
->
logoutDelegate
=
$logoutDelegate
;
$this
->
queueClient
=
$queueClient
;
}
...
...
@@ -139,6 +145,9 @@ class ManagerSpec extends ObjectBehavior
->
shouldBeCalledTimes
(
count
(
$deletionDelegates
))
->
willReturn
(
true
);
$this
->
metricsDelegate
->
onDelete
(
$user
)
->
shouldBeCalled
();
$this
->
logoutDelegate
->
logout
(
$user
)
->
shouldBeCalled
()
->
willReturn
(
true
);
...
...
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