Skip to content
This repository has been archived by the owner. It is now read-only.

Fixes publisher not added to the ledger #11592

Merged
merged 2 commits into from Oct 23, 2017

Conversation

@NejcZdovc
Copy link
Member

NejcZdovc commented Oct 18, 2017

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).
  • Tagged reviewers and labelled the pull request as needed.

Resolves #11553 - Publishers auto-included even with auto-include switch disabled
Resolves #11575 - Page data refactor
Resolves #11273 - Ledger table doesn't auto populate the publishers
Resolves #11274 - Site not added to publisher list even after spending ~10 mins on the site

Auditors:

Test Plan:

for every test plan you need to clean your profile and enable payments

Plan A

  • open preferences, go to payments
  • open a new tab
  • load a site
  • stay on that site for 15s
  • switch to preference tab and site should be added

Plan B

  • open preferences, go to payments
  • open a new tab
  • load a site
  • stay on that site for 15s
  • open a a new tab
  • switch to preference tab and site should be added

Plan C
- do plan B
- switch to the site tab and stay on it for 15s
- open new tab and visit different site for 15s
- switch to preference tab and new site should be added and old site should have 2 visits
Plan C is not valid, please check plan E

Plan D

  • open preferences, go to payments
  • change min visit time to 1min
  • open new tab
  • load a site stay on that site for 15s
  • open another app (so that focus will be out)
  • click back on opened site in brave and wait for 1m
  • switch to preference tab and site should be added

Plan E

  • do plan B
  • go back to site tab and stay on that site for 15s
  • switch to preference tab and site should have 1 visit, but 20+ seconds visit time

Plan F

  • Open preferences, go to payments
  • Disable auto-include settings
  • Visit some random sites so that the sites are added to the ledger table
  • Ensure no site is auto included that gets added to the table

Plan G

  • open preferences, go to payments
  • open a new tab
  • load a site stay on that site for 15s
  • open a private tab
  • load a new site stay on that site for 15s
  • switch to preference tab and table should only contain site visited in normal tab and not from private tab

Plan H

  • do plan A
  • disable payments
  • visit few more sites in new tabs
  • switch to preference tab and ledger table should only have site from plan A

Reviewer Checklist:

Tests

  • Adequate test coverage exists to prevent regressions
  • Tests should be independent and work correctly when run individually or as a suite ref
  • New files have MPL2 license header
@codecov-io
Copy link

codecov-io commented Oct 18, 2017

Codecov Report

Merging #11592 into master will decrease coverage by 0.28%.
The diff coverage is 22.78%.

@@            Coverage Diff             @@
##           master   #11592      +/-   ##
==========================================
- Coverage   52.54%   52.26%   -0.29%     
==========================================
  Files         268      268              
  Lines       25296    25311      +15     
  Branches     4032     4034       +2     
==========================================
- Hits        13293    13228      -65     
- Misses      12003    12083      +80
Flag Coverage Δ
#unittest 52.26% <22.78%> (-0.29%) ⬇️
Impacted Files Coverage Δ
app/sessionStore.js 76.12% <ø> (ø) ⬆️
app/browser/reducers/pageDataReducer.js 100% <ø> (ø) ⬆️
app/common/state/pageDataState.js 79.54% <100%> (-8.6%) ⬇️
app/common/lib/ledgerUtil.js 84.87% <100%> (-0.74%) ⬇️
app/browser/api/ledger.js 31% <15.9%> (-0.3%) ⬇️
app/browser/reducers/ledgerReducer.js 43.76% <18.64%> (-4.8%) ⬇️
@NejcZdovc NejcZdovc force-pushed the NejcZdovc:refactor/#11575-pageData branch 5 times, most recently from 9c20c0b to cc9b183 Oct 18, 2017
@NejcZdovc
Copy link
Member Author

NejcZdovc commented Oct 20, 2017

I am done with an initial work. I am waiting for some feedback regarding what is visit, then I will do final clenup

@NejcZdovc NejcZdovc force-pushed the NejcZdovc:refactor/#11575-pageData branch 3 times, most recently from 30e33b5 to f7b1813 Oct 20, 2017
@NejcZdovc NejcZdovc requested review from bbondy and bsclifton Oct 23, 2017
@NejcZdovc
Copy link
Member Author

NejcZdovc commented Oct 23, 2017

PR is ready for the review

Resolves #11575

Auditors:

Test Plan:
@NejcZdovc NejcZdovc force-pushed the NejcZdovc:refactor/#11575-pageData branch from f7b1813 to 4d5c436 Oct 23, 2017
@@ -3,6 +3,8 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */

const Immutable = require('immutable')
const electron = require('electron')

This comment has been minimized.

Copy link
@bbondy

bbondy Oct 23, 2017

Member

this is fine but I think preferred style is const {BrowserWindow} = require('electron')

This comment has been minimized.

