Skip to content

Commit

Permalink
🤖 Merge PR DefinitelyTyped#70467 Sync latest changes to @types/google…
Browse files Browse the repository at this point in the history
…-publisher-tag by @publisher-ads-audits-bot

Co-authored-by: jimper <[email protected]>
  • Loading branch information
publisher-ads-audits-bot and jimper authored Sep 5, 2024
1 parent 1681195 commit 5b4ed68
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 3 deletions.
45 changes: 43 additions & 2 deletions types/google-publisher-tag/google-publisher-tag-tests.ts
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down Expand Up @@ -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.
}
});
}
85 changes: 85 additions & 0 deletions types/google-publisher-tag/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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,
}

/**
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}
}
2 changes: 1 addition & 1 deletion types/google-publisher-tag/package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down

0 comments on commit 5b4ed68

Please sign in to comment.