Skip to content

Commit

Permalink
fix: Adds fathom analytics to custom search buttons.
Browse files Browse the repository at this point in the history
  • Loading branch information
neomorphic committed Jan 19, 2024
1 parent e03968c commit e85e91e
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 10 deletions.
14 changes: 6 additions & 8 deletions src/components/CustomSearch/CompleteSearchSummary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default function CompleteSearchSummary({ search }) {

const searchType = search.searchType === "em2lm" ? "LM" : "EM";

function copyAlignment() {
const copyAlignment = () => {
setIsCopying(true);
API.post("SearchAPI", "/copy_alignment", {
body: {
Expand All @@ -65,13 +65,11 @@ export default function CompleteSearchSummary({ search }) {
}

const searchMessage = search.errorMessage ? (
<>
<span style={{ color: "red" }}>
<WarningOutlined style={{ color: "#f00", fontSize: "1.5em" }} /> Search
failed. <br />
Please try again.
</span>
</>
<span style={{ color: "red" }}>
<WarningOutlined style={{ color: "#f00", fontSize: "1.5em" }} /> Search
failed. <br />
Please try again.
</span>
) : (
<Link to={searchLink} disabled={Boolean(search.errorMessage)}>
{search.nTotalMatches} {searchType} matches
Expand Down
12 changes: 11 additions & 1 deletion src/components/CustomSearch/CompleteStep.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ import StepTitle from "./StepTitle";

export default function CompleteStep({ state, matches, resultsUrl }) {
let content = "";

const handleView = () => {
if (Object.prototype.hasOwnProperty.call(window, 'fathom')) {
// make sure the fathom code has been loaded and not blocked by an ad blocker.
if (window.fathom) {
window.fathom.trackGoal('view complete results', 0);
}
}
};

if (["complete"].includes(state)) {
content = (
<>
Expand All @@ -21,7 +31,7 @@ export default function CompleteStep({ state, matches, resultsUrl }) {
>
{matches} matches found
</Link>
<Button type="primary" style={{ width: "150px", marginTop: "0.5em" }}>
<Button type="primary" style={{ width: "150px", marginTop: "0.5em" }} onClick={handleView}>
<Link to={resultsUrl} >
View
</Link>
Expand Down
12 changes: 11 additions & 1 deletion src/components/CustomSearch/ImageAlignmentStep.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ export default function ImageAlignmentStep({ state, search }) {
}
}, [search.searchDir, search.uploadThumbnail]);

const handleQualityCheck = () => {
if (Object.prototype.hasOwnProperty.call(window, 'fathom')) {
// make sure the fathom code has been loaded and not blocked by an ad blocker.
if (window.fathom) {
window.fathom.trackGoal('View Alignment Quality check', 0);
}
}
};


let content = "";
if (["complete"].includes(state)) {
const imgClass =
Expand All @@ -50,7 +60,7 @@ export default function ImageAlignmentStep({ state, search }) {
Score: {search.alignmentScore || "N/A"}
</span>
{movieUrl ? (
<a href={movieUrl}>
<a href={movieUrl} onClick={handleQualityCheck}>
<FontAwesomeIcon size="lg" icon={faFileVideo} /> Alignment Quality Check
</a>
) : (
Expand Down
7 changes: 7 additions & 0 deletions src/components/CustomSearch/MaskSelectionStep.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ export default function MaskSelectionStep({ search, state }) {
}, [search.searchMask, search.searchDir]);

const copyAlignment = () => {
if (Object.prototype.hasOwnProperty.call(window, 'fathom')) {
// make sure the fathom code has been loaded and not blocked by an ad blocker.
if (window.fathom) {
window.fathom.trackGoal('Re-select mask', 0);
}
}

setIsCopying(true);
API.post("SearchAPI", "/copy_alignment", {
body: {
Expand Down

0 comments on commit e85e91e

Please sign in to comment.