![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@meniga/analytics
Advanced tools
A library to track events and send them to analytics services, like meniga, google, or segment
This package is used to track events in Meniga products
Create a config file called tracking.js in your container app that specifies which tracking services should be enabled.
Example:
export default {
services: {
google: {
enabled: true,
useAsDefault: true,
id: "UA-10093770-21",
debug: false
},
meniga: {
enabled: true,
useAsDefault: false
},
segment: {
enabled: true,
id: "",
useAsDefault: false
}
}
};
Not all fields are required for each service, but enabled and useAsDefault should always be present.
enabled means that the service is "turned on" and can be explicitly called when needed.
useAsDefault means that the service is always called during tracking calls, allowing you to call multiple services as default if needed. Note: enabled needs to be true as well.
To track an event you need to import the analytics actions to your component, like this:
import { actions as trackingActions } from '@meniga/analytics'
and then you use it like this:
dispatch(trackingActions.trackScreen(request, service))
The request param can either be a single string or a JSON object that should look something like this:
{
type: 'modal' //optional [string] - possible vales: 'page', 'modal', 'tab'. Default value is 'page'.
category: 'Transactions', //optional [string] - the category of the screen. Useful to group different screens together.
name: 'Transaction List', //required [string] - the name of the screen to track
}
If you send only a single string to trackScreen() it is used as the name of the screen.
dispatch(trackingActions.trackEvent(request, service))
The request param should look something like this:
{
type: 'Account', //optional [string] (used as trackingType for meniga's /eventtracking service)
action: 'Account Updated', //required [string] (used as trackingState for meniga's /eventtracking service)
id: 1, //optional [number] (used as trackingId for meniga's /eventtracking service)
meta: {}, //optional [json] (used as media for meniga's /eventtracking service)
}
The service param, if specified, should be a string array. Only the services listed will be called, otherwise the 'useAsDefault' services will be called.
Example:
dispatch(trackingActions.trackEvent({
action: 'Account Updated',
meta: {
fields: [
name: 'Account Type',
value: 'Current'
]
}
}, ['segment', 'meniga']))
Right now we have a built in support for google analytics, segment.com and the meniga /eventtracking api service. In order to add support for a new service, you need to add code to the identifyUser and trackEvent functions in api.js that deals with calling that service. Then you also might have to add code to the initialize.js file to initialize the connection to the service.
Example:
function callMenigaService () {
if(supportedServices.meniga) {
return Request.post(`${ baseUrl }/eventtracking`, { trackingType, trackingState, trackerId, meta })
} else {
return new Promise((resolve) => {
resolve()
})
}
}
function callGoogleService () {
if(supportedServices.google) {
return new Promise((resolve, reject) => {
if (trackingType === 'modal') {
ReactGA.modalview(trackingState)
} else if (trackingType === 'event') {
ReactGA.event(trackingState)
} else if (trackingType === 'page') {
ReactGA.pageview(trackingState)
}
resolve()
})
} else {
return new Promise((resolve) => {
resolve()
})
}
}
function callSegmentService() {
if(supportedServices.segment) {
return new Promise((resolve) => {
if(trackingType === 'page') {
analytics.page(trackingState)
} else {
analytics.track(trackingState, meta);
}
resolve()
})
} else {
return new Promise((resolve) => {
resolve()
})
}
}
etc.
FAQs
A library to track events and send them to analytics services, like meniga, google, or segment
We found that @meniga/analytics demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.