Skip to content

Commit

Permalink
add ad revenue modules
Browse files Browse the repository at this point in the history
03d9a849448ffea9304cebdb7c13d4152afb74fd
  • Loading branch information
KondratyonokNikita committed Apr 4, 2024
1 parent eb4f329 commit e40ba5a
Show file tree
Hide file tree
Showing 96 changed files with 2,189 additions and 17 deletions.
64 changes: 64 additions & 0 deletions .mapping.json

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions ad-revenue-fyber-v3/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# AppMetrica SDK Ad Revenue Auto Collection Adapter for Fyber v3

**Optional module**.
Maven: `io.appmetrica.analytics:analytics-ad-revenue-fyber-v3:${VERSION}`.

## Builds

### Assemble

`./gradlew :ad-revenue-fyber-v3:assembleRelease`

### Publish to MavenLocal

`./gradlew :ad-revenue-fyber-v3:publishReleasePublicationToMavenLocal`

### Tests

`./gradlew :ad-revenue-fyber-v3:testReleaseUnitTest :ad-revenue-fyber-v3:generateReleaseJacocoReport`

### Code style

`./gradlew :ad-revenue-fyber-v3:lint :ad-revenue-fyber-v3:ktlint :ad-revenue-fyber-v3:checkstyleRelease`

### Check AAR API

`./gradlew :ad-revenue-fyber-v3:aarCheck`

### Regenerate AAR API dump

`./gradlew :ad-revenue-fyber-v3:aarDump`
15 changes: 15 additions & 0 deletions ad-revenue-fyber-v3/api/release.api
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
public final class io.appmetrica.analytics.adrevenue.fyber.v3.BuildConfig {
public static final String BUILD_TYPE
public static final boolean DEBUG
public static final String LIBRARY_PACKAGE_NAME

public <init>()
}

public class io.appmetrica.analytics.adrevenue.fyber.v3.internal.FyberClientModuleEntryPoint implementation io.appmetrica.analytics.modulesapi.internal.client.ModuleClientEntryPoint<Object> {
public <init>()
public [NonNull] String getIdentifier()
public void initClientSide([NonNull] io.appmetrica.analytics.modulesapi.internal.client.ClientContext)
public void onActivated()
}

9 changes: 9 additions & 0 deletions ad-revenue-fyber-v3/api/releaseDependencies.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
io.appmetrica.analytics:core-api:unspecified
io.appmetrica.analytics:core-utils:unspecified
io.appmetrica.analytics:location-api:unspecified
io.appmetrica.analytics:logger:unspecified
io.appmetrica.analytics:modules-api:unspecified
io.appmetrica.analytics:proto:unspecified
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.21
org.jetbrains.kotlin:kotlin-stdlib:1.6.21
org.jetbrains:annotations:13.0
7 changes: 7 additions & 0 deletions ad-revenue-fyber-v3/api/releaseManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.appmetrica.analytics.adrevenue.fyber.v3" >

<uses-sdk android:minSdkVersion="14" />

