feat: track events in note creator
This commit is contained in:
parent
d2cec4909c
commit
a1e9df8254
@ -6,7 +6,7 @@ import { TagsInput } from "react-tag-input-component";
|
|||||||
|
|
||||||
import Icon from "@/Icons/Icon";
|
import Icon from "@/Icons/Icon";
|
||||||
import useEventPublisher from "@/Hooks/useEventPublisher";
|
import useEventPublisher from "@/Hooks/useEventPublisher";
|
||||||
import { appendDedupe, openFile } from "@/SnortUtils";
|
import { appendDedupe, openFile, trackEvent } from "@/SnortUtils";
|
||||||
import Textarea from "@/Element/Textarea";
|
import Textarea from "@/Element/Textarea";
|
||||||
import Modal from "@/Element/Modal";
|
import Modal from "@/Element/Modal";
|
||||||
import ProfileImage from "@/Element/User/ProfileImage";
|
import ProfileImage from "@/Element/User/ProfileImage";
|
||||||
@ -158,6 +158,16 @@ export function NoteCreator() {
|
|||||||
async function sendNote() {
|
async function sendNote() {
|
||||||
const ev = await buildNote();
|
const ev = await buildNote();
|
||||||
if (ev) {
|
if (ev) {
|
||||||
|
trackEvent("PostNote")
|
||||||
|
if (ev.tags.find(a => a[0] === "content-warning")) {
|
||||||
|
trackEvent("PostNote:WithContentWarning");
|
||||||
|
}
|
||||||
|
if (ev.tags.find(a => a[0] === "poll_option")) {
|
||||||
|
trackEvent("PostNote:WithPoll");
|
||||||
|
}
|
||||||
|
if (ev.tags.find(a => a[0] === "zap")) {
|
||||||
|
trackEvent("PostNote:WithZapSplit");
|
||||||
|
}
|
||||||
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 => {
|
||||||
@ -193,7 +203,7 @@ export function NoteCreator() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function uploadFile(file: File | Blob) {
|
async function uploadFile(file: File) {
|
||||||
try {
|
try {
|
||||||
if (file) {
|
if (file) {
|
||||||
const rx = await uploader.upload(file, file.name);
|
const rx = await uploader.upload(file, file.name);
|
||||||
@ -259,6 +269,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");
|
||||||
note.update(v => (v.preview = tmpNote));
|
note.update(v => (v.preview = tmpNote));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -341,18 +352,18 @@ export function NoteCreator() {
|
|||||||
onChange={e => {
|
onChange={e => {
|
||||||
note.update(
|
note.update(
|
||||||
v =>
|
v =>
|
||||||
(v.selectedCustomRelays =
|
(v.selectedCustomRelays =
|
||||||
// set false if all relays selected
|
// set false if all relays selected
|
||||||
e.target.checked &&
|
e.target.checked &&
|
||||||
note.selectedCustomRelays &&
|
note.selectedCustomRelays &&
|
||||||
note.selectedCustomRelays.length == a.length - 1
|
note.selectedCustomRelays.length == a.length - 1
|
||||||
? undefined
|
? undefined
|
||||||
: // otherwise return selectedCustomRelays with target relay added / removed
|
: // otherwise return selectedCustomRelays with target relay added / removed
|
||||||
a.filter(el =>
|
a.filter(el =>
|
||||||
el === r
|
el === r
|
||||||
? e.target.checked
|
? e.target.checked
|
||||||
: !note.selectedCustomRelays || note.selectedCustomRelays.includes(el),
|
: !note.selectedCustomRelays || note.selectedCustomRelays.includes(el),
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@ -421,9 +432,9 @@ export function NoteCreator() {
|
|||||||
onChange={e =>
|
onChange={e =>
|
||||||
note.update(
|
note.update(
|
||||||
v =>
|
v =>
|
||||||
(v.zapSplits = arr.map((vv, ii) =>
|
(v.zapSplits = arr.map((vv, ii) =>
|
||||||
ii === i ? { ...vv, weight: Number(e.target.value) } : vv,
|
ii === i ? { ...vv, weight: Number(e.target.value) } : vv,
|
||||||
)),
|
)),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user