Skip to content

setUserId call causes NetRequest console error statements #71

@iainbrux

Description

@iainbrux

❓ General Issue

The Question

When utilising ClickstreamAnalytics.setuserId() API, Chrome Dev Tools is populated with many errors caused from a failed NetRequest. Removing this call removes the NetRequest errors from the console. This is causing concern and potential site performance issues and also detriment to necessary scores such as a Lighthouse with our business' ecommerce website.

Other information

When setting up ClickstreamAnalytics (CA) within our application, we obviously want to set a userId property in CA to be the same of the userId we have saved in our database for the user when they are logged in, or to "guest" when they are not. This is critical for us to be able to build features based off the back of the data collected from CA.

Since the deployment of the standard CA CFN template, we have noticed an issue which causes various NetRequest errors in the Chrome Dev Tools console - this in tandem appears to be affecting the loading times of our ecommerce website. Removing the setUserId api resolves this issue but is not a solution we can work with moving forward as we require the userId.

Screenshot attached, I can also happily attach a video of proof if required.

Image

Our ClickstreamAnalytics.setUserId() API call is within a React useEffect call which triggers code based on parameters of a user object (data from our user's backend) and a authorised logged in user state is true. See code example below:

const setUpClickstreamingAnalytics = () => {
    if (user.loggedIn) {
      ClickstreamAnalytics.setUserId(user.userId);
    } else {
      ClickstreamAnalytics.setUserId("guest_user");
    }
  };
useEffect(() => {
    if (authResolved && user && countries?.length) {
      setUpGtm(); // google analytics
      setUpClickstreamingAnalytics(); // clickstream analytics
    }
  }, [authResolved, countries]);

Removing the lines of ClickstreamAnalytics.setUserId in setUpClickstreamingAnalytics removes the errors from the console.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions