Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#310 #123

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

#310 #123

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
VUE_APP_MAARG_LOGIN=["atp", "company", "order-routing"]
VUE_APP_MIX_PANEL_TOKEN=''
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
11 changes: 11 additions & 0 deletions src/services/UserService.ts
Original file line number Diff line number Diff line change
@@ -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<any> => {
return api({
Expand Down Expand Up @@ -27,6 +28,16 @@ const getUserProfile = async (token: any): Promise<any> => {
}
});
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)
Expand Down
10 changes: 10 additions & 0 deletions src/store/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: () => ({
Expand Down Expand Up @@ -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
Expand Down