Skip to content

Commit

Permalink
feat: exposes impression-level ad revenue events
Browse files Browse the repository at this point in the history
  • Loading branch information
birdofpreyru authored Nov 10, 2023
1 parent 03e18fb commit 969dbfa
Show file tree
Hide file tree
Showing 26 changed files with 280 additions and 42 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -568,3 +568,5 @@ website/public

# generated files by bob
lib/

.yarn
27 changes: 26 additions & 1 deletion RNGoogleMobileAdsExample/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import {Test, TestRegistry, TestResult, TestRunner, TestType} from 'jet';

import MobileAds, {
type PaidEvent,
AdEventType,
AdsConsent,
AdsConsentDebugGeography,
Expand All @@ -19,6 +20,7 @@ import MobileAds, {
TestIds,
BannerAd,
BannerAdSize,
RevenuePrecisions,
RewardedAd,
RewardedAdEventType,
useInterstitialAd,
Expand All @@ -43,6 +45,9 @@ class AppOpenTest implements Test {
// Current no way in jet-next to re-render on async completion or to delay render? But still can log it
this.adListener = appOpen.addAdEventsListener(({type, payload}) => {
console.log(`${Platform.OS} app open ad event: ${type}`);
if (type === AdEventType.PAID) {
console.log(payload);
}
if (type === AdEventType.ERROR) {
console.log(`${Platform.OS} app open error: ${payload?.message}`);
}
Expand Down Expand Up @@ -115,6 +120,9 @@ class InterstitialTest implements Test {
// Current no way in jet-next to re-render on async completion or to delay render? But still can log it
this.adListener = interstitial.addAdEventsListener(({type, payload}) => {
console.log(`${Platform.OS} interstitial ad event: ${type}`);
if (type === AdEventType.PAID) {
console.log('Paid', payload);
}
if (type === AdEventType.ERROR) {
console.log(`${Platform.OS} interstitial error: ${payload?.message}`);
}
Expand Down Expand Up @@ -197,6 +205,13 @@ class BannerTest implements Test {
requestOptions={{
requestNonPersonalizedAdsOnly: true,
}}
onPaid={(event: PaidEvent) => {
console.log(
`Paid: ${event.value} ${event.currency} (precision ${
RevenuePrecisions[event.precision]
}})`,
);
}}
/>
</View>
);
Expand Down Expand Up @@ -226,6 +241,9 @@ class RewardedTest implements Test {
// Current no way in jet-next to re-render on async completion or to delay render? But still can log it
this.adListener = rewarded.addAdEventsListener(({type, payload}) => {
console.log(`${Platform.OS} rewarded ad event: ${type}`);
if (type === AdEventType.PAID) {
console.log(payload);
}
if (type === AdEventType.ERROR) {
console.log(
`${Platform.OS} rewarded error: ${(payload as Error).message}`,
Expand Down Expand Up @@ -303,6 +321,9 @@ class RewardedInterstitialTest implements Test {
this.adListener = rewardedInterstitial.addAdEventsListener(
({type, payload}) => {
console.log(`${Platform.OS} rewarded interstitial ad event: ${type}`);
if (type === AdEventType.PAID) {
console.log(payload);
}
if (type === AdEventType.ERROR) {
console.log(
`${Platform.OS} rewarded interstitial error: ${
Expand Down Expand Up @@ -423,7 +444,7 @@ class AdConsentTest implements Test {
}

const InterstitialHookComponent = React.forwardRef<View>((_, ref) => {
const {load, show, error, isLoaded, isClicked, isClosed, isOpened} =
const {load, show, error, isLoaded, isClicked, isClosed, isOpened, revenue} =
useInterstitialAd(TestIds.INTERSTITIAL);
useEffect(() => {
load();
Expand All @@ -439,6 +460,10 @@ const InterstitialHookComponent = React.forwardRef<View>((_, ref) => {
);
}, [isLoaded, isOpened, isClicked, isClosed]);

if (revenue) {
console.log('Revenue', revenue);
}

return (
<View style={styles.testSpacing} ref={ref}>
<Text>Loaded? {isLoaded ? 'true' : 'false'}</Text>
Expand Down
80 changes: 40 additions & 40 deletions RNGoogleMobileAdsExample/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -70,60 +70,60 @@ PODS:
- FlipperKit/FlipperKitNetworkPlugin
- fmt (6.2.1)
- glog (0.3.5)
- Google-Mobile-Ads-SDK (10.9.0):
- Google-Mobile-Ads-SDK (10.12.0):
- GoogleAppMeasurement (< 11.0, >= 7.0)
- GoogleUserMessagingPlatform (>= 1.1)
- GoogleAppMeasurement (10.7.0):
- GoogleAppMeasurement/AdIdSupport (= 10.7.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.8)
- GoogleUtilities/MethodSwizzler (~> 7.8)
- GoogleUtilities/Network (~> 7.8)
- "GoogleUtilities/NSData+zlib (~> 7.8)"
- GoogleAppMeasurement (10.17.0):
- GoogleAppMeasurement/AdIdSupport (= 10.17.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.11)
- GoogleUtilities/MethodSwizzler (~> 7.11)
- GoogleUtilities/Network (~> 7.11)
- "GoogleUtilities/NSData+zlib (~> 7.11)"
- nanopb (< 2.30910.0, >= 2.30908.0)
- GoogleAppMeasurement/AdIdSupport (10.7.0):
- GoogleAppMeasurement/WithoutAdIdSupport (= 10.7.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.8)
- GoogleUtilities/MethodSwizzler (~> 7.8)
- GoogleUtilities/Network (~> 7.8)
- "GoogleUtilities/NSData+zlib (~> 7.8)"
- GoogleAppMeasurement/AdIdSupport (10.17.0):
- GoogleAppMeasurement/WithoutAdIdSupport (= 10.17.0)
- GoogleUtilities/AppDelegateSwizzler (~> 7.11)
- GoogleUtilities/MethodSwizzler (~> 7.11)
- GoogleUtilities/Network (~> 7.11)
- "GoogleUtilities/NSData+zlib (~> 7.11)"
- nanopb (< 2.30910.0, >= 2.30908.0)
- GoogleAppMeasurement/WithoutAdIdSupport (10.7.0):
- GoogleUtilities/AppDelegateSwizzler (~> 7.8)
- GoogleUtilities/MethodSwizzler (~> 7.8)
- GoogleUtilities/Network (~> 7.8)
- "GoogleUtilities/NSData+zlib (~> 7.8)"
- GoogleAppMeasurement/WithoutAdIdSupport (10.17.0):
- GoogleUtilities/AppDelegateSwizzler (~> 7.11)
- GoogleUtilities/MethodSwizzler (~> 7.11)
- GoogleUtilities/Network (~> 7.11)
- "GoogleUtilities/NSData+zlib (~> 7.11)"
- nanopb (< 2.30910.0, >= 2.30908.0)
- GoogleUserMessagingPlatform (2.1.0)
- GoogleUtilities/AppDelegateSwizzler (7.11.0):
- GoogleUtilities/AppDelegateSwizzler (7.11.6):
- GoogleUtilities/Environment
- GoogleUtilities/Logger
- GoogleUtilities/Network
- GoogleUtilities/Environment (7.11.0):
- GoogleUtilities/Environment (7.11.6):
- PromisesObjC (< 3.0, >= 1.2)
- GoogleUtilities/Logger (7.11.0):
- GoogleUtilities/Logger (7.11.6):
- GoogleUtilities/Environment
- GoogleUtilities/MethodSwizzler (7.11.0):
- GoogleUtilities/MethodSwizzler (7.11.6):
- GoogleUtilities/Logger
- GoogleUtilities/Network (7.11.0):
- GoogleUtilities/Network (7.11.6):
- GoogleUtilities/Logger
- "GoogleUtilities/NSData+zlib"
- GoogleUtilities/Reachability
- "GoogleUtilities/NSData+zlib (7.11.0)"
- GoogleUtilities/Reachability (7.11.0):
- "GoogleUtilities/NSData+zlib (7.11.6)"
- GoogleUtilities/Reachability (7.11.6):
- GoogleUtilities/Logger
- hermes-engine (0.72.2):
- hermes-engine/Pre-built (= 0.72.2)
- hermes-engine/Pre-built (0.72.2)
- Jet (0.8.0):
- React-Core
- libevent (2.1.12)
- nanopb (2.30909.0):
- nanopb/decode (= 2.30909.0)
- nanopb/encode (= 2.30909.0)
- nanopb/decode (2.30909.0)
- nanopb/encode (2.30909.0)
- nanopb (2.30909.1):
- nanopb/decode (= 2.30909.1)
- nanopb/encode (= 2.30909.1)
- nanopb/decode (2.30909.1)
- nanopb/encode (2.30909.1)
- OpenSSL-Universal (1.1.1100)
- PromisesObjC (2.2.0)
- PromisesObjC (2.3.1)
- RCT-Folly (2021.07.22.00):
- boost
- DoubleConversion
Expand Down Expand Up @@ -534,8 +534,8 @@ PODS:
- React-jsi (= 0.72.2)
- React-logger (= 0.72.2)
- React-perflogger (= 0.72.2)
- RNGoogleMobileAds (11.7.0):
- Google-Mobile-Ads-SDK (= 10.9.0)
- RNGoogleMobileAds (12.3.0):
- Google-Mobile-Ads-SDK (= 10.12.0)
- GoogleUserMessagingPlatform (= 2.1.0)
- RCT-Folly (= 2021.07.22.00)
- React-Core
Expand Down Expand Up @@ -735,16 +735,16 @@ SPEC CHECKSUMS:
FlipperKit: 2efad7007d6745a3f95e4034d547be637f89d3f6
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
Google-Mobile-Ads-SDK: e81e8b009a182dc8dd14951782efdbb30a5e4510
GoogleAppMeasurement: fe17c92a32207dd5cdd4e8d742767f2da74857f6
Google-Mobile-Ads-SDK: 976fdf273815674eed30b8aafffedb3c25b055e4
GoogleAppMeasurement: 4dcddfc7f102825c1c4e6422cb35567b101881a7
GoogleUserMessagingPlatform: dce302b8f1b84d6e945812ee7a15c3f65a102cbf
GoogleUtilities: c2bdc4cf2ce786c4d2e6b3bcfd599a25ca78f06f
GoogleUtilities: 202e7a9f5128accd11160fb9c19612de1911aa19
hermes-engine: 3f42310d66bcbc814b3771b79ad8d5a3f8df3df1
Jet: c17c29bfbbaff56f08a17678211f36b859173e99
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
nanopb: b552cce312b6c8484180ef47159bc0f65a1f0431
nanopb: d4d75c12cd1316f4a64e3c6963f879ecd4b5e0d5
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
PromisesObjC: 09985d6d70fbe7878040aa746d78236e6946d2ef
PromisesObjC: c50d2056b5253dadbd6c2bea79b0674bd5a52fa4
RCT-Folly: 424b8c9a7a0b9ab2886ffe9c3b041ef628fd4fb1
RCTRequired: 40bf5271b434eae17c4f950abde576fb25d77d3a
RCTTypeSafety: 14400c4d956ff45c5a188e3b4f5f4daa89e3ae09
Expand Down Expand Up @@ -777,11 +777,11 @@ SPEC CHECKSUMS:
React-runtimescheduler: dbea23f2991dfa010654165de8159862935aed27
React-utils: ec05233cf7ee1d7014d41aaa17ec65ceeba8948d
ReactCommon: 77382645a088a81de55c24bde19c5a2805d891c3
RNGoogleMobileAds: e3762f57b48fd767d587dee9730a56fd5e7718e4
RNGoogleMobileAds: e5aa3c615280588cc70ef1039bd1ce6ead131e6b
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
Yoga: c79810ea24a2a73b7f39174e78d60f4e28261f33
YogaKit: f782866e155069a2cca2517aafea43200b01fd5a

PODFILE CHECKSUM: ad5b72079f3063adc720629375fc9194bb51ba43

COCOAPODS: 1.12.1
COCOAPODS: 1.14.2
Loading

0 comments on commit 969dbfa

Please sign in to comment.