Code Monkey home page Code Monkey logo

clarity-js's Introduction

Clarity

Clarity is a client-side JavaScript library that helps you understand how users view and use your webpage across all modern devices and browsers. Understanding how users navigate, interact and browse your website can provide new insights about your users. Empathizing with your users and seeing where features fail or succeed can help improve your product/site, grow revenue and user retention.

Clarity provides you all these insights by:

  • Observing content layout, viewport, and user's interactions with the page
  • Inspecting network requests on the page
  • Logging the information by sending JSON objects to a specified endpoint

Clarity is a project in active development. While it's not yet ready for production use, we continue making improvements and encourage the community to join us in the process!

Here are some example sessions on popular websites visualized to demonstrate the telemetry captured:

  1. CNN (Web)

  2. Cook with Manali (Mobile)

Project Goals

  • Enable a generic solution that is able to capture telemetry from third-party web-sites
  • Encourage participation from open-source community
  • Minimal configuration required by third party web-sites to get started
  • Mobile first

Privacy Notice

Clarity handles sensitive data with care. By default content on the page is masked before upload, so no actual text from the page is sent to the server. All data collection is performed solely with the purpose of providing better insights into customers' pages interactions and improving their users' experiences.

If there are specific regions of the page which a webmaster is completely confident will have no personal data and there is value in sending the regular text nodes, DOM nodes can be marked with the "data-clarity-unmask" attribute. This will cause the given node and all children to return unmasked text. Masking can be turned back on for arbitrary child DOM nodes by adding the "data-clarity-mask" attribute.

Improving Clarity

If you haven't already done so, start contributing by following instructions in CONTRIBUTING.md.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Happy coding!

clarity-js's People

Contributors

dependabot[bot] avatar ender336 avatar microsoftopensource avatar msftgits avatar ravitheja22 avatar sarveshnagpal avatar ssivov avatar swaathee avatar toby-walker avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

clarity-js's Issues

Privacy: Improve privacy tests

Expand a set of tests ensuring we don't capture any text or images when config disallows it, or when privacy option is set on a node and its subtree. Because we value our users' privacy, our text/image masking tests must be really thorough.

Privacy: Improve image masking

Currently we only strip 'src' attribute on images, if config tells us to hide images. We should improve by also masking images that come from CSS and other possible sources. Keep in mind that CSS might be a referenced resource.

Send metadata with first envelope

Currently, each payload's envelope contains redundant info such as userid and page url. We can send all of this fixed data as an impression metadata property with only the first envelope.

Improve documentation on getting started

This is an interesting project. But the current documentation on getting started is not so great. For example, these are some of things i had trouble with

  1. How to use this library ? Simply (gulp) build and get the clarity.js file and include that in my website ? Should it go in head/ end of body ?
  2. When does the library get activated/start tracking ? Do i need to explicitly call the clarity.start() method ? or something else ?

Text masked even with `showText: true`

I ran across two issues, the first is more of a use error so I'll include the solution I came up with for that as well.

Elements not observed

Firstly, no Input/Textarea's were being observed.

What I did during tests:

  • Added clarity script to top
  • Used clarity config:
var config = {
        plugins: ["viewport", "layout", "pointer", "performance", "errors"],
        uploadUrl: "http://localhost:6969/telemetry/test", // web server that processes the payloads
        projectId: "test",
        urlBlacklist: [],
        delay: 500,
        batchLimit: 100 * 1024,
        totalLimit: 20 * 1024 * 1024,
        reUploadLimit: 1,
        showText: true,
        showLinks: true,
        showImages: true,
        sensitiveAttributes: [],
        timeToYield: 50,
        instrument: false,
        cssRules: false,
        uploadHandler: null,
        customInstrumentation: null,
        debug: true,
        validateConsistency: false,
        backgroundMode: false
    };
  • opened webpage, did clarity.start() in console
  • moved around mouse, scrolled up and down, typed some stuff in input, submitted some forms, continued scrolling
  • there are no iframes, embeds, or contenteditable divs in the webpage, just vanilla input elements and forms

