diff --git a/types/google-publisher-tag/google-publisher-tag-tests.ts b/types/google-publisher-tag/google-publisher-tag-tests.ts index 82746d07ae7afd..8d5a003f88cac4 100644 --- a/types/google-publisher-tag/google-publisher-tag-tests.ts +++ b/types/google-publisher-tag/google-publisher-tag-tests.ts @@ -1,5 +1,5 @@ -// Tests for Google Publisher Tag 1.20240826 -// Synced from: https://github.com/googleads/google-publisher-tag-types/commit/7aa971520f419d3ec8c3a7384996db1fcd82613e +// Tests for Google Publisher Tag 1.20240902 +// Synced from: https://github.com/googleads/google-publisher-tag-types/commit/f32beeaf073095e7d2c8a993c851fe582d830ac3 // Test for googletag.cmd function test_googletag_cmd() { @@ -932,3 +932,44 @@ function test_googletag_events_rewardedSlotReadyEvent() { } }); } + +// Test for googletag.events.GameManualInterstitialSlotReadyEvent +function test_googletag_events_gameManualInterstitialSlotReadyEvent() { + // This listener is called when a game manual interstitial slot is ready to + // be displayed. + const targetSlot = googletag.defineOutOfPageSlot( + "/1234567/example", + googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, + ); + googletag.pubads().addEventListener("gameManualInterstitialSlotReady", event => { + const slot = event.slot; + console.log("Game manual interstital slot", slot.getSlotElementId(), "is ready to be displayed."); + + // Replace with custom logic. + const displayGmiAd = true; + if (displayGmiAd) { + event.makeGameManualInterstitialVisible(); + } + + if (slot === targetSlot) { + // Slot specific logic. + } + }); +} + +// Test for googletag.events.GameManualInterstitialSlotClosedEvent +function test_googletag_events_gameManualInterstitialSlotClosedEvent() { + // This listener is called when a game manual interstial slot is closed. + const targetSlot = googletag.defineOutOfPageSlot( + "/1234567/example", + googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL, + ); + googletag.pubads().addEventListener("gameManualInterstitialSlotClosed", event => { + const slot = event.slot; + console.log("Game manual interstital slot", slot.getSlotElementId(), "is closed."); + + if (slot === targetSlot) { + // Slot specific logic. + } + }); +} diff --git a/types/google-publisher-tag/index.d.ts b/types/google-publisher-tag/index.d.ts index e54c2830c04604..ec337d6dd9ecd2 100644 --- a/types/google-publisher-tag/index.d.ts +++ b/types/google-publisher-tag/index.d.ts @@ -1102,6 +1102,8 @@ declare namespace googletag { * function when a specific GPT event happens on the page. The following * events are supported: * + * - {@link events.GameManualInterstitialSlotClosedEvent} + * - {@link events.GameManualInterstitialSlotReadyEvent} * - {@link events.ImpressionViewableEvent} * - {@link events.RewardedSlotClosedEvent} * - {@link events.RewardedSlotGrantedEvent} @@ -2126,6 +2128,12 @@ declare namespace googletag { LEFT_SIDE_RAIL, /** Right side rail format. */ RIGHT_SIDE_RAIL, + /** + * Game manual interstitial format. + * + * **Note:** Game manual interstitial is a [limited-access](https://support.google.com/admanager/answer/14640119) format. + */ + GAME_MANUAL_INTERSTITIAL, } /** @@ -2633,6 +2641,73 @@ declare namespace googletag { makeRewardedVisible(): void; } + /** + * This event is fired when a game manual interstitial slot is ready to be + * shown to the user. + * + * **Note:** Game manual interstitial is a [limited-access](https://support.google.com/admanager/answer/14640119) format. + * + * @example + * // This listener is called when a game manual interstitial slot is ready to + * // be displayed. + * const targetSlot = googletag.defineOutOfPageSlot( + * '/1234567/example', + * googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL); + * googletag.pubads().addEventListener('gameManualInterstitialSlotReady', + * (event) => { + * const slot = event.slot; + * console.log('Game manual interstital slot', + * slot.getSlotElementId(), 'is ready to be displayed.') + * + * //Replace with custom logic. + * const displayGmiAd = true; + * if (displayGmiAd) { + * event.makeGameManualInterstitialVisible(); + * } + * + * if (slot === targetSlot) { + * // Slot specific logic. + * } + * } + * ); + * + * @see [Ad event listeners](https://developers.google.com/publisher-tag/samples/ad-event-listeners) + * @see [Display a game manual interstitial ad](https://support.google.com/admanager/answer/14640119) + */ + interface GameManualInterstitialSlotReadyEvent extends Event { + /** Displays the game manual interstitial ad to the user. */ + makeGameManualInterstitialVisible(): void; + } + + /** + * This event is fired when a game manual interstitial slot has been closed by + * the user. + * + * **Note:** Game manual interstitial is a [limited-access](https://support.google.com/admanager/answer/14640119) format. + * + * @example + * // This listener is called when a game manual interstial slot is closed. + * const targetSlot = googletag.defineOutOfPageSlot( + * '/1234567/example', + * googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL); + * googletag.pubads().addEventListener('gameManualInterstitialSlotClosed', + * (event) => { + * const slot = event.slot; + * console.log('Game manual interstital slot', + * slot.getSlotElementId(), 'is closed.') + * + * if (slot === targetSlot) { + * // Slot specific logic. + * } + * } + * ); + * + * @see [Ad event listeners](https://developers.google.com/publisher-tag/samples/ad-event-listeners) + * @see [Display a game manual interstitial ad](https://support.google.com/admanager/answer/14640119) + */ + // eslint-disable-next-line @typescript-eslint/no-empty-interface + interface GameManualInterstitialSlotClosedEvent extends Event {} + /** * This is a pseudo-type that maps an event name to its corresponding event * object type for {@link Service.addEventListener} and @@ -2684,6 +2759,16 @@ declare namespace googletag { * Alias for {@link events.RewardedSlotReadyEvent}. */ rewardedSlotReady: RewardedSlotReadyEvent; + + /** + * Alias for {@link events.GameManualInterstitialSlotReadyEvent}. + */ + gameManualInterstitialSlotReady: GameManualInterstitialSlotReadyEvent; + + /** + * Alias for {@link events.GameManualInterstitialSlotClosedEvent}. + */ + gameManualInterstitialSlotClosed: GameManualInterstitialSlotClosedEvent; } } } diff --git a/types/google-publisher-tag/package.json b/types/google-publisher-tag/package.json index d7dd5c01c4e135..17bc38b7263832 100644 --- a/types/google-publisher-tag/package.json +++ b/types/google-publisher-tag/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@types/google-publisher-tag", - "version": "1.20240826.9999", + "version": "1.20240902.9999", "nonNpm": true, "nonNpmDescription": "Google Publisher Tag", "projects": [