PerficientDigital / AEM-DataLayer

Simple DataLayer API for Adobe Experience Manager
Apache License 2.0
34 stars 13 forks source link

configParser issue when applying datalayer to different site than WeRetail #15

Open jhroemer opened 5 years ago

jhroemer commented 5 years ago

AEM version: 6.4 AEM Datalayer version: 0.3.0

Hi there. When we add a datalayer configuration to one of our sites, the following error appears when the page loads:

Uncaught SyntaxError: Invalid or unexpected token
    at Object.ns.configParser (core.js:7499)
    at new constructor (core.js:8461)
    at HTMLUnknownElement.<anonymous> (core.js:34654)
    at Function.each (jquery.js:370)
    at jQuery.fn.init.each (jquery.js:137)
    at Object.ns.ContentFrame.self.getEditables (core.js:34650)
    at Object.ns.ContentFrame.self.loadEditables (core.js:34691)
    at Object.<anonymous> (core.js:34711)
    at Function.Deferred (jquery.js:3472)
    at Array.ns.ContentFrame.self.loadEditablesAsync (core.js:34710)

The datalayer works, we can add data to it and see that it is exposed, but the site does not display properly. Everything works when we add a configuration to the WeRetail project. The issue seems to stem from a bad json config-object in some CQ-specific JS, but we haven't been able to discern the real cause of the issue.

jhroemer commented 5 years ago

The issue seems to be present when the page is within a folder structure - which is the case for all of the websites in the project I'm working on. When there are at least two outer folders (not one weirdly enough) the issue arises. This is an example of the bad json string that can't be parsed:

"{"path":"/content/testfolder/testfolder2/root/jcr:content/par_fullcolumn/brandedcontainer-B4",
"slingPath":"/content/testfolder/testfolder2/root/jcr:content/par_fullcolumn/brandedcontainer-B4.html",
"dialog":"/apps/branded/components/content/brandedcontainer/cq:dialog",
"dialogLoadingMode":"auto",
"dialogLayout":"auto",
"dialogSrc":"/mnt/override/apps/branded/components/content/brandedcontain<!--cq{"

Looks like a code-comment might have something to do with the issue? The string always stops abrubptly at <!--cq{ and obviously lacks some closing parentheses.

jhroemer commented 5 years ago

Also, the issue appears in edit mode and not in published mode. There is a chance that our page components are at fault, but it's hard to say at this point.

jhroemer commented 5 years ago

Also on the backend-side this error appears when we experience the issue:

GET /content/subpath2.html HTTP/1.1] com.day.cq.wcm.core.impl.WCMDeveloperModeFilter Error during include of SlingRequestPathInfo: 
path='/content/subpath2/jcr:content/par_fullcolumn/brandedcontainer-B4/par', selectorString='null', extension='html', suffix='null'
org.apache.sling.api.scripting.ScriptEvaluationException: java.lang.StackOverflowError

"subpath2" is the page where the datalayer configuration is added.