Skip to content

Commit

Permalink
changes for mixpanel api id
Browse files Browse the repository at this point in the history
  • Loading branch information
namansleeps committed Sep 18, 2023
1 parent c29b9a0 commit bdf020f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
9 changes: 5 additions & 4 deletions gui/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
addUser,
installToolkitTemplate, installAgentTemplate, installKnowledgeTemplate, getFirstSignup
} from "@/pages/api/DashboardService";
import {githubClientId} from "@/pages/api/apiConfig";
import {githubClientId, mixpanelId} from "@/pages/api/apiConfig";
import {
getGithubClientId
} from "@/pages/api/DashboardService";
Expand Down Expand Up @@ -112,8 +112,8 @@ export default function App() {
setEnv(env);

if (typeof window !== 'undefined') {
if(response.data.env === 'PROD')
mixpanel.init("66422baf1e14332d36273c6addcf22f7", { debug: false, track_pageview: true, persistence: 'localStorage' });
if(response.data.env === 'PROD' && mixpanelId())
mixpanel.init(mixpanelId(), { debug: false, track_pageview: true, persistence: 'localStorage' });
localStorage.setItem('applicationEnvironment', env);
}

Expand All @@ -136,7 +136,8 @@ export default function App() {
validateAccessToken()
.then((response) => {
setUserName(response.data.name || '');
mixpanel.identify(response.data.email)
if(mixpanelId())
mixpanel.identify(response.data.email)
if(first_login)
getUserClick('New Sign Up', {})
else
Expand Down
5 changes: 5 additions & 0 deletions gui/pages/api/apiConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import axios from 'axios';

const GITHUB_CLIENT_ID = process.env.GITHUB_CLIENT_ID;
const API_BASE_URL = process.env.NEXT_PUBLIC_API_BASE_URL || 'http://localhost:8001';
const MIXPANEL_AUTH_ID = process.env.MIXPANEL_AUTH_ID

export const baseUrl = () => {
return API_BASE_URL;
Expand All @@ -11,6 +12,10 @@ export const githubClientId = () => {
return GITHUB_CLIENT_ID;
};

export const mixpanelId = () => {
return MIXPANEL_AUTH_ID;
};

const api = axios.create({
baseURL: API_BASE_URL,
headers: {
Expand Down
4 changes: 2 additions & 2 deletions gui/utils/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {formatDistanceToNow, format, addMinutes} from 'date-fns';
import {utcToZonedTime} from 'date-fns-tz';
import {baseUrl} from "@/pages/api/apiConfig";
import {baseUrl, mixpanelId} from "@/pages/api/apiConfig";
import {EventBus} from "@/utils/eventBus";
import JSZip from "jszip";
import moment from 'moment';
Expand Down Expand Up @@ -563,7 +563,7 @@ export const getUTMParametersFromURL = () => {

export const getUserClick = (event, props) => {
const env = localStorage.getItem('applicationEnvironment');
if(env === 'PROD'){
if(env === 'PROD' && mixpanelId()){
mixpanel.track(event, props)
}
}

0 comments on commit bdf020f

Please sign in to comment.