using System; using Unity.Services.Analytics.Internal; using UnityEngine; namespace Unity.Services.Analytics { /// /// 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 /// public class AdImpressionEvent : Event { private static readonly string[] k_AdPlacementTypeValues = Event.BakeEnum2String(); private static readonly string[] k_AdProviderValues = Event.BakeEnum2String(true); private static readonly string[] k_AdCompletionStatusValues = Event.BakeEnum2String(true); public AdImpressionEvent() : base("adImpression", true, 1) { } /// /// 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 /// public AdCompletionStatus AdCompletionStatus { set { SetParameter("adCompletionStatus", k_AdCompletionStatusValues[(int)value]); } } /// /// 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. /// public AdProvider AdProvider { set { SetParameter("adProvider", k_AdProviderValues[(int)value]); } } /// /// The unique identifier for the placement where the Ad appeared as integrated into the game. /// public string PlacementId { set { SetParameter("placementId", value); } } /// /// 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. /// public string PlacementName { set { SetParameter("placementName", value); } } /// /// (Optional) Indicates what type of ad is shown - for example, REWARDED, INTERSTITIAL or BANNER. /// public AdPlacementType PlacementType { set { SetParameter("placementType", k_AdPlacementTypeValues[(int)value]); } } /// /// (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. /// public double AdEcpmUsd { set { SetParameter("adEcpmUsd", value); } } /// /// (Optional) The store the player is directed to after clicking the ad - for example, Google Play, App Store, Amazon. /// public string AdStoreDestinationId { set { SetParameter("adStoreDestinationID", value); } } /// /// (Optional) The Ad SDK version you are using. /// public string AdSdkVersion { set { SetParameter("adSdkVersion", value); } } /// /// (Optional) /// public string AdImpressionId { set { SetParameter("adImpressionID", value); } } /// /// (Optional) /// public string AdMediaType { set { SetParameter("adMediaType", value); } } /// /// (Optional) /// public long AdTimeWatchedMs { set { SetParameter("adTimeWatchedMs", value); } } /// /// (Optional) /// public long AdTimeCloseButtonShownMs { set { SetParameter("adTimeCloseButtonShownMs", value); } } /// /// (Optional) /// public long AdLengthMs { set { SetParameter("adLengthMs", value); } } /// /// (Optional) /// public bool AdHasClicked { set { SetParameter("adHasClicked", value); } } /// /// (Optional) /// public string AdSource { set { SetParameter("adSource", value); } } /// /// (Optional) /// 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."); } } } }