Copy link
@bbondy

bbondy Oct 23, 2017

Member

I see it was moved code, so feel free to leave as is.

This comment has been minimized.

Copy link
@NejcZdovc

NejcZdovc Oct 23, 2017

Author Member

done

if (!lastActiveTabId || tabId === lastActiveTabId) {
state = ledgerApi.pageDataChanged(state, {
location: pageUrl,
tabId: tabId

This comment has been minimized.

Copy link
@bbondy

bbondy Oct 23, 2017

Member

nit on style:
just tabId instead of tabId: tabId

This comment has been minimized.

Copy link
@NejcZdovc

NejcZdovc Oct 23, 2017

Author Member

done

@@ -1,5 +1,6 @@
chrome.idle.setDetectionInterval(15 * 60)
chrome.idle.onStateChanged.addListener((idleState) => {
// uses appConstants.APP_IDLE_STATE_CHANGED action constant

This comment has been minimized.

Copy link
@bbondy

bbondy Oct 23, 2017

Member

nit: start comment with capital and end in period.

This comment has been minimized.

Copy link
@NejcZdovc

NejcZdovc Oct 23, 2017

Author Member

done

afterEach(function () {
pageDataChangedSpy.restore()
})
it('doesnt calls ledgerApi.pageDataChanged when no idle state is provided', function () {

This comment has been minimized.

Copy link
@bbondy

bbondy Oct 23, 2017

Member

nit: does not

This comment has been minimized.

Copy link
@NejcZdovc

NejcZdovc Oct 23, 2017

Author Member

done

assert(pageDataChangedSpy.withArgs(appState).calledOnce)
})
it('calls ledgerApi.addVisit', function () {
assert(addVisitSpy.calledOnce)
it('doesnt calls ledgerApi.pageDataChanged when in idleState', function () {

This comment has been minimized.

Copy link
@bbondy

bbondy Oct 23, 2017

Member

nit does not or doesn't

This comment has been minimized.

Copy link
@NejcZdovc

NejcZdovc Oct 23, 2017

Author Member

done

* @return {boolean} true if page should have usage collected, false if not
*/
const shouldTrackView = (view, responseList) => {
if (view == null) {
const shouldTrackView = (tab) => {

This comment has been minimized.

Copy link
@bbondy

bbondy Oct 23, 2017

Member

nit: please rename this to tabValue because we usually use tab as the webContents in code.

This comment has been minimized.

Copy link
@NejcZdovc

NejcZdovc Oct 23, 2017

Author Member

done

if (location === currentUrl) {
return state
}

state = setLocation(state, timestamp, tabId)
/*
Save previous recorder page

This comment has been minimized.

Copy link
@bbondy

bbondy Oct 23, 2017

Member

nit: * to align with other stars

This comment has been minimized.

Copy link
@NejcZdovc

NejcZdovc Oct 23, 2017

Author Member

done

const aboutUrl = getSourceAboutUrl(lastUrl) || lastUrl
if (aboutUrl && aboutUrl.match(/^about/)) {
state = pageDataState.resetInfo(state)
// add visit to the ledger when we are not in a private tab

This comment has been minimized.

Copy link
@bbondy

bbondy Oct 23, 2017

Member

nit comment style

This comment has been minimized.

Copy link
@NejcZdovc

NejcZdovc Oct 23, 2017

Author Member

done


currentUrl = (location && location.match(/^about/)) ? locationDefault : location
currentTimestamp = timestamp
// update to the latest view

This comment has been minimized.

Copy link
@bbondy

bbondy Oct 23, 2017

Member

nit comment style

This comment has been minimized.

Copy link
@NejcZdovc

NejcZdovc Oct 23, 2017

Author Member

done

@bbondy
bbondy approved these changes Oct 23, 2017
@NejcZdovc NejcZdovc force-pushed the NejcZdovc:refactor/#11575-pageData branch from 4d5c436 to eac5a03 Oct 23, 2017
@NejcZdovc NejcZdovc merged commit 3cf6a50 into brave:master Oct 23, 2017
0 of 3 checks passed
0 of 3 checks passed
codecov/patch 22.78% of diff hit (target 52.54%)
Details
codecov/project 52.26% (-0.29%) compared to 27f4a4e
Details
continuous-integration/travis-ci/pr The Travis CI build failed
Details
NejcZdovc added a commit that referenced this pull request Oct 23, 2017
Fixes publisher not added to the ledger
NejcZdovc added a commit that referenced this pull request Oct 23, 2017
Fixes publisher not added to the ledger
NejcZdovc added a commit that referenced this pull request Oct 23, 2017
Fixes publisher not added to the ledger
@NejcZdovc
Copy link
Member Author

NejcZdovc commented Oct 23, 2017

master 3cf6a50
0.21 2fa2f88
0.20 820ed5b
0.19 61c92a8

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.