Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F4117611
subscriber.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
subscriber.js
View Options
/*!
* @author Ori Livneh <ori@wikimedia.org>
*/
'use strict'
;
// Expose publicly
mw
.
eventLog
=
require
(
'./core.js'
);
mw
.
eventLog
.
Schema
=
require
(
'./Schema.js'
);
/**
* Convert the first letter of a string to uppercase.
*
* @ignore
* @private
* @param {string} word
* @return {string}
*/
function
titleCase
(
word
)
{
return
word
[
0
].
toUpperCase
()
+
word
.
slice
(
1
);
}
/**
* mw.track handler for EventLogging events.
*
* @ignore
* @private
* @param {string} topic Topic name ('event.*').
* @param {Object} event
*/
function
handleTrackedEvent
(
topic
,
event
)
{
const
schema
=
titleCase
(
topic
.
slice
(
topic
.
indexOf
(
'.'
)
+
1
)
);
mw
.
eventLog
.
logEvent
(
schema
,
event
);
}
/**
* Subscribe to any 'event'-namespaced topics from mw.track, for example:
*
* `mw.track( 'event.YourSchema', eventData )`
*
* Because subscribers to mw#track receive the full backlog of events
* matching the subscription, event processing can be safely deferred
* until the window's load event has fired. This keeps the impact of
* analytic instrumentation on page load times to a minimum.
*
* @private
* @ignore
*/
function
init
()
{
mw
.
trackSubscribe
(
'event.'
,
handleTrackedEvent
);
}
// It's possible for this code to run after the "load" event has already fired.
if
(
document
.
readyState
===
'complete'
)
{
mw
.
requestIdleCallback
(
init
);
}
else
{
// Avoid the logging of duplicate events (T170018).
//
// The load event must only fire once. However, Firefox 51 introduced a
// bug that causes the event to fire again when returning from the
// "Back-Forward cache" (BFCache) under certain circumstances (see
// https://bugzilla.mozilla.org/show_bug.cgi?id=1379762).
$
(
window
).
one
(
'load'
,
init
);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Aug 19, 02:16 (2 w, 2 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
9d/d8/03baebb0a25274cb352fac11451d
Default Alt Text
subscriber.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment