@schibsted/niche-ads
Advanced tools
Comparing version 0.2.1 to 0.3.0
@@ -0,1 +1,13 @@ | ||
## [0.3.0](https://github.schibsted.io/przemyslaw-babiarz/niche-ads/compare/v0.2.1...v0.3.0) (2021-10-05) | ||
### Features | ||
- add useClearPlacements and add fireImpressionTrackers ([#9](https://github.schibsted.io/przemyslaw-babiarz/niche-ads/issues/9)) ([c925ffe](https://github.schibsted.io/przemyslaw-babiarz/niche-ads/commit/c925ffe06938bff6b94661fba482de794dc36a9d)) | ||
### Miscellaneous Chores | ||
- update dependency react to ^17.0.2 ([#3](https://github.schibsted.io/przemyslaw-babiarz/niche-ads/issues/3)) ([6bb383b](https://github.schibsted.io/przemyslaw-babiarz/niche-ads/commit/6bb383b6b1e5b338e017ec50f06ae3389c70bc26)) | ||
- update linters ([#5](https://github.schibsted.io/przemyslaw-babiarz/niche-ads/issues/5)) ([16f15d8](https://github.schibsted.io/przemyslaw-babiarz/niche-ads/commit/16f15d83e65bc8f71e429d104713f38464aa2556)), closes [#2](https://github.schibsted.io/przemyslaw-babiarz/niche-ads/issues/2) | ||
- update tool packages ([#6](https://github.schibsted.io/przemyslaw-babiarz/niche-ads/issues/6)) ([7592665](https://github.schibsted.io/przemyslaw-babiarz/niche-ads/commit/7592665128128ab9ae30fa9d44db4a24c393fe11)) | ||
### [0.2.1](https://github.schibsted.io/przemyslaw-babiarz/niche-ads/compare/v0.2.0...v0.2.1) (2021-08-27) | ||
@@ -2,0 +14,0 @@ |
@@ -37,2 +37,13 @@ "use strict"; | ||
function cleanUpPlacement(targetId) { | ||
(0, _appnexus.offEvent)(_appnexus.APPNEXUS_EVENT_TYPES.adLoaded, targetId); | ||
(0, _appnexus.offEvent)(_appnexus.APPNEXUS_EVENT_TYPES.adAvailable, targetId); | ||
(0, _appnexus.offEvent)(_appnexus.APPNEXUS_EVENT_TYPES.adBadRequest, targetId); | ||
(0, _appnexus.offEvent)(_appnexus.APPNEXUS_EVENT_TYPES.adError, targetId); | ||
(0, _appnexus.offEvent)(_appnexus.APPNEXUS_EVENT_TYPES.adCollapse, targetId); | ||
(0, _appnexus.offEvent)(_appnexus.APPNEXUS_EVENT_TYPES.adNoBid, targetId); | ||
(0, _appnexus.offEvent)(_appnexus.APPNEXUS_EVENT_TYPES.adRequestFailure, targetId); | ||
(0, _appnexus.offEvent)(_appnexus.APPNEXUS_EVENT_TYPES.adRequested, targetId); | ||
} | ||
function AdContextProvider({ | ||
@@ -175,10 +186,3 @@ adsConfig, | ||
placementsConfig.forEach(placementConfig => { | ||
(0, _appnexus.offEvent)(_appnexus.APPNEXUS_EVENT_TYPES.adLoaded, placementConfig.targetId); | ||
(0, _appnexus.offEvent)(_appnexus.APPNEXUS_EVENT_TYPES.adAvailable, placementConfig.targetId); | ||
(0, _appnexus.offEvent)(_appnexus.APPNEXUS_EVENT_TYPES.adBadRequest, placementConfig.targetId); | ||
(0, _appnexus.offEvent)(_appnexus.APPNEXUS_EVENT_TYPES.adError, placementConfig.targetId); | ||
(0, _appnexus.offEvent)(_appnexus.APPNEXUS_EVENT_TYPES.adCollapse, placementConfig.targetId); | ||
(0, _appnexus.offEvent)(_appnexus.APPNEXUS_EVENT_TYPES.adNoBid, placementConfig.targetId); | ||
(0, _appnexus.offEvent)(_appnexus.APPNEXUS_EVENT_TYPES.adRequestFailure, placementConfig.targetId); | ||
(0, _appnexus.offEvent)(_appnexus.APPNEXUS_EVENT_TYPES.adRequested, placementConfig.targetId); | ||
cleanUpPlacement(placementConfig.targetId); | ||
}); | ||
@@ -190,4 +194,12 @@ }; | ||
}, [placementsConfig, adsConfig === null || adsConfig === void 0 ? void 0 : (_adsConfig$placements = adsConfig.placements) === null || _adsConfig$placements === void 0 ? void 0 : _adsConfig$placements.common]); | ||
const clearPlacements = (0, _react.useCallback)(() => { | ||
placementsConfig.forEach(placementConfig => { | ||
cleanUpPlacement(placementConfig.targetId); | ||
}); | ||
setPlacements({}); | ||
setPlacementsConfig([]); | ||
}, []); | ||
const value = (0, _react.useMemo)(() => ({ | ||
loadAds, | ||
clearPlacements, | ||
placementsConfig, | ||
@@ -194,0 +206,0 @@ placements |
@@ -18,2 +18,8 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "fireImpressionTrackers", { | ||
enumerable: true, | ||
get: function () { | ||
return _appnexus.fireImpressionTrackers; | ||
} | ||
}); | ||
Object.defineProperty(exports, "usePlacement", { | ||
@@ -31,5 +37,13 @@ enumerable: true, | ||
}); | ||
Object.defineProperty(exports, "useClearPlacements", { | ||
enumerable: true, | ||
get: function () { | ||
return _useClearPlacements.default; | ||
} | ||
}); | ||
var _AdContext = _interopRequireWildcard(require("./AdContext")); | ||
var _appnexus = require("./utils/appnexus"); | ||
var _usePlacement = _interopRequireDefault(require("./usePlacement")); | ||
@@ -39,2 +53,4 @@ | ||
var _useClearPlacements = _interopRequireDefault(require("./useClearPlacements")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -41,0 +57,0 @@ |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.getAdId = exports.getUserId = exports.emitEvent = exports.onEvent = exports.offEvent = exports.setPageOpts = exports.showTag = exports.refresh = exports.loadTags = exports.clearRequest = exports.defineTag = exports.setUpAPNObject = exports.subscribeToASTLoad = exports.isASTLoaded = exports.APPNEXUS_EVENT_TYPES = void 0; | ||
exports.getAdId = exports.getUserId = exports.fireImpressionTrackers = exports.emitEvent = exports.onEvent = exports.offEvent = exports.setPageOpts = exports.showTag = exports.refresh = exports.loadTags = exports.clearRequest = exports.defineTag = exports.setUpAPNObject = exports.subscribeToASTLoad = exports.isASTLoaded = exports.APPNEXUS_EVENT_TYPES = void 0; | ||
const apntagLoadSubscribers = []; | ||
@@ -114,2 +114,8 @@ let apntag = { | ||
const fireImpressionTrackers = adPlacement => { | ||
addToQueue(() => apntag.fireImpressionTrackers(adPlacement)); | ||
}; | ||
exports.fireImpressionTrackers = fireImpressionTrackers; | ||
const getUserId = () => { | ||
@@ -116,0 +122,0 @@ const cookie = getCookie(); |
{ | ||
"name": "@schibsted/niche-ads", | ||
"version": "0.2.1", | ||
"version": "0.3.0", | ||
"description": "Package containing ads logic reappearing across our projects", | ||
@@ -37,24 +37,24 @@ "main": "dist/index.js", | ||
"@commitlint/config-conventional": "^13.1.0", | ||
"@release-it/conventional-changelog": "^3.0.1", | ||
"@release-it/conventional-changelog": "^3.3.0", | ||
"babel-eslint": "^10.1.0", | ||
"eslint": "^7.31.0", | ||
"eslint": "^7.32.0", | ||
"eslint-config-airbnb": "^18.2.1", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-babel": "^5.3.1", | ||
"eslint-plugin-import": "^2.23.4", | ||
"eslint-plugin-import": "^2.24.2", | ||
"eslint-plugin-jsx-a11y": "^6.4.1", | ||
"eslint-plugin-prettier": "^3.4.0", | ||
"eslint-plugin-react": "^7.24.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"eslint-plugin-react": "^7.25.1", | ||
"eslint-plugin-react-hooks": "^4.2.0", | ||
"husky": "^7.0.1", | ||
"lint-staged": "^11.1.1", | ||
"prettier": "^2.3.2", | ||
"husky": "^7.0.2", | ||
"lint-staged": "^11.1.2", | ||
"prettier": "^2.4.0", | ||
"prop-types": "^15.7.2", | ||
"release-it": "^14.10.1", | ||
"release-it": "^14.11.5", | ||
"rimraf": "^3.0.2" | ||
}, | ||
"peerDependencies": { | ||
"react": "^17.0.1" | ||
"react": "^17.0.2" | ||
}, | ||
"dependencies": {} | ||
} |
@@ -30,2 +30,13 @@ import { createContext, useCallback, useMemo, useState, useRef, useEffect } from 'react'; | ||
function cleanUpPlacement(targetId) { | ||
offEvent(APPNEXUS_EVENT_TYPES.adLoaded, targetId); | ||
offEvent(APPNEXUS_EVENT_TYPES.adAvailable, targetId); | ||
offEvent(APPNEXUS_EVENT_TYPES.adBadRequest, targetId); | ||
offEvent(APPNEXUS_EVENT_TYPES.adError, targetId); | ||
offEvent(APPNEXUS_EVENT_TYPES.adCollapse, targetId); | ||
offEvent(APPNEXUS_EVENT_TYPES.adNoBid, targetId); | ||
offEvent(APPNEXUS_EVENT_TYPES.adRequestFailure, targetId); | ||
offEvent(APPNEXUS_EVENT_TYPES.adRequested, targetId); | ||
} | ||
function AdContextProvider({ adsConfig, cdn, chatbot, children, cogwheelCdn, device, wallpaper }) { | ||
@@ -165,10 +176,3 @@ const [placementsConfig, setPlacementsConfig] = useState([]); | ||
placementsConfig.forEach((placementConfig) => { | ||
offEvent(APPNEXUS_EVENT_TYPES.adLoaded, placementConfig.targetId); | ||
offEvent(APPNEXUS_EVENT_TYPES.adAvailable, placementConfig.targetId); | ||
offEvent(APPNEXUS_EVENT_TYPES.adBadRequest, placementConfig.targetId); | ||
offEvent(APPNEXUS_EVENT_TYPES.adError, placementConfig.targetId); | ||
offEvent(APPNEXUS_EVENT_TYPES.adCollapse, placementConfig.targetId); | ||
offEvent(APPNEXUS_EVENT_TYPES.adNoBid, placementConfig.targetId); | ||
offEvent(APPNEXUS_EVENT_TYPES.adRequestFailure, placementConfig.targetId); | ||
offEvent(APPNEXUS_EVENT_TYPES.adRequested, placementConfig.targetId); | ||
cleanUpPlacement(placementConfig.targetId); | ||
}); | ||
@@ -181,5 +185,15 @@ }; | ||
const clearPlacements = useCallback(() => { | ||
placementsConfig.forEach((placementConfig) => { | ||
cleanUpPlacement(placementConfig.targetId); | ||
}); | ||
setPlacements({}); | ||
setPlacementsConfig([]); | ||
}, []); | ||
const value = useMemo( | ||
() => ({ | ||
loadAds, | ||
clearPlacements, | ||
placementsConfig, | ||
@@ -186,0 +200,0 @@ placements, |
import AdContext, { AdContextProvider } from './AdContext'; | ||
import { fireImpressionTrackers } from './utils/appnexus'; | ||
import usePlacement from './usePlacement'; | ||
import useLoadAds from './useLoadAds'; | ||
import useClearPlacements from './useClearPlacements'; | ||
export { AdContext, AdContextProvider, usePlacement, useLoadAds }; | ||
export { AdContext, AdContextProvider, usePlacement, useLoadAds, useClearPlacements, fireImpressionTrackers }; |
@@ -77,2 +77,5 @@ const apntagLoadSubscribers = []; | ||
export const emitEvent = (eventType, targetId) => addToQueue(() => apntag.emitEvent(targetId, eventType)); | ||
export const fireImpressionTrackers = (adPlacement) => { | ||
addToQueue(() => apntag.fireImpressionTrackers(adPlacement)); | ||
}; | ||
@@ -79,0 +82,0 @@ export const getUserId = () => { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65360
36
1144