diff --git a/.env.example b/.env.example index f212c93..de98881 100644 --- a/.env.example +++ b/.env.example @@ -4,4 +4,5 @@ VUE_APP_I18N_FALLBACK_LOCALE=en VUE_APP_LOCALES={"en": "English", "ja": "日本語", "es": "Español"} VUE_APP_CURRENCY_FORMATS={"en": {"currency": {"style": "currency","currency": "USD"}}, "ja": {"currency": {"style": "currency", "currency": "JPY"}}, "es": {"currency": {"style": "currency","currency": "ESP"}}} VUE_APP_DEFAULT_ALIAS= -VUE_APP_MAARG_LOGIN=["atp", "company", "order-routing"] \ No newline at end of file +VUE_APP_MAARG_LOGIN=["atp", "company", "order-routing"] +VUE_APP_MIX_PANEL_TOKEN='' \ No newline at end of file diff --git a/package.json b/package.json index f90494f..d5c11ea 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "i18n:report": "vue-cli-service i18n:report --src \"./src/**/*.?(js|vue)\" --locales \"./src/locales/**/*.json\"" }, "dependencies": { - "@hotwax/dxp-components": "^1.12.2", + "@hotwax/dxp-components": "../dxp-components", "@hotwax/oms-api": "^1.13.0", "@ionic/core": "^7.6.0", "@ionic/vue": "^7.6.0", diff --git a/src/services/UserService.ts b/src/services/UserService.ts index 26ad34e..d0ed6ba 100644 --- a/src/services/UserService.ts +++ b/src/services/UserService.ts @@ -1,5 +1,6 @@ import { api, client, hasError } from '@/adapter'; import { useAuthStore } from '@/store/auth'; +import { addMixPanelUser } from '@hotwax/dxp-components'; const login = async (username: string, password: string): Promise => { return api({ @@ -27,6 +28,16 @@ const getUserProfile = async (token: any): Promise => { } }); if (hasError(resp)) return Promise.reject("Error getting user profile: " + JSON.stringify(resp.data)); + + // Mixpanel code to fetch properties of users for analytics (if the role of user changes) + const appName = 'LaunchPad'; + const user = resp.data; + addMixPanelUser(user.userId, { + '$userLoginId': user.userLoginId, + '$email': user.email, + 'app_name': appName, + }); + return Promise.resolve(resp.data) } catch(error: any) { return Promise.reject(error) diff --git a/src/store/auth.ts b/src/store/auth.ts index b5699cd..4c321d5 100644 --- a/src/store/auth.ts +++ b/src/store/auth.ts @@ -5,6 +5,7 @@ import { hasError, logout, updateInstanceUrl, updateToken } from '@/adapter'; import { showToast } from '@/util'; import { translate } from '@/i18n' import emitter from "@/event-bus"; +import { addMixPanelEvent } from '@hotwax/dxp-components'; export const useAuthStore = defineStore('authStore', { state: () => ({ @@ -59,6 +60,15 @@ export const useAuthStore = defineStore('authStore', { this.current = await UserService.getUserProfile(this.token.value); updateToken(this.token.value) + + // Mixpanel code to track login event occurance for analytics + const appName = 'LaunchPad'; + + addMixPanelEvent('Login', { + '$userLoginId':this.current.userLoginId, + '$app_name': appName, + }) + // Handling case for warnings like password may expire in few days if (resp.data._EVENT_MESSAGE_ && resp.data._EVENT_MESSAGE_.startsWith("Alert:")) { // TODO Internationalise text