Skip to content

Commit

Permalink
add casting tracking
Browse files Browse the repository at this point in the history
  • Loading branch information
hellno committed Aug 25, 2023
1 parent f22a2fb commit 034ff09
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/common/helpers/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ import { trackEvent } from "@aptabase/web";
export const trackPageView = (name: string) => {
trackEvent("page_view", { name });
}

export const trackEventWithProperties = (name: string, properties?: Record<string, string | number | boolean> | undefined) => {
trackEvent(name, properties);
}
10 changes: 5 additions & 5 deletions src/stores/useNewPostStore.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { create, State } from "zustand";
import { create } from "zustand";
import { devtools } from "zustand/middleware";
import { create as mutativeCreate, Draft } from 'mutative';
import isEqual from 'lodash.isequal';
import { CommandType } from "@/common/constants/commands";
import { TagIcon } from "@heroicons/react/24/outline";
import { PencilSquareIcon } from "@heroicons/react/20/solid";
import { openWindow } from "@/common/helpers/navigation";
import { convertEditorCastToPublishableCast, publishCast } from "@/common/helpers/farcaster";
import { AccountObjectType } from "./useAccountStore";
import { trackEventWithProperties } from "@/common/helpers/analytics";

export type PostType = {
text: string;
Expand Down Expand Up @@ -81,12 +81,12 @@ const store = (set: StoreSet) => ({
});
},
publishPostDraft: async (draftId: number, account: { privateKey: string, platformAccountId: string }) => {
set((state) => {
set(async (state) => {
const draft = state.postDrafts[draftId];
console.log("publishing post draft", draft);

const castBody = convertEditorCastToPublishableCast(draft.text);
publishCast({
await publishCast({
castBody,
privateKey: account.privateKey,
authorFid: account.platformAccountId,
Expand All @@ -96,7 +96,7 @@ const store = (set: StoreSet) => ({
console.log('err', err);
})

// call farsign api here
trackEventWithProperties('publish_post', { authorFid: account.platformAccountId });
state.postDrafts.splice(draftId, 1);
});
}
Expand Down

0 comments on commit 034ff09

Please sign in to comment.