Skip to content

Commit db65e0a

Browse files
🤖 Merge PR DefinitelyTyped#71666 Sync latest changes to @types/google-publisher-tag by @publisher-ads-audits-bot
Co-authored-by: jimper <[email protected]>
1 parent e6f454f commit db65e0a

File tree

3 files changed

+188
-122
lines changed

3 files changed

+188
-122
lines changed

‎types/google-publisher-tag/google-publisher-tag-tests.ts‎

Lines changed: 94 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// Tests for Google Publisher Tag 1.20241202
2-
// Synced from: https://github.com/googleads/google-publisher-tag-types/commit/11a67de54de9180e5f3cf31c23c402f43071cdca
1+
// Tests for Google Publisher Tag 1.20250113
2+
// Synced from: https://github.com/googleads/google-publisher-tag-types/commit/86021d60da45fad4962a10ec47a079e9e0356ac7
33

44
// Test for googletag.cmd
55
function test_googletag_cmd() {
@@ -895,57 +895,77 @@ function test_googletag_events_slotResponseReceived() {
895895

896896
// Test for googletag.events.RewardedSlotGrantedEvent
897897
function test_googletag_events_rewardedSlotGrantedEvent() {
898-
// This listener is called whenever a reward is granted for a
899-
// rewarded ad.
900-
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
901-
googletag.pubads().addEventListener("rewardedSlotGranted", event => {
902-
const slot = event.slot;
903-
console.group("Reward granted for slot", slot.getSlotElementId(), ".");
904-
905-
// Log details of the reward.
906-
console.log("Reward type:", event.payload?.type);
907-
console.log("Reward amount:", event.payload?.amount);
908-
console.groupEnd();
909-
910-
if (slot === targetSlot) {
911-
// Slot specific logic.
912-
}
913-
});
898+
const targetSlot = googletag.defineOutOfPageSlot("/1234567/example", googletag.enums.OutOfPageFormat.REWARDED);
899+
900+
// Slot returns null if the page or device does not support rewarded ads.
901+
if (targetSlot) {
902+
targetSlot.addService(googletag.pubads());
903+
904+
// This listener is called whenever a reward is granted for a
905+
// rewarded ad.
906+
googletag.pubads().addEventListener("rewardedSlotGranted", event => {
907+
const slot = event.slot;
908+
console.group("Reward granted for slot", slot.getSlotElementId(), ".");
909+
910+
// Log details of the reward.
911+
console.log("Reward type:", event.payload?.type);
912+
console.log("Reward amount:", event.payload?.amount);
913+
console.groupEnd();
914+
915+
if (slot === targetSlot) {
916+
// Slot specific logic.
917+
}
918+
});
919+
}
914920
}
915921

916922
// Test for googletag.events.RewardedSlotClosedEvent
917923
function test_googletag_events_rewardedSlotClosedEvent() {
918-
// This listener is called when the user closes a rewarded ad slot.
919-
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
920-
googletag.pubads().addEventListener("rewardedSlotClosed", event => {
921-
const slot = event.slot;
922-
console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed.");
924+
const targetSlot = googletag.defineOutOfPageSlot("/1234567/example", googletag.enums.OutOfPageFormat.REWARDED);
923925

924-
if (slot === targetSlot) {
925-
// Slot specific logic.
926-
}
927-
});
926+
// Slot returns null if the page or device does not support rewarded ads.
927+
if (targetSlot) {
928+
targetSlot.addService(googletag.pubads());
929+
930+
// This listener is called when the user closes a rewarded ad slot.
931+
googletag.pubads().addEventListener("rewardedSlotClosed", event => {
932+
const slot = event.slot;
933+
console.log("Rewarded ad slot", slot.getSlotElementId(), "has been closed.");
934+
935+
if (slot === targetSlot) {
936+
// Slot specific logic.
937+
}
938+
});
939+
}
928940
}
929941

930942
// Test for googletag.events.RewardedSlotReadyEvent
931943
function test_googletag_events_rewardedSlotReadyEvent() {
932944
// This listener is called when a rewarded ad slot becomes ready to be
933945
// displayed.
934-
const targetSlot = googletag.defineSlot("/1234567/example", [160, 600]);
935-
googletag.pubads().addEventListener("rewardedSlotReady", event => {
936-
const slot = event.slot;
937-
console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed.");
938-
939-
// Replace with custom logic.
940-
const userHasConsented = true;
941-
if (userHasConsented) {
942-
event.makeRewardedVisible();
943-
}
944-
945-
if (slot === targetSlot) {
946-
// Slot specific logic.
947-
}
948-
});
946+
const targetSlot = googletag.defineOutOfPageSlot("/1234567/example", googletag.enums.OutOfPageFormat.REWARDED);
947+
948+
// Slot returns null if the page or device does not support rewarded ads.
949+
if (targetSlot) {
950+
targetSlot.addService(googletag.pubads());
951+
952+
// This listener is called whenever a reward is granted for a
953+
// rewarded ad.
954+
googletag.pubads().addEventListener("rewardedSlotReady", event => {
955+
const slot = event.slot;
956+
console.log("Rewarded ad slot", slot.getSlotElementId(), "is ready to be displayed.");
957+
958+
// Replace with custom logic.
959+
const userHasConsented = true;
960+
if (userHasConsented) {
961+
event.makeRewardedVisible();
962+
}
963+
964+
if (slot === targetSlot) {
965+
// Slot specific logic.
966+
}
967+
});
968+
}
949969
}
950970

951971
// Test for googletag.events.GameManualInterstitialSlotReadyEvent
@@ -956,35 +976,47 @@ function test_googletag_events_gameManualInterstitialSlotReadyEvent() {
956976
"/1234567/example",
957977
googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL,
958978
);
959-
googletag.pubads().addEventListener("gameManualInterstitialSlotReady", event => {
960-
const slot = event.slot;
961-
console.log("Game manual interstital slot", slot.getSlotElementId(), "is ready to be displayed.");
962979

963-
// Replace with custom logic.
964-
const displayGmiAd = true;
965-
if (displayGmiAd) {
966-
event.makeGameManualInterstitialVisible();
967-
}
980+
// Slot returns null if the page or device does not support game manual interstitial ads.
981+
if (targetSlot) {
982+
targetSlot.addService(googletag.pubads());
968983

969-
if (slot === targetSlot) {
970-
// Slot specific logic.
971-
}
972-
});
984+
googletag.pubads().addEventListener("gameManualInterstitialSlotReady", event => {
985+
const slot = event.slot;
986+
console.log("Game manual interstital slot", slot.getSlotElementId(), "is ready to be displayed.");
987+
988+
// Replace with custom logic.
989+
const displayGmiAd = true;
990+
if (displayGmiAd) {
991+
event.makeGameManualInterstitialVisible();
992+
}
993+
994+
if (slot === targetSlot) {
995+
// Slot specific logic.
996+
}
997+
});
998+
}
973999
}
9741000

9751001
// Test for googletag.events.GameManualInterstitialSlotClosedEvent
9761002
function test_googletag_events_gameManualInterstitialSlotClosedEvent() {
977-
// This listener is called when a game manual interstial slot is closed.
1003+
// This listener is called when a game manual interstitial slot is closed.
9781004
const targetSlot = googletag.defineOutOfPageSlot(
9791005
"/1234567/example",
9801006
googletag.enums.OutOfPageFormat.GAME_MANUAL_INTERSTITIAL,
9811007
);
982-
googletag.pubads().addEventListener("gameManualInterstitialSlotClosed", event => {
983-
const slot = event.slot;
984-
console.log("Game manual interstital slot", slot.getSlotElementId(), "is closed.");
9851008

986-
if (slot === targetSlot) {
987-
// Slot specific logic.
988-
}
989-
});
1009+
// Slot returns null if the page or device does not support game manual interstitial ads.
1010+
if (targetSlot) {
1011+
targetSlot.addService(googletag.pubads());
1012+
1013+
googletag.pubads().addEventListener("gameManualInterstitialSlotClosed", event => {
1014+
const slot = event.slot;
1015+
console.log("Game manual interstital slot", slot.getSlotElementId(), "is closed.");
1016+
1017+
if (slot === targetSlot) {
1018+
// Slot specific logic.
1019+
}
1020+
});
1021+
}
9901022
}

0 commit comments

Comments
 (0)