Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
d74153ce
Commit
d74153ce
authored
Mar 10, 2022
by
Niko Belokolodov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not anonymize #note and #diff anchors in URLs
parent
8e319ab2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
1 deletion
+22
-1
app/assets/javascripts/tracking/tracking.js
app/assets/javascripts/tracking/tracking.js
+5
-1
spec/frontend/tracking/tracking_spec.js
spec/frontend/tracking/tracking_spec.js
+17
-0
No files found.
app/assets/javascripts/tracking/tracking.js
View file @
d74153ce
...
@@ -10,6 +10,8 @@ import {
...
@@ -10,6 +10,8 @@ import {
addReferrersCacheEntry
,
addReferrersCacheEntry
,
}
from
'
./utils
'
;
}
from
'
./utils
'
;
const
ALLOWED_URL_HASHES
=
[
'
#diff
'
,
'
#note
'
];
export
default
class
Tracking
{
export
default
class
Tracking
{
static
queuedEvents
=
[];
static
queuedEvents
=
[];
static
initialized
=
false
;
static
initialized
=
false
;
...
@@ -183,7 +185,9 @@ export default class Tracking {
...
@@ -183,7 +185,9 @@ export default class Tracking {
originalUrl
:
window
.
location
.
href
,
originalUrl
:
window
.
location
.
href
,
});
});
window
.
snowplow
(
'
setCustomUrl
'
,
pageLinks
.
url
);
const
appendHash
=
ALLOWED_URL_HASHES
.
some
((
prefix
)
=>
window
.
location
.
hash
.
startsWith
(
prefix
));
const
customUrl
=
`
${
pageUrl
}${
appendHash
?
window
.
location
.
hash
:
''
}
`
;
window
.
snowplow
(
'
setCustomUrl
'
,
customUrl
);
if
(
document
.
referrer
)
{
if
(
document
.
referrer
)
{
const
node
=
referrers
.
find
((
links
)
=>
links
.
originalUrl
===
document
.
referrer
);
const
node
=
referrers
.
find
((
links
)
=>
links
.
originalUrl
===
document
.
referrer
);
...
...
spec/frontend/tracking/tracking_spec.js
View file @
d74153ce
...
@@ -255,6 +255,23 @@ describe('Tracking', () => {
...
@@ -255,6 +255,23 @@ describe('Tracking', () => {
expect
(
snowplowSpy
).
toHaveBeenCalledWith
(
'
setCustomUrl
'
,
TEST_HOST
);
expect
(
snowplowSpy
).
toHaveBeenCalledWith
(
'
setCustomUrl
'
,
TEST_HOST
);
});
});
describe
(
'
allowed hashes/fragments
'
,
()
=>
{
it
.
each
`
hash | appends | description
${
'
note_abc_123
'
}
|
${
true
}
|
${
'
appends
'
}
${
'
diff-content-819
'
}
|
${
true
}
|
${
'
appends
'
}
${
'
first_heading
'
}
|
${
false
}
|
${
'
does not append
'
}
`
(
'
$description `$hash` hash
'
,
({
hash
,
appends
})
=>
{
window
.
gl
.
snowplowPseudonymizedPageUrl
=
TEST_HOST
;
window
.
location
.
hash
=
hash
;
Tracking
.
setAnonymousUrls
();
const
url
=
appends
?
`
${
TEST_HOST
}
#
${
hash
}
`
:
TEST_HOST
;
expect
(
snowplowSpy
).
toHaveBeenCalledWith
(
'
setCustomUrl
'
,
url
);
});
});
it
(
'
does not set the referrer URL by default
'
,
()
=>
{
it
(
'
does not set the referrer URL by default
'
,
()
=>
{
window
.
gl
.
snowplowPseudonymizedPageUrl
=
TEST_HOST
;
window
.
gl
.
snowplowPseudonymizedPageUrl
=
TEST_HOST
;
...
...
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