@mx-cartographer/experiences 9.6.9 → 9.6.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/core/stores/AccountStore.d.ts +1 -0
  3. package/dist/core/stores/AccountStore.es.js +47 -42
  4. package/dist/core/stores/AccountStore.es.js.map +1 -1
  5. package/dist/core/stores/AppDataStore.d.ts +1 -0
  6. package/dist/core/stores/AppDataStore.es.js +15 -11
  7. package/dist/core/stores/AppDataStore.es.js.map +1 -1
  8. package/dist/core/stores/BeatStore.d.ts +1 -0
  9. package/dist/core/stores/BeatStore.es.js +10 -6
  10. package/dist/core/stores/BeatStore.es.js.map +1 -1
  11. package/dist/core/stores/BudgetsStore.d.ts +1 -0
  12. package/dist/core/stores/BudgetsStore.es.js +37 -35
  13. package/dist/core/stores/BudgetsStore.es.js.map +1 -1
  14. package/dist/core/stores/CategoryStore.d.ts +1 -0
  15. package/dist/core/stores/CategoryStore.es.js +36 -32
  16. package/dist/core/stores/CategoryStore.es.js.map +1 -1
  17. package/dist/core/stores/FinstrongStore.d.ts +1 -0
  18. package/dist/core/stores/FinstrongStore.es.js +42 -38
  19. package/dist/core/stores/FinstrongStore.es.js.map +1 -1
  20. package/dist/core/stores/GlobalCopyStore.d.ts +1 -0
  21. package/dist/core/stores/GlobalCopyStore.es.js +17 -13
  22. package/dist/core/stores/GlobalCopyStore.es.js.map +1 -1
  23. package/dist/core/stores/GoalStore.d.ts +1 -0
  24. package/dist/core/stores/GoalStore.es.js +104 -100
  25. package/dist/core/stores/GoalStore.es.js.map +1 -1
  26. package/dist/core/stores/HelpStore.d.ts +1 -0
  27. package/dist/core/stores/HelpStore.es.js +10 -6
  28. package/dist/core/stores/HelpStore.es.js.map +1 -1
  29. package/dist/core/stores/HoldingStore.d.ts +1 -0
  30. package/dist/core/stores/HoldingStore.es.js +6 -2
  31. package/dist/core/stores/HoldingStore.es.js.map +1 -1
  32. package/dist/core/stores/NetWorthStore.d.ts +1 -0
  33. package/dist/core/stores/NetWorthStore.es.js +12 -8
  34. package/dist/core/stores/NetWorthStore.es.js.map +1 -1
  35. package/dist/core/stores/NotificationStore.d.ts +1 -0
  36. package/dist/core/stores/NotificationStore.es.js +11 -7
  37. package/dist/core/stores/NotificationStore.es.js.map +1 -1
  38. package/dist/core/stores/SettingsStore.d.ts +1 -0
  39. package/dist/core/stores/SettingsStore.es.js +23 -19
  40. package/dist/core/stores/SettingsStore.es.js.map +1 -1
  41. package/dist/core/stores/TransactionStore.d.ts +1 -0
  42. package/dist/core/stores/TransactionStore.es.js +71 -67
  43. package/dist/core/stores/TransactionStore.es.js.map +1 -1
  44. package/dist/core/stores/UserStore.d.ts +1 -0
  45. package/dist/core/stores/UserStore.es.js +10 -6
  46. package/dist/core/stores/UserStore.es.js.map +1 -1
  47. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"GoalStore.es.js","names":[],"sources":["../../../src/core/stores/GoalStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\n\nimport { GoalApi } from '../api'\nimport { upsertByGuid } from '../utils/upsertByGuid'\n\nimport {\n type Goal,\n type MonthlyCashFlowProfile,\n type RetirementGoalAccount,\n TrackType,\n} from '../types'\nimport { getProjectedRetirementDate } from '../utils/GoalsUtil'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class GoalStore {\n globalStore: GlobalStore\n api = new GoalApi('/', '')\n\n goals: Goal[] = []\n goalsLoaded: boolean = false\n retirementGoals: Goal[] = []\n retirementGoalsLoaded: boolean = false\n retirementGoalAccounts: RetirementGoalAccount[] = []\n retirementGoalAccountsLoaded: boolean = false\n monthlyCashFlowProfile: MonthlyCashFlowProfile | undefined = undefined\n monthlyCashFlowProfileLoaded: boolean = false\n\n newRetirementGoalAccounts: RetirementGoalAccount[] = []\n\n alert: string = ''\n selectedGoal: Goal | undefined = undefined\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new GoalApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n get allGoals(): Goal[] {\n if (!this.isAllGoalDataLoaded) return []\n\n const goalsCopy = this.globalStore.copyStore.copy.goals\n const userBirthday = this.globalStore.userStore.user.birthday\n return [\n ...this.goals,\n ...this.retirementGoals.map((goal: Goal) => ({\n ...goal,\n amount: goal.target_amount,\n name: goalsCopy.retirement,\n track_type: TrackType.RETIREMENT_TRACK,\n projected_to_complete_at:\n goal.retirement_age && userBirthday\n ? getProjectedRetirementDate(goal.retirement_age, userBirthday)\n : undefined,\n })),\n ] as Goal[]\n }\n\n get orderedGoals(): Goal[] {\n return this.allGoals.slice().sort((a, b) => a.position - b.position)\n }\n\n get debtGoals() {\n return this.orderedGoals.filter((goal) => goal.track_type === TrackType.DEBT_TRACK)\n }\n\n get retirmentGoals() {\n return this.orderedGoals.filter((goal) => goal.track_type === TrackType.RETIREMENT_TRACK)\n }\n\n get savingGoals() {\n return this.orderedGoals.filter((goal) => goal.track_type === TrackType.SAVINGS_TRACK)\n }\n\n get ongoingGoalsForMicroWidget() {\n const ongoingGoals = this.allGoals.filter(\n (goal) =>\n !goal.is_complete &&\n goal.track_type !== TrackType.EMERGENCY_FUND_TRACK &&\n goal.track_type !== null,\n )\n const priorityOrder = [\n TrackType.SAVINGS_TRACK,\n TrackType.DEBT_TRACK,\n TrackType.RETIREMENT_TRACK,\n ]\n return ongoingGoals\n .sort((a, b) => {\n const aIndex = a.track_type ? priorityOrder.indexOf(a.track_type) : -1\n const bIndex = b.track_type ? priorityOrder.indexOf(b.track_type) : -1\n return aIndex - bIndex\n })\n .slice(0, 3)\n }\n\n get isAllGoalDataLoaded() {\n return (\n this.goalsLoaded &&\n this.retirementGoalsLoaded &&\n this.retirementGoalAccountsLoaded &&\n this.monthlyCashFlowProfileLoaded\n )\n }\n\n setGoals = (goals: Goal[]) => {\n this.goals = goals\n this.goalsLoaded = true\n }\n\n setRetirementGoals = (goals: Goal[]) => {\n this.retirementGoals = goals\n this.retirementGoalsLoaded = true\n }\n\n setRetirementGoalAccounts = (accounts: RetirementGoalAccount[]) => {\n this.retirementGoalAccounts = accounts\n this.retirementGoalAccountsLoaded = true\n }\n\n setMonthlyCashFlowProfile = (profile: MonthlyCashFlowProfile) => {\n this.monthlyCashFlowProfile = profile\n this.monthlyCashFlowProfileLoaded = true\n }\n\n loadGoalData = async () => {\n await Promise.all([\n this.loadGoals(),\n this.loadRetirementGoals(),\n this.loadRetirementGoalAccounts(),\n this.loadMonthlyCashFlowProfile(),\n ])\n }\n\n loadGoals = async () => {\n try {\n const goals = await this.api.getGoals()\n this.setGoals(goals)\n } catch (error) {\n console.error('Error occurred while getting goals:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n loadRetirementGoals = async () => {\n try {\n const retirementGoals = await this.api.getRetirementGoals()\n this.setRetirementGoals(retirementGoals)\n } catch (error) {\n console.error('Error occurred while loading retirement goals:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n loadRetirementGoalAccounts = async () => {\n try {\n const retirementGoalAccounts = await this.api.getRetirementGoalAccounts()\n this.setRetirementGoalAccounts(retirementGoalAccounts)\n } catch (error) {\n console.error('Error occurred while loading retirement goal accounts:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n loadMonthlyCashFlowProfile = async () => {\n try {\n const monthlyCashFlowProfile = await this.api.getMonthlyCashFlowProfile()\n this.setMonthlyCashFlowProfile(monthlyCashFlowProfile)\n } catch (error) {\n console.error('Error occurred while loading monthly cash flow profile:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n addGoal = async (goal: Goal) => {\n try {\n const newGoal = await this.api.addGoal(goal)\n this.setGoals(upsertByGuid(this.goals, newGoal))\n } catch (error) {\n console.error('Error occurred while adding goal:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n addRetirementGoal = async (goal: Goal) => {\n try {\n const newGoal: Goal = await this.api.addRetirementGoal(goal)\n const newAccounts = [] as RetirementGoalAccount[]\n for (const account of this.newRetirementGoalAccounts) {\n const newAccount = await this.api.addRetirementGoalAccount({\n ...account,\n retirement_goal_guid: newGoal.guid,\n })\n newAccounts.push(newAccount)\n }\n this.setNewRetirementGoalAccounts([])\n\n runInAction(() => {\n this.setRetirementGoals(upsertByGuid(this.retirementGoals, newGoal))\n this.setRetirementGoalAccounts(\n newAccounts.reduce((acc, a) => upsertByGuid(acc, a), this.retirementGoalAccounts),\n )\n })\n } catch (error) {\n console.error('Error occurred while adding retirement goal:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n addRetirementGoalAccount = async (account: RetirementGoalAccount) => {\n try {\n const newAccount = await this.api.addRetirementGoalAccount(account)\n\n runInAction(() => {\n this.retirementGoalAccounts = upsertByGuid(this.retirementGoalAccounts, newAccount)\n })\n } catch (error) {\n console.error('Error occurred while adding retirement goal account:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n deleteGoal = async (guid: string) => {\n try {\n await this.api.removeGoal(guid)\n\n const index = this.goals.findIndex((g) => g.guid === guid)\n if (index >= 0) {\n this.goals.splice(index, 1)\n }\n } catch (error) {\n console.error('Error occurred while deleting goal:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n deleteRetirementGoal = async (goal: Goal) => {\n try {\n const accounts = this.retirementGoalAccounts.filter(\n (g) => g.retirement_goal_guid === goal.guid,\n )\n for (const account of accounts) {\n await this.deleteRetirementGoalAccount(account.guid)\n }\n await this.api.removeRetirementGoal(goal.guid)\n\n const index = this.retirementGoals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.retirementGoals.splice(index, 1)\n }\n } catch (error) {\n console.error('Error deleting retirement goal:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n deleteRetirementGoalAccount = async (guid: string) => {\n try {\n await this.api.removeRetirementGoalAccount(guid)\n\n const index = this.retirementGoalAccounts.findIndex((rga) => rga.guid === guid)\n if (index >= 0) {\n this.retirementGoalAccounts.splice(index, 1)\n }\n } catch (error) {\n console.error('Error deleting retirement goal account:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n reorderGoals = async (goals: Goal[]) => {\n try {\n const reordered = (await this.api.reorderGoals(goals)) as Goal[]\n\n runInAction(() => {\n for (const goal of reordered) {\n const index = this.goals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.goals[index].position = goal.position\n }\n }\n })\n } catch (error) {\n console.error('Error reordering goals:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n setAlert = (alert: string) => (this.alert = alert)\n\n setNewRetirementGoalAccounts = (accounts: RetirementGoalAccount[]) => {\n this.newRetirementGoalAccounts = accounts\n }\n\n setSelectedGoal = (goal: Goal | undefined) => (this.selectedGoal = goal)\n\n updateGoal = async (goal: Goal) => {\n try {\n const updatedGoal = await this.api.updateGoal(goal)\n\n runInAction(() => {\n const index = this.goals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.goals[index] = updatedGoal\n }\n if (this.selectedGoal?.guid === goal.guid) {\n this.setSelectedGoal(updatedGoal)\n }\n })\n } catch (error) {\n console.error('Error occurred while updating goal:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n updateRetirementGoal = async (goal: Goal) => {\n try {\n const updatedRetirementGoal = await this.api.updateRetirementGoal({\n ...goal,\n target_amount: goal.amount,\n })\n\n runInAction(() => {\n const index = this.retirementGoals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.retirementGoals[index] = updatedRetirementGoal\n }\n\n if (this.selectedGoal?.guid === goal.guid) {\n this.setSelectedGoal(this.allGoals.find((g) => g.guid === goal.guid))\n }\n })\n } catch (error) {\n console.error('Error occurred while updating retirement goal:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n\n updateMonthlyCashFlowProfile = async (profile: MonthlyCashFlowProfile) => {\n try {\n const updatedProfile = await this.api.updateMonthlyCashFlowProfile(profile)\n this.setMonthlyCashFlowProfile(updatedProfile)\n } catch (error) {\n console.error('Error occurred while updating monthly cash flow profile:', error)\n this.globalStore.captureException(error, { store: 'GoalStore' })\n }\n }\n}\n"],"mappings":";;;;;AAeA,IAAa,IAAb,MAAuB;AAAA,EACrB;AAAA,EACA,MAAM,IAAI,EAAQ,KAAK,EAAE;AAAA,EAEzB,QAAgB,CAAC;AAAA,EACjB,cAAuB;AAAA,EACvB,kBAA0B,CAAC;AAAA,EAC3B,wBAAiC;AAAA,EACjC,yBAAkD,CAAC;AAAA,EACnD,+BAAwC;AAAA,EACxC,yBAA6D;AAAA,EAC7D,+BAAwC;AAAA,EAExC,4BAAqD,CAAC;AAAA,EAEtD,QAAgB;AAAA,EAChB,eAAiC;AAAA,EAEjC,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,KAAK,MAAM,IAAI,EAAQ,EAAY,UAAU,EAAY,cAAc,EAAY,OAAO,GAE1F,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,IAAI,WAAmB;AACrB,QAAI,CAAC,KAAK,oBAAqB,QAAO,CAAC;AAEvC,UAAM,IAAY,KAAK,YAAY,UAAU,KAAK,OAC5C,IAAe,KAAK,YAAY,UAAU,KAAK;AACrD,WAAO,CACL,GAAG,KAAK,OACR,GAAG,KAAK,gBAAgB,IAAA,CAAK,OAAgB;AAAA,MAC3C,GAAG;AAAA,MACH,QAAQ,EAAK;AAAA,MACb,MAAM,EAAU;AAAA,MAChB,YAAY,EAAU;AAAA,MACtB,0BACE,EAAK,kBAAkB,IACnB,EAA2B,EAAK,gBAAgB,CAAY,IAC5D;AAAA,IACR,EAAE,CACJ;AAAA,EACF;AAAA,EAEA,IAAI,eAAuB;AACzB,WAAO,KAAK,SAAS,MAAM,EAAE,KAAA,CAAM,GAAG,MAAM,EAAE,WAAW,EAAE,QAAQ;AAAA,EACrE;AAAA,EAEA,IAA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,CAAC;AAAA,MAExE,CAAC;AAAA,IACH,SAAS,GAAO;AACd,cAAQ,MAAM,kDAAkD,CAAK,GACrE,KAAK,YAAY,iBAAiB,GAAO,EAAE,OAAO,YAAY,CAAC;AAAA,IACjE;AAAA,EACF;AAAA,EAEA,+BAA+B,OAAO,MAAoC;AACxE,QAAI;AACF,YAAM,IAAiB,MAAM,KAAK,IAAI,6BAA6B,CAAO;AAC1E,WAAK,0BAA0B,CAAc;AAAA,IAC/C,SAAS,GAAO;AACd,cAAQ,MAAM,4DAA4D,CAAK,GAC/E,KAAK,YAAY,iBAAiB,GAAO,EAAE,OAAO,YAAY,CAAC;AAAA,IACjE;AAAA,EACF;AACF"}
