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

No collector configured raised when calling disableAnonymousTracking on a newly created tracker #1221

Open
astlouisf opened this issue Jul 19, 2023 · 1 comment
Assignees
Labels
type:defect Bugs or weaknesses. The issue has to contain steps to reproduce.

Comments

@astlouisf
Copy link

astlouisf commented Jul 19, 2023

Describe the bug
No collector configured is raised when calling disableAnonymousTracking on a newly created tracker. I investigated the bug and found that this can happen when the local storage queue is non empty.

More specifically:

disableAnonymousTracking calls executeQueue which will throw if configCollectorUrl is not a string. configCollectorUrl is set either by enqueueRequest or by setCollectorUrl. We have that we cannot reach the configCollectorUrl check unless the queue has some items:

if (outQueue.length < 1) {
  executingQueue = false;
  return;
}

// Let's check that we have a URL
if (!isString(configCollectorUrl)) {
  throw 'No collector configured';
}

This would normally ensure that enqueueRequest has been called, BUT outQueue can be initialized from the localstorage in which case, enqueueRequest would not have been called and thus configCollectorUrl would not be set in OutQueueManager.

To Reproduce
A code snippet

Expected behavior
It should be possible to call disableAnonymousTracking on a newly created tracker without errors.

Desktop (please complete the following information):

  • OS: macOS Ventura 13.1
  • Browser Chrome
  • Version 114.0.5735.198 (Official Build) (arm64)

Additional context

I was able to reproduce this error on both the javascript tracker and the browser tracker.

@astlouisf astlouisf added the type:defect Bugs or weaknesses. The issue has to contain steps to reproduce. label Jul 19, 2023
@astlouisf astlouisf changed the title Uncaught No collector configured raised when calling disableAnonymousTracking on a newly created tracker No collector configured raised when calling disableAnonymousTracking on a newly created tracker Jul 19, 2023
@astlouisf
Copy link
Author

For anyone running into this problem,

const tracker = newTracker(trackerName, endpoint, config);
tracker.setCollectorUrl(endpoint);

should fix the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:defect Bugs or weaknesses. The issue has to contain steps to reproduce.
Projects
None yet
Development

No branches or pull requests

2 participants