Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
usage_data
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
usage_data
Merge requests
!6
Issue
#3258021
: Add views field plugin to count events by entity
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3258021
: Add views field plugin to count events by entity
issue/usage_data-3258021:3258021-add-views-field
into
2.0.x
Overview
2
Commits
3
Pipelines
0
Changes
13
Merged
Volodymyr Selyvanov
requested to merge
issue/usage_data-3258021:3258021-add-views-field
into
2.0.x
3 years ago
Overview
2
Commits
3
Pipelines
0
Changes
13
Expand
0
0
Merge request reports
Compare
2.0.x
version 2
93024730
3 years ago
version 1
f3ba4fed
3 years ago
2.0.x (base)
and
latest version
latest version
93024730
3 commits,
3 years ago
version 2
93024730
3 commits,
3 years ago
version 1
f3ba4fed
2 commits,
3 years ago
13 files
+
213
−
41
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
13
Search (e.g. *.vue) (Ctrl+P)
js/statistics.js
+
43
−
21
Options
@@ -3,7 +3,7 @@
* Usage Data functionality.
*/
(
function
(
$
,
Drupal
,
drupalSettings
)
{
(
function
(
$
,
Drupal
,
drupalSettings
,
once
)
{
'
use strict
'
;
@@ -17,28 +17,50 @@
data
:
drupalSettings
.
usage_data
.
data
});
}
});
// Track click event.
$
(
'
[data-usage]
'
).
on
(
'
click
'
,
function
(
e
,
options
)
{
var
data
=
JSON
.
parse
(
$
(
this
).
attr
(
'
data-usage
'
));
if
(
!
data
)
{
return
;
}
// Add path info if not set.
if
(
!
data
[
'
path
'
])
{
var
href
=
$
(
this
).
attr
(
'
href
'
)
?
$
(
this
).
attr
(
'
href
'
)
:
location
.
href
;
data
[
'
path
'
]
=
href
.
replace
(
location
.
origin
,
''
);
}
$
.
ajax
({
type
:
'
POST
'
,
cache
:
false
,
url
:
drupalSettings
.
usage_data
.
url
,
data
:
{
'
type
'
:
'
click
'
,
'
info
'
:
data
Drupal
.
behaviors
.
usageData
=
{
attach
:
function
(
context
,
settings
)
{
// Track click event.
once
(
'
usageData
'
,
'
[data-usage]
'
,
context
).
forEach
(
function
(
el
)
{
el
.
addEventListener
(
'
click
'
,
function
()
{
var
data
=
JSON
.
parse
(
$
(
this
).
attr
(
'
data-usage
'
));
if
(
!
data
)
{
return
;
}
// Add path info if not set.
if
(
!
data
[
'
path
'
])
{
var
href
=
$
(
this
).
attr
(
'
href
'
)
?
$
(
this
).
attr
(
'
href
'
)
:
location
.
href
;
data
[
'
path
'
]
=
href
.
replace
(
location
.
origin
,
''
);
}
$
.
ajax
({
type
:
'
POST
'
,
cache
:
false
,
url
:
drupalSettings
.
usage_data
.
url
,
data
:
{
'
type
'
:
'
click
'
,
'
info
'
:
data
}
});
});
});
},
};
// Track reload for Ajax enabled views.
$
(
document
).
ajaxComplete
(
function
(
event
,
xhr
,
settings
)
{
if
(
xhr
.
responseJSON
&&
xhr
.
responseJSON
.
length
>
1
)
{
xhr
.
responseJSON
.
forEach
(
function
(
v
)
{
if
(
v
.
settings
&&
v
.
settings
.
usage_data
.
data
)
{
$
.
ajax
({
type
:
'
POST
'
,
cache
:
false
,
url
:
v
.
settings
.
usage_data
.
url
,
data
:
v
.
settings
.
usage_data
.
data
});
}
});
}
);
}
});
})(
jQuery
,
Drupal
,
drupalSettings
);
})(
jQuery
,
Drupal
,
drupalSettings
,
once
);
Loading