-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add analytics for tracking order buy
- Loading branch information
1 parent
f97e8aa
commit bfb0f1d
Showing
3 changed files
with
91 additions
and
18 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,26 @@ | ||
import { parseDate } from "chrono-node"; | ||
import type { Command } from "commander"; | ||
import { Box, Text, render, useApp } from "ink"; | ||
import Spinner from "ink-spinner"; | ||
import ms from "ms"; | ||
import dayjs from "npm:[email protected]"; | ||
import duration from "npm:[email protected]/plugin/duration.js"; | ||
import relativeTime from "npm:[email protected]/plugin/relativeTime.js"; | ||
import parseDurationFromLibrary from "parse-duration"; | ||
import React, { useCallback, useEffect, useRef, useState } from "react"; | ||
import invariant from "tiny-invariant"; | ||
import { apiClient } from "../../apiClient.ts"; | ||
import { | ||
logAndQuit, | ||
logSessionTokenExpiredAndQuit, | ||
} from "../../helpers/errors.ts"; | ||
import { roundStartDate } from "../../helpers/units.ts"; | ||
import parseDurationFromLibrary from "parse-duration"; | ||
import { Box, render, useApp } from "ink"; | ||
import { parseDate } from "chrono-node"; | ||
import { GPUS_PER_NODE } from "../constants.ts"; | ||
import ConfirmInput from "../ConfirmInput.tsx"; | ||
import type { Quote } from "../Quote.tsx"; | ||
import QuoteDisplay from "../Quote.tsx"; | ||
import { useCallback, useEffect, useRef, useState } from "react"; | ||
import { Text } from "ink"; | ||
import ConfirmInput from "../ConfirmInput.tsx"; | ||
import React from "react"; | ||
import { Row } from "../Row.tsx"; | ||
import ms from "ms"; | ||
import Spinner from "ink-spinner"; | ||
import invariant from "tiny-invariant"; | ||
import { GPUS_PER_NODE } from "../constants.ts"; | ||
import { analytics } from "../posthog.ts"; | ||
|
||
dayjs.extend(relativeTime); | ||
dayjs.extend(duration); | ||
|
@@ -352,15 +351,24 @@ function BuyOrder(props: BuyOrderProps) { | |
const [resultMessage, setResultMessage] = useState<string | null>(null); | ||
const handleSubmit = useCallback( | ||
(submitValue: boolean) => { | ||
analytics.track({ | ||
event: "buy_order_quoted", | ||
}); | ||
if (submitValue === false) { | ||
setIsLoading(false); | ||
setResultMessage("Order not placed, use 'y' to confirm"); | ||
setTimeout(() => { | ||
analytics.track({ | ||
event: "buy_order_quoted_rejected", | ||
}); | ||
exit(); | ||
}, 0); | ||
return; | ||
} | ||
|
||
analytics.track({ | ||
event: "buy_order_quoted_accepted", | ||
}); | ||
submitOrder(); | ||
}, | ||
[exit, setIsLoading] | ||
|
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