protected void RegisterAction(JSONObject action, string id) { object typeObj, valueObj; if (action.TryGetValue("type", out typeObj)) { action.TryGetValue("value", out valueObj); EventArgs eventArgs = EventArgs.Create( DDNA.Instance.Platform, id, (string)typeObj, valueObj); GameEvent actionEvent = new GameEvent("imageMessageAction"); if (imageMessage.engagement.JSON.ContainsKey("eventParams")) { var eventParams = imageMessage.engagement.JSON["eventParams"] as Dictionary <string, object>; actionEvent.AddParam("responseDecisionpointName", eventParams["responseDecisionpointName"]); actionEvent.AddParam("responseEngagementID", eventParams["responseEngagementID"]); actionEvent.AddParam("responseEngagementName", eventParams["responseEngagementName"]); actionEvent.AddParam("responseEngagementType", eventParams["responseEngagementType"]); actionEvent.AddParam("responseMessageSequence", eventParams["responseMessageSequence"]); actionEvent.AddParam("responseVariantName", eventParams["responseVariantName"]); actionEvent.AddParam("responseTransactionID", eventParams["responseTransactionID"]); } actionEvent.AddParam("imActionName", id); actionEvent.AddParam("imActionType", (string)typeObj); if (!string.IsNullOrEmpty(eventArgs.ActionValue) && (string)typeObj != "dismiss") { actionEvent.AddParam("imActionValue", eventArgs.ActionValue); } switch ((string)typeObj) { case "none": { actions.Add(() => { }); break; } case "action": { actions.Add(() => { if (valueObj != null) { if (imageMessage.OnAction != null) { imageMessage.OnAction(eventArgs); } } ddna.RecordEvent(actionEvent).Run(); imageMessage.Close(); }); break; } case "link": { actions.Add(() => { if (imageMessage.OnAction != null) { imageMessage.OnAction(eventArgs); } if (valueObj != null) { Application.OpenURL((string)valueObj); } ddna.RecordEvent(actionEvent).Run(); imageMessage.Close(); }); break; } case "store": { actions.Add(() => { if (imageMessage.OnStore != null) { imageMessage.OnStore(eventArgs); } ddna.RecordEvent(actionEvent).Run(); imageMessage.Close(); }); break; } default: { // "dismiss" actions.Add(() => { if (imageMessage.OnDismiss != null) { imageMessage.OnDismiss(eventArgs); } ddna.RecordEvent(actionEvent).Run(); imageMessage.Close(); }); break; } } } }
protected void RegisterAction(JSONObject action, string id) { object typeObj, valueObj; if (action.TryGetValue("type", out typeObj)) { action.TryGetValue("value", out valueObj); EventArgs eventArgs = EventArgs.Create( DDNA.Instance.Platform, id, (string)typeObj, valueObj); GameEvent actionEvent = new GameEvent("imageMessageAction"); if (imageMessage.engagement.JSON.ContainsKey("eventParams")) { var eventParams = imageMessage.engagement.JSON["eventParams"] as Dictionary <string, object>; actionEvent.AddParam("responseDecisionpointName", eventParams["responseDecisionpointName"]); actionEvent.AddParam("responseEngagementID", eventParams["responseEngagementID"]); actionEvent.AddParam("responseEngagementName", eventParams["responseEngagementName"]); actionEvent.AddParam("responseEngagementType", eventParams["responseEngagementType"]); actionEvent.AddParam("responseMessageSequence", eventParams["responseMessageSequence"]); actionEvent.AddParam("responseVariantName", eventParams["responseVariantName"]); actionEvent.AddParam("responseTransactionID", eventParams["responseTransactionID"]); } actionEvent.AddParam("imActionName", id); actionEvent.AddParam("imActionType", (string)typeObj); if (!string.IsNullOrEmpty(eventArgs.ActionValue) && (string)typeObj != "dismiss") { actionEvent.AddParam("imActionValue", eventArgs.ActionValue); } //BRD: Added the armoury common properties #if !DELTA_DNA_PUBLIC_REPO if (Armoury.DeltaDnaApi.instance?.overrideImageMessageEvent ?? false) { actionEvent.AddParam("client_event_name", actionEvent.Name); foreach (var pair in Armoury.Analytics.AnalyticsService.GetAllCommonEventProperties()) { actionEvent.AddParam(pair.Key, pair.Value); } } #endif switch ((string)typeObj) { case "none": { actions.Add(() => { }); break; } case "action": { actions.Add(() => { if (valueObj != null) { if (imageMessage.OnAction != null) { imageMessage.OnAction(eventArgs); } } ddna.RecordEvent(actionEvent).Run(); imageMessage.Close(); }); break; } case "link": { actions.Add(() => { if (imageMessage.OnAction != null) { imageMessage.OnAction(eventArgs); } if (valueObj != null) { Application.OpenURL((string)valueObj); } ddna.RecordEvent(actionEvent).Run(); imageMessage.Close(); }); break; } case "store": { actions.Add(() => { if (imageMessage.OnStore != null) { imageMessage.OnStore(eventArgs); } ddna.RecordEvent(actionEvent).Run(); imageMessage.Close(); }); break; } default: { // "dismiss" actions.Add(() => { if (imageMessage.OnDismiss != null) { imageMessage.OnDismiss(eventArgs); } ddna.RecordEvent(actionEvent).Run(); imageMessage.Close(); }); break; } } } }