123 lines
4.9 KiB
C#
123 lines
4.9 KiB
C#
using System;
|
|
using Unity.Services.Analytics.Internal;
|
|
using UnityEngine;
|
|
|
|
namespace Unity.Services.Analytics
|
|
{
|
|
/// <summary>
|
|
/// Use this class to record adImpression events.
|
|
///
|
|
/// For more information about the adImpression event, see the documentation page:
|
|
/// https://docs.unity.com/ugs/en-us/manual/analytics/manual/record-ad-impression-events
|
|
/// </summary>
|
|
public class AdImpressionEvent : Event
|
|
{
|
|
private static readonly string[] k_AdPlacementTypeValues = Event.BakeEnum2String<AdPlacementType>();
|
|
private static readonly string[] k_AdProviderValues = Event.BakeEnum2String<AdProvider>(true);
|
|
private static readonly string[] k_AdCompletionStatusValues = Event.BakeEnum2String<AdCompletionStatus>(true);
|
|
|
|
public AdImpressionEvent() : base("adImpression", true, 1)
|
|
{
|
|
}
|
|
|
|
/// <summary>
|
|
/// Whether the user watched the entire ad (COMPLETED), part of the ad (PARTIAL) or none of the ad (INCOMPLETE).
|
|
/// Most applicable for interstitial ads which can be skipped by players
|
|
/// </summary>
|
|
public AdCompletionStatus AdCompletionStatus { set { SetParameter("adCompletionStatus", k_AdCompletionStatusValues[(int)value]); } }
|
|
|
|
/// <summary>
|
|
/// The ad network that served the ad - ie, UNITY, IRONSOURCE.
|
|
/// This value is often passed on a per-impression level by your mediation provider or ad network.
|
|
/// </summary>
|
|
public AdProvider AdProvider { set { SetParameter("adProvider", k_AdProviderValues[(int)value]); } }
|
|
|
|
/// <summary>
|
|
/// The unique identifier for the placement where the Ad appeared as integrated into the game.
|
|
/// </summary>
|
|
public string PlacementId { set { SetParameter("placementId", value); } }
|
|
|
|
/// <summary>
|
|
/// The name of the placement as integrated in the game - for example, "Boosters" or "Daily Reward".
|
|
/// This would correlate with the placement name configured in your ad network or mediation provider.
|
|
/// </summary>
|
|
public string PlacementName { set { SetParameter("placementName", value); } }
|
|
|
|
/// <summary>
|
|
/// (Optional) Indicates what type of ad is shown - for example, REWARDED, INTERSTITIAL or BANNER.
|
|
/// </summary>
|
|
public AdPlacementType PlacementType { set { SetParameter("placementType", k_AdPlacementTypeValues[(int)value]); } }
|
|
|
|
/// <summary>
|
|
/// (Optional) eCPM ("effective Cost Per Mille" - the revenue generated by 1000 impressions) in US Dollars.
|
|
/// This value is often passed on a per-impression level by your mediation provider or ad network and used in ad LTV calculations.
|
|
/// </summary>
|
|
public double AdEcpmUsd { set { SetParameter("adEcpmUsd", value); } }
|
|
|
|
/// <summary>
|
|
/// (Optional) The store the player is directed to after clicking the ad - for example, Google Play, App Store, Amazon.
|
|
/// </summary>
|
|
public string AdStoreDestinationId { set { SetParameter("adStoreDestinationID", value); } }
|
|
|
|
/// <summary>
|
|
/// (Optional) The Ad SDK version you are using.
|
|
/// </summary>
|
|
public string AdSdkVersion { set { SetParameter("adSdkVersion", value); } }
|
|
|
|
/// <summary>
|
|
/// (Optional)
|
|
/// </summary>
|
|
public string AdImpressionId { set { SetParameter("adImpressionID", value); } }
|
|
|
|
/// <summary>
|
|
/// (Optional)
|
|
/// </summary>
|
|
public string AdMediaType { set { SetParameter("adMediaType", value); } }
|
|
|
|
/// <summary>
|
|
/// (Optional)
|
|
/// </summary>
|
|
public long AdTimeWatchedMs { set { SetParameter("adTimeWatchedMs", value); } }
|
|
|
|
/// <summary>
|
|
/// (Optional)
|
|
/// </summary>
|
|
public long AdTimeCloseButtonShownMs { set { SetParameter("adTimeCloseButtonShownMs", value); } }
|
|
|
|
/// <summary>
|
|
/// (Optional)
|
|
/// </summary>
|
|
public long AdLengthMs { set { SetParameter("adLengthMs", value); } }
|
|
|
|
/// <summary>
|
|
/// (Optional)
|
|
/// </summary>
|
|
public bool AdHasClicked { set { SetParameter("adHasClicked", value); } }
|
|
|
|
/// <summary>
|
|
/// (Optional)
|
|
/// </summary>
|
|
public string AdSource { set { SetParameter("adSource", value); } }
|
|
|
|
/// <summary>
|
|
/// (Optional)
|
|
/// </summary>
|
|
public string AdStatusCallback { set { SetParameter("adStatusCallback", value); } }
|
|
|
|
public override void Validate()
|
|
{
|
|
base.Validate();
|
|
|
|
if (!ParameterHasBeenSet("placementId"))
|
|
{
|
|
Debug.LogWarning("A value for the PlacementId parameter is required for an AdImpression event.");
|
|
}
|
|
|
|
if (!ParameterHasBeenSet("placementName"))
|
|
{
|
|
Debug.LogWarning("A value for the PlacementName parameter is required for an AdImpression event.");
|
|
}
|
|
}
|
|
}
|
|
}
|