Hi,

I'm using your module on a site that needs a bit more control over which pages Chartbeat shows on, and when. For example, we don't want to enable it for editors, the admin section, node edit forms, etc.

I've ported some of the visibility settings across from the googleanalytics module, plus added a new hook_chartbeat_visibility() hook which allows other modules to provide more fine-grained controls.

Patch attached, hope you like it!

Thanks

Comments

jwilson3’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the patch, I'm glad I looked in the queue first, 'cause I was about to write and contribute a patch for this exact functionality!

Code looks good, and works as expected. The only issue I could find was a tiny nitpick: there were two cases where function descriptions extended beyond the recommended 80 columns.

I changed:

/**
 * Based on visibility setting this function returns TRUE if Chartbeat code should
 * be added to the current page and otherwise FALSE.
 */

to:

/**
 * Based on visibility setting this function returns TRUE if Chartbeat code
 * should be added to the current page and otherwise FALSE.
 */
jwilson3’s picture

Actually there are more comment formatting errors in the included api file:

/**
 * Hook to block the inclusion of Chartbeat tracking code on a page by page basis.
 * Note that this hook is only checked after the role and page filters would normally
 * allow Chartbeat to be included on the page. 
 *
 * Only one module needs to return FALSE to block Chartbeat from loading
 *
 * @return bool return FALSE to block inclusion of Chartbeat. Any other return value will allow it.
 */

would be:

/**
 * Hook to block the inclusion of Chartbeat tracking code on a page by page
 * basis. Note that this hook is only checked after the role and page filters
 * would normally allow Chartbeat to be included on the page.
 *
 * Only one module needs to return FALSE to block Chartbeat from loading
 *
 * @return bool 
 *   Return FALSE to block inclusion of Chartbeat. Any other return value
 *   will allow it.
 */
jwilson3’s picture

StatusFileSize
new8.57 KB

fixed these minor errors mentioned in #1 and #2.

BenK’s picture

Subscribing

t-dub’s picture

Subscribing

bleen’s picture

StatusFileSize
new8.57 KB

same s patch in #3 without whitespace issues

dalin’s picture

StatusFileSize
new7.89 KB

Here's a slight variation that has the same default paths excluded as GA:
admin
admin/*
batch
node/add*
node/*/*
user/*/*