Tracklytics implements AspectListener { @Override public void onAspectEventTriggered(TrackEvent trackEvent, Map<String, Object> attributes) { trackEvent(new Event(trackEvent, attributes, superAttributes)); } private  Tracklytics(EventSubscriber eventSubscriber); static Tracklytics init(EventSubscriber eventSubscriber); void trackEvent(String eventName); void trackEvent(String eventName, Map<String, Object> attributes); void setEventLogListener(EventLogListener logger); void addSuperAttribute(String key, Object value); void removeSuperAttribute(String key); @Override void onAspectEventTriggered(TrackEvent trackEvent, Map<String, Object> attributes); @Override void onAspectSuperAttributeAdded(String key, Object value); @Override void onAspectSuperAttributeRemoved(String key);  }
@Test public void trackFromAspectEvent() throws Throwable { class Foo { @TrackEvent("event_name") public void foo() { } } TrackEvent trackEvent = Foo.class.getMethod("foo").getAnnotation(TrackEvent.class); Map<String, Object> attributes = new HashMap<>(); attributes.put("key", "value"); tracklytics.onAspectEventTriggered(trackEvent, attributes); verify(eventSubscriber).onEventTracked(eventCaptor.capture()); assertThat(eventCaptor.getValue().name).isEqualTo("event_name"); assertThat(eventCaptor.getValue().attributes).containsExactly("key", "value"); }