diff --git a/packages/core/src/analytics/analytics.ts b/packages/core/src/analytics/analytics.ts index 7ec2893b..9105d6f0 100644 --- a/packages/core/src/analytics/analytics.ts +++ b/packages/core/src/analytics/analytics.ts @@ -17,6 +17,16 @@ export function recordEvent(name: string, data?: ExtraData) { } } +export function recordCurrentSheetEvent(eventName: string, extraData: ExtraData) { + const sheet = window['currentSheet']; + if (sheet instanceof GearPlanSheet) { + recordSheetEvent(eventName, sheet, extraData); + } + else { + recordEvent(eventName, extraData); + } +} + export function recordSheetEvent(eventName: string, sheet: GearPlanSheet, extraData: ExtraData = {}) { const fullData = { // ...prepSheetData(sheet), @@ -27,9 +37,9 @@ export function recordSheetEvent(eventName: string, sheet: GearPlanSheet, extraD } function prepSheetData(sheet: GearPlanSheet) { - return { - 'job': sheet.classJobName, - 'level': sheet.level, - 'isync': sheet.ilvlSync - } + return { + 'job': sheet.classJobName, + 'level': sheet.level, + 'isync': sheet.ilvlSync + } } \ No newline at end of file diff --git a/packages/frontend/src/scripts/components/gear_edit_toolbar.ts b/packages/frontend/src/scripts/components/gear_edit_toolbar.ts index 1acf2c9a..4c3dbb11 100644 --- a/packages/frontend/src/scripts/components/gear_edit_toolbar.ts +++ b/packages/frontend/src/scripts/components/gear_edit_toolbar.ts @@ -5,7 +5,7 @@ import {StatTierDisplay} from "./stat_tier_display"; import {CharacterGearSet} from "@xivgear/core/gear"; import {GearPlanSheet} from "@xivgear/core/sheet"; import {makeActionButton, redoIcon, undoIcon} from "@xivgear/common-ui/components/util"; -import {recordEvent} from "@xivgear/core/analytics/analytics"; +import {recordEvent, recordSheetEvent} from "@xivgear/core/analytics/analytics"; export class UndoArea extends HTMLDivElement { private _currentSet: CharacterGearSet; @@ -69,10 +69,22 @@ export class GearEditToolbar extends HTMLDivElement { ilvlDiv.classList.add('ilvl-picker-area'); const itemIlvlRange = new ILvlRangePicker(itemDisplaySettings, 'minILvl', 'maxILvl', 'Gear:'); itemIlvlRange.addListener(displayUpdateCallback); + itemIlvlRange.addListener((min, max) => { + recordSheetEvent('itemIlvlRange', sheet, { + min: min, + max: max + }); + }); ilvlDiv.appendChild(itemIlvlRange); const foodIlvlRange = new ILvlRangePicker(itemDisplaySettings, 'minILvlFood', 'maxILvlFood', 'Food:'); foodIlvlRange.addListener(displayUpdateCallback); + foodIlvlRange.addListener((min, max) => { + recordSheetEvent('foodIlvlRange', sheet, { + min: min, + max: max + }); + }); ilvlDiv.appendChild(foodIlvlRange); this.appendChild(ilvlDiv); diff --git a/packages/frontend/src/scripts/components/items.ts b/packages/frontend/src/scripts/components/items.ts index f3be237d..2f1a8e11 100644 --- a/packages/frontend/src/scripts/components/items.ts +++ b/packages/frontend/src/scripts/components/items.ts @@ -43,6 +43,7 @@ import {shortenItemName} from "@xivgear/core/util/strutils"; import {GearPlanSheet} from "@xivgear/core/sheet"; import {makeRelicStatEditor} from "./relic_stats"; import {ShowHideButton} from "@xivgear/common-ui/components/show_hide_chevron"; +import {recordSheetEvent} from "@xivgear/core/analytics/analytics"; function statCellStylerRemover(cell: CustomCell) { cell.classList.remove("secondary"); @@ -604,6 +605,9 @@ export class GearItemsTable extends CustomTable { // TODO: just make the getters/setters on this class instead data.push(makeShowHideRow(slot.name, gearSet.isSlotCollapsed(slotId), (val) => { gearSet.setSlotCollapsed(slotId, val); + recordSheetEvent('hideSlot', sheet, { + hidden: val + }); this.updateShowHide(); }, extras)); let itemsInSlot = itemMapping.get(slot.gearSlot); diff --git a/packages/frontend/src/scripts/components/materia.ts b/packages/frontend/src/scripts/components/materia.ts index f79c3f35..f84a3837 100644 --- a/packages/frontend/src/scripts/components/materia.ts +++ b/packages/frontend/src/scripts/components/materia.ts @@ -21,7 +21,7 @@ import { quickElement } from "@xivgear/common-ui/components/util"; import {GearPlanSheet} from "@xivgear/core/sheet"; -import {recordEvent} from "@xivgear/core/analytics/analytics"; +import {recordCurrentSheetEvent, recordEvent} from "@xivgear/core/analytics/analytics"; /** * Component for managing all materia slots on an item @@ -426,6 +426,11 @@ export class MateriaPriorityPicker extends HTMLElement { } }] }); + minGcdInput.addListener(val => { + recordCurrentSheetEvent('currentSheet', { + gcd: val + }); + }); minGcdInput.pattern = '\\d\\.\\d\\d?'; minGcdInput.title = 'Enter the minimum desired GCD in the form x.yz.\nSkS/SpS materia will be de-prioritized once this target GCD is met.'; minGcdInput.classList.add('min-gcd-input'); diff --git a/packages/frontend/src/scripts/components/sheet.ts b/packages/frontend/src/scripts/components/sheet.ts index 9324e5e3..e459b530 100644 --- a/packages/frontend/src/scripts/components/sheet.ts +++ b/packages/frontend/src/scripts/components/sheet.ts @@ -78,6 +78,7 @@ import {SaveAsModal} from "./new_sheet_form"; import {DropdownActionMenu} from "./dropdown_actions_menu"; import {CustomFoodPopup, CustomItemPopup} from "./custom_item_manager"; import {confirmDelete} from "@xivgear/common-ui/components/delete_confirm"; +import {recordSheetEvent} from "@xivgear/core/analytics/analytics"; export type GearSetSel = SingleCellRowOrHeaderSelect; @@ -1512,6 +1513,11 @@ export class GearPlanSheetGui extends GearPlanSheet { }, [undefined, ...Object.keys(RACE_STATS) as RaceName[]]); buttonsArea.appendChild(raceDropdown); + raceDropdown.addListener((val) => { + recordSheetEvent('changeRace', this, { + race: val + }); + }); const partySizeDropdown = new FieldBoundDataSelect( this, @@ -1526,6 +1532,11 @@ export class GearPlanSheetGui extends GearPlanSheet { }, rangeInc(0, MAX_PARTY_BONUS) ); + partySizeDropdown.addListener((val) => { + recordSheetEvent('changePartyBonus', this, { + partyBonus: val + }); + }); buttonsArea.appendChild(partySizeDropdown); if (this.saveKey) { diff --git a/packages/frontend/src/scripts/components/stat_tier_display.ts b/packages/frontend/src/scripts/components/stat_tier_display.ts index a6bad0b3..4c34b50d 100644 --- a/packages/frontend/src/scripts/components/stat_tier_display.ts +++ b/packages/frontend/src/scripts/components/stat_tier_display.ts @@ -16,6 +16,7 @@ import { vitToHp } from "@xivgear/xivmath/xivmath"; import {GearPlanSheet} from "@xivgear/core/sheet"; +import {recordSheetEvent} from "@xivgear/core/analytics/analytics"; interface Tiering { lower: number, @@ -174,7 +175,11 @@ export class StatTierDisplay extends HTMLDivElement { // singleStatTierDisplay.addEventListener('click', () => this.toggleState()); singleStatTierDisplay.addEventListener('click', (ev) => { if (ev.detail == 1) { - singleStatTierDisplay.expanded = !singleStatTierDisplay.expanded; + const expanded = singleStatTierDisplay.expanded = !singleStatTierDisplay.expanded; + recordSheetEvent('singleTierDisplayClick', this.sheet, { + expanded: expanded, + stat: stat + }); } else if (ev.detail >= 2) { // If this is a double click, the first click would have already toggled the state @@ -183,6 +188,10 @@ export class StatTierDisplay extends HTMLDivElement { for (const display of this.eleMap.values()) { display.expanded = newState; } + recordSheetEvent('allTierDisplayClick', this.sheet, { + expanded: newState, + stat: stat + }); } }); } diff --git a/packages/frontend/src/scripts/settings/settings_modal.ts b/packages/frontend/src/scripts/settings/settings_modal.ts index 8cb596a8..d3ac7a1f 100644 --- a/packages/frontend/src/scripts/settings/settings_modal.ts +++ b/packages/frontend/src/scripts/settings/settings_modal.ts @@ -2,6 +2,7 @@ import {BaseModal} from "@xivgear/common-ui/components/modal"; import {FieldBoundCheckBox} from "@xivgear/common-ui/components/util"; import {DISPLAY_SETTINGS} from "./display_settings"; import {BoolToggle} from "@xivgear/common-ui/components/bool_toggle"; +import {recordEvent} from "@xivgear/core/analytics/analytics"; class SettingsModal extends BaseModal { @@ -11,10 +12,12 @@ class SettingsModal extends BaseModal { // TODO: consider using slide toggles const settings = DISPLAY_SETTINGS; - const lightModeToggle = new BoolToggle(new FieldBoundCheckBox(settings, 'lightMode'), 'Light', 'Dark'); - const modernThemeToggle = new BoolToggle(new FieldBoundCheckBox(settings, 'modernTheme'), 'Modern', 'Classic'); - // const lightModeToggle = labeledCheckbox('Light Mode', new FieldBoundCheckBox(settings, 'lightMode')); - // const modernThemeToggle = labeledCheckbox('Modern Theme', new FieldBoundCheckBox(settings, 'modernTheme')); + const lightModeCb = new FieldBoundCheckBox(settings, 'lightMode'); + const lightModeToggle = new BoolToggle(lightModeCb, 'Light', 'Dark'); + lightModeCb.addListener(val => recordEvent('lightModeToggle', {lightMode: val})); + const modernThemeCb = new FieldBoundCheckBox(settings, 'modernTheme'); + const modernThemeToggle = new BoolToggle(modernThemeCb, 'Modern', 'Classic'); + modernThemeCb.addListener(val => recordEvent('modernTheme', {modernTheme: val})); this.contentArea.append(lightModeToggle); this.contentArea.append(modernThemeToggle); @@ -25,6 +28,7 @@ class SettingsModal extends BaseModal { export function showSettingsModal() { const dialog = new SettingsModal(); dialog.attachAndShow(); + recordEvent('openSettingsModal'); } customElements.define('settings-modal', SettingsModal); \ No newline at end of file