forked from xiv-gear-planner/gear-planner
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request xiv-gear-planner#331 from xiv-gear-planner/add-ana…
…lytics-events Add analytics events for common actions
- Loading branch information
Showing
8 changed files
with
77 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import {GearPlanSheet} from "../sheet"; | ||
|
||
|
||
type ExtraData = { | ||
[key: string]: unknown | ||
} | ||
|
||
export function recordEvent(name: string, data?: ExtraData) { | ||
try { | ||
const umami = window['umami']; | ||
// Don't blindly expect this to exist - someone might block the script with an adblocker, and we don't want | ||
// the rest of the site to blow up. It also might just be down. | ||
umami?.track(name, data); | ||
} | ||
catch (e) { | ||
console.error("Error recording analytics", e); | ||
} | ||
} | ||
|
||
export function recordSheetEvent(eventName: string, sheet: GearPlanSheet, extraData: ExtraData = {}) { | ||
const fullData = { | ||
// ...prepSheetData(sheet), | ||
...extraData, | ||
sheet: prepSheetData(sheet) | ||
}; | ||
recordEvent(eventName, fullData); | ||
} | ||
|
||
function prepSheetData(sheet: GearPlanSheet) { | ||
return { | ||
'job': sheet.classJobName, | ||
'level': sheet.level, | ||
'isync': sheet.ilvlSync | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters