New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@visual-framework/vf-analytics-google

Package Overview
Dependencies
Maintainers
2
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@visual-framework/vf-analytics-google - npm Package Compare versions

Comparing version 1.0.0-rc.1 to 1.0.0-rc.3

12

CHANGELOG.md

@@ -0,1 +1,13 @@

### 1.0.0-rc.3
* documentation cleanup
* `analyticsTrackInteraction()` is now namespaced as `vfGaTrackInteraction()`
* `vfGaTrackInteraction()` now documented for direct usage
* Fix console verbose logging: if set to false it would pass
* https://github.com/visual-framework/vf-core/issues/1131
### 1.0.0-rc.2
* more robust fallback handling of image-based links
### 1.0.0-rc.1

@@ -2,0 +14,0 @@

4

package.json
{
"version": "1.0.0-rc.1",
"version": "1.0.0-rc.3",
"name": "@visual-framework/vf-analytics-google",

@@ -23,3 +23,3 @@ "description": "vf-analytics-google component",

],
"gitHead": "4390495a19d399f41d345eb38b884b338ce6f0e4"
"gitHead": "ec830b6b46d9772fc87556b36befa2734e819b53"
}

@@ -29,3 +29,3 @@ # Google Analytics enhancements component

```html
<div data-vf-google-anlaytics-region="main-content-area-OR-SOME-OTHER-NAME">
<div data-vf-google-analytics-region="main-content-area-OR-SOME-OTHER-NAME">
<a href="//www.example.com">My link here</a>

@@ -47,2 +47,18 @@ </div>

- `vfGaIndicateUnloaded` Utility method to invalidate prior GA check `<body data-vf-google-analytics-loaded='false'>`
- `vfGaTrackInteraction()` can be used to directly track events if you wish to use your own event handler
```js
/**
* This code tracks the user's clicks in various parts of the site and logs them as GA events.
*
* Dev note:
* add class verbose-analytics to your body for a readout to console on clicks.
*
* @param {element} actedOnItem
* @param {string} customEventName Event action
* @example
* jQuery(".analytics-content-footer").on('mousedown', 'a, button', function(e) {
* vfGaTrackInteraction(e.target,'Content footer');
* });
* /
```

@@ -49,0 +65,0 @@ ## Install

@@ -137,6 +137,2 @@ // vf-analytics-google

function vfGaLinkTrackingInit() {
// jQuery("body.google-analytics-loaded .track-with-analytics-events a").on('mousedown', function(e) {
// analyticsTrackInteraction(e.target,'Manually tracked area');
// });
document.body.addEventListener("mousedown", function (evt) {

@@ -146,3 +142,3 @@ // send GA events if GA closest area is detected

if (closestContainer) {
analyticsTrackInteraction(evt.target);
vfGaTrackInteraction(evt.target);
} else {

@@ -153,3 +149,3 @@ var from = findParent('a',evt.target || evt.srcElement);

// console.log('clicked from findParent: ',from);
analyticsTrackInteraction(from);
vfGaTrackInteraction(from);
}

@@ -200,7 +196,13 @@ }

// Catch any use cases that may have been existing
// To be removed in 2.0.0
function analyticsTrackInteraction(actedOnItem, customEventName) {
console.warn('vfGa','As of 1.0.0-rc.3 analyticsTrackInteraction() is now vfGaTrackInteraction(). You function call is being proxied. You should update your code.');
vfGaTrackInteraction(actedOnItem, customEventName);
}
/**
* Analytics tracking
* ---
* This code tracks the user's clicks in various parts of the site and logs them as GA events.<br/>
* Links in non-generic regions can be tracked by adding '.track-with-analytics-events' to a parent div. Careful with the scoping.
* This code tracks the user's clicks in various parts of the site and logs them as GA events.
*

@@ -214,6 +216,6 @@ * Dev note:

* jQuery(".analytics-content-footer").on('mousedown', 'a, button', function(e) {
* analyticsTrackInteraction(e.target,'Content footer');
* vfGaTrackInteraction(e.target,'Content footer');
* });
*/
function analyticsTrackInteraction(actedOnItem, customEventName) {
function vfGaTrackInteraction(actedOnItem, customEventName) {
var customEventName = customEventName || []; // you can pass some custom text as a 3rd param

@@ -232,3 +234,3 @@ let linkName;

linkName = actedOnItem.innerText;
console.log('linkName',linkName);
// console.log('linkName',linkName);

@@ -239,2 +241,14 @@ // if there's no text, it's probably and image

// is there an inner image?
if (linkName.length == 0 && actedOnItem.getElementsByTagName('img')) {
if (actedOnItem.getElementsByTagName('img')[0]) {
if (actedOnItem.getElementsByTagName('img')[0].hasAttribute('src')) {
linkName = actedOnItem.src.split('/').vfGaLinkLast();
}
}
}
// fallback to an href value
if (linkName.length == 0 && actedOnItem.href) linkName = actedOnItem.href;
// special things for gloabl search box

@@ -286,5 +300,7 @@ // if (parentContainer == 'Global search') {

if (conditionalLoggingCheck.dataset.vfGoogleAnalyticsVerbose) {
console.log('%c Verbose analytics on ', 'color: #FFF; background: #111; font-size: .75rem;');
console.log('clicked on: %o ',actedOnItem);
console.log('sent to GA: ', 'event ->', 'UI ->', 'UI Element / ' + parentContainer + ' ->', linkName, '; at: ',lastGaEventTime);
if (conditionalLoggingCheck.dataset.vfGoogleAnalyticsVerbose == 'true') {
console.log('%c Verbose analytics on ', 'color: #FFF; background: #111; font-size: .75rem;');
console.log('clicked on: %o ',actedOnItem);
console.log('sent to GA: ', 'event ->', 'UI ->', 'UI Element / ' + parentContainer + ' ->', linkName, '; at: ',lastGaEventTime);
}
}

@@ -291,0 +307,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc