-
Notifications
You must be signed in to change notification settings - Fork 974
Conversation
Codecov Report
@@ Coverage Diff @@
## master #13142 +/- ##
==========================================
+ Coverage 55.93% 56.07% +0.14%
==========================================
Files 281 282 +1
Lines 27856 28017 +161
Branches 4571 4602 +31
==========================================
+ Hits 15580 15711 +131
- Misses 12276 12306 +30
|
b8b0d8e
to
09f2bba
Compare
blocked on brave-intl/bat-publisher#12 |
05ac8c1
to
9b98357
Compare
a1bbea0
to
96073c3
Compare
96073c3
to
3fbf258
Compare
3fbf258
to
c54a1e3
Compare
app/common/lib/ledgerUtil.js
Outdated
// Twitch | ||
if ( | ||
( | ||
(firstPartyUrl && firstPartyUrl.startsWith('https://www.twitch.tv')) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
food for thought- with more integrations being added, it might make sense to move the URLs into ledgerMediaProviders.js
. That module could then export:
- type (ex: YOUTUBE, TWITCH)
- providerUrls (indexed by type)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this url's are used only here, so I wouldn't add it into the providers
app/common/lib/ledgerUtil.js
Outdated
{ | ||
if ( | ||
( | ||
data.event === 'minute-watched' || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these events would be great to put into a module (so it could work like an enum); ex: twitchEvents.MINUTE_WATCHED
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another way you could do this:
if (['minute-watched', 'video-play', 'player_click_playpause', 'vod_seek'].includes(data.event))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added new syntax
c54a1e3
to
c1186ae
Compare
app/common/lib/ledgerUtil.js
Outdated
const previousData = ledgerVideoCache.getDataByVideoId(state, mediaKey) | ||
|
||
if (previousData.isEmpty() && data.event === 'video-play') { | ||
return milliseconds.second * 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this (and the magic number 10
below) might be better expressed as a constant; like twitchMinimumSeconds
(or something like this). For readability and also so it's easy to change both (if needed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
app/common/lib/ledgerUtil.js
Outdated
return milliseconds.second * 10 | ||
} | ||
|
||
if (!data.properties) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be moved up to the initial check? ex:
if (data == null || mediaKey == null || !data.properties) {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can, done
app/common/lib/ledgerUtil.js
Outdated
} | ||
|
||
// we get seconds back, so we need to convert it into ms | ||
time = time * 1000 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for readability, you can use milliseconds.second
instead of 1000 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
app/common/lib/ledgerUtil.js
Outdated
}) | ||
} | ||
|
||
const getMediaFavicon = (providerName) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would this be better named as getDefaultMediaFavicon
, since it would only be used when one is not present (ex: when watching live stream on Twitch)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment left 😄 Overall- awesome job! Works extremely well
Initial findings:
seeking doesn't record time watched before heartbeatyou fixed this issue 😄- playing again (after pause) and then pausing AGAIN doesn't capture time. I captured Resume after pause on twitch media does not resume timer #13257 for this
NOT TWITCH SPECIFIC (existing bug)
When criteria is met, publisher button (to right of URL bar) doesn't become clickable to include. You mentioned this would be fixed though w/ next version
so do you still need the Twitch scraper in https://github.com/brave-intl/bat-publisher/blob/master/getMedia.js#L182 ? if not let's revert it. |
@diracdeltas we are not using scraper for Twitch. We skip it here https://github.com/brave-intl/bat-publisher/blob/master/getMedia.js#L151 |
app/common/lib/ledgerUtil.js
Outdated
// Twitch | ||
if ( | ||
( | ||
(firstPartyUrl && firstPartyUrl.startsWith('https://www.twitch.tv')) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this origin check can be spoofed, e.g. by a request to 'https://www.twitch.tv.evil.com'. you probably want to add a trailing slash or do a proper URL parse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
app/common/lib/ledgerUtil.js
Outdated
if ( | ||
( | ||
(firstPartyUrl && firstPartyUrl.startsWith('https://www.twitch.tv')) || | ||
(referrer && referrer.startsWith('https://player.twitch.tv')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
app/common/lib/ledgerUtil.js
Outdated
(firstPartyUrl && firstPartyUrl.startsWith('https://www.twitch.tv')) || | ||
(referrer && referrer.startsWith('https://player.twitch.tv')) | ||
) && | ||
url.startsWith('https://api.mixpanel.com') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
app/filtering.js
Outdated
// this can happen if the tab is closed and the webContents is no longer available | ||
if (!firstPartyUrl) { | ||
muonCb({ cancel: true }) | ||
return | ||
} | ||
|
||
if (module.exports.isResourceEnabled('ledger') && module.exports.isResourceEnabled('ledgerMedia')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curious why this was moved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also this should check !isPrivate
. i know it checks for a private tab state later in the ledger reducer, but can't hurt to do it here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added private check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this block was moved, because we need to get data from mixpanel which is blocked on our side and we need to get data first and then block it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/brave/browser-laptop/pull/13142/files#r170109044 and following comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested again after updates per code review. Works great! Made sure to try Twitch in a private tab and confirmed nothing is recorded. Nice job 😄
Resolves brave#13139 Auditors: Test Plan:
edc1e12
to
b0738dc
Compare
@@ -93,6 +93,7 @@ AppStore | |||
ledgerVideos: { | |||
[mediaKey]: { | |||
publisher: string // publisher key | |||
beatData: object // data that we get from a heartbeat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is this set?
master e1738ad @NejcZdovc can you help me cherry-pick into 0.22.x and 0.21.x? |
0.21 twitch d39cb3c |
Resolves #13139
Submitter Checklist:
git rebase -i
to squash commits (if needed).Test Plan:
Reviewer Checklist:
Tests