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
9855f4fd
Commit
9855f4fd
authored
Jun 24, 2021
by
jejacks0n
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix load timing with snowplow form tracking
parent
2fca139b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
6 deletions
+25
-6
app/assets/javascripts/tracking/index.js
app/assets/javascripts/tracking/index.js
+15
-6
spec/frontend/tracking_spec.js
spec/frontend/tracking_spec.js
+10
-0
No files found.
app/assets/javascripts/tracking/index.js
View file @
9855f4fd
...
@@ -34,6 +34,12 @@ const addExperimentContext = (opts) => {
...
@@ -34,6 +34,12 @@ const addExperimentContext = (opts) => {
return
options
;
return
options
;
};
};
const
renameKey
=
(
o
,
oldKey
,
newKey
)
=>
{
const
ret
=
{};
delete
Object
.
assign
(
ret
,
o
,
{
[
newKey
]:
o
[
oldKey
]
})[
oldKey
];
return
ret
;
};
const
createEventPayload
=
(
el
,
{
suffix
=
''
}
=
{})
=>
{
const
createEventPayload
=
(
el
,
{
suffix
=
''
}
=
{})
=>
{
const
{
const
{
trackAction
,
trackAction
,
...
@@ -186,15 +192,18 @@ export default class Tracking {
...
@@ -186,15 +192,18 @@ export default class Tracking {
(
context
)
=>
context
.
schema
!==
standardContext
.
schema
,
(
context
)
=>
context
.
schema
!==
standardContext
.
schema
,
);
);
const
mappedConfig
=
{
const
mappedConfig
=
{};
forms
:
{
whitelist
:
config
.
forms
?.
allow
||
[]
},
if
(
config
.
forms
)
mappedConfig
.
forms
=
renameKey
(
config
.
forms
,
'
allow
'
,
'
whitelist
'
);
fields
:
{
whitelist
:
config
.
fields
?.
allow
||
[]
},
if
(
config
.
fields
)
mappedConfig
.
fields
=
renameKey
(
config
.
fields
,
'
allow
'
,
'
whitelist
'
);
};
const
enabler
=
()
=>
window
.
snowplow
(
'
enableFormTracking
'
,
mappedConfig
,
userProvidedContexts
);
const
enabler
=
()
=>
window
.
snowplow
(
'
enableFormTracking
'
,
mappedConfig
,
userProvidedContexts
);
if
(
document
.
readyState
!==
'
loading
'
)
enabler
();
if
(
document
.
readyState
===
'
complete
'
)
enabler
();
else
document
.
addEventListener
(
'
DOMContentLoaded
'
,
enabler
);
else
{
document
.
addEventListener
(
'
readystatechange
'
,
()
=>
{
if
(
document
.
readyState
===
'
complete
'
)
enabler
();
});
}
}
}
static
mixin
(
opts
=
{})
{
static
mixin
(
opts
=
{})
{
...
...
spec/frontend/tracking_spec.js
View file @
9855f4fd
...
@@ -197,6 +197,16 @@ describe('Tracking', () => {
...
@@ -197,6 +197,16 @@ describe('Tracking', () => {
expectedError
,
expectedError
,
);
);
});
});
it
(
'
does not add empty form whitelist rules
'
,
()
=>
{
Tracking
.
enableFormTracking
({
fields
:
{
allow
:
[
'
input-class1
'
]
}
});
expect
(
snowplowSpy
).
toHaveBeenCalledWith
(
'
enableFormTracking
'
,
{
fields
:
{
whitelist
:
[
'
input-class1
'
]
}
},
[],
);
});
});
});
describe
(
'
.flushPendingEvents
'
,
()
=>
{
describe
(
'
.flushPendingEvents
'
,
()
=>
{
...
...
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