Skip to content

Commit

Permalink
Mixpanel additons (TransformerOptimus#1344)
Browse files Browse the repository at this point in the history
  • Loading branch information
namansleeps authored Oct 18, 2023
1 parent b2e0c7f commit 862a701
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gui/pages/Content/Agents/AgentCreate.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ export default function AgentCreate({
const name = response.data.name;
const executionId = response.data.execution_id;
fetchAgents();
getUserClick('Agent Created Successfully', {})
getUserClick('Agent Created Successfully', {'templateName': template?.id ? template.name : ''})
getUserClick('Agent Run created successfully', {})
uploadResources(agentId, name, executionId)
})
Expand Down
1 change: 1 addition & 0 deletions gui/pages/Dashboard/TopBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default function TopBar({selectedProject, userName, env}) {
// localStorage.removeItem('accessToken');
Cookies.set('accessToken', '', { expires: new Date(0),domain: '.superagi.com', path: '/'});
Cookies.set('Source', 'app.superagi', {domain: '.superagi.com', path: '/'});
Cookies.set('mixpanel_initialized', 'false', {domain: '.superagi.com', path: '/'});
refreshUrl();
router.reload();
};
Expand Down
21 changes: 13 additions & 8 deletions gui/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,11 @@ export default function App() {
.then((response) => {
const env = response.data.env;
setEnv(env);

const mixpanelInitialized = Cookies.get('mixpanel_initialized') === 'true'
if (typeof window !== 'undefined') {
if(response.data.env === 'PROD' && mixpanelId())
mixpanel.init(mixpanelId(), { debug: false, track_pageview: true, persistence: 'localStorage' });
if(response.data.env === 'PROD' && mixpanelId()) {
mixpanel.init(mixpanelId(), {debug: false, track_pageview: !mixpanelInitialized, persistence: 'localStorage'});
}
localStorage.setItem('applicationEnvironment', env);
}

Expand All @@ -122,7 +123,7 @@ export default function App() {
const queryParams = router.asPath.split('?')[1];
const parsedParams = querystring.parse(queryParams);
let access_token = parsedParams.access_token || null;
let first_login = parsedParams.first_time_login || false
let first_login = parsedParams.first_time_login || ''

const utmParams = getUTMParametersFromURL();
if (utmParams) {
Expand All @@ -136,7 +137,7 @@ export default function App() {

if (typeof window !== 'undefined' && access_token) {
// localStorage.setItem('accessToken', access_token);
Cookies.set('accessToken', access_token, { domain: '.superagi.com', path: '/' });
Cookies.set('accessToken', access_token, {domain: '.superagi.com', path: '/'});
refreshUrl();
}
validateAccessToken()
Expand All @@ -145,15 +146,19 @@ export default function App() {
sendGAEvent(response.data.email, 'Signed Up Successfully', {'utm_source': signupSource || '', 'utm_medium': signupMedium || '', 'campaign': singupCampaign || ''})
if(mixpanelId())
mixpanel.identify(response.data.email)
if(first_login)
if(first_login === 'True') {
getUserClick('New Sign Up', {})
else
getUserClick('User Logged In', {})
}
else {
if (first_login === 'False')
getUserClick('User Logged In', {})
}

if(signupSource) {
handleSignUpSource(signupSource)
}
fetchOrganisation(response.data.id);
Cookies.set('mixpanel_initialized', 'true', {domain: '.superagi.com', path: '/'});
})
.catch((error) => {
console.error('Error validating access token:', error);
Expand Down

0 comments on commit 862a701

Please sign in to comment.