@atlaskit/editor-core
Version:
A package contains Atlassian editor core functionality
18 lines (14 loc) • 619 B
text/typescript
import { AnalyticsHandler, detectHandler } from './handler';
/**
* The service allows @analytics annotations to access the analytics Handler
* from an arbitrary scope. This coupling assumes that there is only one analytics
* Handler that should be used on the page across all components.
*/
export class AnalyticsService {
// trackEvent: analyticsHandler = (name: string, properties?: analyticsProperties) => {};
trackEvent: AnalyticsHandler = detectHandler();
set handler(handler: AnalyticsHandler | null) {
this.trackEvent = handler ? handler : () => {};
}
}
export default new AnalyticsService();