Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impression tracker for original API #804

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void failure(@NonNull PbFindSizeError error) {
protected void onDestroy() {
super.onDestroy();
if (adUnit != null) {
adUnit.stopAutoRefresh();
adUnit.destroy();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private void setOpenRtbConfig() {
protected void onDestroy() {
super.onDestroy();
if (adUnit != null) {
adUnit.stopAutoRefresh();
adUnit.destroy();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ protected void onDestroy() {
super.onDestroy();

if (adUnit != null) {
adUnit.stopAutoRefresh();
adUnit.destroy();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void failure(@NonNull PbFindSizeError error) {
protected void onDestroy() {
super.onDestroy();
if (adUnit != null) {
adUnit.stopAutoRefresh();
adUnit.destroy();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected void onDestroy() {
super.onDestroy();

if (adUnit != null) {
adUnit.stopAutoRefresh();
adUnit.destroy();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ protected void onDestroy() {
adView.destroy();
}
if (adUnit != null) {
adUnit.stopAutoRefresh();
adUnit.destroy();
}
if (unifiedNativeAd != null) {
unifiedNativeAd.destroy();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private void configureNativeAdUnit(NativeAdUnit adUnit) {
protected void onDestroy() {
super.onDestroy();
if (nativeAdUnit != null) {
nativeAdUnit.stopAutoRefresh();
nativeAdUnit.destroy();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected void onDestroy() {
super.onDestroy();

if (adUnit != null) {
adUnit.stopAutoRefresh();
adUnit.destroy();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ protected void onDestroy() {
super.onDestroy();

if (adUnit != null) {
adUnit.stopAutoRefresh();
adUnit.destroy();
}
if (adsLoader != null) {
adsLoader.setPlayer(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
protected void onDestroy() {
super.onDestroy();
if (adUnit != null) {
adUnit.stopAutoRefresh();
adUnit.destroy();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void onAdFailedToLoad(@NonNull LoadAdError loadAdError) {
protected void onDestroy() {
super.onDestroy();
if (adUnit != null) {
adUnit.stopAutoRefresh();
adUnit.destroy();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class GamOriginalApiDisplayBanner300x250Activity : BaseAdActivity() {

override fun onDestroy() {
super.onDestroy()
adUnit?.stopAutoRefresh()
adUnit?.destroy()
}

private fun createGAMListener(adView: AdManagerAdView): AdListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class GamOriginalApiDisplayBanner320x50Activity : BaseAdActivity() {

companion object {
const val AD_UNIT_ID = "/21808260008/prebid_demo_app_original_api_banner"
const val CONFIG_ID = "prebid-demo-banner-320-50"
const val CONFIG_ID = "prebid-ita-banner-320-50"
const val WIDTH = 320
const val HEIGHT = 50
}
Expand Down Expand Up @@ -72,6 +72,9 @@ class GamOriginalApiDisplayBanner320x50Activity : BaseAdActivity() {
parameters.api = listOf(Signals.Api.MRAID_3, Signals.Api.OMID_1)
adUnit?.bannerParameters = parameters

// Optional: the activation of the native impression tracker
adUnit?.activatePrebidImpressionTracker(adView)

adUnit?.setAutoRefreshInterval(refreshTimeSeconds)
adUnit?.fetchDemand(request) {
adView.loadAd(request)
Expand All @@ -95,7 +98,7 @@ class GamOriginalApiDisplayBanner320x50Activity : BaseAdActivity() {

override fun onDestroy() {
super.onDestroy()
adUnit?.stopAutoRefresh()
adUnit?.destroy()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class GamOriginalApiDisplayBannerMultiSizeActivity : BaseAdActivity() {

override fun onDestroy() {
super.onDestroy()
adUnit?.stopAutoRefresh()
adUnit?.destroy()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import com.google.android.gms.ads.LoadAdError
import com.google.android.gms.ads.admanager.AdManagerAdRequest
import com.google.android.gms.ads.admanager.AdManagerInterstitialAd
import com.google.android.gms.ads.admanager.AdManagerInterstitialAdLoadCallback
import org.prebid.mobile.AdUnit
import org.prebid.mobile.InterstitialAdUnit
import org.prebid.mobile.prebidkotlindemo.activities.BaseAdActivity

Expand All @@ -32,7 +31,7 @@ class GamOriginalApiDisplayInterstitialActivity : BaseAdActivity() {
const val CONFIG_ID = "prebid-demo-display-interstitial-320-480"
}

private var adUnit: AdUnit? = null
private var adUnit: InterstitialAdUnit? = null


override fun onCreate(savedInstanceState: Bundle?) {
Expand All @@ -45,6 +44,9 @@ class GamOriginalApiDisplayInterstitialActivity : BaseAdActivity() {
// 1. Create InterstitialAdUnit
adUnit = InterstitialAdUnit(CONFIG_ID, 80, 60)

// Activate additional impression tracker (for burl)
adUnit?.activateInterstitialPrebidImpressionTracker()

// 2. Make a bid request to Prebid Server
val request = AdManagerAdRequest.Builder().build()
adUnit?.fetchDemand(request) {
Expand Down Expand Up @@ -78,6 +80,6 @@ class GamOriginalApiDisplayInterstitialActivity : BaseAdActivity() {
override fun onDestroy() {
super.onDestroy()

adUnit?.stopAutoRefresh()
adUnit?.destroy()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class GamOriginalApiInStreamActivity : BaseAdActivity() {
override fun onDestroy() {
super.onDestroy()

adUnit?.stopAutoRefresh()
adUnit?.destroy()
adsLoader?.setPlayer(null)
adsLoader?.release()
player?.release()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class GamOriginalApiMultiformatBannerActivity : BaseAdActivity() {

override fun onDestroy() {
super.onDestroy()
adUnit?.stopAutoRefresh()
adUnit?.destroy()
}

private fun createGAMListener(adView: AdManagerAdView): AdListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,6 @@ class GamOriginalApiMultiformatInterstitialActivity : BaseAdActivity() {
override fun onDestroy() {
super.onDestroy()

adUnit?.stopAutoRefresh()
adUnit?.destroy()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ class GamOriginalApiNativeInAppActivity : BaseAdActivity() {
override fun onDestroy() {
super.onDestroy()
adView?.destroy()
adUnit?.stopAutoRefresh()
adUnit?.destroy()
unifiedNativeAd?.destroy()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class GamOriginalApiNativeStylesActivity : BaseAdActivity() {
override fun onDestroy() {
super.onDestroy()

nativeAdUnit?.stopAutoRefresh()
nativeAdUnit?.destroy()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class GamOriginalApiVideoInterstitialActivity : BaseAdActivity() {
override fun onDestroy() {
super.onDestroy()

adUnit?.stopAutoRefresh()
adUnit?.destroy()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class GamOriginalApiVideoRewardedActivity : BaseAdActivity() {
override fun onDestroy() {
super.onDestroy()

adUnit?.stopAutoRefresh()
adUnit?.destroy()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ open class GamOriginalBannerFragment : AdFragment() {
override fun onDestroyView() {
super.onDestroyView()
adView?.destroy()
adUnit?.stopAutoRefresh()
adUnit?.destroy()
}

private class Events(parentView: View) : BaseEvents(parentView) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class GamOriginalInstreamFragment : AdFragment() {

override fun onDestroyView() {
super.onDestroyView()
adUnit?.stopAutoRefresh()
adUnit?.destroy()
adsLoader?.setPlayer(null)
adsLoader?.release()
player?.release()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class GamOriginalInstreamNewApiFragment : AdFragment() {

override fun onDestroyView() {
super.onDestroyView()
adUnit?.stopAutoRefresh()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change looks as potential memory leak. What if the publisher utilizes a new counting methodology and will not call destroy()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a user uses this burl tracker, it's better to use destroy(). Otherwise the monitor will traverse view hierarchy as long as the ad view container exists.

adUnit?.destroy()
adsLoader?.setPlayer(null)
adsLoader?.release()
player?.release()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class GamOriginalNativeBannerFragment : AdFragment() {

override fun onDestroy() {
super.onDestroy()
nativeAdUnit?.stopAutoRefresh()
nativeAdUnit?.destroy()
}

private class Events(parentView: View) : BaseEvents(parentView) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ class GamOriginalNativeInAppFragment : PpmNativeFragment() {
override fun onDestroy() {
super.onDestroy()
adView?.destroy()
adUnit?.stopAutoRefresh()
adUnit?.destroy()
unifiedNativeAd?.destroy()
}
}
Loading