How can we pass custom parameters in predefined and Custom Events of Facebook Analytics - facebook-analytics

I want to trigger event on user registration like this
FB.AppEvents.logEvent("Registration");
but how can I pass both the valueToSum and parameters arguments to this custom Event?
and likewise How can I pass custom parameters to my predefined Events like FB.AppEvents.EventNames.ADDED_TO_CART?

Like this:
FB.AppEvents.logEvent(
FB.AppEvents.EventNames.COMPLETED_REGISTRATION,
valueToSum /* number */,
customParams /* Object */
);
I'd recommend using FB.AppEvents.EventNames.COMPLETED_REGISTRATION instead of "Registration" since it's one of the predefined events.
The above example also shows how to pass custom parameters to predefined events.
You can find more information here: https://developers.facebook.com/docs/app-events/web
Out of curiosity, what do you need valueToSum for on a registration event? Registration typically isn't something that needs an aggregate value.

Related

Accessing Cognito Custom Attributes in a post-confirmation lambda function

I have a post-confirmation lambda function that writes user attribute information to a dynamoDB table. I've managed to get access to standard user attributes fields in the "event" parameter by doing stuff like
event.request.userAttributes.sub
but trying to run
event.request.userAttributes.role //where role is the name of my custom attribute
doesn't seem to work. Anyone know what the proper syntax for this is? And do I need to set any special read permissions for custom attributes? I created this custom attribute a long time after I originally made this user pool, if that changes things.
All custom attributes are prefixed with the custom: prefix (Documentation - Custom Attributes).
Therefore (I'll assume you're using JavaScript here- if not feel free to specify and I can change this example), you'd need to use:
event.request.userAttributes['custom:role']
You don't need to set any special read permissions- all the user attributes are returned in the PostConfirmation lambda.

Event Parameters List

I am trying to understand what exactly is stored in an event using the SAPUI5 documentation here. Where can I find a list of parameters that come with an Event? For example, I just found out that DatePicker has a parameter called "valid", but how would I know that? Surely I wouldn't have to use getParameters() for every entity right? Also when you define a function to be called in XML, do they all send the same Event type?
In general the parameters depend on the intention of the event, e.g. a change event which indicates that the source object has changed its value contains other parameters than an event which informs you that a file upload has failed.
You'll find the available event parameters in API documentation. To stick with your example: Check the API documentation of the DatePicker control, select the change event from the available events and check the available parameter. You will find the parameter valid with a description. To see the difference between the events you may also check the ListBase implementation, which defines a bunch of events.
It is good style to use getParameter in your event handler to access the parameters values.
onDatePickerChanged : function(event) {
let validDate = event.getParameter("valid");
}

How to run validation on a slice of a redux-form FieldArray state

I am running something very similar to the example here:
http://redux-form.com/6.0.5/examples/fieldArrays/
Say I want to add a list of members and a list of hobbies under each member, like in the example above.
What is different from the example above is, I want to also be able to validate each member, before I am able to add additional members or hobbies for that member.
Similarly, I also want to be able to validate each hobby, before I can add another hobby.
In other words, I want to be able to treat each entry in the FieldArray as a form and each add button as a submit function for that form.
I would have a validateMember and validateHobby validation functions that I would run against the respective FieldArray entries.
I am not aware of any feature of redux-form that allows running synchronous validation on a subset of the form's state. Alternatively, I also cannot treat everything as a form as then I would lose all the nesting (i.e. which hobby belongs to each address).
Any ideas and suggestions are greatly appreciated!

I would like to define a component as optionally required (based on another field's value)

I built two custom components using built-in CQ components. The components' JSP's, along with some custom javascript, have a line like below in order to leverage the built-in components (and their formatting, labels, etc.).
<cq:include path="." resourceType="foundation/components/form/dropdown" />
I have one each of my custom dropdown components on a form. I can mark field A and field B as both being required in their respective components' editor dialog. I can provide required messages so that when either field is blank and the form is submitted, I get a message that the fields are required (with my custom messages). However, what I really want to do is hide or disable field B based on the value supplied in field A. I'm handling this manually via jQuery. However, this of course presents a problem on validation. I want field B to be NOT required when it is hidden/disabled and for it to be required when it is enabled/visible. Since the showing/hiding is done client-side, the server-side validation has know knowledge of the change and still expect a value to be provided for field B.
I'm been trying to poke around in the CQ Widgets API to find if there is something I can do on the client side to set/unset the required property so that when the form gets posted it is handled correctly. I'm guessing that there isn't since the validation seems to be happening on post instead of client-side.
Any ideas/thoughts/options?
It turns out that the link from my comment gave me the idea that I can have custom server-side validation for my form, I just wasn't sure how to connect it to the field. It turns out that all I had to do was create a servervalidation.jsp file in my "B" component. CQ will see the servervalidation.jsp and automatically invoke it for my custom component.
I was then able to examine the submitted value of field "A" (by getting the parameter from the request object) and doing some other custom logic for my needs.
I was then able to optionally do this:
FieldDescription field = FieldHelper.getConstraintFieldDescription(slingRequest);
FieldHelper.checkRequired(slingRequest, field);

YUI: adding event at the top of some event queue after page loading?

How can I put a new event at the top of all attached events linked to an object just after the page load?
Pratically I have an accordion using some YUI funcs to activate its behavior, now without modifying the YUI main function I need some new functions used to call AJAX routines.
Currently I am trying with Event.getListeners, but I don't know how to treat the returned objects.
Regards
The responses you get from Event.getListeners is all the arguments passed into the Event.addListener. According to the docs for Event.getListeners it returns
the listener. Contains the following fields:
type: (string) the type of event
fn: (function) the callback supplied to addListener
obj: (object) the custom object supplied to addListener
adjust: (boolean|object) whether or not to adjust the default context
scope: (boolean) the derived context based on the adjust parameter
index: (int) its position in the Event util listener cache
So using that object you can probably just remove the Listeners using Event.removeListener & then re-add them all in the order you want using Event.addListener. The object's properties map 1:1 with the args for Event.addListener so nothing will be lost.

Resources