mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-10-14 13:51:29 +08:00

* feat: setup the app context to fetch users,licenses and feature flags * feat: added global event listeners for after_login event * feat: remove redux from app state and private route * feat: syncronize the approutes file * feat: cleanup the private routes * feat: handle login and logout * feat: cleanup the app layout file * feat: cleanup and syncronize side nav item * fix: minor small re-render issue * feat: parallel processing for sync calls for faster bootup of application * feat: some refactoring for private routes * fix: entire application too much re-rendering * fix: remove redux * feat: some more corrections * feat: fix all the files except signup * feat: add app provider to the test-utils * feat: should fix a lot of tests * chore: fix more tests * chore: fix more tests * feat: fix some tests and corrected the redux mock * feat: delete snapshot * fix: test cases * fix: pipeline actions test cases * fix: billing test cases * feat: update the signup API to accept isAnonymous and hasOptedUpdates * chore: cleanup the console logs * fix: indefinite loading on manage licenses screen * fix: better handling and route to something_went_wrong in case of qs down * fix: signup for subsequent users * chore: update test-utils * fix: jerky behaviour on entering the home page * feat: handle the retention for login context flow * fix: do not let users workaround workspace blocked screen
41 lines
945 B
TypeScript
41 lines
945 B
TypeScript
import { useAppContext } from 'providers/App/App';
|
|
import { useCallback } from 'react';
|
|
import { extractDomain } from 'utils/app';
|
|
|
|
const useAnalytics = (): any => {
|
|
const { user } = useAppContext();
|
|
|
|
// Segment Page View - analytics.page([category], [name], [properties], [options], [callback]);
|
|
const trackPageView = useCallback(
|
|
(pageName: string): void => {
|
|
if (user && user.email) {
|
|
window.analytics.page(null, pageName, {
|
|
userId: user.email,
|
|
});
|
|
}
|
|
},
|
|
[user],
|
|
);
|
|
|
|
const trackEvent = (
|
|
eventName: string,
|
|
properties?: Record<string, unknown>,
|
|
): void => {
|
|
if (user && user.email) {
|
|
const context = {
|
|
context: {
|
|
groupId: extractDomain(user?.email),
|
|
},
|
|
};
|
|
|
|
const updatedProperties = { ...properties };
|
|
updatedProperties.userId = user.email;
|
|
window.analytics.track(eventName, properties, context);
|
|
}
|
|
};
|
|
|
|
return { trackPageView, trackEvent };
|
|
};
|
|
|
|
export default useAnalytics;
|