public void UseBadEndpointId() { var request = new PutEventsRequest { EndpointId = "badactor.com?foo=bar" }; var internalRequest = EventBridgeTestUtils.RunMockRequest(request, PutEventsRequestMarshaller.Instance); }
/// <summary> /// Initiates the asynchronous execution of the PutEvents operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the PutEvents operation on AmazonPersonalizeEventsClient.</param> /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param> /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> /// /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndPutEvents /// operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/personalize-events-2018-03-22/PutEvents">REST API Reference for PutEvents Operation</seealso> public virtual IAsyncResult BeginPutEvents(PutEventsRequest request, AsyncCallback callback, object state) { var options = new InvokeOptions(); options.RequestMarshaller = PutEventsRequestMarshaller.Instance; options.ResponseUnmarshaller = PutEventsResponseUnmarshaller.Instance; return(BeginInvoke(request, options, callback, state)); }
public async Task <PutEventsResponse> FunctionHandler(string input, ILambdaContext context) { PutEventsRequest events = SampleData.transactionEvents; AmazonEventBridgeClient client = new AmazonEventBridgeClient(); var response = await client.PutEventsAsync(events); return(response); }
/// <summary> /// Records user interaction event data. For more information see <a>event-record-api</a>. /// </summary> /// <param name="request">Container for the necessary parameters to execute the PutEvents service method.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// /// <returns>The response from the PutEvents service method, as returned by PersonalizeEvents.</returns> /// <exception cref="Amazon.PersonalizeEvents.Model.InvalidInputException"> /// Provide a valid value for the field or parameter. /// </exception> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/personalize-events-2018-03-22/PutEvents">REST API Reference for PutEvents Operation</seealso> public virtual Task <PutEventsResponse> PutEventsAsync(PutEventsRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var options = new InvokeOptions(); options.RequestMarshaller = PutEventsRequestMarshaller.Instance; options.ResponseUnmarshaller = PutEventsResponseUnmarshaller.Instance; return(InvokeAsync <PutEventsResponse>(request, options, cancellationToken)); }
public void UseEmptyEndpointId() { var request = new PutEventsRequest { EndpointId = "" }; var internalRequest = EventBridgeTestUtils.RunMockRequest(request, PutEventsRequestMarshaller.Instance); }
internal virtual PutEventsResponse PutEvents(PutEventsRequest request) { var options = new InvokeOptions(); options.RequestMarshaller = PutEventsRequestMarshaller.Instance; options.ResponseUnmarshaller = PutEventsResponseUnmarshaller.Instance; return(Invoke <PutEventsResponse>(request, options)); }
public void UseDefaultEndpointWhenEndpointIdIsNotSet() { var request = new PutEventsRequest { EndpointId = null }; var internalRequest = EventBridgeTestUtils.RunMockRequest(request, PutEventsRequestMarshaller.Instance); Assert.AreEqual("https://events.us-east-1.amazonaws.com/", internalRequest.Endpoint.ToString()); CheckV4Authorization(internalRequest); }
public void UseMrapEndpointWhenEndpointIdIsSet() { var request = new PutEventsRequest { EndpointId = "abc123.456def" }; var internalRequest = EventBridgeTestUtils.RunMockRequest(request, PutEventsRequestMarshaller.Instance); Assert.AreEqual("https://abc123.456def.endpoint.events.amazonaws.com/", internalRequest.Endpoint.ToString()); CheckV4aAuthorization(internalRequest); Assert.AreEqual("*", internalRequest.AuthenticationRegion); Assert.AreEqual("*", internalRequest.Headers["x-amz-region-set"]); }
public async Task <PutEventsResponse> SendEvent(PutEventsRequestEntry eventEntry) { var request = new PutEventsRequest { Entries = { eventEntry } }; PutEventsRequest events = request; AmazonEventBridgeClient client = new AmazonEventBridgeClient(); return(await client.PutEventsAsync(events)); }
public void UseFIPSEndpointWithEndpointIdSet() { var request = new PutEventsRequest { EndpointId = "abc123.456def" }; var config = new AmazonEventBridgeConfig { RegionEndpoint = RegionEndpoint.USEast1, UseFIPSEndpoint = true }; var internalRequest = EventBridgeTestUtils.RunMockRequest(request, PutEventsRequestMarshaller.Instance, config); }
/// <summary> /// 用于Event事件投递 /// </summary> /// <param name="req"><see cref="PutEventsRequest"/></param> /// <returns><see cref="PutEventsResponse"/></returns> public PutEventsResponse PutEventsSync(PutEventsRequest req) { JsonResponseModel <PutEventsResponse> rsp = null; try { var strResp = this.InternalRequestSync(req, "PutEvents"); rsp = JsonConvert.DeserializeObject <JsonResponseModel <PutEventsResponse> >(strResp); } catch (JsonSerializationException e) { throw new TencentCloudSDKException(e.Message); } return(rsp.Response); }
public void TestLowLevelAPIErrorCaseEmptyEvent() { PutEventsRequest putRequest = new PutEventsRequest(); string clientContext = BuildClientContext(); Console.WriteLine("client context is {0}", clientContext); putRequest.ClientContext = Convert.ToBase64String( System.Text.Encoding.UTF8.GetBytes(clientContext)); putRequest.ClientContextEncoding = "base64"; var exception = AssertExtensions.ExpectExceptionAsync <AmazonMobileAnalyticsException>(Client.PutEventsAsync(putRequest)).Result; Assert.AreEqual(exception.StatusCode, HttpStatusCode.BadRequest); Assert.AreEqual(exception.ErrorCode, "ValidationException"); }
public void UseDefaultIsoEndpointWhenEndpointIdIsNotSet() { var request = new PutEventsRequest { EndpointId = null }; var config = new AmazonEventBridgeConfig { RegionEndpoint = RegionEndpoint.USIsoEast1 }; var internalRequest = EventBridgeTestUtils.RunMockRequest(request, PutEventsRequestMarshaller.Instance, config); Assert.AreEqual("https://events.us-iso-east-1.c2s.ic.gov/", internalRequest.Endpoint.ToString()); CheckV4Authorization(internalRequest); }
public void UseOverrideEndpointWhenEndpointIdIsNotSet() { var request = new PutEventsRequest { EndpointId = null }; var config = new AmazonEventBridgeConfig { ServiceURL = "https://example.org" }; var internalRequest = EventBridgeTestUtils.RunMockRequest(request, PutEventsRequestMarshaller.Instance, config); Assert.AreEqual("https://example.org/", internalRequest.Endpoint.ToString()); CheckV4Authorization(internalRequest); }
public void UseDualStackEndpointWithEndpointIdNotSet() { var request = new PutEventsRequest { EndpointId = null }; var config = new AmazonEventBridgeConfig { RegionEndpoint = RegionEndpoint.USEast1, UseDualstackEndpoint = true }; var internalRequest = EventBridgeTestUtils.RunMockRequest(request, PutEventsRequestMarshaller.Instance, config); Assert.AreEqual("https://events.us-east-1.api.aws/", internalRequest.Endpoint.ToString()); CheckV4Authorization(internalRequest); }
public void AddEventTracker(string movieItemId, string userId) { try { //record events var eventRequest = new PutEventsRequest { TrackingId = AwsParameterStoreClient.GetClickStreamTrackingId(), UserId = userId, //USER_ID SessionId = Guid.NewGuid().ToString() //SESSION_ID }; var ev1 = new TrackingEvent { itemId = movieItemId }; var ev = JsonConvert.SerializeObject(ev1); var e = new Event { //e.EventId = "event1"; EventType = "click", //EVENT_TYPE Properties = ev, SentAt = DateTime.Now //TIMESTAMP }; var events = new List <Event> { e }; eventRequest.EventList = events; var amazonPersonalizeEventsClient = new AmazonPersonalizeEventsClient(RegionEndpoint.USEast1); amazonPersonalizeEventsClient.PutEventsAsync(eventRequest); Logger.LogInformation("Adding a clickstream event for userid:" + userId + ", movieitemid: " + movieItemId); } catch (Exception exception) { throw; } }
public void UseOverrideEndpointWhenEndpointIdIsSet() { var request = new PutEventsRequest { EndpointId = "abc123.456def" }; var config = new AmazonEventBridgeConfig { ServiceURL = "https://example.org" }; var internalRequest = EventBridgeTestUtils.RunMockRequest(request, PutEventsRequestMarshaller.Instance, config); Assert.AreEqual("https://example.org/", internalRequest.Endpoint.ToString()); CheckV4aAuthorization(internalRequest); Assert.AreEqual("*", internalRequest.AuthenticationRegion); Assert.AreEqual("*", internalRequest.Headers["x-amz-region-set"]); }
//[TestMethod] //[TestCategory("MobileAnalytics")] public void TestLowLevelAPIErrorCaseWrongCognitoCred() { List <Amazon.MobileAnalytics.Model.Event> listEvent = new List <Amazon.MobileAnalytics.Model.Event>(); listEvent.Add(BuildCustomEvent()); PutEventsRequest putRequest = new PutEventsRequest(); putRequest.Events = listEvent; string clientContext = BuildClientContext(); Console.WriteLine("client context is {0}", clientContext); putRequest.ClientContext = Convert.ToBase64String( System.Text.Encoding.UTF8.GetBytes(clientContext)); putRequest.ClientContextEncoding = "base64"; PutEventsResponse PutResponse = null; bool hasCatchException = false; AmazonMobileAnalyticsClient client = new AmazonMobileAnalyticsClient(new CognitoAWSCredentials("wrong-cognito-pool-id", RegionEndpoint.USEast1), RegionEndpoint.USEast1); try { PutResponse = client.PutEvents(putRequest); } catch (AmazonMobileAnalyticsException e) { Console.WriteLine("Get AmazonMobileAnalyticsException: error code : {0} ; error type : {1} ; request id : {2} ; status code : {3} ; error message is {4}", e.ErrorCode, e.ErrorType, e.RequestId, e.StatusCode, e.Message); Assert.Fail(); } catch (AmazonServiceException e) { Console.WriteLine("Get AmazonServiceException: error code : {0} ; error type : {1} ; request id : {2} ; status code : {3} ; error message is {4}", e.ErrorCode, e.ErrorType, e.RequestId, e.StatusCode, e.Message); Assert.AreEqual(e.StatusCode, HttpStatusCode.BadRequest); Assert.AreEqual(true, e.ErrorCode.Equals("ValidationException", StringComparison.InvariantCultureIgnoreCase)); hasCatchException = true; } if (!hasCatchException) { Assert.Fail(); } }
public void UseDualStackEndpointWithEndpointIdSet() { var request = new PutEventsRequest { EndpointId = "abc123.456def" }; var config = new AmazonEventBridgeConfig { RegionEndpoint = RegionEndpoint.USEast1, UseDualstackEndpoint = true }; var internalRequest = EventBridgeTestUtils.RunMockRequest(request, PutEventsRequestMarshaller.Instance, config); Assert.AreEqual("https://abc123.456def.endpoint.events.api.aws/", internalRequest.Endpoint.ToString()); CheckV4aAuthorization(internalRequest); Assert.AreEqual("*", internalRequest.AuthenticationRegion); Assert.AreEqual("*", internalRequest.Headers["x-amz-region-set"]); }
//[TestMethod] //[TestCategory("MobileAnalytics")] public void TestLowLevelAPI() { List <Amazon.MobileAnalytics.Model.Event> listEvent = new List <Amazon.MobileAnalytics.Model.Event>(); listEvent.Add(BuildCustomEvent()); PutEventsRequest putRequest = new PutEventsRequest(); putRequest.Events = listEvent; string clientContext = BuildClientContext(); Console.WriteLine("client ocntext is {0}", clientContext); putRequest.ClientContext = Convert.ToBase64String( System.Text.Encoding.UTF8.GetBytes(clientContext)); putRequest.ClientContextEncoding = "base64"; PutEventsResponse PutResponse = Client.PutEvents(putRequest); Assert.AreEqual(HttpStatusCode.Accepted, PutResponse.HttpStatusCode); }
public void TestSessionEvent() { string sessionID = Guid.NewGuid().ToString(); List <Amazon.MobileAnalytics.Model.Event> listEvent = new List <Amazon.MobileAnalytics.Model.Event>(); listEvent.Add(BuildSessionStartEvent(sessionID)); listEvent.Add(BuildSessionEndEvent(sessionID)); PutEventsRequest putRequest = new PutEventsRequest(); putRequest.Events = listEvent; string clientContext = BuildClientContext(); putRequest.ClientContext = Convert.ToBase64String( System.Text.Encoding.UTF8.GetBytes(clientContext)); putRequest.ClientContextEncoding = "base64"; AutoResetEvent ars = new AutoResetEvent(false); Exception responseException = new Exception(); HttpStatusCode httpStatusCode = HttpStatusCode.Forbidden; Client.PutEventsAsync(new PutEventsRequest() { ClientContext = Convert.ToBase64String( System.Text.Encoding.UTF8.GetBytes(clientContext)), ClientContextEncoding = "base64", Events = listEvent }, (response) => { responseException = response.Exception; if (responseException == null) { httpStatusCode = response.Response.HttpStatusCode; } ars.Set(); }, new AsyncOptions { ExecuteCallbackOnMainThread = false }); ars.WaitOne(); Assert.IsNull(responseException); Assert.AreEqual(HttpStatusCode.Accepted, httpStatusCode); }
public void TestSessionEvent() { string sessionID = Guid.NewGuid().ToString(); List <Amazon.MobileAnalytics.Model.Event> listEvent = new List <Amazon.MobileAnalytics.Model.Event>(); listEvent.Add(BuildSessionStartEvent(sessionID)); listEvent.Add(BuildSessionEndEvent(sessionID)); PutEventsRequest putRequest = new PutEventsRequest(); putRequest.Events = listEvent; string clientContext = BuildClientContext(); putRequest.ClientContext = Convert.ToBase64String( System.Text.Encoding.UTF8.GetBytes(clientContext)); putRequest.ClientContextEncoding = "base64"; PutEventsResponse PutResponse = Client.PutEventsAsync(putRequest).Result; Assert.AreEqual(HttpStatusCode.Accepted, PutResponse.HttpStatusCode); }
/// <summary> /// Initiates the asynchronous execution of the PutEvents operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the PutEvents operation on AmazonMobileAnalyticsClient.</param> /// <param name="callback">An Action delegate that is invoked when the operation completes.</param> /// <param name="options">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.</param> public void PutEventsAsync(PutEventsRequest request, AmazonServiceCallback <PutEventsRequest, PutEventsResponse> callback, AsyncOptions options = null) { options = options == null?new AsyncOptions():options; var marshaller = new PutEventsRequestMarshaller(); var unmarshaller = PutEventsResponseUnmarshaller.Instance; Action <AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null; if (callback != null) { callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { AmazonServiceResult <PutEventsRequest, PutEventsResponse> responseObject = new AmazonServiceResult <PutEventsRequest, PutEventsResponse>((PutEventsRequest)req, (PutEventsResponse)res, ex, ao.State); callback(responseObject); } } ; BeginInvoke <PutEventsRequest>(request, marshaller, unmarshaller, options, callbackHelper); } #endregion }
public void TestLowLevelAPIErrorCaseWrongCognitoCred() { List <Amazon.MobileAnalytics.Model.Event> listEvent = new List <Amazon.MobileAnalytics.Model.Event>(); listEvent.Add(BuildCustomEvent()); PutEventsRequest putRequest = new PutEventsRequest(); putRequest.Events = listEvent; string clientContext = BuildClientContext(); Console.WriteLine("client context is {0}", clientContext); putRequest.ClientContext = Convert.ToBase64String( System.Text.Encoding.UTF8.GetBytes(clientContext)); putRequest.ClientContextEncoding = "base64"; PutEventsResponse PutResponse = null; AmazonServiceException exception = null; AmazonMobileAnalyticsClient client = new AmazonMobileAnalyticsClient(new CognitoAWSCredentials("wrong-cognito-pool-id", RegionEndpoint.USEast1), RegionEndpoint.USEast1); try { PutResponse = client.PutEventsAsync(putRequest).Result; } catch (AggregateException ae) { foreach (var e in ae.InnerExceptions) { if (e is AmazonServiceException) { exception = e as AmazonServiceException; break; } } } Assert.IsNotNull(exception); Assert.AreEqual(exception.StatusCode, HttpStatusCode.BadRequest); Assert.AreEqual(exception.ErrorCode, "ValidationException"); }
public static void PutEventExample() { AmazonCloudWatchEventsClient client = new AmazonCloudWatchEventsClient(); var putEventsRequest = new PutEventsRequest { Entries = new List <PutEventsRequestEntry> { new PutEventsRequestEntry { Detail = @"{ ""key1"" : ""value1"", ""key2"" : ""value2"" }", DetailType = "appRequestSubmitted", Resources = { "RESOURCE_ARN" }, Source = "com.compnay.myapp" } } }; client.PutEvents(putEventsRequest); }
//TrackException will send the entire monitored exception from WorkBench to CloudWatch. public override void TrackException(Exception exception) { //Create a object to send the event PutEventsRequest PutEventsRequest putEventsRequest = new PutEventsRequest() { //Create a Entries of the request Entries = new List <PutEventsRequestEntry>() { //Compose the object dynamically new PutEventsRequestEntry() { Detail = exception.Message, DetailType = "Exception", Resources = { exception.TargetSite.Name, exception.HelpLink }, Source = exception.StackTrace, Time = DateTime.Now } } }; //Client send to AWS am event for be registred. _amazonCloudEvents.PutEventsAsync(putEventsRequest); }
private PutEventsRequest CreatePublishRequest(ApplicationMessage message) { string invokedLambdaArn = GetInvokedLambdaArn(); var request = new PutEventsRequest { Entries = new List <PutEventsRequestEntry> { new PutEventsRequestEntry { Source = "Genesis.PoC.EventDrivenSolution.CloudWatch", Detail = JsonConvert.SerializeObject(message), DetailType = $"new {nameof(ApplicationMessage)} received", Resources = new List <string> { invokedLambdaArn } } } }; return(request); }
private async Task SubmitEvents(List <string> rowIds, List <Amazon.MobileAnalytics.Model.Event> eventList) #endif { PutEventsRequest putRequest = new PutEventsRequest(); putRequest.Events = eventList; putRequest.ClientContext = Convert.ToBase64String( System.Text.Encoding.UTF8.GetBytes(_clientContext.ToJsonString())); putRequest.ClientContextEncoding = "base64"; _logger.DebugFormat("Client Context is : {0}", _clientContext.ToJsonString()); PutEventsResponse resp = null; try { resp = await _mobileAnalyticsLowLevelClient.PutEventsAsync(putRequest).ConfigureAwait(false); } catch (AmazonMobileAnalyticsException e) { _logger.Error(e, "An AmazonMobileAnalyticsException occurred while sending Amazon Mobile Analytics request: error code is {0} ; error type is {1} ; request id is {2} ; status code is {3} ; error message is {4}", e.ErrorCode, e.ErrorType, e.RequestId, e.StatusCode, e.Message); // Delete events in any of the three error codes. if (e.StatusCode == HttpStatusCode.BadRequest && (e.ErrorCode.Equals("ValidationException", StringComparison.CurrentCultureIgnoreCase) || e.ErrorCode.Equals("SerializationException", StringComparison.CurrentCultureIgnoreCase) || e.ErrorCode.Equals("BadRequestException", StringComparison.CurrentCultureIgnoreCase))) { MobileAnalyticsErrorEventArgs eventArgs = new MobileAnalyticsErrorEventArgs(this.GetType().Name, "Amazon Mobile Analytics Service returned an error.", e, eventList); _maManager.OnRaiseErrorEvent(eventArgs); _logger.InfoFormat("The error code is not retriable. Delete {0} events from local storage.", rowIds.Count); _eventStore.DeleteEvent(rowIds); } else { MobileAnalyticsErrorEventArgs eventArgs = new MobileAnalyticsErrorEventArgs(this.GetType().Name, "Amazon Mobile Analytics Service returned an error.", e, new List <Amazon.MobileAnalytics.Model.Event>()); _maManager.OnRaiseErrorEvent(eventArgs); } } catch (AmazonServiceException e) { _logger.Error(e, "An AmazonServiceException occurred while sending Amazon Mobile Analytics request: error code is {0} ; error type is {1} ; request id is {2} ; status code is {3} ; error message is {4} ", e.ErrorCode, e.ErrorType, e.RequestId, e.StatusCode, e.Message); MobileAnalyticsErrorEventArgs eventArgs = new MobileAnalyticsErrorEventArgs(this.GetType().Name, "Amazon Web Service returned an error.", e, new List <Amazon.MobileAnalytics.Model.Event>()); _maManager.OnRaiseErrorEvent(eventArgs); } catch (Exception e) { _logger.Error(e, "An exception occurred while sending Amazon Mobile Analytics request."); MobileAnalyticsErrorEventArgs eventArgs = new MobileAnalyticsErrorEventArgs(this.GetType().Name, "An exception occurred when sending request to Amazon Mobile Analytics.", e, new List <Amazon.MobileAnalytics.Model.Event>()); _maManager.OnRaiseErrorEvent(eventArgs); } finally { if (resp != null && resp.HttpStatusCode == HttpStatusCode.Accepted) { _logger.InfoFormat("Mobile Analytics client successfully delivered {0} events to service. Delete those events from local storage.", rowIds.Count); _eventStore.DeleteEvent(rowIds); } lock (_deliveryLock) { _deliveryInProgress = false; } } }
public void PutEventsAsync(PutEventsRequest request, AmazonServiceCallback <PutEventsRequest, PutEventsResponse> callback, AsyncOptions options = null) { throw new System.NotImplementedException(); }
private async void MainPage_Loaded(object sender, RoutedEventArgs e) { try { CognitoAWSCredentials credentials = new CognitoAWSCredentials(poolId, RegionEndpoint.USEast1); var pinpoint = new AmazonPinpointClient(credentials, RegionEndpoint.USEast1); var installId = await AppCenter.GetInstallIdAsync(); EndpointDemographic endpointDemographic = new EndpointDemographic { AppVersion = "1.0.0", Locale = "zh-hk", Make = "Microsoft", Model = "Xbox one s", ModelVersion = "19042", Platform = "xbox", PlatformVersion = "19042", }; PublicEndpoint publicEndpoint = new PublicEndpoint { ChannelType = ChannelType.CUSTOM, Demographic = endpointDemographic, //More }; string myIp = "77";//await new HttpClient().GetStringAsync("https://api.ipify.org/"); //Maximum number of attribute keys and metric keys for each event ------ 40 per request Dictionary <string, string> attribute = new Dictionary <string, string> { { "event_type", "screen" }, { "event_screen", "Login" }, { "event_category", "Profile" }, { "event_action", "Login" }, { "is_interactive", "true" }, { "screen_referrer", "" }, //Previous screen name { "device_id", "2222-0000-0000-2222" }, { "event_ip", myIp }, { "window_width", "1920" }, { "window_height", "1080" }, { "device_platform_name", "xbox" }, { "location", "1" }, { "tagging_version", "TV 1.0.0" }, { "user_id", "1234567890" }, { "user_email", "*****@*****.**" }, { "user_subscription_source", "IAP" }, { "device_type", "TV" }, { "screen_inch", "" }, { "system_language", "EN" }, { "app_language", "EN" }, { "app_session_id", Guid.NewGuid().ToString() }, //Initialize while App open/Browser first time open VIU after software open { "activity_session_id", Guid.NewGuid().ToString() }, //Change while App go to background >= 5s , Web >= 30mins { "video_player_session_id", Guid.NewGuid().ToString() }, //Initialize while each time of the Video Player screen is launched. If the current episode is finished and the next episode is auto-played, this ID should be re-generated to another value. { "network_mode", "Wifi" }, { "category_section_name", "" }, { "product_id", "123456" }, //Category ID, Series ID, Episode ID, Ad ID { "grid_position_identifier", "" }, //grid_id from API { "grid_position", "1" }, //Grid position { "grid_title", "韩剧_Grid" }, { "search_keyword_1", "美好的" }, //{"error_code", "" }, //{"error_message", "" }, { "button_name", "Play Series" }, { "video_play_mode", "remote" }, { "resolution", "1080p" }, { "subtitle_status", "简体中文" }, { "duration", "1200" }, { "screen_mode", "landscape" }, { "timeline_at", "" },//?jindu //{"ad_system", "DPF" }, //{"ad_width", "1280" }, //{"ad_height", "720" }, //{"ad_title", "PG - 13" }, //{"ad_request_url", "https://www" }, //{"ad_space_id", "567890"}, }; var current = Package.Current; Event @event = new Event { Attributes = attribute, EventType = "screen", AppPackageName = Package.Current.Id.Name, AppTitle = Package.Current.DisplayName, AppVersionCode = "10700", SdkName = GetAWSSDKName(pinpoint.Config.UserAgent), ClientSdkVersion = GetAWSSDKVersion(pinpoint.Config.UserAgent), Timestamp = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss") }; Dictionary <string, Event> events = new Dictionary <string, Event>(); events.Add("Events", @event); EventsBatch eventsBatch = new EventsBatch { Endpoint = publicEndpoint, Events = events }; Dictionary <string, EventsBatch> batchItem = new Dictionary <string, EventsBatch>(); batchItem.Add(installId.ToString(), eventsBatch); EventsRequest eventsRequest = new EventsRequest { BatchItem = batchItem }; PutEventsRequest putEventsRequest = new PutEventsRequest { ApplicationId = appId, EventsRequest = eventsRequest }; CancellationTokenSource cancellationTokenSource = new CancellationTokenSource(new TimeSpan(0, 0, 3)); var res = await pinpoint.PutEventsAsync(putEventsRequest, cancellationTokenSource.Token); if (res != null) { Debug.WriteLine("PinPoint.PutEventsAsync: " + DateTime.UtcNow); Debug.WriteLine("EndpointItemResponse: " + res?.EventsResponse?.Results[installId.ToString()]?.EndpointItemResponse.StatusCode + res?.EventsResponse?.Results[installId.ToString()]?.EndpointItemResponse.Message); Debug.WriteLine("EndpointItemResponse: " + res?.EventsResponse?.Results[installId.ToString()]?.EventsItemResponse["Events"].StatusCode + res?.EventsResponse?.Results[installId.ToString()]?.EventsItemResponse["Events"].Message); } } catch (AmazonPinpointException ex) { } catch (Exception ex) { } }