Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Sign in / Register
Toggle navigation
D
Data Recovery White
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wanglei
Data Recovery White
Commits
ed74f56a
Commit
ed74f56a
authored
Jul 16, 2024
by
maxiaoliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
ae422211
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
103 additions
and
33 deletions
+103
-33
AdMaxEvent.kt
...src/main/java/com/base/datarecovery/ads/max/AdMaxEvent.kt
+103
-33
No files found.
app/src/main/java/com/base/datarecovery/ads/max/AdMaxEvent.kt
View file @
ed74f56a
package
com.base.datarecovery.ads.max
import
android.app.Activity
import
android.os.Bundle
import
com.applovin.mediation.MaxAd
import
com.applovin.mediation.MaxAdRevenueListener
import
com.applovin.sdk.AppLovinSdk
import
com.base.datarecovery.help.BaseApplication
import
com.base.datarecovery.utils.EventUtils
import
com.facebook.FacebookSdk
import
com.google.firebase.analytics.FirebaseAnalytics
import
com.google.firebase.analytics.ktx.analytics
import
com.google.firebase.ktx.Firebase
import
org.json.JSONObject
object
AdMaxEvent
{
fun
clickAd
(
nativeAd
:
MaxAd
,
adUnit
:
String
)
{
// val response = responseInfo?.adapterResponses?.getOrNull(0)
fun
pullAd
(
ad
:
MaxAd
,
adUnit
:
String
,
error
:
String
?
=
null
,
reqId
:
String
?
=
null
){
val
obj
=
JSONObject
()
// obj.put("source", response?.adSourceName)
obj
.
put
(
"source"
,
nativeAd
.
dspName
)
obj
.
put
(
"UnitId"
,
ad
?.
adUnitId
)
obj
.
put
(
"ad_unit"
,
adUnit
)
val
credentials
=
mapOf
(
"placementid"
to
nativeAd
.
placement
,
"appid"
to
nativeAd
.
adUnitId
,
// "pubid" to
obj
.
put
(
"creativeId"
,
ad
?.
creativeId
)
// obj.put("credentials", credentials.toString())
// obj.put("session_id", responseInfo?.responseId)
// obj.put("networkname", responseInfo?.mediationAdapterClassName)
obj
.
put
(
"networkname"
,
nativeAd
.
networkName
)
if
(
adUnit
!=
"nativeAd"
)
{
EventUtils
.
event
(
"ad_click"
,
ext
=
obj
)
obj
.
put
(
"req_id"
,
reqId
)
obj
.
put
(
"status"
,
if
(
ad
==
null
)
"0"
else
"1"
)
obj
.
put
(
"networkname"
,
ad
?.
networkName
)
obj
.
put
(
"placement"
,
ad
?.
placement
)
obj
.
put
(
"networkplacement"
,
ad
?.
networkPlacement
)
obj
.
put
(
"requestLatencyMillis"
,
ad
?.
requestLatencyMillis
)
obj
.
put
(
"valueMicros"
,
ad
?.
revenue
?.
times
(
1000000
))
if
(
error
==
null
)
{
obj
.
put
(
"status"
,
"1"
)
}
else
{
EventUtils
.
event
(
"bigimage_ad_click"
,
ext
=
obj
)
obj
.
put
(
"errMsg"
,
error
)
obj
.
put
(
"status"
,
"2"
)
}
EventUtils
.
event
(
"ad_pull"
,
ext
=
obj
)
}
fun
clickAd
(
ad
:
MaxAd
?,
adUnit
:
String
)
{
fun
showAd
(
nativeAd
:
MaxAd
,
adUnit
:
String
,
activity
:
Activity
?
=
null
)
{
// val response = responseInfo?.adapterResponses?.getOrNull(0)
val
obj
=
JSONObject
()
// obj.put("source", response?.adSourceName
)
obj
.
put
(
"UnitId"
,
ad
?.
adUnitId
)
obj
.
put
(
"ad_unit"
,
adUnit
)
obj
.
put
(
"networkname"
,
nativeAd
.
networkName
)
// val credentials = mapOf(
// "placementid" to response?.credentials?.get("placementid"),
// "appid" to response?.credentials?.get("appid"),
// "pubid" to response?.credentials?.get("pubid")
// )
// obj.put("credentials", credentials.toString())
// obj.put("session_id", responseInfo?.responseId)
obj
.
put
(
"from"
,
activity
?.
javaClass
?.
simpleName
)
if
(
adUnit
!=
"nativeAd"
)
{
EventUtils
.
event
(
"ad_show"
,
ext
=
obj
)
}
else
{
EventUtils
.
event
(
"bigimage_ad_show"
,
ext
=
obj
)
obj
.
put
(
"creativeId"
,
ad
?.
creativeId
)
obj
.
put
(
"networkname"
,
ad
?.
networkName
)
obj
.
put
(
"placement"
,
ad
?.
placement
)
obj
.
put
(
"networkplacement"
,
ad
?.
networkPlacement
)
obj
.
put
(
"requestLatencyMillis"
,
ad
?.
requestLatencyMillis
)
obj
.
put
(
"valueMicros"
,
ad
?.
revenue
)
EventUtils
.
event
(
"ad_click"
,
ext
=
obj
)
}
fun
showAd
(
ad
:
MaxAd
?,
adUnit
:
String
)
{
val
obj
=
JSONObject
()
obj
.
put
(
"UnitId"
,
ad
?.
adUnitId
)
obj
.
put
(
"ad_unit"
,
adUnit
)
obj
.
put
(
"creativeId"
,
ad
?.
creativeId
)
obj
.
put
(
"networkname"
,
ad
?.
networkName
)
obj
.
put
(
"placement"
,
ad
?.
placement
)
obj
.
put
(
"networkplacement"
,
ad
?.
networkPlacement
)
obj
.
put
(
"requestLatencyMillis"
,
ad
?.
requestLatencyMillis
)
obj
.
put
(
"valueMicros"
,
ad
?.
revenue
)
EventUtils
.
event
(
"ad_show"
,
ext
=
obj
)
}
private
val
taichiPref
=
FacebookSdk
.
getApplicationContext
()
.
getSharedPreferences
(
"TaichiTroasCache"
,
0
)
private
val
taichiSharedPreferencesEditor
=
taichiPref
.
edit
()
class
EventOnPaidEventListener
:
MaxAdRevenueListener
{
override
fun
onAdRevenuePaid
(
ad
:
MaxAd
)
{
val
params
=
Bundle
()
val
currentImpressionRevenue
:
Double
=
ad
.
revenue
// In USD
val
mFirebaseAnalytics
=
FirebaseAnalytics
.
getInstance
(
BaseApplication
.
context
)
params
.
putString
(
FirebaseAnalytics
.
Param
.
AD_PLATFORM
,
"appLovin"
)
params
.
putString
(
FirebaseAnalytics
.
Param
.
AD_SOURCE
,
ad
.
networkName
)
params
.
putString
(
FirebaseAnalytics
.
Param
.
AD_FORMAT
,
ad
.
format
.
getDisplayName
())
params
.
putString
(
FirebaseAnalytics
.
Param
.
AD_UNIT_NAME
,
ad
.
adUnitId
)
params
.
putDouble
(
FirebaseAnalytics
.
Param
.
VALUE
,
currentImpressionRevenue
)
params
.
putString
(
FirebaseAnalytics
.
Param
.
CURRENCY
,
"USD"
)
mFirebaseAnalytics
.
logEvent
(
FirebaseAnalytics
.
Event
.
AD_IMPRESSION
,
params
)
mFirebaseAnalytics
.
logEvent
(
"Ad_Impression_Revenue"
,
params
)
val
previousTaichiTroasCache
=
taichiPref
.
getFloat
(
"TaichiTroasCache"
,
0f
)
val
currentTaichiTroasCache
=
previousTaichiTroasCache
+
currentImpressionRevenue
if
(
currentTaichiTroasCache
>=
0.01
)
{
val
roasbundle
=
Bundle
()
roasbundle
.
putDouble
(
FirebaseAnalytics
.
Param
.
VALUE
,
currentTaichiTroasCache
)
roasbundle
.
putString
(
FirebaseAnalytics
.
Param
.
CURRENCY
,
"USD"
)
///(Required)tROAS事件必须
mFirebaseAnalytics
.
logEvent
(
"Total_Ads_Revenue_001"
,
roasbundle
)
// 给Taichi用
taichiSharedPreferencesEditor
.
putFloat
(
"TaichiTroasCache"
,
0f
)
//重新清零,开始计算
}
else
{
taichiSharedPreferencesEditor
.
putFloat
(
"TaichiTroasCache"
,
currentTaichiTroasCache
.
toFloat
()
)
taichiSharedPreferencesEditor
.
commit
()
}
val
obj
=
JSONObject
()
val
revenue
=
ad
.
revenue
val
countryCode
=
AppLovinSdk
.
getInstance
(
BaseApplication
.
context
).
configuration
.
countryCode
val
networkName
=
ad
.
networkName
val
adUnitId
=
ad
.
adUnitId
val
adFormat
=
ad
.
format
val
placement
=
ad
.
placement
val
networkPlacement
=
ad
.
networkPlacement
obj
.
put
(
"valueMicros"
,
revenue
)
obj
.
put
(
"currencyCode"
,
countryCode
)
obj
.
put
(
"adUnitId"
,
adUnitId
)
obj
.
put
(
"networkName"
,
networkName
)
obj
.
put
(
"adFormat"
,
adFormat
)
obj
.
put
(
"placement"
,
placement
)
obj
.
put
(
"networkPlacement"
,
networkPlacement
)
EventUtils
.
event
(
"ad_price"
,
ext
=
obj
)
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment