microsoft / clarity

A behavioral analytics library that uses dom mutations and user interactions to generate aggregated insights.
https://clarity.microsoft.com
MIT License
2.16k stars 214 forks source link

How to stop clarity tracking conditionally? #535

Open M7m00d opened 9 months ago

M7m00d commented 9 months ago

I am working on a React/Next.js project and I have some sensitive user-pages that I want to stop Clarity to track them.

I call this before redirecting the user to the sensitive page

window.clarity('stop')

And call this when the user leaves the page.

window.clarity("consent");
window.clarity("start", {
projectId: CLARITY_ID_HERE,
upload: "https://m.clarity.ms/collect",
track: true,
content: true,
cookies: [],
});

The stop call works well, but the start snippet doesn't resume or restart the interaction tracking.

Am I missing something here? Also, what's the difference between pause, stop, resume, pause, and start? I couldn't find a reference for them in the documentation.

M-Valentino commented 7 months ago

I'm thinking stop just ends the recording. To me it makes the most sense to use pause and resume instead to avoid recording sensitive info.

It does sound like the documentation needs improving. Using the words stop, resume, pause, and start is kind of confusing to me I will say since I was thinking about how a DVD player worked. Maybe Microsoft should rename stop to endRecording if that is what stop is supposed to do, because the word 'stop' almost implies you can 'go' at a later point.

itpropro commented 1 month ago

@AbdelrhmanMagdy any updates on this?