1
+ {"version":3,"file":"GoalStore.es.js","names":[],"sources":["../../../src/core/stores/GoalStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\n\nimport { GoalApi } from '../api'\nimport { upsertByGuid } from '../utils/upsertByGuid'\n\nimport {\n type Goal,\n type MonthlyCashFlowProfile,\n type RetirementGoalAccount,\n TrackType,\n} from '../types'\nimport { getProjectedRetirementDate } from '../utils/GoalsUtil'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class GoalStore {\n globalStore: GlobalStore\n api = new GoalApi('/', '')\n\n goals: Goal[] = []\n goalsLoaded: boolean = false\n retirementGoals: Goal[] = []\n retirementGoalsLoaded: boolean = false\n retirementGoalAccounts: RetirementGoalAccount[] = []\n retirementGoalAccountsLoaded: boolean = false\n monthlyCashFlowProfile: MonthlyCashFlowProfile | undefined = undefined\n monthlyCashFlowProfileLoaded: boolean = false\n\n newRetirementGoalAccounts: RetirementGoalAccount[] = []\n\n alert: string = ''\n selectedGoal: Goal | undefined = undefined\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new GoalApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n get allGoals(): Goal[] {\n if (!this.isAllGoalDataLoaded) return []\n\n const goalsCopy = this.globalStore.copyStore.copy.goals\n const userBirthday = this.globalStore.userStore.user.birthday\n return [\n ...this.goals,\n ...this.retirementGoals.map((goal: Goal) => ({\n ...goal,\n amount: goal.target_amount,\n name: goalsCopy.retirement,\n track_type: TrackType.RETIREMENT_TRACK,\n projected_to_complete_at:\n goal.retirement_age && userBirthday\n ? getProjectedRetirementDate(goal.retirement_age, userBirthday)\n : undefined,\n })),\n ] as Goal[]\n }\n\n get orderedGoals(): Goal[] {\n return this.allGoals.slice().sort((a, b) => a.position - b.position)\n }\n\n get debtGoals() {\n return this.orderedGoals.filter((goal) => goal.track_type === TrackType.DEBT_TRACK)\n }\n\n get retirmentGoals() {\n return this.orderedGoals.filter((goal) => goal.track_type === TrackType.RETIREMENT_TRACK)\n }\n\n get savingGoals() {\n return this.orderedGoals.filter((goal) => goal.track_type === TrackType.SAVINGS_TRACK)\n }\n\n get ongoingGoalsForMicroWidget() {\n const ongoingGoals = this.allGoals.filter(\n (goal) =>\n !goal.is_complete &&\n goal.track_type !== TrackType.EMERGENCY_FUND_TRACK &&\n goal.track_type !== null,\n )\n const priorityOrder = [\n TrackType.SAVINGS_TRACK,\n TrackType.DEBT_TRACK,\n TrackType.RETIREMENT_TRACK,\n ]\n return ongoingGoals\n .sort((a, b) => {\n const aIndex = a.track_type ? priorityOrder.indexOf(a.track_type) : -1\n const bIndex = b.track_type ? priorityOrder.indexOf(b.track_type) : -1\n return aIndex - bIndex\n })\n .slice(0, 3)\n }\n\n get isAllGoalDataLoaded() {\n return (\n this.goalsLoaded &&\n this.retirementGoalsLoaded &&\n this.retirementGoalAccountsLoaded &&\n this.monthlyCashFlowProfileLoaded\n )\n }\n\n setGoals = (goals: Goal[]) => {\n this.goals = goals\n this.goalsLoaded = true\n }\n\n setRetirementGoals = (goals: Goal[]) => {\n this.retirementGoals = goals\n this.retirementGoalsLoaded = true\n }\n\n setRetirementGoalAccounts = (accounts: RetirementGoalAccount[]) => {\n this.retirementGoalAccounts = accounts\n this.retirementGoalAccountsLoaded = true\n }\n\n setMonthlyCashFlowProfile = (profile: MonthlyCashFlowProfile) => {\n this.monthlyCashFlowProfile = profile\n this.monthlyCashFlowProfileLoaded = true\n }\n\n loadGoalData = async () => {\n await Promise.all([\n this.loadGoals(),\n this.loadRetirementGoals(),\n this.loadRetirementGoalAccounts(),\n this.loadMonthlyCashFlowProfile(),\n ])\n }\n\n loadGoals = async () => {\n try {\n const goals = await this.api.getGoals()\n this.setGoals(goals)\n } catch (error) {\n this.captureError('loadGoals', error)\n }\n }\n\n loadRetirementGoals = async () => {\n try {\n const retirementGoals = await this.api.getRetirementGoals()\n this.setRetirementGoals(retirementGoals)\n } catch (error) {\n this.captureError('loadRetirementGoals', error)\n }\n }\n\n loadRetirementGoalAccounts = async () => {\n try {\n const retirementGoalAccounts = await this.api.getRetirementGoalAccounts()\n this.setRetirementGoalAccounts(retirementGoalAccounts)\n } catch (error) {\n this.captureError('loadRetirementGoalAccounts', error)\n }\n }\n\n loadMonthlyCashFlowProfile = async () => {\n try {\n const monthlyCashFlowProfile = await this.api.getMonthlyCashFlowProfile()\n this.setMonthlyCashFlowProfile(monthlyCashFlowProfile)\n } catch (error) {\n this.captureError('loadMonthlyCashFlowProfile', error)\n }\n }\n\n addGoal = async (goal: Goal) => {\n try {\n const newGoal = await this.api.addGoal(goal)\n this.setGoals(upsertByGuid(this.goals, newGoal))\n } catch (error) {\n this.captureError('addGoal', error)\n }\n }\n\n addRetirementGoal = async (goal: Goal) => {\n try {\n const newGoal: Goal = await this.api.addRetirementGoal(goal)\n const newAccounts = [] as RetirementGoalAccount[]\n for (const account of this.newRetirementGoalAccounts) {\n const newAccount = await this.api.addRetirementGoalAccount({\n ...account,\n retirement_goal_guid: newGoal.guid,\n })\n newAccounts.push(newAccount)\n }\n this.setNewRetirementGoalAccounts([])\n\n runInAction(() => {\n this.setRetirementGoals(upsertByGuid(this.retirementGoals, newGoal))\n this.setRetirementGoalAccounts(\n newAccounts.reduce((acc, a) => upsertByGuid(acc, a), this.retirementGoalAccounts),\n )\n })\n } catch (error) {\n this.captureError('addRetirementGoal', error)\n }\n }\n\n addRetirementGoalAccount = async (account: RetirementGoalAccount) => {\n try {\n const newAccount = await this.api.addRetirementGoalAccount(account)\n\n runInAction(() => {\n this.retirementGoalAccounts = upsertByGuid(this.retirementGoalAccounts, newAccount)\n })\n } catch (error) {\n this.captureError('addRetirementGoalAccount', error)\n }\n }\n\n deleteGoal = async (guid: string) => {\n try {\n await this.api.removeGoal(guid)\n\n const index = this.goals.findIndex((g) => g.guid === guid)\n if (index >= 0) {\n this.goals.splice(index, 1)\n }\n } catch (error) {\n this.captureError('deleteGoal', error)\n }\n }\n\n deleteRetirementGoal = async (goal: Goal) => {\n try {\n const accounts = this.retirementGoalAccounts.filter(\n (g) => g.retirement_goal_guid === goal.guid,\n )\n for (const account of accounts) {\n await this.deleteRetirementGoalAccount(account.guid)\n }\n await this.api.removeRetirementGoal(goal.guid)\n\n const index = this.retirementGoals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.retirementGoals.splice(index, 1)\n }\n } catch (error) {\n this.captureError('deleteRetirementGoal', error)\n }\n }\n\n deleteRetirementGoalAccount = async (guid: string) => {\n try {\n await this.api.removeRetirementGoalAccount(guid)\n\n const index = this.retirementGoalAccounts.findIndex((rga) => rga.guid === guid)\n if (index >= 0) {\n this.retirementGoalAccounts.splice(index, 1)\n }\n } catch (error) {\n this.captureError('deleteRetirementGoalAccount', error)\n }\n }\n\n reorderGoals = async (goals: Goal[]) => {\n try {\n const reordered = (await this.api.reorderGoals(goals)) as Goal[]\n\n runInAction(() => {\n for (const goal of reordered) {\n const index = this.goals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.goals[index].position = goal.position\n }\n }\n })\n } catch (error) {\n this.captureError('reorderGoals', error)\n }\n }\n\n setAlert = (alert: string) => (this.alert = alert)\n\n setNewRetirementGoalAccounts = (accounts: RetirementGoalAccount[]) => {\n this.newRetirementGoalAccounts = accounts\n }\n\n setSelectedGoal = (goal: Goal | undefined) => (this.selectedGoal = goal)\n\n updateGoal = async (goal: Goal) => {\n try {\n const updatedGoal = await this.api.updateGoal(goal)\n\n runInAction(() => {\n const index = this.goals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.goals[index] = updatedGoal\n }\n if (this.selectedGoal?.guid === goal.guid) {\n this.setSelectedGoal(updatedGoal)\n }\n })\n } catch (error) {\n this.captureError('updateGoal', error)\n }\n }\n\n updateRetirementGoal = async (goal: Goal) => {\n try {\n const updatedRetirementGoal = await this.api.updateRetirementGoal({\n ...goal,\n target_amount: goal.amount,\n })\n\n runInAction(() => {\n const index = this.retirementGoals.findIndex((g) => g.guid === goal.guid)\n if (index >= 0) {\n this.retirementGoals[index] = updatedRetirementGoal\n }\n\n if (this.selectedGoal?.guid === goal.guid) {\n this.setSelectedGoal(this.allGoals.find((g) => g.guid === goal.guid))\n }\n })\n } catch (error) {\n this.captureError('updateRetirementGoal', error)\n }\n }\n\n updateMonthlyCashFlowProfile = async (profile: MonthlyCashFlowProfile) => {\n try {\n const updatedProfile = await this.api.updateMonthlyCashFlowProfile(profile)\n this.setMonthlyCashFlowProfile(updatedProfile)\n } catch (error) {\n this.captureError('updateMonthlyCashFlowProfile', error)\n }\n }\n\n private captureError = (action: string, error: unknown) =>\n this.globalStore.captureException(error, { store: 'GoalStore', action })\n}\n"],"mappings":";;;;;AAeA,IAAa,IAAb,MAAuB;AAAA,EACrB;AAAA,EACA,MAAM,IAAI,EAAQ,KAAK,EAAE;AAAA,EAEzB,QAAgB,CAAC;AAAA,EACjB,cAAuB;AAAA,EACvB,kBAA0B,CAAC;AAAA,EAC3B,wBAAiC;AAAA,EACjC,yBAAkD,CAAC;AAAA,EACnD,+BAAwC;AAAA,EACxC,yBAA6D;AAAA,EAC7D,+BAAwC;AAAA,EAExC,4BAAqD,CAAC;AAAA,EAEtD,QAAgB;AAAA,EAChB,eAAiC;AAAA,EAEjC,YAAY,GAA0B;AACpC,SAAK,cAAc,GAC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AAK,aAAa,wBAAwB,CAAK;AAAA,IACjD;AAAA,EACF;AAAA,EAEA,+BAA+B,OAAO,MAAoC;AACxE,QAAI;AACF,YAAM,IAAiB,MAAM,KAAK,IAAI,6BAA6B,CAAO;AAC1E,WAAK,0BAA0B,CAAc;AAAA,IAC/C,SAAS,GAAO;AACd,WAAK,aAAa,gCAAgC,CAAK;AAAA,IACzD;AAAA,EACF;AAAA,EAEA,eAAA,CAAwB,GAAgB,MACtC,KAAK,YAAY,iBAAiB,GAAO;AAAA,IAAE,OAAO;AAAA,IAAa,QAAA;AAAA,EAAO,CAAC;AAC3E"}
@@ -15,4 +15,5 @@ export declare class HelpStore {
15
15
  };
