Expand my Community achievements bar.

Fix Exception in Web SDK

Avatar

Level 3

9/5/23

Description - An exception is thrown and processing halts when using the WebSDK extension and there are two instances of the adobe_mc in the query string.

 

Note:  this was reported in Support Case E-001008770, and even though it does not seem to be a Analytics-related problem I was asked to also enter it here.  For good measure, it was also reported in the Alloy extension github as issue #346.  Hopefully one of these will get it fixed.

 

Why is this feature important to you - While there should not be two instances of the adobe_mc parameter in the query string when attempting to pass identity between domains, the WebSDK extension should deal with the situation better than throwing and exception and halting processing.  When this happens, no tracking occurs, no test propositions are returned, etc.

 

How would you like the feature to work - When there are two instances of the same parameter, the results of a parse operation are returned as an array, not a string.  The extension code that is looking for the identity parameter needs to be aware of this, check the type and proceed accordingly instead of assuming it will be a string and throwing an exception when attempting a split operation.

 

Current Behaviour - The following error popped up in the console:

Uncaught (in promise) TypeError: [alloy] [Identity] An error occurred while executing the getIdentity command.
Caused by: [Identity] An error occurred while executing the onBeforeRequest lifecycle hook.
Caused by: o.split is not a function

This kept the page from working. Investigation showed the root of the problem was the adobe_mc parameter had been appended to the URL twice (by accident). The code that parses the parameter value does not do a type check after getting the parameter, and when there are more than one instance of a parameter it is represented by an array instead of a string. The code attempts to do a split() operation, but since the type is Array the exception is thrown.

 

To recreate, simply duplicate the adobe_mc parameter on any link and load it.

The extension needs to be updated to check the type and take appropriate action if it is an Array and not a String.

1 Comment