Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Understand how your tool is being used by anonymously reporting usage metrics to Google Analytics
The 'insight' npm package is used for tracking and reporting anonymous usage metrics for your Node.js applications. It helps developers understand how their tools are being used by collecting data such as command usage, version information, and other relevant metrics.
Tracking Usage
This feature allows you to track usage events in your application. The code sample demonstrates how to initialize the Insight instance, ask for user permission, and track an event.
const Insight = require('insight');
const pkg = require('./package.json');
const insight = new Insight({
trackingCode: 'UA-000000-01',
pkg
});
// Ask for permission the first time
if (insight.optOut === undefined) {
insight.askPermission();
}
// Track an event
insight.track('event', 'category', 'action', 'label', 'value');
Opt-in/Opt-out Management
This feature allows you to manage user consent for tracking. The code sample shows how to check if the user has opted out of tracking.
const Insight = require('insight');
const pkg = require('./package.json');
const insight = new Insight({
trackingCode: 'UA-000000-01',
pkg
});
// Check if the user has opted out
if (insight.optOut) {
console.log('User has opted out of tracking');
} else {
console.log('User has opted in to tracking');
}
Custom Event Tracking
This feature allows you to track custom events specific to your application. The code sample demonstrates how to track a custom event with specific parameters.
const Insight = require('insight');
const pkg = require('./package.json');
const insight = new Insight({
trackingCode: 'UA-000000-01',
pkg
});
// Track a custom event
insight.track('customEvent', 'customCategory', 'customAction', 'customLabel', 'customValue');
The 'analytics-node' package is a client for Segment's analytics service. It allows you to track events and send them to various analytics services. Compared to 'insight', 'analytics-node' offers more integrations and is part of a larger analytics ecosystem.
The 'universal-analytics' package is a Node.js module for Google's Universal Analytics. It allows you to send data to Google Analytics from your server-side applications. Unlike 'insight', which is more focused on anonymous usage tracking, 'universal-analytics' is specifically designed for Google Analytics.
The 'mixpanel' package is a client for Mixpanel's analytics service. It provides robust event tracking and user analytics capabilities. Compared to 'insight', 'mixpanel' offers more advanced features like user segmentation and funnel analysis.
Understand how your tool is being used by anonymously reporting usage metrics to Google Analytics or Yandex.Metrica
This module uses the newly released Universal Analytics API from Google Analytics
Displaying metrics from Yeoman which makes use of Insight.
Google Analytics
var Insight = require('insight');
var insight = new Insight({
// Google Analytics tracking code
trackingCode: 'UA-XXXXXXXX-X'
});
// ask for permission the first time
if (insight.optOut === undefined) {
return insight.askPermission();
}
insight.track('foo', 'bar');
// recorded in Analytics as `/foo/bar`
Yandex.Metrica
var Insight = require('insight');
var insight = new Insight({
// Yandex.Metrica counter id
trackingCode: 'XXXXXXXXX'
trackingProvider: 'yandex'
});
// ask for permission the first time
if (insight.optOut === undefined) {
return insight.askPermission();
}
insight.track('foo', 'bar');
// recorded in Yandex.Metrica as `http://<package-name>.insight/foo/bar`
or a live example
Type: string
Required
Your Google Analytics trackingCode or Yandex.Metrica counter id.
Type: string
Default: 'google'
Tracking provider to use
Possible values are 'google'
or 'yandex'
Type: string
Default: 'package.json'
Relative path to your module package.json
Type: string
Default: Inferred from packageFile
Used instead of inferring it from packageFile
Requires you to also specify packageVersion
Type: string
Default: Inferred from packageFile
Used instead of inferring it from packageFile
Requires you to also specify packageName
Accepts keywords which ends up as a path in Analytics.
.track('init', 'backbone')
becomes /init/backbone
Asks the user for permission to track and sets the optOut
property. You can also choose to set this manually.
Optionally supply your own message
and callback
. The callback will be called with the arguments error
and optOut
when the prompt is done, and is useful for when you want to continue the execution while the prompt is running.
Returns a boolean whether the user has opted out of tracking. Should preferably only be set by a user action, eg. a prompt.
BSD license and copyright Google
FAQs
Understand how your tool is being used by anonymously reporting usage metrics to Google Analytics or Yandex.Metrica
The npm package insight receives a total of 96,091 weekly downloads. As such, insight popularity was classified as popular.
We found that insight demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 10 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.