16
16
  get copy(): HelpCopy;
17
17
  get helpCategories(): import('..').HelpCategory[];
18
+ private captureError;
18
19
  }
@@ -1,4 +1,4 @@
1
- import { HelpApi as o } from "../api/HelpApi.es.js";
1
+ import { HelpApi as r } from "../api/HelpApi.es.js";
2
2
  import { HelpUtil as s } from "../utils/HelpUtil.es.js";
3
3
  import { makeAutoObservable as i } from "mobx";
4
4
  var l = class {
@@ -6,18 +6,18 @@ var l = class {
6
6
  message: "",
7
7
  severity: void 0
8
8
  };
9
- api = new o("/", "");
9
+ api = new r("/", "");
10
10
  appConfig;
11
11
  globalStore;
12
12
  isLoading = !1;
13
13
  constructor(t) {
14
- this.globalStore = t, this.api = new o(t.endpoint, t.sessionToken, t.onError), i(this);
14
+ this.globalStore = t, this.api = new r(t.endpoint, t.sessionToken, t.onError), i(this);
15
15
  }
16
16
  createSupportTicket = async (t) => {
17
17
  try {
18
18
  this.isLoading = !0, await this.api.createSupportTicket(t), this.setAlert(this.copy.request_support_submit_success_message, "success");
19
19
  } catch (e) {
20
- console.error("Error occurred while submitting support ticket:", e), this.globalStore.captureException(e, { store: "HelpStore" }), this.setAlert(this.copy.request_support_submit_failure_message, "error");
20
+ this.captureError("createSupportTicket", e), this.setAlert(this.copy.request_support_submit_failure_message, "error");
21
21
  } finally {
22
22
  this.isLoading = !1;
23
23
  }
@@ -30,13 +30,17 @@ var l = class {
30
30
  return this.globalStore.copyStore.copy.help;
31
31
  }
32
32
  get helpCategories() {
33
- const { client_communication_profile: t, client_profile: e } = this.globalStore.appDataStore.appData, { help: { category_list: r } } = this.globalStore.copyStore.copy;
33
+ const { client_communication_profile: t, client_profile: e } = this.globalStore.appDataStore.appData, { help: { category_list: o } } = this.globalStore.copyStore.copy;
34
34
  return s({
35
35
  ...t,
36
36
  ...e,
37
37
  ...this.globalStore.appConfig.config
38
- }, r);
38
+ }, o);
39
39
  }
40
+ captureError = (t, e) => this.globalStore.captureException(e, {
41
+ store: "HelpStore",
42
+ action: t
43
+ });
40
44
  };