</manifest>
89 changes: 89 additions & 0 deletions ad-revenue-fyber-v3/api/releaseModule.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"formatVersion": "1.1",
"component": {
"group": "io.appmetrica.analytics",
"module": "analytics-ad-revenue-fyber-v3",
"version": "6.4.0",
"attributes": {
"org.gradle.status": "release"
}
},
"createdBy": {
"gradle": {
"version": "8.2.1",
"buildId": "<random-string>"
}
},
"variants": [
{
"name": "releaseVariantReleaseApiPublication",
"attributes": {
"org.gradle.category": "library",
"org.gradle.dependency.bundling": "external",
"org.gradle.libraryelements": "aar",
"org.gradle.usage": "java-api"
},
"files": [
{
"name": "analytics-ad-revenue-fyber-v3-6.4.0.aar",
"url": "analytics-ad-revenue-fyber-v3-6.4.0.aar",
"size": -1,
"sha512": "<sha512>",
"sha256": "<sha256>",
"sha1": "<sha1>",
"md5": "<md5>"
}
]
},
{
"name": "releaseVariantReleaseRuntimePublication",
"attributes": {
"org.gradle.category": "library",
"org.gradle.dependency.bundling": "external",
"org.gradle.libraryelements": "aar",
"org.gradle.usage": "java-runtime"
},
"dependencies": [
{
"group": "org.jetbrains.kotlin",
"module": "kotlin-stdlib",
"version": {
"requires": "1.6.21"
}
},
{
"group": "io.appmetrica.analytics",
"module": "analytics-core-utils",
"version": {
"requires": "6.4.0"
}
},
{
"group": "io.appmetrica.analytics",
"module": "analytics-logger",
"version": {
"requires": "6.4.0"
}
},
{
"group": "io.appmetrica.analytics",
"module": "analytics-modules-api",
"version": {
"requires": "6.4.0"
}
}
],
"files": [
{
"name": "analytics-ad-revenue-fyber-v3-6.4.0.aar",
"url": "analytics-ad-revenue-fyber-v3-6.4.0.aar",
"size": -1,
"sha512": "<sha512>",
"sha256": "<sha256>",
"sha1": "<sha1>",
"md5": "<md5>"
}
]
}
]
}
61 changes: 61 additions & 0 deletions ad-revenue-fyber-v3/api/releasePom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!-- This module was also published with a richer model, Gradle metadata, -->
<!-- which should be used instead. Do not delete the following line which -->
<!-- is to indicate to Gradle or any Gradle module metadata file consumer -->
<!-- that they should prefer consuming it instead. -->
<!-- do_not_remove: published-with-gradle-metadata -->
<modelVersion>4.0.0</modelVersion>
<groupId>io.appmetrica.analytics</groupId>
<artifactId>analytics-ad-revenue-fyber-v3</artifactId>
<version>6.4.0</version>
<packaging>aar</packaging>
<name>AppMetrica SDK Ad Revenue Auto Collection Adaptet for Fyber v3</name>
<description>AppMetrica SDK Module</description>
<url>https://appmetrica.io/</url>
<licenses>
<license>
<name>MIT License</name>
<url>https://www.opensource.org/licenses/mit-license.php</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<name>AppMetrica</name>
<url>https://appmetrica.io/</url>
</developer>
</developers>
<scm>
<connection>scm:git:https://github.com/appmetrica/appmetrica-sdk-android.git</connection>
<developerConnection>scm:git:https://github.com/appmetrica/appmetrica-sdk-android.git</developerConnection>
<url>https://github.com/appmetrica/appmetrica-sdk-android</url>
</scm>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>1.6.21</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.appmetrica.analytics</groupId>
<artifactId>analytics-core-utils</artifactId>
<version>6.4.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.appmetrica.analytics</groupId>
<artifactId>analytics-logger</artifactId>
<version>6.4.0</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>io.appmetrica.analytics</groupId>
<artifactId>analytics-modules-api</artifactId>
<version>6.4.0</version>
<scope>runtime</scope>
</dependency>
</dependencies>
</project>
3 changes: 3 additions & 0 deletions ad-revenue-fyber-v3/api/releaseProguard.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-dontwarn com.fyber.fairbid.ads.**

-keep class io.appmetrica.analytics.adrevenue.fyber.v3.** { *; }
26 changes: 26 additions & 0 deletions ad-revenue-fyber-v3/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
plugins {
id("appmetrica-module")
}

publishingInfo {
baseArtifactId.set("analytics-ad-revenue-fyber-v3")
name.set("AppMetrica SDK Ad Revenue Auto Collection Adaptet for Fyber v3")
withJavadoc.set(false)
}

android {
namespace = "io.appmetrica.analytics.adrevenue.fyber.v3"

defaultConfig {
missingDimensionStrategy("tier", "binaryProd")
}
}

dependencies {
implementation(project(":core-utils"))
implementation(project(":logger"))
implementation(project(":modules-api"))

compileOnly("com.fyber:fairbid-sdk:3.48.0")
testImplementation("com.fyber:fairbid-sdk:3.48.0")
}
3 changes: 3 additions & 0 deletions ad-revenue-fyber-v3/proguard/consumer-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-dontwarn com.fyber.fairbid.ads.**

-keep class io.appmetrica.analytics.adrevenue.fyber.v3.** { *; }
7 changes: 7 additions & 0 deletions ad-revenue-fyber-v3/proguard/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-include ../../proguard/proguard-root-project.txt

-repackageclasses 'io.appmetrica.analytics.adrevenue.fyber.v3.impl'

