@schibsted/niche-ads
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -0,1 +1,10 @@ | ||
### [1.2.1](https://github.schibsted.io/przemyslaw-babiarz/niche-ads/compare/v1.2.0...v1.2.1) (2022-06-28) | ||
### Miscellaneous Chores | ||
- add error logs ([#59](https://github.schibsted.io/przemyslaw-babiarz/niche-ads/issues/59)) ([9f30be2](https://github.schibsted.io/przemyslaw-babiarz/niche-ads/commit/9f30be2e4806b1043a1df2a5bd978a782c0fdea0)) | ||
- update dependency lint-staged to ^13.0.1 ([#54](https://github.schibsted.io/przemyslaw-babiarz/niche-ads/issues/54)) ([fba15d5](https://github.schibsted.io/przemyslaw-babiarz/niche-ads/commit/fba15d5f0493b3b56d8e0d12b1dbbbd4644ff131)) | ||
- update dependency lint-staged to ^13.0.2 ([#57](https://github.schibsted.io/przemyslaw-babiarz/niche-ads/issues/57)) ([9344d6c](https://github.schibsted.io/przemyslaw-babiarz/niche-ads/commit/9344d6c8e8dbecc03c46a46604742c0d488f1576)) | ||
- update tool packages ([#58](https://github.schibsted.io/przemyslaw-babiarz/niche-ads/issues/58)) ([506d412](https://github.schibsted.io/przemyslaw-babiarz/niche-ads/commit/506d412965f6845f5b5c77a12af54ef983003fb7)) | ||
## [1.2.0](https://github.schibsted.io/przemyslaw-babiarz/niche-ads/compare/v1.1.2...v1.2.0) (2022-06-07) | ||
@@ -2,0 +11,0 @@ |
@@ -73,2 +73,7 @@ "use strict"; | ||
const scriptsLoadPromise = (0, _react.useRef)(); | ||
const logger = (0, _react.useCallback)(error => { | ||
if (adsConfig.loggingEnabled) { | ||
console.log(error); | ||
} | ||
}, [adsConfig.loggingEnabled]); | ||
(0, _react.useEffect)(() => { | ||
@@ -204,3 +209,7 @@ adScriptsReadyRef.current = adScriptsReady; | ||
}); | ||
(0, _appnexus.onEvent)(_appnexus.APPNEXUS_EVENT_TYPES.adBadRequest, placementConfig.targetId, () => { | ||
(0, _appnexus.onEvent)(_appnexus.APPNEXUS_EVENT_TYPES.adBadRequest, placementConfig.targetId, error => { | ||
logger({ | ||
error, | ||
placementConfig | ||
}); | ||
setPlacements(state => ({ ...state, | ||
@@ -210,3 +219,7 @@ [placementConfig.targetId]: null | ||
}); | ||
(0, _appnexus.onEvent)(_appnexus.APPNEXUS_EVENT_TYPES.adError, placementConfig.targetId, () => { | ||
(0, _appnexus.onEvent)(_appnexus.APPNEXUS_EVENT_TYPES.adError, placementConfig.targetId, error => { | ||
logger({ | ||
error, | ||
placementConfig | ||
}); | ||
setPlacements(state => ({ ...state, | ||
@@ -226,3 +239,7 @@ [placementConfig.targetId]: null | ||
}); | ||
(0, _appnexus.onEvent)(_appnexus.APPNEXUS_EVENT_TYPES.adRequestFailure, placementConfig.targetId, () => { | ||
(0, _appnexus.onEvent)(_appnexus.APPNEXUS_EVENT_TYPES.adRequestFailure, placementConfig.targetId, error => { | ||
logger({ | ||
error, | ||
placementConfig | ||
}); | ||
setPlacements(state => ({ ...state, | ||
@@ -260,4 +277,5 @@ [placementConfig.targetId]: null | ||
placementsConfig, | ||
placements | ||
}), [placementsConfig, loadAds, placements, clearPlacements]); | ||
placements, | ||
logger | ||
}), [placementsConfig, loadAds, placements, clearPlacements, logger]); | ||
return /*#__PURE__*/(0, _jsxRuntime.jsx)(AdContext.Provider, { | ||
@@ -291,2 +309,3 @@ value: value, | ||
}).isRequired, | ||
loggingEnabled: _propTypes.default.bool, | ||
keywords: _propTypes.default.shape({ | ||
@@ -293,0 +312,0 @@ common: _propTypes.default.shape({ |
@@ -18,3 +18,3 @@ "use strict"; | ||
} | ||
} catch (e) {// ignore caching error | ||
} catch (e) {// ignore | ||
} | ||
@@ -30,3 +30,3 @@ } | ||
} | ||
} catch (e) {// ignore error | ||
} catch (e) {// ignore | ||
} | ||
@@ -33,0 +33,0 @@ |
{ | ||
"name": "@schibsted/niche-ads", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"description": "Package containing ads logic reappearing across our projects", | ||
@@ -37,4 +37,4 @@ "main": "dist/index.js", | ||
"@babel/preset-react": "^7.17.12", | ||
"@commitlint/cli": "^17.0.2", | ||
"@commitlint/config-conventional": "^17.0.2", | ||
"@commitlint/cli": "^17.0.3", | ||
"@commitlint/config-conventional": "^17.0.3", | ||
"@release-it/conventional-changelog": "^5.0.0", | ||
@@ -51,6 +51,6 @@ "eslint": "^8.17.0", | ||
"husky": "^8.0.1", | ||
"lint-staged": "^13.0.0", | ||
"lint-staged": "^13.0.3", | ||
"prettier": "^2.6.2", | ||
"prop-types": "^15.8.1", | ||
"release-it": "^15.0.0", | ||
"release-it": "^15.1.0", | ||
"rimraf": "^3.0.2" | ||
@@ -57,0 +57,0 @@ }, |
@@ -44,2 +44,4 @@ # Niche ads | ||
If the project you use this package in, does not have webpack, you can try https://benjaminwfox.com/blog/tech/why-isnt-npm-link-working#if-you-use-react. | ||
And now you are all good. Your project will now use the local version of niche-ads instead of the one in node_modules. | ||
@@ -94,2 +96,3 @@ | ||
- **device** - required - string - one of `desktop`, `tablet`, `mobile` | ||
- **loggingEnabled** - optional - boolean - determines if logging is enabled | ||
- **adsConfig** - required - object - ads configuration object | ||
@@ -120,2 +123,3 @@ - **options** - required - object | ||
}, | ||
loggingEnabled: false, | ||
placements: { | ||
@@ -122,0 +126,0 @@ common: { |
@@ -1,2 +0,2 @@ | ||
import { createContext, useMemo, useState, useRef, useEffect } from 'react'; | ||
import { createContext, useMemo, useState, useRef, useEffect, useCallback } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
@@ -56,2 +56,11 @@ import splitEvery from './utils/splitEvery'; | ||
const logger = useCallback( | ||
(error) => { | ||
if (adsConfig.loggingEnabled) { | ||
console.log(error); | ||
} | ||
}, | ||
[adsConfig.loggingEnabled] | ||
); | ||
useEffect(() => { | ||
@@ -183,6 +192,8 @@ adScriptsReadyRef.current = adScriptsReady; | ||
}); | ||
onEvent(APPNEXUS_EVENT_TYPES.adBadRequest, placementConfig.targetId, () => { | ||
onEvent(APPNEXUS_EVENT_TYPES.adBadRequest, placementConfig.targetId, (error) => { | ||
logger({ error, placementConfig }); | ||
setPlacements((state) => ({ ...state, [placementConfig.targetId]: null })); | ||
}); | ||
onEvent(APPNEXUS_EVENT_TYPES.adError, placementConfig.targetId, () => { | ||
onEvent(APPNEXUS_EVENT_TYPES.adError, placementConfig.targetId, (error) => { | ||
logger({ error, placementConfig }); | ||
setPlacements((state) => ({ ...state, [placementConfig.targetId]: null })); | ||
@@ -196,3 +207,4 @@ }); | ||
}); | ||
onEvent(APPNEXUS_EVENT_TYPES.adRequestFailure, placementConfig.targetId, () => { | ||
onEvent(APPNEXUS_EVENT_TYPES.adRequestFailure, placementConfig.targetId, (error) => { | ||
logger({ error, placementConfig }); | ||
setPlacements((state) => ({ ...state, [placementConfig.targetId]: null })); | ||
@@ -232,4 +244,5 @@ }); | ||
placements, | ||
logger, | ||
}), | ||
[placementsConfig, loadAds, placements, clearPlacements] | ||
[placementsConfig, loadAds, placements, clearPlacements, logger] | ||
); | ||
@@ -262,2 +275,3 @@ | ||
}).isRequired, | ||
loggingEnabled: PropTypes.bool, | ||
keywords: PropTypes.shape({ | ||
@@ -264,0 +278,0 @@ common: PropTypes.shape({ |
@@ -11,3 +11,3 @@ export function saveToLocalStorageWithExpiration(key, value) { | ||
} catch (e) { | ||
// ignore caching error | ||
// ignore | ||
} | ||
@@ -24,3 +24,3 @@ } | ||
} catch (e) { | ||
// ignore error | ||
// ignore | ||
} | ||
@@ -27,0 +27,0 @@ |
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
88730
1398
222