Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Paste
P9413
Minimum banner history logger
Active
Public
Actions
Authored by
awight
on Oct 21 2019, 3:09 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Referenced Files
F30873022: raw.txt
Oct 21 2019, 3:09 PM
2019-10-21 15:09:33 (UTC+0)
Subscribers
None
Not empty banner.
<
button
class
=
"foobutt"
>
Foo
</
button
>
<
script
lang
=
"javascript"
>
/**
* Minimal banner code to report banner history information and associate with a click.
* Requires that the containing campaign have "Banner history logging" enabled.
*
* If sampling the banner history logs, use parameter `?bannerHistoryLogRate=1` for debugging.
*/
$
(
function
()
{
$
(
'.foobutt'
).
click
(
function
()
{
var
bannerHistoryLoggingId
,
mixins
=
mw
.
centralNotice
.
getDataProperty
(
'mixins'
),
trackers
=
[];
if
(
mixins
&&
mixins
.
bannerHistoryLogger
)
{
// Note that the logging ID is not uniquely-identifying for a given user, it is `mw.user.generateRandomSessionId()` and will change between requests.
bannerHistoryLoggingId
=
mw
.
centralNotice
.
bannerHistoryLogger
.
id
;
trackers
.
push
(
// FIXME: this is really annoying, it can be omitted if you're okay with dropping browsers without beaconSend.
mw
.
centralNotice
.
bannerHistoryLogger
.
ensureLogSent
()
);
}
Promise
.
all
(
trackers
).
then
(
function
()
{
mw
.
track
(
'event.WMDEBannerEvents'
,
{
bannerAction
:
'mobile-mini-banner-expanded'
,
// FIXME: logging ID would be passed in its own field, this was a workaround for EventLogging validation.
bannerName
:
'TestBanner, logging ID '
+
bannerHistoryLoggingId
,
eventRate
:
123
}
);
}
);
}
);
}
);
</
script
>
Event Timeline
awight
created this paste.
Oct 21 2019, 3:09 PM
2019-10-21 15:09:33 (UTC+0)
awight
mentioned this in
T235182: 20% things for 9.Oct sprint
.
Oct 21 2019, 3:13 PM
2019-10-21 15:13:51 (UTC+0)
Log In to Comment