-keep public class !io.appmetrica.analytics.adrevenue.fyber.v3.impl.**, io.appmetrica.analytics.adrevenue.fyber.v3.** {
public *;
}
4 changes: 4 additions & 0 deletions ad-revenue-fyber-v3/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>

<manifest>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package io.appmetrica.analytics.adrevenue.fyber.v3.impl;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.fyber.fairbid.ads.ImpressionData;
import com.fyber.fairbid.ads.PlacementType;
import io.appmetrica.analytics.modulesapi.internal.client.adrevenue.AutoAdRevenue;
import io.appmetrica.analytics.modulesapi.internal.client.adrevenue.AutoAdType;
import java.math.BigDecimal;
import java.util.Currency;

public class AdRevenueConverter {

public AutoAdRevenue convert(@NonNull final ImpressionData data) {
return new AutoAdRevenue(
BigDecimal.valueOf(getFiniteDoubleOrDefault(data.getNetPayout(), 0)), // adRevenue
Currency.getInstance(data.getCurrency()), // currency
convert(data.getPlacementType()), // adType
data.getDemandSource(), // adNetwork
data.getCreativeId(), // adUnitId
null, // adUnitName
null, // adPlacementId
null, // adPlacementName
data.getPriceAccuracy().toString(), // precision
null // payload
);
}

@Nullable
private AutoAdType convert(@Nullable final PlacementType type) {
if (type == null) {
return null;
}
switch (type) {
case BANNER: return AutoAdType.BANNER;
case REWARDED: return AutoAdType.REWARDED;
case INTERSTITIAL: return AutoAdType.INTERSTITIAL;
default: return AutoAdType.OTHER;
}
}

private double getFiniteDoubleOrDefault(double input, double fallback) {
return Double.isNaN(input) || Double.isInfinite(input) ? fallback : input;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.appmetrica.analytics.adrevenue.fyber.v3.impl;

public class Constants {

public static final String MODULE_ID = "ad-revenue-fyber-v3";
public static final String LIBRARY_MAIN_CLASS = "com.fyber.fairbid.ads.Interstitial";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.appmetrica.analytics.adrevenue.fyber.v3.impl;

import androidx.annotation.NonNull;
import com.fyber.fairbid.ads.Interstitial;
import io.appmetrica.analytics.logger.internal.YLogger;
import io.appmetrica.analytics.modulesapi.internal.client.ClientContext;

public class FyberAdRevenueAdapter {

private static final String TAG = "[FyberAdRevenueAdapter]";

public static void registerListener(@NonNull ClientContext clientContext) {
YLogger.info(TAG, "registerListener");
Interstitial.setInterstitialListener(new FyberAdRevenueDataListener(clientContext));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package io.appmetrica.analytics.adrevenue.fyber.v3.impl;

import androidx.annotation.NonNull;
import com.fyber.fairbid.ads.ImpressionData;
import com.fyber.fairbid.ads.interstitial.InterstitialListener;
import io.appmetrica.analytics.logger.internal.YLogger;
import io.appmetrica.analytics.modulesapi.internal.client.ClientContext;

public class FyberAdRevenueDataListener implements InterstitialListener {

private static final String TAG = "[FyberAdRevenueDataListener]";

@NonNull
private final ClientContext clientContext;
@NonNull
private final AdRevenueConverter adRevenueConverter = new AdRevenueConverter();

public FyberAdRevenueDataListener(@NonNull ClientContext clientContext) {
this.clientContext = clientContext;
}

@Override
public void onUnavailable(@NonNull String s) {
// do nothing
}

@Override
public void onShowFailure(@NonNull String s, @NonNull ImpressionData impressionData) {
// do nothing
}

@Override
public void onShow(@NonNull String s, @NonNull ImpressionData impressionData) {
if (impressionData != null) {
YLogger.info(TAG, "impressionData is " + impressionData.getJsonString());
clientContext.getAutoAdRevenueReporter().reportAutoAdRevenue(adRevenueConverter.convert(impressionData));
} else {
YLogger.info(TAG, "impressionData is null");
}
}

@Override
public void onRequestStart(@NonNull String s, @NonNull String s1) {
// do nothing
}

@Override
public void onHide(@NonNull String s) {
// do nothing
}

@Override
public void onClick(@NonNull String s) {
// do nothing
}

@Override
public void onAvailable(@NonNull String s) {
// do nothing
}
}
Loading

0 comments on commit e40ba5a

Please sign in to comment.