core icon indicating copy to clipboard operation
core copied to clipboard

Inject the Jitsu code and the DotCMS AB Testing init code

Open freddyucv opened this issue 3 years ago • 1 comments

We need to inject the JS code needed to use jitsu:

https://github.com/dotCMS/core/pull/22626/files#diff-7e96902b18f77558b283b78c20a1df78af30bd3f57a1ae41f3b4e6dc67a3918fR1-R6

but data-init-only should be false and jitsu_key should be set by configuration.

Also we need to inject the init code needed by DotCMS to run a Experiment, it should do:

  • Check if the user is not already running a experiment, for this we need to check if the experiment cookie exists
  • If the experiment cookie exist then we need to load from the local storage the current experiment data
  • Is the experiment cookie does not exists then we need to hit the experiment end point to check if the user should go into a experiment and save into the local storage the experiment data.

it should be something like:

https://github.com/dotCMS/core/pull/22626/files#diff-9417bef73d32b061e75306b404886f1b00b867e22696a5ba0b0717473190c922R11

I think the API is the best place to inject this code

https://github.com/dotCMS/core/pull/22626/files#diff-3e34bcc38231d5f5c905331e68d93d63940b6f5e6276f67057d06ca76752651fR299

freddyucv avatar Aug 19 '22 20:08 freddyucv

Hey team! Please add your planning poker estimate with Zenhub @dsilvam @victoralfaro-dotcms

freddyucv avatar Sep 14 '22 18:09 freddyucv

Note to QA:

  • Start dotcms up with the full starter.
  • Navigate for the different pages check the Page Source of ths pages and you should not see any JS code injected for experiment nor hit to the isUserIncluded end point neither.
  • Create a start a new experiment without any rules.
  • Navigate again by the pages, now you should see the JS Code injected and a hit to the isUserIncluded end point, this hit should happened just when request the first page, it should. not happend again later.
  • Algo you should have a new cookie call runningExperiment_<experiment's id>, and a item into the localStorage call experiment_data.
  • Remove the cookie and the localStorage, Stop the Experiment and create and start a new one but now with a Rules.
  • If you request a page but the rules is not valid then you should see any code injected nor cookie nor localStorage Item neither.
  • Request a page again but now with the rules valid, now you should have the cookie, localStorage item, code injected and the hit to the isUserInclude end point.

Another test you can stop the previous experiment and create two new experiment without rules, remove cookie, local storage item and request a page again. now you should have to cookies created one for each experiment, and in the local storage item into the experiments attribute you should have two experiment too.

For now we have a bug, If you create and start just one experiment, request a page, later create/start another experiment without clean cookies and local storage it should hit the isUserIncluded end point again but excluding the first experiment, this case is fix in this PR: https://github.com/dotCMS/core/pull/23417

freddyucv avatar Nov 22 '22 22:11 freddyucv

Passed Internal QA: Steps above behaving like expected.

dsilvam avatar Nov 23 '22 02:11 dsilvam