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