@folklore/ads 0.0.77 → 0.0.79

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/cjs.js +65 -38
  2. package/dist/es.js +65 -38
  3. package/package.json +2 -2
package/dist/cjs.js CHANGED
@@ -276,7 +276,7 @@ class AdSlot extends EventEmitter__default["default"] {
276
276
  }
277
277
 
278
278
  /* globals refreshDisabledLineItems: [] */
279
- const debug = createDebug__default["default"]('folklore:ads');
279
+ const debug$1 = createDebug__default["default"]('folklore:ads');
280
280
  class AdsManager extends EventEmitter__default["default"] {
281
281
  // static index = 0;
282
282
 
@@ -384,7 +384,7 @@ class AdsManager extends EventEmitter__default["default"] {
384
384
  if (this.disabled) {
385
385
  return;
386
386
  }
387
- debug('Initializing GPT...');
387
+ debug$1('Initializing GPT...');
388
388
  const {
389
389
  disabled,
390
390
  personnalizedAdsDisabled
@@ -398,19 +398,19 @@ class AdsManager extends EventEmitter__default["default"] {
398
398
  fetchMarginPercent = 300
399
399
  } = this.options;
400
400
  if (disabled) {
401
- debug('Disable initial load');
401
+ debug$1('Disable initial load');
402
402
  googletag.pubads().disableInitialLoad();
403
403
  }
404
404
  if (!disableSingleRequest) {
405
- debug('Enable single request');
405
+ debug$1('Enable single request');
406
406
  googletag.pubads().enableSingleRequest();
407
407
  }
408
408
  if (personnalizedAdsDisabled) {
409
- debug('Disable personalized ads');
409
+ debug$1('Disable personalized ads');
410
410
  googletag.pubads().setRequestNonPersonalizedAds(1);
411
411
  }
412
412
  if (!disableLazyLoad) {
413
- debug('Enable lazy loading %o', {
413
+ debug$1('Enable lazy loading %o', {
414
414
  fetchMarginPercent,
415
415
  renderMarginPercent,
416
416
  mobileScaling
@@ -422,13 +422,13 @@ class AdsManager extends EventEmitter__default["default"] {
422
422
  });
423
423
  }
424
424
  if (!disableVideoAds) {
425
- debug('Enable video ads');
425
+ debug$1('Enable video ads');
426
426
  googletag.pubads().enableVideoAds();
427
427
  }
428
428
  googletag.pubads().addEventListener('slotRenderEnded', this.onSlotRenderEnded);
429
429
  googletag.pubads().addEventListener('impressionViewable', this.onSlotImpressionViewable);
430
430
  googletag.enableServices();
431
- debug('GPT is ready');
431
+ debug$1('GPT is ready');
432
432
  this.enabled = true;
433
433
  this.ready = true;
434
434
  this.emit('ready');
@@ -448,9 +448,9 @@ class AdsManager extends EventEmitter__default["default"] {
448
448
  renderSlot.setRefreshDisabled();
449
449
  }
450
450
  if (event.isEmpty) {
451
- debug('Render ended for slot #%s(%s). Slot is empty.', eventSlot.getSlotElementId(), eventSlot.getAdUnitPath());
451
+ debug$1('Render ended for slot #%s(%s). Slot is empty.', eventSlot.getSlotElementId(), eventSlot.getAdUnitPath());
452
452
  } else {
453
- debug('Render ended for slot #%s(%s) with size %s.', eventSlot.getSlotElementId(), eventSlot.getAdUnitPath(), size !== null ? size.join('x') : '-');
453
+ debug$1('Render ended for slot #%s(%s) with size %s.', eventSlot.getSlotElementId(), eventSlot.getAdUnitPath(), size !== null ? size.join('x') : '-');
454
454
  }
455
455
  }
456
456
  onSlotImpressionViewable(event) {
@@ -461,12 +461,12 @@ class AdsManager extends EventEmitter__default["default"] {
461
461
  if (impressionSlot !== null) {
462
462
  impressionSlot.setViewable(true);
463
463
  }
464
- debug('Impression viewable for slot #%s(%s).', eventSlot.getSlotElementId(), eventSlot.getAdUnitPath());
464
+ debug$1('Impression viewable for slot #%s(%s).', eventSlot.getSlotElementId(), eventSlot.getAdUnitPath());
465
465
  }
466
466
 
467
467
  // eslint-disable-next-line class-methods-use-this
468
468
  onSlotVisibleChange(visible, slot) {
469
- debug('Slot #%s(%s) visibility change to %s', slot.getElementId(), slot.getAdPath(), visible ? 'visible' : 'not visible');
469
+ debug$1('Slot #%s(%s) visibility change to %s', slot.getElementId(), slot.getAdPath(), visible ? 'visible' : 'not visible');
470
470
  }
471
471
  isReady() {
472
472
  return this.ready && this.enabled && !this.disabled;
@@ -504,7 +504,7 @@ class AdsManager extends EventEmitter__default["default"] {
504
504
  id: providedId = null
505
505
  } = opts;
506
506
  const id = providedId || this.createAdId();
507
- debug('Creating slot #%s(%s)...', id, path);
507
+ debug$1('Creating slot #%s(%s)...', id, path);
508
508
  const slot = new AdSlot(id, path, size, {
509
509
  ...opts
510
510
  });
@@ -523,7 +523,7 @@ class AdsManager extends EventEmitter__default["default"] {
523
523
  const id = slot.getElementId();
524
524
  const path = slot.getAdPath();
525
525
  const size = slot.getAdSize();
526
- debug('Defining slot #%s(%s)...', id, path);
526
+ debug$1('Defining slot #%s(%s)...', id, path);
527
527
  const adSlot = googletag.defineSlot(path, size, id).addService(googletag.pubads());
528
528
  slot.setAdSlot(adSlot);
529
529
  });
@@ -532,7 +532,7 @@ class AdsManager extends EventEmitter__default["default"] {
532
532
  const slotsToDisplay = this.slots.filter(slot => slot.canBeDisplayed());
533
533
  const slotsCount = slotsToDisplay.length;
534
534
  if (slotsCount > 0) {
535
- debug('Displaying %i slot(s)...', slotsCount);
535
+ debug$1('Displaying %i slot(s)...', slotsCount);
536
536
  slotsToDisplay.forEach(slot => this.callDisplaySlot(slot));
537
537
  }
538
538
  return true;
@@ -552,7 +552,7 @@ class AdsManager extends EventEmitter__default["default"] {
552
552
  googletag.cmd.push(() => {
553
553
  const id = slot.getElementId();
554
554
  const path = slot.getAdPath();
555
- debug('Displaying slot #%s(%s)...', id, path);
555
+ debug$1('Displaying slot #%s(%s)...', id, path);
556
556
  googletag.display(slot.getAdSlot());
557
557
  if (googletag.pubads().isInitialLoadDisabled()) {
558
558
  googletag.pubads().refresh([slot.getAdSlot()]);
@@ -574,7 +574,7 @@ class AdsManager extends EventEmitter__default["default"] {
574
574
  slot.destroy();
575
575
  this.slots = this.slots.filter(it => it !== slot);
576
576
  if (adSlot !== null) {
577
- debug('Destroying slot #%s(%s)...', adSlot.getAdUnitPath(), adSlot.getSlotElementId());
577
+ debug$1('Destroying slot #%s(%s)...', adSlot.getAdUnitPath(), adSlot.getSlotElementId());
578
578
  googletag.cmd.push(() => {
579
579
  googletag.destroySlots([adSlot]);
580
580
  });
@@ -591,7 +591,7 @@ class AdsManager extends EventEmitter__default["default"] {
591
591
  }
592
592
  const adSlot = slot.getAdSlot();
593
593
  if (adSlot !== null) {
594
- debug('Refreshing slot #%s(%s)...', adSlot.getAdUnitPath(), slot.getElementId());
594
+ debug$1('Refreshing slot #%s(%s)...', adSlot.getAdUnitPath(), slot.getElementId());
595
595
  googletag.cmd.push(() => {
596
596
  googletag.pubads().refresh([adSlot], {
597
597
  changeCorrelator: false
@@ -607,7 +607,7 @@ class AdsManager extends EventEmitter__default["default"] {
607
607
  if (slots.length === 0) {
608
608
  return;
609
609
  }
610
- debug('Refreshing slots %o...', slots.map(slot => `#${slot.getElementId()}(${slot.getAdUnitPath()})`));
610
+ debug$1('Refreshing slots %o...', slots.map(slot => `#${slot.getElementId()}(${slot.getAdUnitPath()})`));
611
611
  googletag.cmd.push(() => {
612
612
  googletag.pubads().refresh(slots);
613
613
  });
@@ -616,7 +616,7 @@ class AdsManager extends EventEmitter__default["default"] {
616
616
  const {
617
617
  googletag
618
618
  } = this;
619
- debug('Refreshing all slots...');
619
+ debug$1('Refreshing all slots...');
620
620
  googletag.cmd.push(() => {
621
621
  googletag.pubads().refresh();
622
622
  });
@@ -1065,27 +1065,49 @@ function useAd(path, size) {
1065
1065
  };
1066
1066
  }
1067
1067
 
1068
- function useRichAd(containerRef, id) {
1068
+ const debug = createDebug__default["default"]('folklore:ads');
1069
+ function parseRichAd(data) {
1070
+ let richAd = null;
1071
+ try {
1072
+ const eventData = JSON.parse(data) || null;
1073
+ richAd = eventData !== null ? eventData.richAd || null : null;
1074
+ } catch (e) {}
1075
+ return richAd;
1076
+ }
1077
+ function useRichAd(containerRef, id, opts) {
1069
1078
  const [richAd, setRichAd] = React.useState(null);
1079
+ const {
1080
+ onRichAd = null
1081
+ } = opts || {};
1070
1082
  React.useEffect(() => {
1083
+ if (id === null) {
1084
+ return () => {};
1085
+ }
1071
1086
  setRichAd(null);
1072
- window.addEventListener('message', event => {
1073
- if (event.origin.match(/safeframe\.googlesyndication\.com/) !== null) {
1074
- let newRichAd = null;
1075
- try {
1076
- const eventData = JSON.parse(event.data) || null;
1077
- newRichAd = eventData !== null ? eventData.richAd || null : null;
1078
- } catch (e) {}
1079
- if (newRichAd !== null) {
1080
- const container = containerRef.current || document;
1081
- const iframe = container.querySelector('iframe') || null;
1082
- if (iframe !== null && iframe.contentWindow === event.source) {
1083
- setRichAd(newRichAd);
1084
- }
1085
- }
1087
+ function onMessage(event) {
1088
+ if (event.origin.match(/safeframe\.googlesyndication\.com/) === null) {
1089
+ return;
1086
1090
  }
1087
- });
1088
- }, [id]);
1091
+ const container = containerRef.current || null;
1092
+ const iframe = container !== null ? container.querySelector('iframe') || null : null;
1093
+ if (iframe === null || iframe.contentWindow !== event.source) {
1094
+ return;
1095
+ }
1096
+ const newRichAd = parseRichAd(event.data);
1097
+ if (newRichAd === null) {
1098
+ return;
1099
+ }
1100
+ debug('Received rich ad for %s %O', id, newRichAd);
1101
+ setRichAd(newRichAd);
1102
+ if (onRichAd !== null) {
1103
+ onRichAd(newRichAd);
1104
+ }
1105
+ }
1106
+ window.addEventListener('message', onMessage);
1107
+ return () => {
1108
+ window.removeEventListener('message', onMessage);
1109
+ };
1110
+ }, [id, onRichAd]);
1089
1111
  return richAd;
1090
1112
  }
1091
1113
 
@@ -1109,6 +1131,7 @@ const propTypes = {
1109
1131
  richAdIframeClassName: PropTypes__default["default"].string,
1110
1132
  onRender: PropTypes__default["default"].func,
1111
1133
  onDestroy: PropTypes__default["default"].func,
1134
+ onRichAd: PropTypes__default["default"].func,
1112
1135
  slotRef: PropTypes__default["default"].oneOfType([PropTypes__default["default"].func, PropTypes__default["default"].object])
1113
1136
  };
1114
1137
  const defaultProps = {
@@ -1130,6 +1153,7 @@ const defaultProps = {
1130
1153
  richAdIframeClassName: null,
1131
1154
  onRender: null,
1132
1155
  onDestroy: null,
1156
+ onRichAd: null,
1133
1157
  slotRef: null
1134
1158
  };
1135
1159
  function Ad(_ref) {
@@ -1153,6 +1177,7 @@ function Ad(_ref) {
1153
1177
  richAdIframeClassName,
1154
1178
  onRender,
1155
1179
  onDestroy,
1180
+ onRichAd,
1156
1181
  slotRef
1157
1182
  } = _ref;
1158
1183
  const {
@@ -1251,7 +1276,9 @@ function Ad(_ref) {
1251
1276
  disableTracking
1252
1277
  });
1253
1278
  const adContainerRef = React.useRef(null);
1254
- const richAd = useRichAd(adContainerRef, id);
1279
+ const richAd = useRichAd(adContainerRef, id, {
1280
+ onRichAd
1281
+ });
1255
1282
  if (slotRef !== null && isFunction__default["default"](slotRef)) {
1256
1283
  slotRef(slotObject);
1257
1284
  } else if (slotRef !== null && isObject__default["default"](slotRef)) {
package/dist/es.js CHANGED
@@ -258,7 +258,7 @@ class AdSlot extends EventEmitter {
258
258
  }
259
259
 
260
260
  /* globals refreshDisabledLineItems: [] */
261
- const debug = createDebug('folklore:ads');
261
+ const debug$1 = createDebug('folklore:ads');
262
262
  class AdsManager extends EventEmitter {
263
263
  // static index = 0;
264
264
 
@@ -366,7 +366,7 @@ class AdsManager extends EventEmitter {
366
366
  if (this.disabled) {
367
367
  return;
368
368
  }
369
- debug('Initializing GPT...');
369
+ debug$1('Initializing GPT...');
370
370
  const {
371
371
  disabled,
372
372
  personnalizedAdsDisabled
@@ -380,19 +380,19 @@ class AdsManager extends EventEmitter {
380
380
  fetchMarginPercent = 300
381
381
  } = this.options;
382
382
  if (disabled) {
383
- debug('Disable initial load');
383
+ debug$1('Disable initial load');
384
384
  googletag.pubads().disableInitialLoad();
385
385
  }
386
386
  if (!disableSingleRequest) {
387
- debug('Enable single request');
387
+ debug$1('Enable single request');
388
388
  googletag.pubads().enableSingleRequest();
389
389
  }
390
390
  if (personnalizedAdsDisabled) {
391
- debug('Disable personalized ads');
391
+ debug$1('Disable personalized ads');
392
392
  googletag.pubads().setRequestNonPersonalizedAds(1);
393
393
  }
394
394
  if (!disableLazyLoad) {
395
- debug('Enable lazy loading %o', {
395
+ debug$1('Enable lazy loading %o', {
396
396
  fetchMarginPercent,
397
397
  renderMarginPercent,
398
398
  mobileScaling
@@ -404,13 +404,13 @@ class AdsManager extends EventEmitter {
404
404
  });
405
405
  }
406
406
  if (!disableVideoAds) {
407
- debug('Enable video ads');
407
+ debug$1('Enable video ads');
408
408
  googletag.pubads().enableVideoAds();
409
409
  }
410
410
  googletag.pubads().addEventListener('slotRenderEnded', this.onSlotRenderEnded);
411
411
  googletag.pubads().addEventListener('impressionViewable', this.onSlotImpressionViewable);
412
412
  googletag.enableServices();
413
- debug('GPT is ready');
413
+ debug$1('GPT is ready');
414
414
  this.enabled = true;
415
415
  this.ready = true;
416
416
  this.emit('ready');
@@ -430,9 +430,9 @@ class AdsManager extends EventEmitter {
430
430
  renderSlot.setRefreshDisabled();
431
431
  }
432
432
  if (event.isEmpty) {
433
- debug('Render ended for slot #%s(%s). Slot is empty.', eventSlot.getSlotElementId(), eventSlot.getAdUnitPath());
433
+ debug$1('Render ended for slot #%s(%s). Slot is empty.', eventSlot.getSlotElementId(), eventSlot.getAdUnitPath());
434
434
  } else {
435
- debug('Render ended for slot #%s(%s) with size %s.', eventSlot.getSlotElementId(), eventSlot.getAdUnitPath(), size !== null ? size.join('x') : '-');
435
+ debug$1('Render ended for slot #%s(%s) with size %s.', eventSlot.getSlotElementId(), eventSlot.getAdUnitPath(), size !== null ? size.join('x') : '-');
436
436
  }
437
437
  }
438
438
  onSlotImpressionViewable(event) {
@@ -443,12 +443,12 @@ class AdsManager extends EventEmitter {
443
443
  if (impressionSlot !== null) {
444
444
  impressionSlot.setViewable(true);
445
445
  }
446
- debug('Impression viewable for slot #%s(%s).', eventSlot.getSlotElementId(), eventSlot.getAdUnitPath());
446
+ debug$1('Impression viewable for slot #%s(%s).', eventSlot.getSlotElementId(), eventSlot.getAdUnitPath());
447
447
  }
448
448
 
449
449
  // eslint-disable-next-line class-methods-use-this
450
450
  onSlotVisibleChange(visible, slot) {
451
- debug('Slot #%s(%s) visibility change to %s', slot.getElementId(), slot.getAdPath(), visible ? 'visible' : 'not visible');
451
+ debug$1('Slot #%s(%s) visibility change to %s', slot.getElementId(), slot.getAdPath(), visible ? 'visible' : 'not visible');
452
452
  }
453
453
  isReady() {
454
454
  return this.ready && this.enabled && !this.disabled;
@@ -486,7 +486,7 @@ class AdsManager extends EventEmitter {
486
486
  id: providedId = null
487
487
  } = opts;
488
488
  const id = providedId || this.createAdId();
489
- debug('Creating slot #%s(%s)...', id, path);
489
+ debug$1('Creating slot #%s(%s)...', id, path);
490
490
  const slot = new AdSlot(id, path, size, {
491
491
  ...opts
492
492
  });
@@ -505,7 +505,7 @@ class AdsManager extends EventEmitter {
505
505
  const id = slot.getElementId();
506
506
  const path = slot.getAdPath();
507
507
  const size = slot.getAdSize();
508
- debug('Defining slot #%s(%s)...', id, path);
508
+ debug$1('Defining slot #%s(%s)...', id, path);
509
509
  const adSlot = googletag.defineSlot(path, size, id).addService(googletag.pubads());
510
510
  slot.setAdSlot(adSlot);
511
511
  });
@@ -514,7 +514,7 @@ class AdsManager extends EventEmitter {
514
514
  const slotsToDisplay = this.slots.filter(slot => slot.canBeDisplayed());
515
515
  const slotsCount = slotsToDisplay.length;
516
516
  if (slotsCount > 0) {
517
- debug('Displaying %i slot(s)...', slotsCount);
517
+ debug$1('Displaying %i slot(s)...', slotsCount);
518
518
  slotsToDisplay.forEach(slot => this.callDisplaySlot(slot));
519
519
  }
520
520
  return true;
@@ -534,7 +534,7 @@ class AdsManager extends EventEmitter {
534
534
  googletag.cmd.push(() => {
535
535
  const id = slot.getElementId();
536
536
  const path = slot.getAdPath();
537
- debug('Displaying slot #%s(%s)...', id, path);
537
+ debug$1('Displaying slot #%s(%s)...', id, path);
538
538
  googletag.display(slot.getAdSlot());
539
539
  if (googletag.pubads().isInitialLoadDisabled()) {
540
540
  googletag.pubads().refresh([slot.getAdSlot()]);
@@ -556,7 +556,7 @@ class AdsManager extends EventEmitter {
556
556
  slot.destroy();
557
557
  this.slots = this.slots.filter(it => it !== slot);
558
558
  if (adSlot !== null) {
559
- debug('Destroying slot #%s(%s)...', adSlot.getAdUnitPath(), adSlot.getSlotElementId());
559
+ debug$1('Destroying slot #%s(%s)...', adSlot.getAdUnitPath(), adSlot.getSlotElementId());
560
560
  googletag.cmd.push(() => {
561
561
  googletag.destroySlots([adSlot]);
562
562
  });
@@ -573,7 +573,7 @@ class AdsManager extends EventEmitter {
573
573
  }
574
574
  const adSlot = slot.getAdSlot();
575
575
  if (adSlot !== null) {
576
- debug('Refreshing slot #%s(%s)...', adSlot.getAdUnitPath(), slot.getElementId());
576
+ debug$1('Refreshing slot #%s(%s)...', adSlot.getAdUnitPath(), slot.getElementId());
577
577
  googletag.cmd.push(() => {
578
578
  googletag.pubads().refresh([adSlot], {
579
579
  changeCorrelator: false
@@ -589,7 +589,7 @@ class AdsManager extends EventEmitter {
589
589
  if (slots.length === 0) {
590
590
  return;
591
591
  }
592
- debug('Refreshing slots %o...', slots.map(slot => `#${slot.getElementId()}(${slot.getAdUnitPath()})`));
592
+ debug$1('Refreshing slots %o...', slots.map(slot => `#${slot.getElementId()}(${slot.getAdUnitPath()})`));
593
593
  googletag.cmd.push(() => {
594
594
  googletag.pubads().refresh(slots);
595
595
  });
@@ -598,7 +598,7 @@ class AdsManager extends EventEmitter {
598
598
  const {
599
599
  googletag
600
600
  } = this;
601
- debug('Refreshing all slots...');
601
+ debug$1('Refreshing all slots...');
602
602
  googletag.cmd.push(() => {
603
603
  googletag.pubads().refresh();
604
604
  });
@@ -1047,27 +1047,49 @@ function useAd(path, size) {
1047
1047
  };
1048
1048
  }
1049
1049
 
1050
- function useRichAd(containerRef, id) {
1050
+ const debug = createDebug('folklore:ads');
1051
+ function parseRichAd(data) {
1052
+ let richAd = null;
1053
+ try {
1054
+ const eventData = JSON.parse(data) || null;
1055
+ richAd = eventData !== null ? eventData.richAd || null : null;
1056
+ } catch (e) {}
1057
+ return richAd;
1058
+ }
1059
+ function useRichAd(containerRef, id, opts) {
1051
1060
  const [richAd, setRichAd] = useState(null);
1061
+ const {
1062
+ onRichAd = null
1063
+ } = opts || {};
1052
1064
  useEffect(() => {
1065
+ if (id === null) {
1066
+ return () => {};
1067
+ }
1053
1068
  setRichAd(null);
1054
- window.addEventListener('message', event => {
1055
- if (event.origin.match(/safeframe\.googlesyndication\.com/) !== null) {
1056
- let newRichAd = null;
1057
- try {
1058
- const eventData = JSON.parse(event.data) || null;
1059
- newRichAd = eventData !== null ? eventData.richAd || null : null;
1060
- } catch (e) {}
1061
- if (newRichAd !== null) {
1062
- const container = containerRef.current || document;
1063
- const iframe = container.querySelector('iframe') || null;
1064
- if (iframe !== null && iframe.contentWindow === event.source) {
1065
- setRichAd(newRichAd);
1066
- }
1067
- }
1069
+ function onMessage(event) {
1070
+ if (event.origin.match(/safeframe\.googlesyndication\.com/) === null) {
1071
+ return;
1068
1072
  }
1069
- });
1070
- }, [id]);
1073
+ const container = containerRef.current || null;
1074
+ const iframe = container !== null ? container.querySelector('iframe') || null : null;
1075
+ if (iframe === null || iframe.contentWindow !== event.source) {
1076
+ return;
1077
+ }
1078
+ const newRichAd = parseRichAd(event.data);
1079
+ if (newRichAd === null) {
1080
+ return;
1081
+ }
1082
+ debug('Received rich ad for %s %O', id, newRichAd);
1083
+ setRichAd(newRichAd);
1084
+ if (onRichAd !== null) {
1085
+ onRichAd(newRichAd);
1086
+ }
1087
+ }
1088
+ window.addEventListener('message', onMessage);
1089
+ return () => {
1090
+ window.removeEventListener('message', onMessage);
1091
+ };
1092
+ }, [id, onRichAd]);
1071
1093
  return richAd;
1072
1094
  }
1073
1095
 
@@ -1091,6 +1113,7 @@ const propTypes = {
1091
1113
  richAdIframeClassName: PropTypes.string,
1092
1114
  onRender: PropTypes.func,
1093
1115
  onDestroy: PropTypes.func,
1116
+ onRichAd: PropTypes.func,
1094
1117
  slotRef: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
1095
1118
  };
1096
1119
  const defaultProps = {
@@ -1112,6 +1135,7 @@ const defaultProps = {
1112
1135
  richAdIframeClassName: null,
1113
1136
  onRender: null,
1114
1137
  onDestroy: null,
1138
+ onRichAd: null,
1115
1139
  slotRef: null
1116
1140
  };
1117
1141
  function Ad(_ref) {
@@ -1135,6 +1159,7 @@ function Ad(_ref) {
1135
1159
  richAdIframeClassName,
1136
1160
  onRender,
1137
1161
  onDestroy,
1162
+ onRichAd,
1138
1163
  slotRef
1139
1164
  } = _ref;
1140
1165
  const {
@@ -1233,7 +1258,9 @@ function Ad(_ref) {
1233
1258
  disableTracking
1234
1259
  });
1235
1260
  const adContainerRef = useRef(null);
1236
- const richAd = useRichAd(adContainerRef, id);
1261
+ const richAd = useRichAd(adContainerRef, id, {
1262
+ onRichAd
1263
+ });
1237
1264
  if (slotRef !== null && isFunction(slotRef)) {
1238
1265
  slotRef(slotObject);
1239
1266
  } else if (slotRef !== null && isObject(slotRef)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@folklore/ads",
3
- "version": "0.0.77",
3
+ "version": "0.0.79",
4
4
  "description": "Ads library",
5
5
  "keywords": [
6
6
  "javascript",
@@ -50,7 +50,7 @@
50
50
  "publishConfig": {
51
51
  "access": "public"
52
52
  },
53
- "gitHead": "9396a889403576ed2daf2f06d597e9ad5b1a8ca7",
53
+ "gitHead": "d4912741fa4d4942651be59b0276fcbe8dd25e19",
54
54
  "dependencies": {
55
55
  "@folklore/hooks": "^0.0.65",
56
56
  "@folklore/tracking": "^0.0.25",