Skip to content

Commit ca1386b

Browse files
committed
- update for new version Appsflyer
1 parent 304fd87 commit ca1386b

File tree

3 files changed

+38
-36
lines changed

3 files changed

+38
-36
lines changed

README.md

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,27 @@
2424

2525
### Add the line below to `Packages/manifest.json`
2626

27-
for version `1.0.3`
27+
for version `1.0.4`
28+
2829
```csharp
29-
"com.wolf-org.tracking":"https://github.com/unity-package/app-tracking-unity.git#1.0.3",
30+
"com.wolf-org.tracking":"https://github.com/unity-package/app-tracking-unity.git#1.0.4",
3031
```
3132

3233
## Use
3334

3435
#### Firebase Tracking
3536

36-
- Add define symbols `VIRTUESKY_FIREBASE_ANALYTIC` to use ([Get Firebase Analytic Sdk](https://github.com/firebase-unity/firebase-analytics))
37+
- Add define symbols `VIRTUESKY_FIREBASE_ANALYTIC` to
38+
use ([Get Firebase Analytic Sdk](https://github.com/firebase-unity/firebase-analytics))
3739
- Tracking event
40+
3841
```csharp
3942
static void TrackEvent(string eventName)
4043
static void TrackEvent(string eventName, string parameterName, string parameterValue)
4144
static void TrackEvent(string eventName, Dictionary<string, string> dictParameters)
4245
static void TrackEvent(string eventName, Parameter[] parameters)
4346
```
47+
4448
Example
4549

4650
```csharp
@@ -84,6 +88,7 @@ Example
8488
```csharp
8589
static void FirebaseAnalyticTrackRevenue(double value, string network, string unitId, string format, string adNetwork)
8690
```
91+
8792
Example
8893

8994
```csharp
@@ -103,6 +108,7 @@ Example
103108
```
104109

105110
Example
111+
106112
```csharp
107113
void TrackingEventAdjust()
108114
{
@@ -111,9 +117,11 @@ Example
111117
```
112118

113119
- Tracking ads revenue
120+
114121
```csharp
115122
static void AdjustTrackRevenue(double value, string network, string unitId, string placement, string adNetwork)
116123
```
124+
117125
Example
118126

119127
```csharp
@@ -125,7 +133,8 @@ Example
125133

126134
#### AppsFlyer Tracking
127135

128-
- Add define symbol `VIRTUESKY_APPSFLYER` to use ([Get Appsflyer Sdk](https://github.com/AppsFlyerSDK/appsflyer-unity-plugin) , [Get AppsFlyer AdRevenue](https://github.com/AppsFlyerSDK/appsflyer-unity-adrevenue-generic-connector))
136+
- Add define symbol `VIRTUESKY_APPSFLYER` to
137+
use ([Get Appsflyer Sdk](https://github.com/AppsFlyerSDK/appsflyer-unity-plugin) , [Get AppsFlyer AdRevenue](https://github.com/AppsFlyerSDK/appsflyer-unity-adrevenue-generic-connector))
129138
- Tracking event
130139

131140
```csharp
@@ -160,6 +169,7 @@ Example
160169
AppsFlyerTracking.TrackEvent("WinGame", dict);
161170
}
162171
```
172+
163173
- Tracking ads revenue
164174

165175
```csharp
@@ -174,22 +184,28 @@ Example
174184
AppsFlyerTrackingRevenue.AppsFlyerTrackRevenueAd(...);
175185
}
176186
```
187+
177188
- Tracking iap revenue
178-
Add define symbol `VIRTUESKY_IAP` to use
189+
Add define symbol `VIRTUESKY_IAP` to use
190+
179191
```csharp
180192
static void AppFlyerTrackingRevenueInAppPurchase(Product product)
181193
```
182194

183195
Example
196+
184197
```csharp
185198
void TrackingRevenue(Product productIAP)
186199
{
187200
AppsFlyerTrackingRevenue.AppFlyerTrackingRevenueInAppPurchase(productIAP);
188201
}
189202
```
203+
190204
#### App Tracking
191205

192-
- Tracking ad revenue (If calling `Track Revenue` through `App Tracking`, revenue will be tracked in all of Firebase Analytics, Adjust, and AppsFlyer)
206+
- Tracking ad revenue (If calling `Track Revenue` through `App Tracking`, revenue will be tracked in all of Firebase
207+
Analytics, Adjust, and AppsFlyer)
208+
193209
```csharp
194210
static void TrackRevenue(double value, string network, string unitId, string format, string adNetwork)
195211
```
@@ -203,7 +219,7 @@ Example
203219
}
204220
```
205221

206-
- Firebase tracking ATT Results IOS (App Tracking Transparency)
222+
- Firebase tracking ATT Results IOS (App Tracking Transparency)
207223
- Require: `"com.unity.ads.ios-support": "1.2.0"`
208224

209225
```csharp

Runtime/AppsFlyerTracking/AppsFlyerTrackingRevenue.cs

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -9,55 +9,41 @@
99
#endif
1010

1111

12-
namespace VirtueSky.Tracking
13-
{
14-
public struct AppsFlyerTrackingRevenue
15-
{
12+
namespace VirtueSky.Tracking {
13+
public struct AppsFlyerTrackingRevenue {
1614
public static void AppsFlyerTrackRevenueAd(double value, string network, string unitId, string format,
17-
string adNetwork)
18-
{
15+
string adNetwork) {
1916
#if VIRTUESKY_APPSFLYER
20-
var mediationNetworks = AppsFlyerAdRevenueMediationNetworkType
21-
.AppsFlyerAdRevenueMediationNetworkTypeGoogleAdMob;
22-
switch (adNetwork.ToLower())
23-
{
17+
var mediationNetworks = MediationNetwork.GoogleAdMob;
18+
switch (adNetwork.ToLower()) {
2419
case "admob":
25-
mediationNetworks = AppsFlyerAdRevenueMediationNetworkType
26-
.AppsFlyerAdRevenueMediationNetworkTypeGoogleAdMob;
20+
mediationNetworks = MediationNetwork.GoogleAdMob;
2721
break;
2822
case "max":
29-
mediationNetworks = AppsFlyerAdRevenueMediationNetworkType
30-
.AppsFlyerAdRevenueMediationNetworkTypeApplovinMax;
23+
mediationNetworks = MediationNetwork.ApplovinMax;
3124
break;
3225
case "ironsource":
33-
mediationNetworks = AppsFlyerAdRevenueMediationNetworkType
34-
.AppsFlyerAdRevenueMediationNetworkTypeIronSource;
26+
mediationNetworks = MediationNetwork.IronSource;
3527
break;
3628
}
3729

3830
Dictionary<string, string> additionalParams = new Dictionary<string, string>();
39-
additionalParams.Add(AFAdRevenueEvent.COUNTRY, "US");
40-
additionalParams.Add(AFAdRevenueEvent.AD_UNIT, unitId);
41-
additionalParams.Add(AFAdRevenueEvent.AD_TYPE, format);
42-
AppsFlyerAdRevenue.logAdRevenue(network,
43-
mediationNetworks,
44-
value,
45-
"USD",
46-
additionalParams);
31+
additionalParams.Add(AdRevenueScheme.COUNTRY, "US");
32+
additionalParams.Add(AdRevenueScheme.AD_UNIT, unitId);
33+
additionalParams.Add(AdRevenueScheme.AD_TYPE, format);
34+
AppsFlyer.logAdRevenue(new AFAdRevenueData(network, mediationNetworks, "USD", value), additionalParams);
4735
#endif
4836
}
4937
#if VIRTUESKY_APPSFLYER && VIRTUESKY_IAP
50-
public static void AppFlyerTrackingRevenueInAppPurchase(Product product)
51-
{
38+
public static void AppFlyerTrackingRevenueInAppPurchase(Product product) {
5239
Dictionary<string, string> eventValue = new Dictionary<string, string>();
5340
eventValue.Add("af_revenue", GetAppsflyerRevenue(product.metadata.localizedPrice));
5441
eventValue.Add("af_content_id", product.definition.id);
5542
eventValue.Add("af_currency", product.metadata.isoCurrencyCode);
5643
AppsFlyer.sendEvent("af_purchase", eventValue);
5744
}
5845

59-
public static string GetAppsflyerRevenue(decimal amount)
60-
{
46+
public static string GetAppsflyerRevenue(decimal amount) {
6147
decimal val = decimal.Multiply(amount, 0.63m);
6248
return val.ToString();
6349
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "com.wolf-org.tracking",
33
"displayName": "UnityCommon-Tracking",
44
"description": "Tracking for Unity",
5-
"version": "1.0.3",
5+
"version": "1.0.4",
66
"unity": "2021.3",
77
"category": "virtuesky",
88
"license": "MIT",

0 commit comments

Comments
 (0)