-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* started on mv3 ad click * passes integration tests * use ddg2dnr * Update shared/js/background/classes/ad-click-attribution-policy.js Co-authored-by: Jonathan Kingston <jkingston@duckduckgo.com> * add unique rule id, oneadclick per tab * lint * check that tab exists * use ad attribution priority * lint * lint * remove debug lines * remove debug lines * check for adClickDNR for mv2 * Update shared/js/background/classes/ad-click-attribution-policy.js Co-authored-by: Dave Vandyke <kzar@kzar.co.uk> * rename module * unused function * Apply suggestions from code review Co-authored-by: Jonathan Kingston <jkingston@duckduckgo.com> Co-authored-by: Dave Vandyke <kzar@kzar.co.uk> * Apply suggestions from code review Co-authored-by: Jonathan Kingston <jkingston@duckduckgo.com> * simplify session ids, move dnr stuff around * fix removal * everything in adclick * get offset from storage * set session id on startup * Update shared/js/background/dnr-session-rule-id.js Co-authored-by: Jonathan Kingston <jkingston@duckduckgo.com> * Update shared/js/background/dnr-session-rule-id.js Co-authored-by: Dave Vandyke <kzar@kzar.co.uk> * Update shared/js/background/classes/ad-click-attribution-policy.js Co-authored-by: Jonathan Kingston <jkingston@duckduckgo.com> * add tests * fix test * changes from pr review * add ready flag to session id * make linter happy Co-authored-by: Jonathan Kingston <jkingston@duckduckgo.com> Co-authored-by: Dave Vandyke <kzar@kzar.co.uk>
- Loading branch information
1 parent
c98c80e
commit c7576f1
Showing
7 changed files
with
224 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* For managing dynamically created MV3 session rules | ||
* getNextSessionRuleId will return the next unique session rule id to use when creating new session rules | ||
**/ | ||
import * as browserWrapper from './wrapper.es6' | ||
const SESSION_RULE_ID_START = 100000 | ||
const SESSION_RULE_STORAGE_KEY = 'sessionRuleOffset' | ||
let sessionRuleOffset = 0 | ||
let ready = false | ||
|
||
export async function setSessionRuleOffsetFromStorage () { | ||
const offset = await browserWrapper.getFromSessionStorage(SESSION_RULE_STORAGE_KEY) | ||
if (offset) { | ||
sessionRuleOffset = offset | ||
} | ||
ready = true | ||
} | ||
|
||
/** | ||
* Get the next unique session rule id to use when craeting session DNR rules | ||
* @returns {number | null} nextRuleId | ||
*/ | ||
export function getNextSessionRuleId () { | ||
if (!ready) { | ||
console.warn('Tried to get session rule id before reading offset from storage') | ||
return null | ||
} | ||
|
||
const nextRuleId = SESSION_RULE_ID_START + sessionRuleOffset | ||
sessionRuleOffset += 1 | ||
browserWrapper.setToSessionStorage(SESSION_RULE_STORAGE_KEY, sessionRuleOffset) | ||
return nextRuleId | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.