Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
@automattic/calypso-analytics
Advanced tools
Currently this package supports calls to Tracks only.
Automatticians may refer to internal documentation for more information about Tracks.
Note: In most situations it is best to use the Analytics Middleware, which has no direct browser dependencies and therefore will not complicate any unit testing of the modules where it is used.
recordTracksEvent( name, properties )
import { recordTracksEvent } from '@automattic/calypso-analytics';
recordTracksEvent( 'calypso_signup_step_start', { step: 'a_nice_step' } );
Note: Unless you have a strong reason to call recordTracksEvent
directly, you should use the Analytics Middleware instead:
import { recordTracksEvent } from 'calypso/state/analytics/actions';
dispatch( recordTracksEvent( 'calypso_checkout_coupon_apply', { coupon_code: 'abc123' } ) );
Record an event with optional properties:
import { initializeAnalytics, recordTracksEvent } from '@automattic/calypso-analytics';
// first the module should be initialized with extra metadata by caling initialize once from app boot or other middleware
// ... client/boot/common.js
initializeAnalytics( currentUser, superProps );
//in your component
recordTracksEvent( 'calypso_do_thing', { extra: 'info' } );
recordTracksEvent( name, properties )
deprecates the following call to the analytics lib method:
// eslint-disable-next-line no-restricted-imports
import { recordTracksEvent } from 'calypso/lib/analytics/tracks';
recordTracksEvent( name, properties );
To be recorded, event names originating from Calypso must be prefixed by calypso_
, and each token in the event and property names must be separated by an underscore (_
).
_Note: Events not prefixed by calypso_
, with words not separated by underscore (e.g. by spaces or dashes), or written in camel case, will be discarded._
In order to keep similar events grouped together when sorted in an alphabetized list (as is typical with analytics tools), put the verb at the end of the event name:
calypso_cart_product_add
calypso_cart_product_remove
If we had instead used calypso_add_cart_product
and calypso_remove_cart_product
, then they'd likely be separated in a list of all the event names.
Finally, for consistency, the verb at the end should be in a non-conjugated form like add
, remove
, view
, or click
, and not adds
, added
, or adding
.
With the exception of separating tokens with underscores, these rules do not apply to property names. coupon_code
is perfectly fine.
FAQs
Automattic Analytics.
The npm package @automattic/calypso-analytics receives a total of 2,577 weekly downloads. As such, @automattic/calypso-analytics popularity was classified as popular.
We found that @automattic/calypso-analytics demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 50 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 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.