Debugging

Did not see the input changes pop up anywhere on server. I modified Layout.prototype.watch to include the following sanity check:

// added toUpperCase to make sure string is uppercase
if (element.tagName.toUpperCase() === "INPUT" || element.tagName.toUpperCase() === "SELECT") {
    console.log("FOUND AN INPUT ELEMENT!!!!!"); // sanity check
    bind(element, "change", this.layoutHandler.bind(this, element, 3));
    this.watchList[layoutState.index] = true;
}

This did not trigger anything. For further sanity:

Layout.prototype.watch = function (node, nodeLayoutState) {
    if (node.nodeType !== Node.ELEMENT_NODE || this.watchList[nodeLayoutState.index]) {
        return;
    }
    console.log(node.tagName); // second sanity check
    ...

No input tags were logged. Furthermore, the only tags logged were SVG nodes (path, circle, g, etc.) and div (not even p tags logged).

Solution

The solution is quite simple, put the call to clarity.start() in the head somewhere. This solved the issue as it now observes the entire DOM tree.

I think the expected behaviour is that it would traverse and observe the existing DOM tree on start anyways, but have not come up with a modification to allow this currently.

Text still masked even with showText: true

What I did during tests:

Same as above except clarity.start() at the end of clarity.js (not using minified to allow debugging).

(inl. showText: true and debug: true)

Debugging

Put breakpoints before config.showText was being used, and did a sanity check in console to make sure it was true (it was).

Workaround

I changed each instance that config.showText was being used (usually var showText = ... config.showText ...;) to have it as true, usually:

var showText = true; //... config.showText ...

This seems to have fixed the issue. I believe the issue may lie with the forceMask variable, perhaps this is intended behaviour and I am not understanding how forceMask is calculated?

Any help would be appreciated. Thanks!

Improve tslint pre-commit check

We have a git hook, which runs tslint on the project before a commit can be made to make sure that code standards are passing. If a staged version of the file fails tslint check, but an unstaged version passes, then pre-commit tslint check would pass, but the failing version would get commited. Need to upgrade hook to inspect staged versions of files.

Capture canvas changes

Clarity currently can't handle reading the state of canvas elements on the page and isn't wired up to see when they change. Similar products punt on canvas support:

HotJar does not support or according to their documentation:

https://help.hotjar.com/hc/en-us/articles/115011822728-Troubleshooting-FAQs-for-Recordings

Why do some elements of the page appear blank or without content?
There are a few limitations on the type of content Hotjar supports for Recordings. If you've noticed that your Recording appears blank or seems to have some missing content, here are a few possibilities:
• Your page has a canvas/SVG element
• Your page uses Adobe Flash to render the content

Similarly for FullStory: https://help.fullstory.com/using/google-maps-during-playback https://help.fullstory.com/using/148817
• SmartLook (https://www.smartlook.com/help/smartlook-user-guide/)

We would have to do support “smart” capture if we didn’t do a polling based approach of finding all canvas element on the page and polling there getImageData() every time we poll. The interception approach with polling could be combined – intercept to find out when a canvas is changed and then (after some delay) trigger a capture of the image data.

https://github.com/Rob--W/canvas-interceptor/blob/master/canvas-interceptor.js

Support custom event logging

Give users opportunity to create custom instrumentation events through Clarity. This could be implemented by adding .instrument(key, payload) api to the clarity object, which would add an instrumentation event to core, containing key and payload in its state.

Add Teardown summary

Include some metadata about the page in the 'Teardown' event. This data should probably indicate the quality of the impression (e.g. how many XHR posts failed, whether ShadowDom was always consistent, JS error count, etc).

Add event emitters

Use app-wide event dispatchers to reduce coupling in communication between various app components

Is this being maintained?

I attempted to create an account and my websites were not approved for several months now.

The email address has not responded either.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.