41
45
  export {
42
46
  l as HelpStore
@@ -1 +1 @@
1
- {"version":3,"file":"HelpStore.es.js","names":[],"sources":["../../../src/core/stores/HelpStore.ts"],"sourcesContent":["import { makeAutoObservable } from 'mobx'\n\nimport { HelpApi } from '../api'\nimport type { Config, HelpCopy, HelpAlertProps, Ticket } from '../types'\nimport { HelpUtil } from '../utils/HelpUtil'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class HelpStore {\n alert: HelpAlertProps = { message: '', severity: undefined }\n api = new HelpApi('/', '')\n appConfig: Config | undefined\n globalStore: GlobalStore\n isLoading: boolean = false\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new HelpApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n createSupportTicket = async (ticket: Ticket) => {\n try {\n this.isLoading = true\n await this.api.createSupportTicket(ticket)\n this.setAlert(this.copy.request_support_submit_success_message, 'success')\n } catch (error) {\n console.error('Error occurred while submitting support ticket:', error)\n this.globalStore.captureException(error, { store: 'HelpStore' })\n this.setAlert(this.copy.request_support_submit_failure_message, 'error')\n } finally {\n this.isLoading = false\n }\n }\n\n setAlert = (message: string, severity: HelpAlertProps['severity'] = undefined) =>\n (this.alert = { message, severity })\n\n get copy(): HelpCopy {\n return this.globalStore.copyStore.copy.help\n }\n\n get helpCategories() {\n const { client_communication_profile, client_profile } = this.globalStore.appDataStore.appData\n\n const {\n help: { category_list },\n } = this.globalStore.copyStore.copy\n\n return HelpUtil(\n {\n ...client_communication_profile,\n ...client_profile,\n ...this.globalStore.appConfig.config,\n },\n category_list,\n )\n }\n}\n"],"mappings":";;;AAQA,IAAa,IAAb,MAAuB;AAAA,EACrB,QAAwB;AAAA,IAAE,SAAS;AAAA,IAAI,UAAU;AAAA,EAAU;AAAA,EAC3D,MAAM,IAAI,EAAQ,KAAK,EAAE;AAAA,EACzB;AAAA,EACA;AAAA,EACA,YAAqB;AAAA,EAErB,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,KAAK,MAAM,IAAI,EAAQ,EAAY,UAAU,EAAY,cAAc,EAAY,OAAO,GAE1F,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,sBAAsB,OAAO,MAAmB;AAC9C,QAAI;AACF,WAAK,YAAY,IACjB,MAAM,KAAK,IAAI,oBAAoB,CAAM,GACzC,KAAK,SAAS,KAAK,KAAK,wCAAwC,SAAS;AAAA,IAC3E,SAAS,GAAO;AACd,cAAQ,MAAM,mDAAmD,CAAK,GACtE,KAAK,YAAY,iBAAiB,GAAO,EAAE,OAAO,YAAY,CAAC,GAC/D,KAAK,SAAS,KAAK,KAAK,wCAAwC,OAAO;AAAA,IACzE,UAAA;AACE,WAAK,YAAY;AAAA,IACnB;AAAA,EACF;AAAA,EAEA,WAAA,CAAY,GAAiB,IAAuC,WACjE,KAAK,QAAQ;AAAA,IAAE,SAAA;AAAA,IAAS,UAAA;AAAA,EAAS;AAAA,EAEpC,IAAI,OAAiB;AACnB,WAAO,KAAK,YAAY,UAAU,KAAK;AAAA,EACzC;AAAA,EAEA,IAAI,iBAAiB;AACnB,UAAM,EAAE,8BAAA,GAA8B,gBAAA,EAAA,IAAmB,KAAK,YAAY,aAAa,SAEjF,EACJ,MAAM,EAAE,eAAA,EAAA,EAAA,IACN,KAAK,YAAY,UAAU;AAE/B,WAAO,EACL;AAAA,MACE,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG,KAAK,YAAY,UAAU;AAAA,IAChC,GACA,CACF;AAAA,EACF;AACF"}
1
+ {"version":3,"file":"HelpStore.es.js","names":[],"sources":["../../../src/core/stores/HelpStore.ts"],"sourcesContent":["import { makeAutoObservable } from 'mobx'\n\nimport { HelpApi } from '../api'\nimport type { Config, HelpCopy, HelpAlertProps, Ticket } from '../types'\nimport { HelpUtil } from '../utils/HelpUtil'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class HelpStore {\n alert: HelpAlertProps = { message: '', severity: undefined }\n api = new HelpApi('/', '')\n appConfig: Config | undefined\n globalStore: GlobalStore\n isLoading: boolean = false\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new HelpApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n createSupportTicket = async (ticket: Ticket) => {\n try {\n this.isLoading = true\n await this.api.createSupportTicket(ticket)\n this.setAlert(this.copy.request_support_submit_success_message, 'success')\n } catch (error) {\n this.captureError('createSupportTicket', error)\n this.setAlert(this.copy.request_support_submit_failure_message, 'error')\n } finally {\n this.isLoading = false\n }\n }\n\n setAlert = (message: string, severity: HelpAlertProps['severity'] = undefined) =>\n (this.alert = { message, severity })\n\n get copy(): HelpCopy {\n return this.globalStore.copyStore.copy.help\n }\n\n get helpCategories() {\n const { client_communication_profile, client_profile } = this.globalStore.appDataStore.appData\n\n const {\n help: { category_list },\n } = this.globalStore.copyStore.copy\n\n return HelpUtil(\n {\n ...client_communication_profile,\n ...client_profile,\n ...this.globalStore.appConfig.config,\n },\n category_list,\n )\n }\n\n private captureError = (action: string, error: unknown) =>\n this.globalStore.captureException(error, { store: 'HelpStore', action })\n}\n"],"mappings":";;;AAQA,IAAa,IAAb,MAAuB;AAAA,EACrB,QAAwB;AAAA,IAAE,SAAS;AAAA,IAAI,UAAU;AAAA,EAAU;AAAA,EAC3D,MAAM,IAAI,EAAQ,KAAK,EAAE;AAAA,EACzB;AAAA,EACA;AAAA,EACA,YAAqB;AAAA,EAErB,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,KAAK,MAAM,IAAI,EAAQ,EAAY,UAAU,EAAY,cAAc,EAAY,OAAO,GAE1F,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,sBAAsB,OAAO,MAAmB;AAC9C,QAAI;AACF,WAAK,YAAY,IACjB,MAAM,KAAK,IAAI,oBAAoB,CAAM,GACzC,KAAK,SAAS,KAAK,KAAK,wCAAwC,SAAS;AAAA,IAC3E,SAAS,GAAO;AACd,WAAK,aAAa,uBAAuB,CAAK,GAC9C,KAAK,SAAS,KAAK,KAAK,wCAAwC,OAAO;AAAA,IACzE,UAAA;AACE,WAAK,YAAY;AAAA,IACnB;AAAA,EACF;AAAA,EAEA,WAAA,CAAY,GAAiB,IAAuC,WACjE,KAAK,QAAQ;AAAA,IAAE,SAAA;AAAA,IAAS,UAAA;AAAA,EAAS;AAAA,EAEpC,IAAI,OAAiB;AACnB,WAAO,KAAK,YAAY,UAAU,KAAK;AAAA,EACzC;AAAA,EAEA,IAAI,iBAAiB;AACnB,UAAM,EAAE,8BAAA,GAA8B,gBAAA,EAAA,IAAmB,KAAK,YAAY,aAAa,SAEjF,EACJ,MAAM,EAAE,eAAA,EAAA,EAAA,IACN,KAAK,YAAY,UAAU;AAE/B,WAAO,EACL;AAAA,MACE,GAAG;AAAA,MACH,GAAG;AAAA,MACH,GAAG,KAAK,YAAY,UAAU;AAAA,IAChC,GACA,CACF;AAAA,EACF;AAAA,EAEA,eAAA,CAAwB,GAAgB,MACtC,KAAK,YAAY,iBAAiB,GAAO;AAAA,IAAE,OAAO;AAAA,IAAa,QAAA;AAAA,EAAO,CAAC;AAC3E"}
@@ -23,4 +23,5 @@ export declare class HoldingStore {
23
23
  loadHoldings: () => Promise<void>;
24
24
  setAnalysisType: (analysisType: AnalysisType) => void;
25
25
  updateHoldings: (holding: Holding) => Promise<void>;
26
+ private captureError;
26
27
  }
@@ -42,7 +42,7 @@ var m = class {
42
42
  const s = await this.api.getHoldings();
43
43
  this.setHoldings(s);
44
44
  } catch (s) {
45
- console.error("Error occurred while getting holdings:", s), this.globalStore.captureException(s, { store: "HoldingStore" });
45
+ this.captureError("loadHoldings", s);
46
46
  }
47
47
  };
48
48
  setAnalysisType = (s) => {
@@ -59,9 +59,13 @@ var m = class {
59
59
  });
60
60
  }
61
61
  } catch (t) {
62
- console.error("Error occurred while updating holding:", t), this.globalStore.captureException(t, { store: "HoldingStore" });
62
+ this.captureError("updateHoldings", t);
63
63
  }
64
64
  };
65
+ captureError = (s, t) => this.globalStore.captureException(t, {
66
+ store: "HoldingStore",
67
+ action: s
68
+ });
65
69
  };
