/// <summary> /// Constructor of <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.DeliveryClient"/> class. /// </summary> /// <param name="policyFactory">An instance of IDeliveryPolicyFactory. <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.IDeliveryPolicyFactory"/></param> /// <param name="maConfig">Mobile Analytics Manager configuration. <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.MobileAnalyticsManagerConfig"/></param> /// <param name="clientContext">An instance of ClientContext. <see cref="Amazon.Runtime.Internal.ClientContext"/></param> /// <param name="credentials">An instance of Credentials. <see cref="Amazon.Runtime.AWSCredentials"/></param> /// <param name="regionEndPoint">Region endpoint. <see cref="Amazon.RegionEndpoint"/></param> public DeliveryClient(IDeliveryPolicyFactory policyFactory, MobileAnalyticsManagerConfig maConfig, ClientContext clientContext, AWSCredentials credentials, RegionEndpoint regionEndPoint) { _policyFactory = policyFactory; _deliveryPolicies = new List<IDeliveryPolicy>(); _deliveryPolicies.Add(_policyFactory.NewConnectivityPolicy()); _clientContext = clientContext; _appID = clientContext.AppID; _maConfig = maConfig; _eventStore = new SQLiteEventStore(maConfig); #if PCL _mobileAnalyticsLowLevelClient = new AmazonMobileAnalyticsClient(credentials, regionEndPoint); #elif BCL if (null == credentials && null == regionEndPoint) { _mobileAnalyticsLowLevelClient = new AmazonMobileAnalyticsClient(); } else if (null == credentials) { _mobileAnalyticsLowLevelClient = new AmazonMobileAnalyticsClient(regionEndPoint); } else if (null == regionEndPoint) { _mobileAnalyticsLowLevelClient = new AmazonMobileAnalyticsClient(credentials); } else { _mobileAnalyticsLowLevelClient = new AmazonMobileAnalyticsClient(credentials, regionEndPoint); } #endif }
/// <summary> /// Constructor of <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.SQLiteEventStore"/> /// </summary> /// <param name="maConfig">Mobile Analytics Manager Configuration.</param> public SQLiteEventStore(MobileAnalyticsManagerConfig maConfig) { _maConfig = maConfig; #if BCL _dbFileFullPath = InternalSDKUtils.DetermineAppLocalStoragePath(dbFileName); #elif PCL _dbFileFullPath = System.IO.Path.Combine(PCLStorage.FileSystem.Current.LocalStorage.Path, dbFileName); #endif _logger.InfoFormat("Initialize SQLite event store. The SQLite DB file path is {0}.", _dbFileFullPath); SetupSQLiteEventStore(); }
/// <summary> /// Gets or creates Mobile Analytics Manager instance. If the instance already exists, returns the instance; otherwise /// creates new instance and returns it. /// </summary> /// <param name="appID">Amazon Mobile Analytics Application ID.</param> /// <param name="credentials">AWS Credentials.</param> /// <param name="regionEndpoint">Region endpoint.</param> /// <returns>Mobile Analytics Manager instance.</returns> public static MobileAnalyticsManager GetOrCreateInstance(string appID, AWSCredentials credentials, RegionEndpoint regionEndpoint) { if (string.IsNullOrEmpty(appID)) throw new ArgumentNullException("appID"); if (null == credentials) throw new ArgumentNullException("credentials"); if (null == regionEndpoint) throw new ArgumentNullException("regionEndpoint"); MobileAnalyticsManagerConfig maConfig = new MobileAnalyticsManagerConfig(); return GetOrCreateInstanceHelper(appID, credentials, regionEndpoint, maConfig); }
/// <summary> /// Constructor of <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.DeliveryClient"/> class. /// </summary> /// <param name="policyFactory">An instance of IDeliveryPolicyFactory <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.IDeliveryPolicyFactory"/></param> /// <param name="maConfig"></param> /// <param name="maManager"></param> /// <param name="clientContext">An instance of ClientContext <see cref="Amazon.Runtime.Internal.ClientContext"/></param> /// <param name="credentials">An instance of Credentials <see cref="Amazon.Runtime.AWSCredentials"/></param> /// <param name="regionEndPoint">Region end point <see cref="Amazon.RegionEndpoint"/></param> public DeliveryClient(IDeliveryPolicyFactory policyFactory, MobileAnalyticsManagerConfig maConfig, ClientContext clientContext, AWSCredentials credentials, RegionEndpoint regionEndPoint, MobileAnalyticsManager maManager) { _policyFactory = policyFactory; _mobileAnalyticsLowLevelClient = new AmazonMobileAnalyticsClient(credentials, regionEndPoint); _clientContext = clientContext; _appID = clientContext.AppID; _maConfig = maConfig; _maManager = maManager; _eventStore = new SQLiteEventStore(maConfig); _deliveryPolicies = new List<IDeliveryPolicy>(); _deliveryPolicies.Add(_policyFactory.NewConnectivityPolicy()); }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { // Override point for customization after application launch. // If not required for your application you can safely delete this method // customize your Mobile Analytics Manager Config MobileAnalyticsManagerConfig config = new MobileAnalyticsManagerConfig(); config.AllowUseDataNetwork = true; ViewController.Manager = MobileAnalyticsManager.GetOrCreateInstance(APP_ID, new CognitoAWSCredentials(COGNITO_POOL_ID, COGNITO_REGION), RegionEndpoint.USEast1, config); return true; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button customEventButton = FindViewById<Button>(Resource.Id.button_custom_event); Button monetizationEventButton = FindViewById<Button>(Resource.Id.button_monetization_event); customEventButton.Click += delegate { CustomEvent customEvent = new CustomEvent("level_complete"); customEvent.AddAttribute("LevelName", "Level5"); customEvent.AddAttribute("Successful", "True"); customEvent.AddMetric("Score", 12345); customEvent.AddMetric("TimeInLevel", 64); _manager.RecordEvent(customEvent); }; monetizationEventButton.Click += delegate { MonetizationEvent monetizationEvent = new MonetizationEvent(); monetizationEvent.Quantity = 10.0; monetizationEvent.ItemPrice = 2.00; monetizationEvent.ProductId = "ProductId123"; monetizationEvent.ItemPriceFormatted = "$2.00"; monetizationEvent.Store = "Amazon"; monetizationEvent.TransactionId = "TransactionId123"; monetizationEvent.Currency = "USD"; _manager.RecordEvent(monetizationEvent); }; // customize your Mobile Analytics Manager Config MobileAnalyticsManagerConfig config = new MobileAnalyticsManagerConfig(); config.AllowUseDataNetwork = true; _manager = MobileAnalyticsManager.GetOrCreateInstance(APP_ID, new CognitoAWSCredentials(COGNITO_POOL_ID, COGNITO_REGION), RegionEndpoint.USEast1, config); }
/// <summary> /// Gets or creates Mobile Analytics Manager instance. If the instance already exists, returns the instance; otherwise /// creates new instance and returns it. /// </summary> /// <param name="appID">Amazon Mobile Analytics Application ID.</param> /// <param name="credentials">AWS Credentials.</param> /// <param name="regionEndpoint">Region endpoint.</param> /// <param name="maConfig">Amazon Mobile Analytics Manager configuration.</param> /// <returns>Mobile Analytics Manager instance. </returns> public static MobileAnalyticsManager GetOrCreateInstance(string appID, AWSCredentials credentials, RegionEndpoint regionEndpoint, MobileAnalyticsManagerConfig maConfig) { if (string.IsNullOrEmpty(appID)) { throw new ArgumentNullException("appID"); } if (null == credentials) { throw new ArgumentNullException("credentials"); } if (null == regionEndpoint) { throw new ArgumentNullException("regionEndpoint"); } if (null == maConfig) { throw new ArgumentNullException("maConfig"); } return(GetOrCreateInstanceHelper(appID, credentials, regionEndpoint, maConfig)); }
private MobileAnalyticsManager(string appID, AWSCredentials credentials, RegionEndpoint regionEndpoint, MobileAnalyticsManagerConfig maConfig) { #if PCL || UNITY this.ClientContext = new ClientContext(appID); #elif BCL if (null == maConfig) { maConfig = new MobileAnalyticsManagerConfig(); } this.ClientContext = new ClientContext(appID, maConfig.ClientContextConfiguration); #endif this.BackgroundDeliveryClient = new DeliveryClient(maConfig, ClientContext, credentials, regionEndpoint, this); this.Session = new Session(appID, maConfig); }
private static MobileAnalyticsManager GetOrCreateInstanceHelper(string appID, AWSCredentials credentials, RegionEndpoint regionEndpoint, MobileAnalyticsManagerConfig maConfig) { #if BCL ValidateParameters(); #endif MobileAnalyticsManager managerInstance = null; bool isNewInstance = false; lock (_lock) { if (_instanceDictionary.TryGetValue(appID, out managerInstance)) { return(managerInstance); } else { managerInstance = new MobileAnalyticsManager(appID, credentials, regionEndpoint, maConfig); _instanceDictionary[appID] = managerInstance; isNewInstance = true; } } if (isNewInstance) { managerInstance.Session.Start(); } _backgroundRunner.StartWork(); return(managerInstance); }
/// <summary> /// Constructor of <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.DeliveryClient"/> class. /// </summary> /// <param name="maConfig">Mobile Analytics Manager configuration. <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.MobileAnalyticsManagerConfig"/></param> /// <param name="clientContext">An instance of ClientContext. <see cref="Amazon.Runtime.Internal.ClientContext"/></param> /// <param name="credentials">An instance of Credentials. <see cref="Amazon.Runtime.AWSCredentials"/></param> /// <param name="regionEndPoint">Region endpoint. <see cref="Amazon.RegionEndpoint"/></param> public DeliveryClient(MobileAnalyticsManagerConfig maConfig, ClientContext clientContext, AWSCredentials credentials, RegionEndpoint regionEndPoint) : this(new DeliveryPolicyFactory(maConfig.AllowUseDataNetwork), maConfig, clientContext, credentials, regionEndPoint) { }
private MobileAnalyticsManager(string appID, AWSCredentials credentials, RegionEndpoint regionEndpoint, MobileAnalyticsManagerConfig maConfig) { #if PCL this.ClientContext = new ClientContext(appID); #elif BCL if (null == maConfig) maConfig = new MobileAnalyticsManagerConfig(); this.ClientContext = new ClientContext(appID, maConfig.ClientContextConfiguration); #endif this.BackgroundDeliveryClient = new DeliveryClient(maConfig, ClientContext, credentials, regionEndpoint, this); this.Session = new Session(appID, maConfig); }
private static MobileAnalyticsManager GetOrCreateInstanceHelper(string appID, AWSCredentials credentials, RegionEndpoint regionEndpoint, MobileAnalyticsManagerConfig maConfig) { #if BCL ValidateParameters(); #endif MobileAnalyticsManager managerInstance = null; bool isNewInstance = false; lock (_lock) { if (_instanceDictionary.TryGetValue(appID, out managerInstance)) { return managerInstance; } else { managerInstance = new MobileAnalyticsManager(appID, credentials, regionEndpoint, maConfig); _instanceDictionary[appID] = managerInstance; isNewInstance = true; } } if (isNewInstance) { managerInstance.Session.Start(); } return managerInstance; }
/// <summary> /// Gets or creates Mobile Analytics Manager instance. If the instance already exists, returns the instance; otherwise /// creates new instance and returns it. /// </summary> /// <param name="appID">Amazon Mobile Analytics Application ID.</param> /// <param name="maConfig">Amazon Mobile Analytics Manager configuration.</param> /// <returns>Mobile Analytics Manager instance. </returns> public static MobileAnalyticsManager GetOrCreateInstance(string appID, MobileAnalyticsManagerConfig maConfig) { if (string.IsNullOrEmpty(appID)) throw new ArgumentNullException("appID"); if (null == maConfig) throw new ArgumentNullException("maConfig"); return GetOrCreateInstanceHelper(appID, null, null, maConfig); }
private static MobileAnalyticsManager GetOrCreateInstanceHelper(string appID, AWSCredentials credentials, RegionEndpoint regionEndpoint, MobileAnalyticsManagerConfig maConfig) { #if BCL ValidateParameters(); #endif MobileAnalyticsManager managerInstance = null; bool isNewInstance = false; lock (_lock) { if (_instanceDictionary.TryGetValue(appID, out managerInstance)) { return(managerInstance); } else { managerInstance = new MobileAnalyticsManager(appID, credentials, regionEndpoint, maConfig); _instanceDictionary[appID] = managerInstance; isNewInstance = true; } } if (isNewInstance) { managerInstance.Session.Start(); } #if UNITY if (UnityEngine.Application.platform == UnityEngine.RuntimePlatform.WebGLPlayer) { _coroutineRunner.StartWork(); } else { _backgroundRunner.StartWork(); } #else _backgroundRunner.StartWork(); #endif return(managerInstance); }
/// <summary> /// Constructor of <see cref="Amazon.MobileAnalytics.MobileAnalyticsManager.Internal.SQLiteEventStore"/> /// </summary> /// <param name="maConfig">Mobile Analytics Manager Configuration.</param> public SQLiteEventStore(MobileAnalyticsManagerConfig maConfig) { _maConfig = maConfig; }