Move getting user id and session id to model, create GA Data if it was not set by cart #70
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is somewhat of a large PR, luckily most of it has been moving functions around.
The aim of this PR is to support creating the GA analytics data when the order gets created.
why?
Because not every module actually creates a cart in a way that it triggers SaveGaUserDataToDb
For example: Channable
So we're better off attempting to create it if it doesn't exist during the order creation as well since that will always exist.
We might always miss the link to the user session, but at least we do have the purchase events.
Due to the separation of concerns with:
We should also never again run into PRs like #55
since order of execution is clearly defined as:
getUserIdFromCookie() ?? getGaUserId() ?? generateFallbackUserId()
Thus the fallback generation will only run once per quote/order which has not been the case before,
since
getUserIdFromCookie
also handledgenerateFallbackUserId
turning execution order into:getUserIdFromCookie() ?? generateFallbackUserId() ?? getGaUserId()
Making the database value essentially useless.