Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move getting user id and session id to model, create GA Data if it was not set by cart #70

Merged

Conversation

indykoning
Copy link
Contributor

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:

  • "getUserIdFromCookie"
  • "getGaUserId"
  • "generateFallbackUserId"

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 handled generateFallbackUserId turning execution order into:
getUserIdFromCookie() ?? generateFallbackUserId() ?? getGaUserId()
Making the database value essentially useless.

@WouterSteen WouterSteen merged commit 632a34c into elgentos:master Dec 3, 2024
@WouterSteen
Copy link
Contributor

Thanks @indykoning awesome work!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants