using System;
using UnityEngine;
namespace Unity.Services.Analytics
{
public static partial class Events
{
[Obsolete("This enum has been moved outside the Events class. Please use that instead. This enum will be removed in an upcoming release.")]
public enum AdCompletionStatus
{
///
/// If the ad is fully viewed and therefore will count as an impression for the ad network.
///
Completed = 0,
///
/// If there is an option to exit the ad before generating revenue.
///
Partial = 1,
///
/// If the ad is not viewed at all (alternatively, don’t record the adImpression event in.
///
Incomplete = 2
}
[Obsolete("This enum has been moved outside the Events class. Please use that instead. This enum will be removed in an upcoming release.")]
public enum AdProvider
{
AdColony = 0,
AdMob = 1,
Amazon = 2,
AppLovin = 3,
ChartBoost = 4,
Facebook = 5,
Fyber = 6,
Hyprmx = 7,
Inmobi = 8,
Maio = 9,
Pangle = 10,
Tapjoy = 11,
UnityAds = 12,
Vungle = 13,
IrnSource = 14,
Other = 15
}
///
/// Helper object to handle arguments for recording an AdImpression event.
///
[Obsolete("This class has been aligned with other interfaces. Please use AdImpressionParameters with the AnalyticsService.Instance API instead. This class will be removed in an upcoming release")]
public class AdImpressionArgs
{
/// (Required) Indicates a successful Ad view. Select one of the `AdCompletionStatus` values.
/// (Required) The Ad SDK that provided the Ad. Select one of the `AdProvider` values.
/// (Required) The unique identifier for the placement as integrated into the game.
/// (Required) If there is a place in the game that can show Ads from multiple networks, there won’t be a single placementId. This field compensates for that by providing a single name for your placement. Ideally, this would be an easily human-readable name such as ‘revive’ or ‘daily bonus’. This value is here for reporting purposes only.
public AdImpressionArgs(AdCompletionStatus adCompletionStatus, AdProvider adProvider, string placementID, string placementName)
{
AdCompletionStatus = adCompletionStatus;
AdProvider = adProvider;
PlacementID = placementID;
PlacementName = placementName;
}
///
/// Indicates whether the Ad view was successful or not.
///
public AdCompletionStatus AdCompletionStatus { get; set; }
///
/// The Ad SDK that provided the Ad.
///
public AdProvider AdProvider { get; set; }
///
/// The unique identifier for the placement where the Ad appeared as integrated into the game.
///
public string PlacementID { get; set; }
///
/// If there is a place in the game that can show Ads from multiple networks, there won’t be a single placementId. This field compensates for that by providing a single name for your placement. Ideally, this would be an easily human-readable name such as ‘revive’ or ‘daily bonus’.
/// This value is here for reporting purposes only.
///
public string PlacementName { get; set; }
///
/// Optional.
/// The placementType should indicate what type of Ad is shown.
/// This value is here for reporting purposes only.
///
public string PlacementType { get; set; }
///
/// Optional.
/// The estimated ECPM in USD, you should populate this value if you can.
///
public double? AdEcpmUsd { get; set; }
///
/// Optional.
/// The Ad SDK version you are using.
///
public string SdkVersion { get; set; }
///
/// Optional.
///
public string AdImpressionID { get; set; }
///
/// Optional.
///
public string AdStoreDstID { get; set; }
///
/// Optional.
///
public string AdMediaType { get; set; }
///
/// Optional.
///
public Int64? AdTimeWatchedMs { get; set; }
///
/// Optional.
///
public Int64? AdTimeCloseButtonShownMs { get; set; }
///
/// Optional.
///
public Int64? AdLengthMs { get; set; }
///
/// Optional.
///
public bool? AdHasClicked { get; set; }
///
/// Optional.
///
public string AdSource { get; set; }
///
/// Optional.
///
public string AdStatusCallback { get; set; }
}
///
/// Record an Ad Impression event.
///
/// (Required) Helper object to handle arguments.
[Obsolete("The interface provided by this method has moved to AnalyticsService.Instance.AdImpression, and should be accessed from there instead. This API will be removed in an upcoming release.")]
public static void AdImpression(AdImpressionArgs args)
{
// Enum.TryParse will fill out placementType if possible, but if it returns false or we get passed a null value we need to provide a default value to prevent runtime problems.
if (!string.IsNullOrEmpty(args.PlacementType) || !Enum.TryParse(args.PlacementType, out AdPlacementType placementType))
{
placementType = AdPlacementType.BANNER;
}
var newParams = new AdImpressionParameters
{
AdCompletionStatus = (Analytics.AdCompletionStatus)(int)args.AdCompletionStatus,
AdProvider = (Analytics.AdProvider)(int)args.AdProvider,
AdEcpmUsd = args.AdEcpmUsd,
AdHasClicked = args.AdHasClicked,
AdImpressionID = args.AdImpressionID,
AdLengthMs = args.AdLengthMs,
AdMediaType = args.AdMediaType,
AdSource = args.AdSource,
AdStatusCallback = args.AdStatusCallback,
AdStoreDstID = args.AdStoreDstID,
AdTimeCloseButtonShownMs = args.AdTimeCloseButtonShownMs,
AdTimeWatchedMs = args.AdTimeWatchedMs,
PlacementID = args.PlacementID,
PlacementName = args.PlacementName,
PlacementType = placementType,
SdkVersion = args.SdkVersion
};
AnalyticsService.Instance.AdImpression(newParams);
}
}
}