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

Prevent running multiple instances of Clarity simultaneously #160

Merged
merged 2 commits into from
Aug 4, 2021

Conversation

sarveshnagpal
Copy link
Member

Set a "v" property on the global clarity variable so we can look for it before running a second instance.

Copy link
Contributor

@swaathee swaathee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@sarveshnagpal sarveshnagpal merged commit 093a931 into master Aug 4, 2021
@sarveshnagpal sarveshnagpal deleted the sarveshn/tag branch August 4, 2021 22:48
const c = 'clarity';

// Do not execute or reset global "clarity" variable if a version of Clarity is already running on the page
if (w[c] && w[c].v) { return console.warn("Error CL001: Multiple Clarity tags detected."); }
Copy link
Member

@toby-walker toby-walker Aug 4, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we instrument this with a custom variable or event?
And, even better, grab a stack trace?

while (queue.length > 0) { w.clarity(...queue.shift()); }
const c = 'clarity';

// Do not execute or reset global "clarity" variable if a version of Clarity is already running on the page
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we track the project id that is also running and then figure out which project id is the source of the duplication?

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.

3 participants