chore: track events with props
This commit is contained in:
parent
d00f8b0d85
commit
755ba17dab
@ -158,16 +158,21 @@ export function NoteCreator() {
|
||||
async function sendNote() {
|
||||
const ev = await buildNote();
|
||||
if (ev) {
|
||||
trackEvent("PostNote");
|
||||
let props: Record<string, boolean> | undefined = undefined;
|
||||
if (ev.tags.find(a => a[0] === "content-warning")) {
|
||||
trackEvent("PostNote:WithContentWarning");
|
||||
props ??= {};
|
||||
props["content-warning"] = true;
|
||||
}
|
||||
if (ev.tags.find(a => a[0] === "poll_option")) {
|
||||
trackEvent("PostNote:WithPoll");
|
||||
props ??= {};
|
||||
props["poll"] = true;
|
||||
}
|
||||
if (ev.tags.find(a => a[0] === "zap")) {
|
||||
trackEvent("PostNote:WithZapSplit");
|
||||
props ??= {};
|
||||
props["zap-split"] = true;
|
||||
}
|
||||
trackEvent("PostNote", props);
|
||||
|
||||
const events = (note.otherEvents ?? []).concat(ev);
|
||||
events.map(a =>
|
||||
sendEventToRelays(system, a, note.selectedCustomRelays, r => {
|
||||
@ -269,7 +274,7 @@ export function NoteCreator() {
|
||||
note.update(v => (v.preview = undefined));
|
||||
} else if (publisher) {
|
||||
const tmpNote = await buildNote();
|
||||
trackEvent("PostNote:Preview");
|
||||
trackEvent("PostNotePreview");
|
||||
note.update(v => (v.preview = tmpNote));
|
||||
}
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ export default function ZapPoolPage() {
|
||||
{wallet && (
|
||||
<AsyncButton
|
||||
onClick={async () => {
|
||||
trackEvent("ZapPool:Manual");
|
||||
trackEvent("ZapPool", { manual: true });
|
||||
await ZapPoolController?.payout(wallet);
|
||||
}}>
|
||||
<FormattedMessage defaultMessage="Payout Now" id="+PzQ9Y" />
|
||||
|
@ -24,7 +24,7 @@ export function Profile() {
|
||||
name: state.name,
|
||||
picture,
|
||||
});
|
||||
trackEvent("Login:NewAccount");
|
||||
trackEvent("Login", { newAccount: true });
|
||||
navigate("/login/sign-up/topics");
|
||||
} catch (e) {
|
||||
if (e instanceof Error) {
|
||||
|
@ -28,7 +28,7 @@ export function SignIn() {
|
||||
"getRelays" in unwrap(window.nostr) ? await unwrap(window.nostr?.getRelays).call(window.nostr) : undefined;*/
|
||||
const pubKey = await unwrap(window.nostr).getPublicKey();
|
||||
LoginStore.loginWithPubkey(pubKey, LoginSessionType.Nip7);
|
||||
trackEvent("Login:NIP7");
|
||||
trackEvent("Login", { type: "NIP7" });
|
||||
navigate("/");
|
||||
}
|
||||
|
||||
@ -41,8 +41,7 @@ export function SignIn() {
|
||||
setError("");
|
||||
try {
|
||||
await loginHandler.doLogin(key, key => Promise.resolve(new NotEncrypted(key)));
|
||||
|
||||
trackEvent("Login:Key");
|
||||
trackEvent("Login", { type: "Key" });
|
||||
navigate("/");
|
||||
} catch (e) {
|
||||
if (e instanceof Error) {
|
||||
|
@ -533,8 +533,8 @@ export function getCountry() {
|
||||
};
|
||||
}
|
||||
|
||||
export function trackEvent(event: string) {
|
||||
window.plausible?.(event);
|
||||
export function trackEvent(event: string, props?: Record<string, string | boolean>) {
|
||||
window.plausible?.(event, props ? { props } : undefined);
|
||||
}
|
||||
|
||||
export function storeRefCode() {
|
||||
|
@ -168,7 +168,7 @@ class ZapPool extends ExternalStore<Array<ZapPoolRecipient>> {
|
||||
if (wallet.canAutoLogin()) {
|
||||
await wallet.login();
|
||||
}
|
||||
trackEvent("ZapPool:Automatic");
|
||||
trackEvent("ZapPool", { automatic: true });
|
||||
await this.payout(wallet);
|
||||
}
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ import NetworkGraph from "@/Pages/NetworkGraph";
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
plausible?: (tag: string) => void;
|
||||
plausible?: (tag: string, e?: object) => void;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user