Skip to content

Commit

Permalink
Improved: removed console logs(hotwax#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ridwan6947 committed Jul 16, 2024
1 parent 679c006 commit 1b9ebaf
Showing 1 changed file with 1 addition and 24 deletions.
25 changes: 1 addition & 24 deletions src/mixins/analytics.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// composables/useAnalytics.ts

import { onMounted, onBeforeUnmount } from 'vue';
import mixpanel from 'mixpanel-browser';
import { appContext } from '../index';

interface TrackableMetadata {
label?: string;
id?: string;
[key: string]: any; // Allow other properties as well
[key: string]: any;
}

function useAnalytics() {
Expand All @@ -29,8 +27,6 @@ function useAnalytics() {
const buttonLabel = metadata.label || button.innerText || button.getAttribute('aria-label') || 'Unnamed button';
const buttonId = button.id || metadata.id || 'no-id';

console.log('Trackable Button Clicked:', { label: buttonLabel, id: buttonId });

mixpanel.track(buttonLabel, {
label: buttonLabel,
id: buttonId,
Expand All @@ -45,49 +41,30 @@ function useAnalytics() {

try {
mixpanel.init('5d1a58b28169000ca197c14274eddf87', { debug: true });
console.log('Mixpanel initialized');
} catch (error) {
console.error('Error initializing Mixpanel:', error);
return;
}

const appState = appContext.config.globalProperties.$store;

if (!appState) {
console.error('appState is not defined');
return;
}

const userProfile = appState.getters['user/getUserProfile'];

if (!userProfile) {
console.error('userProfile is not defined');
return;
}

const userEmail = userProfile.email;
const userID = userProfile.userLoginId;

console.log('User Profile:', { userID, userEmail });

try {
mixpanel.identify(userID);
mixpanel.people.set({
$email: userEmail,
$userId: userID,
});
} catch (error) {
console.error('Error identifying user in Mixpanel:', error);
return;
}

document.addEventListener('click', handleButtonClick);
console.log('Event listener added for button clicks');
});

onBeforeUnmount(() => {
document.removeEventListener('click', handleButtonClick);
console.log('Event listener removed for button clicks');
});
}

Expand Down

0 comments on commit 1b9ebaf

Please sign in to comment.