Files
myeasycms-v2/packages/analytics/src/null-analytics-service.ts
Giancarlo Buomprisco 6f9cf22fa8 EsLint v9 (#154)
* Upgrade ESLint and related configurations to version 9

- Update ESLint to version 9.19.0
- Migrate ESLint configurations to flat config format
- Remove deprecated ESLint config files
- Update package dependencies and configurations
- Simplify ESLint setup across packages
- Remove unnecessary ESLint config blocks from package.json files
- Improved CI caching with Turborepo tasks
- Removed duplicate styles
2025-02-07 11:38:29 +08:00

24 lines
748 B
TypeScript

import { AnalyticsService } from './types';
const noop = (event: string) => {
// do nothing - this is to prevent errors when the analytics service is not initialized
return async (...args: unknown[]) => {
console.debug(
`Noop analytics service called with event: ${event}`,
...args.filter(Boolean),
);
};
};
/**
* Null analytics service that does nothing. It is initialized with a noop function. This is useful for testing or when
* the user is calling analytics methods before the analytics service is initialized.
*/
export const NullAnalyticsService: AnalyticsService = {
initialize: noop('initialize'),
trackPageView: noop('trackPageView'),
trackEvent: noop('trackEvent'),
identify: noop('identify'),
};