
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@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
The npm package @meniga/analytics receives a total of 249 weekly downloads. As such, @meniga/analytics popularity was classified as not popular.
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
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.