Events

Registration can provide detailed information on user and application state using JavaScript events. These are useful for making customizations based information gathered at run time, and for using third-party analytics to track specific events.

Note:  The event names have been changed. This only affects a select number of customers, and newer customers will not see these original names. All old names have been aliased to their new equivalents. If your implementation uses the legacy naming conventions, refer to Table 1 to map your event functionality.

Registering Event Handlers

To add a handler for an event, use the addHandler method. All event handlers must be wrapped within a ready function, as shown here:

function janrainCaptureWidgetOnLoad() {
   janrain.events.onCaptureLoginSuccess.addHandler(function(result){
       //do stuff
   }
}

Note: functions are case sensitive.

Supported Events

The following fields in the janrain.events object define events.

Render Events

Event Description Values Returned
onCaptureRenderStart Fires when a screen starts rendering. If (_isMobile) is present, then add the event handler for orientation change which in turn calls this event. flow
onCaptureRenderComplete Fires when a screen finishes rendering. For each element with the class name janrain.settings.capture.modalOpenClass (default="capture_modal_open"), attach an event handler on “click” that renders the defaultScreen from the current layout’s flow and fires this event. flow
screen
onCaptureScreenShow Fires when a screen is shown and returns the name of the screen. The registration solution attaches an on “click” event handler to each DOM element with the class name janrain.settings.capture.modalOpenClass (default = "capture_modal_open"). The “click” event handler renders the screen named by the flow object’s defaultScreen property. screen
onCaptureModalReady Fires when the screen is ready to be shown, before onCaptureScreenShow. When a page loads, we check to see if an existing modal needs to be closed so it can be refreshed and reopened. This can occur when clicking the ‘back’ button in a browser or due to a page redirect. Once any open modal is closed, onCaptureModalReady fires, and then we are ready to open a new modal window. None.
onModalOpen Fires when the modal window (Janrain login pop-up window) opens. None.
onModalClose Fires when the modal window (Janrain login pop-up window) closes. None.
onCaptureAccessDenied Fires when attempting to load a screen that requires an access token when there is no access token. You can use this event to redirect to an access denied or login page. None.

Session Events

Event Description Values Returned
onCaptureSessionCreated Fires when a new session starts; returns an accessToken or code depending on janrain.settings.capture.responseType, which you can set to code or token. accessToken
code
onCaptureSessionEnded Fires when a session is ended using the endCaptureSession api call. None.
onCaptureSessionFound Fires when a an access token is found on page load; returns a token. accessToken
onCaptureSessionNotFound Fires after page load if there is no janrainCaptureToken cookie. None.
onCaptureTransactionTimeout Fires after the time for a transaction has expired. transactionId
onCaptureExpiredToken Fires when an error is thrown due to an expired accessToken. This occurs when the onCaptureError event returns a result object with an error property that equals access_token_expired. None.
onCaptureInvalidToken Fires when the access token is invalid for an unknown reason. None.

Login Events

Federate transaction status object.

Event Description Values Returned
onCaptureLoginStart Fires when a login screen is shown, such as socialSignin or traditionalSignin. action
screen
onCaptureLoginSuccess Fires on a successful login. The result will have the accessToken or, in the case of an SSO login, the Federate transaction status object. accessToken
onCaptureLoginFailed Fires on a failed login. None.

Registration and Validation Events

Event Description Values Returned
onCaptureRegistrationStart Fires when an end user initiates registration. action
screen
onCaptureRegistrationSuccess Fires on a successful registration. None.
onCaptureRegistrationSuccessNoLogin Fires when there is a oneTime screen to render after the user signs in, that they must deal with (like a TOS agreement) before they are signed in for real. transaction object
onCaptureRegistrationFailed Fires on a failed registration. None.
onCapturePostLoginScreen Fires when the app loads a screen for post-login.  This means that the user has entered their credentials, but there are still other steps necessary to fully complete the login. transaction object
onCaptureValidationSuccess Fires when a field successfully validates; returns field. eventObject
onCaptureValidationFailed Fires when a field fails validation; returns field. eventObject
onCaptureServerValidationFailed Fires when a server validation fails, such as an email address format error or failed uniqueness check. Field validations can be defined in the flow file. The field object that failed validation, the invalidType, a validation error message and the parentDiv element of the field.
onCaptureValidationComplete Fires when all validations have run before a form is submitted. fieldsWithError

Profile Events

Event Description Values Returned
onCaptureProfileSaveFailed Fires when a user profile does not save successfully. None.
onCaptureProfileLink Fires when a user successfully links an additional social provider account to their current user profile. Returns provider, a string with the name of the social provider, and authProfile, an object that contains information from the user’s social provider account.
onCaptureProfileUnlink Fires when a user successfully unlinks a social account from their current user profile. Returns provider, a string with the name of the social provider.
onCaptureProfileSaveSuccess Fires when a user profile saves successfully. None.
onCaptureProfileCookieSet Fires when registration sets the janrainCaptureProfileData cookie with profile data from the user’s record, such as upon signing in. Returns a userData object that contains the data stored in the cookie. The Capture attributes to be saved in the cookie are defined in the userData array in the flow file.

Password Events

Event Description Values Returned
onCaptureForgotPasswordCodeSuccess Fires after the forgot password code has run successfully. None.
onCaptureForgotPasswordCodeFailed Fires after the forgot password code has failed. None.

Data Events

Event Description Values Returned
onCaptureSaveSuccess Fires on any save of data to the server. None.
onCaptureSaveFailed Fires on any failed save of data. None.
onCaptureAutoSaveUpdate Fires after a successful AutoSave update. To turn on AutoSave, set janrain.settings.capture.autoSave to true. durationSinceLastUpdate
onCaptureContentChange Fires when the content on a screen is changed. Various actions can fire this event, such as when a screen is rendered, when validation messages are added or removed, and so forth. None.
onCapturePhotoUploadSuccess Fires when a photograph uploads successfully. None.

Account Events

Event Description Values Returned
onCaptureAccountReactivateSuccess Fires after an account has been successfully reactivated. None.
onCaptureAccountReactivateFailed Fires when an account reactivation attempt fails. None.
onCaptureAccountDeactivateSuccess Fires when an account deactivates successfully. None.
onCaptureAccountDeactivateFailed Fires when an account deactivation fails. None.

Email Events

Event Description Values Returned
onCaptureEmailVerificationSuccess Fires when an end user’s email address is successfully verified. None.
onCaptureEmailVerificationFailed Fires when an end user’s email address fails verification. None.
onCaptureEmailSent Fires when registration sends an email.

Error Events

Note that some events fire when a call fails. This section is for errors.

Event Description Values Returned
onCaptureFormError Fires if there are errors when the form renders. Returns an errors object.
onCaptureError Fires when there is an error response from the server. Returns the error object.
onCaptureLinkAccountError Fires when an attempt to link accounts fails. message
provider
linkError Registration can pass a customError property in the error response that will, if present, contain the exact text to place on the page. When a linkError occurs, the error message “That account is already in use.” appears in the UI, and the onCaptureLinkAccountError event fires.
customError You can define customError messages in i18nStrings, which will override the default messages. In this release, you must ask Janrain to change the messages in i18nStrings. Contact your Janrain Account Representative.

Single Sign-on Events

Event Description Values Returned
onCaptureFederateLogin Fires on an SSO login; onCaptureLoginSuccess also fires, as it does on all sign ins. None.
onCaptureFederateNoLogin Fires when Federate does not find an existing sign in. result
onCaptureFederateRefreshedToken Fires after a Federate token has been refreshed. accessToken

Backplane Events

Event Description Values Returned
onCaptureBackplaneReady Fires when the Backplane server signals that it is ready to run. None.
onCaptureBackplaneInitFailed Fires when Backplane initialization fails. None.

Mobile Events

For more information, see the Mobile overview pages.

Event Description Values Returned
mobile.onOrientationChange Fires when the orientation on a mobile device changes. orientation

Table 1: Old Event Names Mapped to New Event Names

This table is for customers using a version of Registration with an older event naming scheme. Newer customers will not see these names. All old events are aliased to the corresponding new event, and will fire identically.

Old Event New Event
onCaptureStartRegistration onCaptureRegistrationStart
onCaptureStartLogin onCaptureLoginStart
onCaptureSuccessfulLogin onCaptureLoginSuccess
onCaptureSuccessfulProfileSave onCaptureProfileSaveSuccess
onCaptureFailedProfileSave onCaptureProfileSaveFailed
onCaptureFailedLogin onCaptureLoginFailed
onCaptureSuccessfulRegistration onCaptureRegistrationSuccess
onCaptureFailedRegistration onCaptureRegistrationFailed
onCaptureSuccessfulEmailVerification onCaptureEmailVerificationSuccess
onCaptureFailedEmailVerification onCaptureEmailVerificationFailed
onCaptureSuccessfulSave onCaptureSaveSuccess
onCaptureFailedSave onCaptureSaveFailed
onCaptureFailedServerValidation onCaptureServerValidationFailed

Transaction Object

The transaction object has information about the data sent to Janrain registration. It looks similar to this example.

{code}
action: "profile"
fields: Array[8]
0: "displayName"
1: "profileBlurb"
2: "name"
3: "email"
4: "phone"
5: "addressDrop"
6: "gender"
7: "birthdate"
flow: "editProfileFlow"
form: "editProfileForm"
renders: true
screen: "editProfile"
status: "success"
statusMessage: "profileSaved"
transactionId: "l34zb7blahblahblahh94dmvsbtz0z9nqknscyou"
version: "_r3UvXVvxA4gKhcWzQsypw"
{code}