66
70
  export {
67
71
  m as HoldingStore
@@ -1 +1 @@
1
- {"version":3,"file":"HoldingStore.es.js","names":[],"sources":["../../../src/core/stores/HoldingStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\n\nimport { HoldingApi } from '../api'\nimport { AnalysisType } from '../constants/Investments'\nimport { type Holding } from '../types'\nimport {\n analysisChartData,\n analysisDetailsData,\n holdingHasAllocationData,\n holdingHasStyleData,\n mapDataToPercentageGrid,\n} from '../utils/InvestmentUtil'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class HoldingStore {\n analysisType: AnalysisType = AnalysisType.Stocks\n api = new HoldingApi('/', '')\n holdings: Holding[] = []\n holdingsLoaded = false\n globalStore: GlobalStore\n showConnectionsWidget = false\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new HoldingApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n get analysisChartData() {\n return mapDataToPercentageGrid(analysisChartData(this.visibleHoldings), this.analysisType)\n }\n\n get analysisDetails() {\n return analysisDetailsData(this.visibleHoldings)[this.analysisType] || {}\n }\n\n get visibleHoldings() {\n return this.holdings.filter((holding) =>\n this.globalStore.globalUiStore.selectedAccountGuids.includes(holding.account_guid),\n )\n }\n\n // Cash counts because a cash balance renders as a synthetic donut slice.\n get hasAllocationData() {\n if (this.visibleHoldings.some(holdingHasAllocationData)) return true\n\n return this.selectedInvestmentAccounts.some((account) => (account.cash_balance ?? 0) > 0)\n }\n\n get hasAnalysisData() {\n return this.visibleHoldings.some(holdingHasStyleData)\n }\n\n get selectedInvestmentAccounts() {\n const { selectedAccountGuids } = this.globalStore.globalUiStore\n return this.globalStore.accountStore.visibleInvestmentAccounts.filter((account) =>\n selectedAccountGuids.includes(account.guid),\n )\n }\n\n setHoldings = (holdings: Holding[]) => {\n this.holdings = holdings\n this.holdingsLoaded = true\n }\n\n setShowConnectionsWidget = (value: boolean) => {\n this.showConnectionsWidget = value\n }\n\n loadHoldings = async () => {\n try {\n const holdings = await this.api.getHoldings()\n this.setHoldings(holdings)\n } catch (error) {\n console.error('Error occurred while getting holdings:', error)\n this.globalStore.captureException(error, { store: 'HoldingStore' })\n }\n }\n\n setAnalysisType = (analysisType: AnalysisType) => {\n this.analysisType = analysisType\n }\n\n updateHoldings = async (holding: Holding) => {\n this.holdingsLoaded = false\n try {\n const updatedHolding = await this.api.updateHoldings(holding)\n const updatedIndex = this.holdings.findIndex(({ guid }) => guid === holding.guid)\n\n if (updatedIndex >= 0) {\n const holdings = [...this.holdings]\n holdings[updatedIndex] = updatedHolding\n\n runInAction(() => {\n this.holdings = holdings\n this.holdingsLoaded = true\n })\n }\n } catch (error) {\n console.error('Error occurred while updating holding:', error)\n this.globalStore.captureException(error, { store: 'HoldingStore' })\n }\n }\n}\n"],"mappings":";;;;AAeA,IAAa,IAAb,MAA0B;AAAA,EACxB,eAA6B,EAAa;AAAA,EAC1C,MAAM,IAAI,EAAW,KAAK,EAAE;AAAA,EAC5B,WAAsB,CAAC;AAAA,EACvB,iBAAiB;AAAA,EACjB;AAAA,EACA,wBAAwB;AAAA,EAExB,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,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A,EAEA,kBAAA,CAAmB,MAA+B;AAChD,SAAK,eAAe;AAAA,EACtB;AAAA,EAEA,iBAAiB,OAAO,MAAqB;AAC3C,SAAK,iBAAiB;AACtB,QAAI;AACF,YAAM,IAAiB,MAAM,KAAK,IAAI,eAAe,CAAO,GACtD,IAAe,KAAK,SAAS,UAAA,CAAW,EAAE,MAAA,EAAA,MAAW,MAAS,EAAQ,IAAI;AAEhF,UAAI,KAAgB,GAAG;AACrB,cAAM,IAAW,CAAC,GAAG,KAAK,QAAQ;AAClC,QAAA,EAAS,CAAA,IAAgB,GAEzB,EAAA,MAAkB;AAChB,eAAK,WAAW,GAChB,KAAK,iBAAiB;AAAA,QACxB,CAAC;AAAA,MACH;AAAA,IACF,SAAS,GAAO;AACd,cAAQ,MAAM,0CAA0C,CAAK,GAC7D,KAAK,YAAY,iBAAiB,GAAO,EAAE,OAAO,eAAe,CAAC;AAAA,IACpE;AAAA,EACF;AACF"}
1
+ {"version":3,"file":"HoldingStore.es.js","names":[],"sources":["../../../src/core/stores/HoldingStore.ts"],"sourcesContent":["import { makeAutoObservable, runInAction } from 'mobx'\n\nimport { HoldingApi } from '../api'\nimport { AnalysisType } from '../constants/Investments'\nimport { type Holding } from '../types'\nimport {\n analysisChartData,\n analysisDetailsData,\n holdingHasAllocationData,\n holdingHasStyleData,\n mapDataToPercentageGrid,\n} from '../utils/InvestmentUtil'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class HoldingStore {\n analysisType: AnalysisType = AnalysisType.Stocks\n api = new HoldingApi('/', '')\n holdings: Holding[] = []\n holdingsLoaded = false\n globalStore: GlobalStore\n showConnectionsWidget = false\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new HoldingApi(globalStore.endpoint, globalStore.sessionToken, globalStore.onError)\n\n makeAutoObservable(this)\n }\n\n get analysisChartData() {\n return mapDataToPercentageGrid(analysisChartData(this.visibleHoldings), this.analysisType)\n }\n\n get analysisDetails() {\n return analysisDetailsData(this.visibleHoldings)[this.analysisType] || {}\n }\n\n get visibleHoldings() {\n return this.holdings.filter((holding) =>\n this.globalStore.globalUiStore.selectedAccountGuids.includes(holding.account_guid),\n )\n }\n\n // Cash counts because a cash balance renders as a synthetic donut slice.\n get hasAllocationData() {\n if (this.visibleHoldings.some(holdingHasAllocationData)) return true\n\n return this.selectedInvestmentAccounts.some((account) => (account.cash_balance ?? 0) > 0)\n }\n\n get hasAnalysisData() {\n return this.visibleHoldings.some(holdingHasStyleData)\n }\n\n get selectedInvestmentAccounts() {\n const { selectedAccountGuids } = this.globalStore.globalUiStore\n return this.globalStore.accountStore.visibleInvestmentAccounts.filter((account) =>\n selectedAccountGuids.includes(account.guid),\n )\n }\n\n setHoldings = (holdings: Holding[]) => {\n this.holdings = holdings\n this.holdingsLoaded = true\n }\n\n setShowConnectionsWidget = (value: boolean) => {\n this.showConnectionsWidget = value\n }\n\n loadHoldings = async () => {\n try {\n const holdings = await this.api.getHoldings()\n this.setHoldings(holdings)\n } catch (error) {\n this.captureError('loadHoldings', error)\n }\n }\n\n setAnalysisType = (analysisType: AnalysisType) => {\n this.analysisType = analysisType\n }\n\n updateHoldings = async (holding: Holding) => {\n this.holdingsLoaded = false\n try {\n const updatedHolding = await this.api.updateHoldings(holding)\n const updatedIndex = this.holdings.findIndex(({ guid }) => guid === holding.guid)\n\n if (updatedIndex >= 0) {\n const holdings = [...this.holdings]\n holdings[updatedIndex] = updatedHolding\n\n runInAction(() => {\n this.holdings = holdings\n this.holdingsLoaded = true\n })\n }\n } catch (error) {\n this.captureError('updateHoldings', error)\n }\n }\n\n private captureError = (action: string, error: unknown) =>\n this.globalStore.captureException(error, { store: 'HoldingStore', action })\n}\n"],"mappings":";;;;AAeA,IAAa,IAAb,MAA0B;AAAA,EACxB,eAA6B,EAAa;AAAA,EAC1C,MAAM,IAAI,EAAW,KAAK,EAAE;AAAA,EAC5B,WAAsB,CAAC;AAAA,EACvB,iBAAiB;AAAA,EACjB;AAAA,EACA,wBAAwB;AAA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A,CAAmB,MAA+B;AAChD,SAAK,eAAe;AAAA,EACtB;AAAA,EAEA,iBAAiB,OAAO,MAAqB;AAC3C,SAAK,iBAAiB;AACtB,QAAI;AACF,YAAM,IAAiB,MAAM,KAAK,IAAI,eAAe,CAAO,GACtD,IAAe,KAAK,SAAS,UAAA,CAAW,EAAE,MAAA,EAAA,MAAW,MAAS,EAAQ,IAAI;AAEhF,UAAI,KAAgB,GAAG;AACrB,cAAM,IAAW,CAAC,GAAG,KAAK,QAAQ;AAClC,QAAA,EAAS,CAAA,IAAgB,GAEzB,EAAA,MAAkB;AAChB,eAAK,WAAW,GAChB,KAAK,iBAAiB;AAAA,QACxB,CAAC;AAAA,MACH;AAAA,IACF,SAAS,GAAO;AACd,WAAK,aAAa,kBAAkB,CAAK;AAAA,IAC3C;AAAA,EACF;AAAA,EAEA,eAAA,CAAwB,GAAgB,MACtC,KAAK,YAAY,iBAAiB,GAAO;AAAA,IAAE,OAAO;AAAA,IAAgB,QAAA;AAAA,EAAO,CAAC;AAC9E"}
@@ -27,4 +27,5 @@ export declare class NetWorthStore {
27
27
  setMonthlyAccountBalances: (balances: MonthlyAccountBalance[]) => void;
28
28
  setSelectedIndex: (index: number) => number;
29
29
  setTimeframe: (months: number) => number;
30
+ private captureError;
30
31
  }
@@ -1,8 +1,8 @@
1
1
  import { AccountApi as o } from "../api/AccountApi.es.js";
2
- import { isFeatureEnabled as c } from "../utils/UserUtils.es.js";
3
- import { buildAssetsLiabilities as n, buildChartData as i, buildGainsLosses as l, filterAccounts as h, flattenBalances as u, getLatestNetWorthData as s, sortByYearMonthAscending as d, toMonthlyAccountBalance as A } from "../utils/NetWorthUtils.es.js";
2
+ import { isFeatureEnabled as n } from "../utils/UserUtils.es.js";
3
+ import { buildAssetsLiabilities as c, buildChartData as i, buildGainsLosses as l, filterAccounts as h, flattenBalances as u, getLatestNetWorthData as s, sortByYearMonthAscending as d, toMonthlyAccountBalance as A } from "../utils/NetWorthUtils.es.js";
4
4
  import { makeAutoObservable as g } from "mobx";
5
- var m = "Historical account balances", W = class {
5
+ var m = "Historical account balances", D = class {
6
6
  globalStore;
7
7
  accountsApi = new o("/", "");
8
8
  monthlyAccountBalances = [];
@@ -39,10 +39,10 @@ var m = "Historical account balances", W = class {
39
39
  return l(this.selectedData);
40
40
  }
41
41
  get isHistoricalBalancesEnabled() {
42
- return c(this.globalStore.userStore.userFeatures, m);
42
+ return n(this.globalStore.userStore.userFeatures, m);
43
43
  }
44
44
  get assetsLiabilities() {
45
- const { assets: t, liabilities: e, totalAssets: a, totalLiabilities: r } = n(this.netWorthData.accounts);
45
+ const { assets: t, liabilities: e, totalAssets: a, totalLiabilities: r } = c(this.netWorthData.accounts);
46
46
  return {
47
47
  netWorth: s(this.netWorthChartData),
48
48
  assets: t,
@@ -60,14 +60,14 @@ var m = "Historical account balances", W = class {
60
60
  try {
61
61
  return await this.accountsApi.getMonthlyAccountBalances(t);
62
62
  } catch (e) {
63
- return console.error("Error occurred while fetching monthly account balances:", e), this.globalStore.captureException(e, { store: "NetWorthStore" }), [];
63
+ return this.captureError("getMonthlyAccountBalances", e), [];
64
64
  }
65
65
  };
66
66
  getHistoricalAccountBalances = async (t) => {
67
67
  try {
68
68
  return (await this.accountsApi.getHistoricalAccountBalances(t)).map(A);
69
69
  } catch (e) {
70
- return console.error("Error occurred while fetching historical account balances:", e), this.globalStore.captureException(e, { store: "NetWorthStore" }), [];
70
+ return this.captureError("getHistoricalAccountBalances", e), [];
71
71
  }
72
72
  };
73
73
  setHoveredIndex = (t) => this.hoveredIndex = t;
@@ -76,10 +76,14 @@ var m = "Historical account balances", W = class {
76
76
  };
77
77
  setSelectedIndex = (t) => this.selectedIndex = t;
78
78
  setTimeframe = (t) => this.timeframe = t;
79
+ captureError = (t, e) => this.globalStore.captureException(e, {
80
+ store: "NetWorthStore",
81
+ action: t
82
+ });
79
83
  };
80
84
  export {
81
85
  m as HISTORICAL_ACCOUNT_BALANCES,
82
- W as NetWorthStore
86
+ D as NetWorthStore
83
87
  };
84
88
 
85
89
  //# sourceMappingURL=NetWorthStore.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NetWorthStore.es.js","names":[],"sources":["../../../src/core/stores/NetWorthStore.ts"],"sourcesContent":["import { makeAutoObservable } from 'mobx'\n\nimport { AccountApi } from '../api'\nimport type {\n Account,\n AssetsLiabilities,\n DetailedAccount,\n GainsLosses,\n HistoricalAccountBalance,\n MonthlyAccountBalance,\n NetWorth,\n NetWorthData,\n} from '../types'\nimport {\n filterAccounts,\n flattenBalances,\n buildAssetsLiabilities,\n buildChartData,\n buildGainsLosses,\n getLatestNetWorthData,\n sortByYearMonthAscending,\n toMonthlyAccountBalance,\n} from '../utils/NetWorthUtils'\nimport { isFeatureEnabled } from '../utils/UserUtils'\n\nimport { GlobalStore } from './GlobalStore'\n\n// Looks wrong next to the MD_* flags, but isn't: this is the seeded feature_name. Do not rename.\nexport const HISTORICAL_ACCOUNT_BALANCES = 'Historical account balances'\n\nexport class NetWorthStore {\n globalStore: GlobalStore\n accountsApi: AccountApi = new AccountApi('/', '')\n\n monthlyAccountBalances: MonthlyAccountBalance[] = []\n monthlyAccountBalancesLoaded: boolean = false\n hoveredIndex: number = -1\n selectedIndex: number = -1\n timeframe: number = 6 // default timeframe is 6 months\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.accountsApi = new AccountApi(\n globalStore.endpoint,\n globalStore.sessionToken,\n globalStore.onError,\n )\n makeAutoObservable(this)\n }\n\n get isNetWorthDataLoaded(): boolean {\n return this.globalStore.accountStore.isAccountDataLoaded && this.monthlyAccountBalancesLoaded\n }\n\n get netWorthAccounts(): DetailedAccount[] {\n return filterAccounts(\n this.globalStore.globalUiStore.selectedAccounts,\n this.globalStore.accountStore.members,\n )\n }\n\n get netWorthData(): NetWorthData {\n return {\n accounts: this.netWorthAccounts,\n monthlyAccountBalances: this.monthlyAccountBalances,\n }\n }\n\n get netWorthChartData(): NetWorth[] {\n return buildChartData(this.netWorthAccounts, this.monthlyAccountBalances, this.timeframe)\n }\n\n get selectedData(): NetWorth | undefined {\n if (!this.netWorthChartData || this.netWorthChartData.length === 0) return undefined\n return this.selectedIndex === -1\n ? getLatestNetWorthData(this.netWorthChartData)\n : this.netWorthChartData[this.selectedIndex]\n }\n\n get hoveredData(): NetWorth | undefined {\n return this.hoveredIndex >= 0 ? this.netWorthChartData[this.hoveredIndex] : undefined\n }\n\n get gainsLosses(): GainsLosses {\n return buildGainsLosses(this.selectedData)\n }\n\n get isHistoricalBalancesEnabled(): boolean {\n return isFeatureEnabled(this.globalStore.userStore.userFeatures, HISTORICAL_ACCOUNT_BALANCES)\n }\n\n get assetsLiabilities(): AssetsLiabilities {\n const { assets, liabilities, totalAssets, totalLiabilities } = buildAssetsLiabilities(\n this.netWorthData.accounts,\n )\n return {\n netWorth: getLatestNetWorthData(this.netWorthChartData),\n assets,\n liabilities,\n totalAssets,\n totalLiabilities,\n }\n }\n\n loadNetWorthData = async () => {\n if (!this.globalStore.accountStore.isAccountDataLoaded) {\n await this.globalStore.accountStore.loadAccountData()\n }\n\n if (!this.globalStore.userStore.userFeaturesLoaded) {\n await this.globalStore.userStore.loadUserFeatures()\n }\n\n const fetchBalances = this.isHistoricalBalancesEnabled\n ? (guid: string) => this.getHistoricalAccountBalances(guid)\n : (guid: string) => this.getMonthlyAccountBalances(guid)\n\n const accountBalances = await Promise.all(\n this.netWorthAccounts.map((account: Account) => fetchBalances(account.guid)),\n )\n\n const monthlyAccountBalances = accountBalances\n .reduce(flattenBalances, [])\n .sort(sortByYearMonthAscending)\n\n this.setMonthlyAccountBalances(monthlyAccountBalances)\n }\n\n getMonthlyAccountBalances = async (accountGuid: string) => {\n try {\n const balances = await this.accountsApi.getMonthlyAccountBalances(accountGuid)\n return balances as MonthlyAccountBalance[]\n } catch (error) {\n console.error('Error occurred while fetching monthly account balances:', error)\n this.globalStore.captureException(error, { store: 'NetWorthStore' })\n return []\n }\n }\n\n getHistoricalAccountBalances = async (accountGuid: string): Promise<MonthlyAccountBalance[]> => {\n try {\n const balances: HistoricalAccountBalance[] =\n await this.accountsApi.getHistoricalAccountBalances(accountGuid)\n return balances.map(toMonthlyAccountBalance)\n } catch (error) {\n console.error('Error occurred while fetching historical account balances:', error)\n this.globalStore.captureException(error, { store: 'NetWorthStore' })\n return []\n }\n }\n\n setHoveredIndex = (index: number) => (this.hoveredIndex = index)\n\n setMonthlyAccountBalances = (balances: MonthlyAccountBalance[]) => {\n this.monthlyAccountBalances = balances\n this.monthlyAccountBalancesLoaded = true\n }\n\n setSelectedIndex = (index: number) => (this.selectedIndex = index)\n setTimeframe = (months: number) => (this.timeframe = months)\n}\n"],"mappings":";;;;AA4BA,IAAa,IAA8B,+BAE9B,IAAb,MAA2B;AAAA,EACzB;AAAA,EACA,cAA0B,IAAI,EAAW,KAAK,EAAE;AAAA,EAEhD,yBAAkD,CAAC;AAAA,EACnD,+BAAwC;AAAA,EACxC,eAAuB;AAAA,EACvB,gBAAwB;AAAA,EACxB,YAAoB;AAAA,EAEpB,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,KAAK,cAAc,IAAI,EACrB,EAAY,UACZ,EAAY,cACZ,EAAY,OACd,GACA,EAAmB,IAAI;AAAA,EACzB;AAAA,EAEA,IAAI,uBAAgC;AAClC,WAAO,KAAK,YAAY,aAAa,uBAAuB,KAAK;AAAA,EACnE;AAAA,EAEA,IAAI,mBAAsC;AACxC,WAAO,EACL,KAAK,YAAY,cAAc,kBAC/B,KAAK,YAAY,aAAa,OAChC;AAAA,EACF;AAAA,EAEA,IAAI,eAA6B;AAC/B,WAAO;AAAA,MACL,UAAU,KAAK;AAAA,MACf,wBAAwB,KAAK;AAAA,IAC/B;AAAA,EACF;AAAA,EAEA,IAAI,oBAAgC;AAClC,WAAO,EAAe,KAAK,kBAAkB,KAAK,wBAAwB,KAAK,SAAS;AAAA,EAC1F;AAAA,EAEA,IAAI,eAAqC;AACvC,QAAI,GAAC,KAAK,qBAAqB,KAAK,kBAAkB,WAA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AM,2DAA2D,CAAK,GAC9E,KAAK,YAAY,iBAAiB,GAAO,EAAE,OAAO,gBAAgB,CAAC,GAC5D,CAAC;AAAA,IACV;AAAA,EACF;AAAA,EAEA,+BAA+B,OAAO,MAA0D;AAC9F,QAAI;AAGF,cAAO,MADC,KAAK,YAAY,6BAA6B,CAAW,GACjD,IAAI,CAAuB;AAAA,IAC7C,SAAS,GAAO;AACd,qBAAQ,MAAM,8DAA8D,CAAK,GACjF,KAAK,YAAY,iBAAiB,GAAO,EAAE,OAAO,gBAAgB,CAAC,GAC5D,CAAC;AAAA,IACV;AAAA,EACF;AAAA,EAEA,kBAAA,CAAmB,MAAmB,KAAK,eAAe;AAAA,EAE1D,4BAAA,CAA6B,MAAsC;AACjE,SAAK,yBAAyB,GAC9B,KAAK,+BAA+B;AAAA,EACtC;AAAA,EAEA,mBAAA,CAAoB,MAAmB,KAAK,gBAAgB;AAAA,EAC5D,eAAA,CAAgB,MAAoB,KAAK,YAAY;AACvD"}
1
+ {"version":3,"file":"NetWorthStore.es.js","names":[],"sources":["../../../src/core/stores/NetWorthStore.ts"],"sourcesContent":["import { makeAutoObservable } from 'mobx'\n\nimport { AccountApi } from '../api'\nimport type {\n Account,\n AssetsLiabilities,\n DetailedAccount,\n GainsLosses,\n HistoricalAccountBalance,\n MonthlyAccountBalance,\n NetWorth,\n NetWorthData,\n} from '../types'\nimport {\n filterAccounts,\n flattenBalances,\n buildAssetsLiabilities,\n buildChartData,\n buildGainsLosses,\n getLatestNetWorthData,\n sortByYearMonthAscending,\n toMonthlyAccountBalance,\n} from '../utils/NetWorthUtils'\nimport { isFeatureEnabled } from '../utils/UserUtils'\n\nimport { GlobalStore } from './GlobalStore'\n\n// Looks wrong next to the MD_* flags, but isn't: this is the seeded feature_name. Do not rename.\nexport const HISTORICAL_ACCOUNT_BALANCES = 'Historical account balances'\n\nexport class NetWorthStore {\n globalStore: GlobalStore\n accountsApi: AccountApi = new AccountApi('/', '')\n\n monthlyAccountBalances: MonthlyAccountBalance[] = []\n monthlyAccountBalancesLoaded: boolean = false\n hoveredIndex: number = -1\n selectedIndex: number = -1\n timeframe: number = 6 // default timeframe is 6 months\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.accountsApi = new AccountApi(\n globalStore.endpoint,\n globalStore.sessionToken,\n globalStore.onError,\n )\n makeAutoObservable(this)\n }\n\n get isNetWorthDataLoaded(): boolean {\n return this.globalStore.accountStore.isAccountDataLoaded && this.monthlyAccountBalancesLoaded\n }\n\n get netWorthAccounts(): DetailedAccount[] {\n return filterAccounts(\n this.globalStore.globalUiStore.selectedAccounts,\n this.globalStore.accountStore.members,\n )\n }\n\n get netWorthData(): NetWorthData {\n return {\n accounts: this.netWorthAccounts,\n monthlyAccountBalances: this.monthlyAccountBalances,\n }\n }\n\n get netWorthChartData(): NetWorth[] {\n return buildChartData(this.netWorthAccounts, this.monthlyAccountBalances, this.timeframe)\n }\n\n get selectedData(): NetWorth | undefined {\n if (!this.netWorthChartData || this.netWorthChartData.length === 0) return undefined\n return this.selectedIndex === -1\n ? getLatestNetWorthData(this.netWorthChartData)\n : this.netWorthChartData[this.selectedIndex]\n }\n\n get hoveredData(): NetWorth | undefined {\n return this.hoveredIndex >= 0 ? this.netWorthChartData[this.hoveredIndex] : undefined\n }\n\n get gainsLosses(): GainsLosses {\n return buildGainsLosses(this.selectedData)\n }\n\n get isHistoricalBalancesEnabled(): boolean {\n return isFeatureEnabled(this.globalStore.userStore.userFeatures, HISTORICAL_ACCOUNT_BALANCES)\n }\n\n get assetsLiabilities(): AssetsLiabilities {\n const { assets, liabilities, totalAssets, totalLiabilities } = buildAssetsLiabilities(\n this.netWorthData.accounts,\n )\n return {\n netWorth: getLatestNetWorthData(this.netWorthChartData),\n assets,\n liabilities,\n totalAssets,\n totalLiabilities,\n }\n }\n\n loadNetWorthData = async () => {\n if (!this.globalStore.accountStore.isAccountDataLoaded) {\n await this.globalStore.accountStore.loadAccountData()\n }\n\n if (!this.globalStore.userStore.userFeaturesLoaded) {\n await this.globalStore.userStore.loadUserFeatures()\n }\n\n const fetchBalances = this.isHistoricalBalancesEnabled\n ? (guid: string) => this.getHistoricalAccountBalances(guid)\n : (guid: string) => this.getMonthlyAccountBalances(guid)\n\n const accountBalances = await Promise.all(\n this.netWorthAccounts.map((account: Account) => fetchBalances(account.guid)),\n )\n\n const monthlyAccountBalances = accountBalances\n .reduce(flattenBalances, [])\n .sort(sortByYearMonthAscending)\n\n this.setMonthlyAccountBalances(monthlyAccountBalances)\n }\n\n getMonthlyAccountBalances = async (accountGuid: string) => {\n try {\n const balances = await this.accountsApi.getMonthlyAccountBalances(accountGuid)\n return balances as MonthlyAccountBalance[]\n } catch (error) {\n this.captureError('getMonthlyAccountBalances', error)\n return []\n }\n }\n\n getHistoricalAccountBalances = async (accountGuid: string): Promise<MonthlyAccountBalance[]> => {\n try {\n const balances: HistoricalAccountBalance[] =\n await this.accountsApi.getHistoricalAccountBalances(accountGuid)\n return balances.map(toMonthlyAccountBalance)\n } catch (error) {\n this.captureError('getHistoricalAccountBalances', error)\n return []\n }\n }\n\n setHoveredIndex = (index: number) => (this.hoveredIndex = index)\n\n setMonthlyAccountBalances = (balances: MonthlyAccountBalance[]) => {\n this.monthlyAccountBalances = balances\n this.monthlyAccountBalancesLoaded = true\n }\n\n setSelectedIndex = (index: number) => (this.selectedIndex = index)\n setTimeframe = (months: number) => (this.timeframe = months)\n\n private captureError = (action: string, error: unknown) =>\n this.globalStore.captureException(error, { store: 'NetWorthStore', action })\n}\n"],"mappings":";;;;AA4BA,IAAa,IAA8B,+BAE9B,IAAb,MAA2B;AAAA,EACzB;AAAA,EACA,cAA0B,IAAI,EAAW,KAAK,EAAE;AAAA,EAEhD,yBAAkD,CAAC;AAAA,EACnD,+BAAwC;AAAA,EACxC,eAAuB;AAAA,EACvB,gBAAwB;AAAA,EACxB,YAAoB;AAAA,EAEpB,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,KAAK,cAAc,IAAI,EACrB,EAA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;
16
16
  updateNotification: (notification: Notification) => Promise<void>;
17
+ private captureError;
17
18
  }
@@ -1,20 +1,20 @@
1
1
  import { NotificationApi as t } from "../api/NotificationApi.es.js";
2
- import { filterRecentNotifications as o } from "../utils/NotificationUtils.es.js";
3
- import { makeAutoObservable as e, observable as a, runInAction as n } from "mobx";
4
- var f = class {
2
+ import { filterRecentNotifications as a } from "../utils/NotificationUtils.es.js";
3
+ import { makeAutoObservable as e, observable as s, runInAction as n } from "mobx";
4
+ var h = class {
5
5
  globalStore;
6
6
  api = new t("/", "");
7
7
  isLoading = !0;
8
8
  notifications = [];
9
9
  notificationsLoaded = !1;
10
10
  constructor(i) {
11
- this.globalStore = i, this.api = new t(i.endpoint, i.sessionToken, i.onError), e(this, { notifications: a });
11
+ this.globalStore = i, this.api = new t(i.endpoint, i.sessionToken, i.onError), e(this, { notifications: s });
12
12
  }
13
13
  get newNotifications() {
14
14
  return this.recentNotifications.filter((i) => !i.has_been_viewed);
15
15
  }
16
16
  get recentNotifications() {
17
- return o(this.notifications);
17
+ return a(this.notifications);
18
18
  }
19
19
  setNotifications = (i) => {
20
20
  this.notifications = i, this.notificationsLoaded = !0;
@@ -25,7 +25,7 @@ var f = class {
25
25
  const i = await this.api.getNotifications();
26
26
  this.setNotifications(i);
27
27
  } catch (i) {
28
- console.error("Error occurred while loading notifications:", i), this.globalStore.captureException(i, { store: "NotificationStore" });
28
+ this.captureError("loadNotifications", i);
29
29
  } finally {
30
30
  n(() => {
31
31
  this.isLoading = !1;
@@ -38,9 +38,13 @@ var f = class {
38
38
  updateNotification = async (i) => {
39
39
  i.has_been_viewed = !0, await this.api.updateNotification(i);
40
40
  };
41
+ captureError = (i, o) => this.globalStore.captureException(o, {
42
+ store: "NotificationStore",
43
+ action: i
44
+ });
41
45
  };
42
46
  export {
43
- f as NotificationStore
47
+ h as NotificationStore
44
48
  };
45
49
 
46
50
  //# sourceMappingURL=NotificationStore.es.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationStore.es.js","names":[],"sources":["../../../src/core/stores/NotificationStore.ts"],"sourcesContent":["import { makeAutoObservable, observable, runInAction } from 'mobx'\n\nimport { NotificationApi } from '../api'\nimport { type Notification } from '../types'\nimport { filterRecentNotifications } from '../utils/NotificationUtils'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class NotificationStore {\n globalStore: GlobalStore\n api = new NotificationApi('/', '')\n\n isLoading: boolean = true\n notifications: Notification[] = []\n notificationsLoaded: boolean = false\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new NotificationApi(\n globalStore.endpoint,\n globalStore.sessionToken,\n globalStore.onError,\n )\n\n makeAutoObservable(this, { notifications: observable })\n }\n\n // Used in Money Dashboard\n get newNotifications(): Notification[] {\n return this.recentNotifications.filter((n) => !n.has_been_viewed)\n }\n\n get recentNotifications(): Notification[] {\n return filterRecentNotifications(this.notifications)\n }\n\n setNotifications = (notifications: Notification[]) => {\n this.notifications = notifications\n this.notificationsLoaded = true\n }\n\n loadNotifications = async () => {\n this.isLoading = true\n try {\n const notifications = await this.api.getNotifications()\n this.setNotifications(notifications)\n } catch (error) {\n console.error('Error occurred while loading notifications:', error)\n this.globalStore.captureException(error, { store: 'NotificationStore' })\n } finally {\n runInAction(() => {\n this.isLoading = false\n })\n }\n }\n\n markAllAsViewed = async () => {\n // Update on the server\n await this.api.markAllAsViewed()\n }\n\n updateNotification = async (notification: Notification) => {\n notification.has_been_viewed = true\n await this.api.updateNotification(notification)\n }\n}\n"],"mappings":";;;AAQA,IAAa,IAAb,MAA+B;AAAA,EAC7B;AAAA,EACA,MAAM,IAAI,EAAgB,KAAK,EAAE;AAAA,EAEjC,YAAqB;AAAA,EACrB,gBAAgC,CAAC;AAAA,EACjC,sBAA+B;AAAA,EAE/B,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,KAAK,MAAM,IAAI,EACb,EAAY,UACZ,EAAY,cACZ,EAAY,OACd,GAEA,EAAmB,MAAM,EAAE,eAAe,EAAW,CAAC;AAAA,EACxD;AAAA,EAGA,IAAI,mBAAmC;AACrC,WAAO,KAAK,oBAAoB,OAAA,CAAQ,MAAM,CAAC,EAAE,eAAe;AAAA,EAClE;AAAA,EAEA,IAAI,sBAAsC;AACxC,WAAO,EAA0B,KAAK,aAAa;AAAA,EACrD;AAAA,EAEA,mBAAA,CAAoB,MAAkC;AACpD,SAAK,gBAAgB,GACrB,KAAK,sBAAsB;AAAA,EAC7B;AAAA,EAEA,oBAAoB,YAAY;AAC9B,SAAK,YAAY;AACjB,QAAI;AACF,YAAM,IAAgB,MAAM,KAAK,IAAI,iBAAiB;AACtD,WAAK,iBAAiB,CAAa;AAAA,IACrC,SAAS,GAAO;AACd,cAAQ,MAAM,+CAA+C,CAAK,GAClE,KAAK,YAAY,iBAAiB,GAAO,EAAE,OAAO,oBAAoB,CAAC;AAAA,IACzE,UAAA;AACE,MAAA,EAAA,MAAkB;AAChB,aAAK,YAAY;AAAA,MACnB,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,kBAAkB,YAAY;AAE5B,UAAM,KAAK,IAAI,gBAAgB;AAAA,EACjC;AAAA,EAEA,qBAAqB,OAAO,MAA+B;AACzD,IAAA,EAAa,kBAAkB,IAC/B,MAAM,KAAK,IAAI,mBAAmB,CAAY;AAAA,EAChD;AACF"}
1
+ {"version":3,"file":"NotificationStore.es.js","names":[],"sources":["../../../src/core/stores/NotificationStore.ts"],"sourcesContent":["import { makeAutoObservable, observable, runInAction } from 'mobx'\n\nimport { NotificationApi } from '../api'\nimport { type Notification } from '../types'\nimport { filterRecentNotifications } from '../utils/NotificationUtils'\n\nimport { GlobalStore } from './GlobalStore'\n\nexport class NotificationStore {\n globalStore: GlobalStore\n api = new NotificationApi('/', '')\n\n isLoading: boolean = true\n notifications: Notification[] = []\n notificationsLoaded: boolean = false\n\n constructor(globalStore: GlobalStore) {\n this.globalStore = globalStore\n this.api = new NotificationApi(\n globalStore.endpoint,\n globalStore.sessionToken,\n globalStore.onError,\n )\n\n makeAutoObservable(this, { notifications: observable })\n }\n\n // Used in Money Dashboard\n get newNotifications(): Notification[] {\n return this.recentNotifications.filter((n) => !n.has_been_viewed)\n }\n\n get recentNotifications(): Notification[] {\n return filterRecentNotifications(this.notifications)\n }\n\n setNotifications = (notifications: Notification[]) => {\n this.notifications = notifications\n this.notificationsLoaded = true\n }\n\n loadNotifications = async () => {\n this.isLoading = true\n try {\n const notifications = await this.api.getNotifications()\n this.setNotifications(notifications)\n } catch (error) {\n this.captureError('loadNotifications', error)\n } finally {\n runInAction(() => {\n this.isLoading = false\n })\n }\n }\n\n markAllAsViewed = async () => {\n // Update on the server\n await this.api.markAllAsViewed()\n }\n\n updateNotification = async (notification: Notification) => {\n notification.has_been_viewed = true\n await this.api.updateNotification(notification)\n }\n\n private captureError = (action: string, error: unknown) =>\n this.globalStore.captureException(error, { store: 'NotificationStore', action })\n}\n"],"mappings":";;;AAQA,IAAa,IAAb,MAA+B;AAAA,EAC7B;AAAA,EACA,MAAM,IAAI,EAAgB,KAAK,EAAE;AAAA,EAEjC,YAAqB;AAAA,EACrB,gBAAgC,CAAC;AAAA,EACjC,sBAA+B;AAAA,EAE/B,YAAY,GAA0B;AACpC,SAAK,cAAc,GACnB,KAAK,MAAM,IAAI,EACb,EAAY,UACZ,EAAY,cACZ,EAAY,OACd,GAEA,EAAmB,MAAM,EAAE,eAAe,EAAW,CAAC;AAAA,EACxD;AAAA,EAGA,IAAI,mBAAmC;AACrC,WAAO,KAAK,oBAAoB,OAAA,CAAQ,MAAM,CAAC,EAAE,eAAe;AAAA,EAClE;AAAA,EAEA,IAAI,sBAAsC;AACxC,WAAO,EAA0B,KAAK,aAAa;AAAA,EACrD;AAAA,EAEA,mBAAA,CAAoB,MAAkC;AACpD,SAAK,gBAAgB,GACrB,KAAK,sBAAsB;AAAA,EAC7B;AAAA,EAEA,oBAAoB,YAAY;AAC9B,SAAK,YAAY;AACjB,QAAI;AACF,YAAM,IAAgB,MAAM,KAAK,IAAI,iBAAiB;AACtD,WAAK,iBAAiB,CAAa;AAAA,IACrC,SAAS,GAAO;AACd,WAAK,aAAa,qBAAqB,CAAK;AAAA,IAC9C,UAAA;AACE,MAAA,EAAA,MAAkB;AAChB,aAAK,YAAY;AAAA,MACnB,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,kBAAkB,YAAY;AAE5B,UAAM,KAAK,IAAI,gBAAgB;AAAA,EACjC;AAAA,EAEA,qBAAqB,OAAO,MAA+B;AACzD,IAAA,EAAa,kBAAkB,IAC/B,MAAM,KAAK,IAAI,mBAAmB,CAAY;AAAA,EAChD;AAAA,EAEA,eAAA,CAAwB,GAAgB,MACtC,KAAK,YAAY,iBAAiB,GAAO;AAAA,IAAE,OAAO;AAAA,IAAqB,QAAA;AAAA,EAAO,CAAC;AACnF"}
@@ -52,5 +52,6 @@ export declare class SettingsStore {
52
52
  updateUser: (user: User) => Promise<void>;
53
53
  updateUserCommunicationProfile: (profile: UserCommunicationProfile) => Promise<void>;
54
54
  verifyPhoneToken: (sms_verification_token: string) => Promise<void>;
55
+ private captureError;
55
56
  }
56
57
  export {};
@@ -2,8 +2,8 @@ import { AccountNotificationTypes as r, BudgetNotificationTypes as a, InsightNot
2
2
  import { SettingsApi as n } from "../api/SettingsApi.es.js";
3
3
  import { TransactionApi as c } from "../api/TransactionApi.es.js";
4
4
  import { augmentNotificationProfiles as u } from "../utils/SettingsUtil.es.js";
5
- import { makeAutoObservable as p, runInAction as o } from "mobx";
6
- var _ = class {
5
+ import { makeAutoObservable as d, runInAction as o } from "mobx";
6
+ var g = class {
7
7
  globalStore;
8
8
  api = new n("/", "");
9
9
  transactionApi = new c("/", "");
@@ -16,7 +16,7 @@ var _ = class {
16
16
  selectedRule = void 0;
17
17
  transactionRules = [];
18
18
  constructor(t) {
19
- this.globalStore = t, this.api = new n(t.endpoint, t.sessionToken, t.onError), this.transactionApi = new c(t.endpoint, t.sessionToken, t.onError), p(this);
19
+ this.globalStore = t, this.api = new n(t.endpoint, t.sessionToken, t.onError), this.transactionApi = new c(t.endpoint, t.sessionToken, t.onError), d(this);
20
20
  }
21
21
  get accountProfiles() {
22
22
  const t = this.globalStore.appDataStore.clientCommunicationProfile;
@@ -49,7 +49,7 @@ var _ = class {
49
49
  this.devices.splice(e, 1);
50
50
  }), { success: !0 };
51
51
  } catch (e) {
52
- return console.error("Error deleting device:", e), this.globalStore.captureException(e, { store: "SettingsStore" }), { success: !1 };
52
+ return this.captureError("deleteDevice", e), { success: !1 };
53
53
  }
54
54
  };
55
55
  deleteTransactionRule = async () => {
@@ -57,14 +57,14 @@ var _ = class {
57
57
  try {
58
58
  await this.transactionApi.removeTransactionRule(this.selectedRule?.guid), this.setAlert(this.copy.delete_rule_success, "success"), await this.loadTransactionRules();
59
59
  } catch (t) {
60
- console.error("Error deleting transaction rule:", t), this.globalStore.captureException(t, { store: "SettingsStore" }), this.setAlert(this.copy.delete_rule_error, "error");
60
+ this.captureError("deleteTransactionRule", t), this.setAlert(this.copy.delete_rule_error, "error");
61
61
  }
62
62
  };
63
63
  generateDeviceToken = async () => {
64
64
  try {
65
65
  return await this.api.generateDeviceToken();
66
66
  } catch (t) {
67
- console.error("Error generating device token:", t), this.globalStore.captureException(t, { store: "SettingsStore" });
67
+ this.captureError("generateDeviceToken", t);
68
68
  }
69
69
  };
70
70
  loadDevices = async () => {
@@ -74,7 +74,7 @@ var _ = class {
74
74
  this.devices = t;
75
75
  });
76
76
  } catch (t) {
77
- console.error("Error loading devices:", t), this.globalStore.captureException(t, { store: "SettingsStore" });
77
+ this.captureError("loadDevices", t);
78
78
  }
79
79
  };
80
80
  loadNotificationProfiles = async () => {
@@ -84,7 +84,7 @@ var _ = class {
84
84
  this.notificationProfiles = t;
85
85
  });
86
86
  } catch (t) {
87
- console.error("Error loading notification profiles:", t), this.globalStore.captureException(t, { store: "SettingsStore" });
87
+ this.captureError("loadNotificationProfiles", t);
88
88
  }
89
89
  };
90
90
  loadTransactionRules = async () => {
@@ -94,21 +94,21 @@ var _ = class {
94
94
  this.transactionRules = t;
95
95
  });
96
96
  } catch (t) {
97
- console.error("Error loading transaction rules:", t), this.globalStore.captureException(t, { store: "SettingsStore" });
97
+ this.captureError("loadTransactionRules", t);
98
98
  }
99
99
  };
100
100
  sendEmailVerification = async () => {
101
101
  try {
102
102
  await this.api.sendEmailVerification(), this.setAlert(this.copy.verification_sent_success, "success");
103
103
  } catch (t) {
104
- console.error("Error sending email verification:", t), this.globalStore.captureException(t, { store: "SettingsStore" }), this.setAlert(this.copy.verification_sent_error, "error");
104
+ this.captureError("sendEmailVerification", t), this.setAlert(this.copy.verification_sent_error, "error");
105
105
  }
106
106
  };
107
107
  sendPhoneVerification = async () => {
108
108
  try {
109
109
  await this.api.sendPhoneVerification(), this.setAlert(this.copy.verification_sent_success, "success");
110
110
  } catch (t) {
111
- console.error("Error sending phone verification:", t), this.globalStore.captureException(t, { store: "SettingsStore" }), this.setAlert(this.copy.verification_sent_error, "error");
111
+ this.captureError("sendPhoneVerification", t), this.setAlert(this.copy.verification_sent_error, "error");
112
112
  }
113
113
  };
114
114
  setAlert = (t, e = void 0) => this.alert = {
@@ -122,7 +122,7 @@ var _ = class {
122
122
  try {
123
123
  await this.api.updatePassword(t), this.setAlert(this.copy.password_updated_success, "success");
124
124
  } catch (e) {
125
- console.error("Error updating password:", e), this.globalStore.captureException(e, { store: "SettingsStore" }), this.setAlert(this.copy.password_updated_error, "error");
125
+ this.captureError("updatePassword", e), this.setAlert(this.copy.password_updated_error, "error");
126
126
  }
127
127
  };
128
128
  updateDevice = async (t) => {
@@ -132,7 +132,7 @@ var _ = class {
132
132
  this.devices[i] = e;
133
133
  }), { success: !0 };
134
134
  } catch (e) {
135
- return console.error("Error updating device:", e), this.globalStore.captureException(e, { store: "SettingsStore" }), { success: !1 };
135
+ return this.captureError("updateDevice", e), { success: !1 };
136
136
  }
137
137
  };
138
138
  updateNotificationProfile = async (t) => {
@@ -142,21 +142,21 @@ var _ = class {
142
142
  this.notificationProfiles[i] = e;
143
143
  }), !0;
144
144
  } catch (e) {
145
- return console.error("Error updating notification profile:", e), this.globalStore.captureException(e, { store: "SettingsStore" }), !1;
145
+ return this.captureError("updateNotificationProfile", e), !1;
146
146
  }
147
147
  };
148
148
  updateRuleCategory = async (t) => {
149
149
  try {
150
150
  await this.transactionApi.updateTransactionRule(t), await this.loadTransactionRules();
151
151
  } catch (e) {
152
- console.error("Error updating rule category:", e), this.globalStore.captureException(e, { store: "SettingsStore" });
152
+ this.captureError("updateRuleCategory", e);
153
153
  }
154
154
  };
155
155
  updateRulePayee = async (t) => {
156
156
  try {
157
157
  await this.transactionApi.updateTransactionRule(t), this.setAlert(this.copy.edit_payee_success, "success"), await this.loadTransactionRules();
158
158
  } catch (e) {
159
- console.error("Error updating rule payee:", e), this.globalStore.captureException(e, { store: "SettingsStore" }), this.setAlert(this.copy.edit_payee_error, "error");
159
+ this.captureError("updateRulePayee", e), this.setAlert(this.copy.edit_payee_error, "error");
160
160
  }
161
161
  };
162
162
  updateUser = async (t) => {
@@ -171,7 +171,7 @@ var _ = class {
171
171
  const e = await this.api.updateUserCommunicationProfile(t);
172
172
  this.globalStore.appDataStore.setUserCommunicationProfile(e);
173
173
  } catch (e) {
174
- console.error("Error occurred while updating user communication profile:", e), this.globalStore.captureException(e, { store: "SettingsStore" });
174
+ this.captureError("updateUserCommunicationProfile", e);
175
175
  }
176
176
  };
177
177
  verifyPhoneToken = async (t) => {
@@ -180,12 +180,16 @@ var _ = class {
180
180
  if (!e) throw new Error();
181
181
  this.setAlert(this.copy.verified_phone_success, "success");
182
182
  } catch (e) {
183
- console.error("Error verifying phone token:", e), this.globalStore.captureException(e, { store: "SettingsStore" }), this.setAlert(this.copy.verified_phone_error, "error");
183
+ this.captureError("verifyPhoneToken", e), this.setAlert(this.copy.verified_phone_error, "error");
184
184
  }
185
185
  };
186
+ captureError = (t, e) => this.globalStore.captureException(e, {
187
+ store: "SettingsStore",
188
+ action: t
189
+ });
186
190
  };
187
191
  export {
188
- _ as SettingsStore
192
+ g as SettingsStore
189
193
  };
190
194
 
191
195
  //# sourceMappingURL=SettingsStore.es.js.map