-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #532 from alleslabs/feat/new-amplitude-structure
new amplitude structure
- Loading branch information
Showing
177 changed files
with
2,421 additions
and
1,392 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
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from "./track-event"; | ||
export * from "./useAmplitudeInit"; | ||
export * from "./types"; |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { track as amplitudeTrack } from "@amplitude/analytics-browser"; | ||
import { useCallback } from "react"; | ||
|
||
import type { AmpEvent, ActionAmpEvent, SpecialAmpEvent } from "../types"; | ||
|
||
import { useMandatoryProperties } from "./useMandatoryProperties"; | ||
import { useTrackAction } from "./useTrackAction"; | ||
import { useTrackComponent } from "./useTrackComponent"; | ||
import { useTrackExternal } from "./useTrackExternal"; | ||
import { useTrackInteraction } from "./useTrackInteraction"; | ||
import { useTrackToPage } from "./useTrackToPage"; | ||
import { useTrackTx } from "./useTrackTx"; | ||
|
||
export const useTrack = () => { | ||
const mandatoryProperties = useMandatoryProperties(); | ||
|
||
const trackAction = useTrackAction(); | ||
const trackComponent = useTrackComponent(); | ||
const trackExternal = useTrackExternal(); | ||
const trackInteraction = useTrackInteraction(); | ||
const trackToPage = useTrackToPage(); | ||
const trackTx = useTrackTx(); | ||
|
||
const track = useCallback( | ||
( | ||
event: Exclude<AmpEvent, ActionAmpEvent | SpecialAmpEvent>, | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
properties?: Record<string, any> | ||
) => { | ||
amplitudeTrack(event, { | ||
...mandatoryProperties, | ||
...properties, | ||
}); | ||
}, | ||
[mandatoryProperties] | ||
); | ||
|
||
return { | ||
track, | ||
...trackAction, | ||
...trackComponent, | ||
...trackExternal, | ||
...trackInteraction, | ||
...trackToPage, | ||
...trackTx, | ||
}; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { fromBech32 } from "@cosmjs/encoding"; | ||
import { useRouter } from "next/router"; | ||
import { useMemo } from "react"; | ||
|
||
import { useCelatoneApp, useNavContext } from "lib/app-provider/contexts"; | ||
import { useCurrentChain, useMobile } from "lib/app-provider/hooks"; | ||
import { StorageKeys } from "lib/data"; | ||
import { sha256Hex, getItem } from "lib/utils"; | ||
|
||
export const useMandatoryProperties = () => { | ||
const { currentChainId } = useCelatoneApp(); | ||
const { prevPathname } = useNavContext(); | ||
const { address } = useCurrentChain(); | ||
const isMobile = useMobile(); | ||
const router = useRouter(); | ||
|
||
// TODO: make utility function | ||
const rawAddressHash = address | ||
? sha256Hex(fromBech32(address).data) | ||
: "Not Connected"; | ||
|
||
return useMemo( | ||
() => ({ | ||
page: router.pathname.replace("/[network]", ""), | ||
prevPathname, | ||
rawAddressHash, | ||
chain: currentChainId, | ||
mobile: isMobile, | ||
navSidebar: getItem(StorageKeys.NavSidebar, ""), | ||
devSidebar: getItem(StorageKeys.DevSidebar, ""), | ||
projectSidebar: getItem(StorageKeys.ProjectSidebar, ""), | ||
}), | ||
[currentChainId, isMobile, prevPathname, router.pathname, rawAddressHash] | ||
); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { track } from "@amplitude/analytics-browser"; | ||
import { useCallback } from "react"; | ||
|
||
import type { ActionAmpEvent } from "../types"; | ||
import type { AttachFundsType } from "lib/components/fund/types"; | ||
|
||
import { useMandatoryProperties } from "./useMandatoryProperties"; | ||
|
||
export const useTrackAction = () => { | ||
const mandatoryProperties = useMandatoryProperties(); | ||
|
||
const trackActionWithFunds = useCallback( | ||
( | ||
event: ActionAmpEvent, | ||
funds: number, | ||
attachFundsOption: AttachFundsType, | ||
method: "json-input" | "schema" | ||
) => | ||
track(event, { | ||
...mandatoryProperties, | ||
funds, | ||
attachFundsOption, | ||
method, | ||
}), | ||
[mandatoryProperties] | ||
); | ||
|
||
const trackAction = useCallback( | ||
(event: ActionAmpEvent, method: "json-input" | "schema") => | ||
track(event, { | ||
...mandatoryProperties, | ||
method, | ||
}), | ||
[mandatoryProperties] | ||
); | ||
|
||
const trackActionQuery = useCallback( | ||
( | ||
event: ActionAmpEvent, | ||
method: "json-input" | "schema", | ||
isInputRequired: boolean | ||
) => | ||
track(event, { | ||
...mandatoryProperties, | ||
method, | ||
isInputRequired, | ||
}), | ||
[mandatoryProperties] | ||
); | ||
|
||
// TODO: implement custom action here | ||
|
||
return { trackAction, trackActionWithFunds, trackActionQuery }; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { track } from "@amplitude/analytics-browser"; | ||
import { useCallback } from "react"; | ||
|
||
import { AmpEvent } from "../types"; | ||
|
||
import { useMandatoryProperties } from "./useMandatoryProperties"; | ||
|
||
export const useTrackComponent = () => { | ||
const mandatoryProperties = useMandatoryProperties(); | ||
|
||
const trackInvalidState = useCallback( | ||
(title: string) => | ||
track(AmpEvent.INVALID_STATE, { ...mandatoryProperties, title }), | ||
[mandatoryProperties] | ||
); | ||
|
||
return { | ||
trackInvalidState, | ||
}; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { track } from "@amplitude/analytics-browser"; | ||
import { useCallback } from "react"; | ||
|
||
import { AmpEvent } from "../types"; | ||
import type { Dict } from "lib/types"; | ||
|
||
import { useMandatoryProperties } from "./useMandatoryProperties"; | ||
|
||
export const useTrackExternal = () => { | ||
const mandatoryProperties = useMandatoryProperties(); | ||
|
||
const trackMintScan = useCallback( | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
(type: string, properties?: Dict<string, any>, section?: string) => { | ||
track(AmpEvent.MINTSCAN, { | ||
...mandatoryProperties, | ||
type, | ||
properties, | ||
section, | ||
}); | ||
}, | ||
[mandatoryProperties] | ||
); | ||
|
||
const trackWebsite = useCallback( | ||
(url: string, section?: string) => | ||
track(AmpEvent.WEBSITE, { | ||
...mandatoryProperties, | ||
url, | ||
section, | ||
}), | ||
[mandatoryProperties] | ||
); | ||
|
||
const trackSocial = useCallback( | ||
(url: string, section?: string) => | ||
track(AmpEvent.SOCIAL, { | ||
...mandatoryProperties, | ||
url, | ||
section, | ||
}), | ||
[mandatoryProperties] | ||
); | ||
|
||
const trackCelatone = useCallback( | ||
(url: string, section?: string) => | ||
track(AmpEvent.CELATONE, { | ||
...mandatoryProperties, | ||
url, | ||
section, | ||
}), | ||
[mandatoryProperties] | ||
); | ||
|
||
return { | ||
trackMintScan, | ||
trackWebsite, | ||
trackSocial, | ||
trackCelatone, | ||
}; | ||
}; |
Oops, something went wrong.
10cf59e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
celatone-frontend-staging – ./
dev.celat.one
celatone-frontend-staging-alleslabs.vercel.app
celatone-frontend-staging.vercel.app
celatone-frontend-staging-git-develop-alleslabs.vercel.app
10cf59e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
osmosis-celatone-frontend-staging – ./
osmosis-celatone-frontend-staging.vercel.app
staging.osmoscan.io
osmosis-celatone-frontend-staging-alleslabs.vercel.app
osmosis-celatone-frontend-staging-git-develop-alleslabs.vercel.app
osmosis-staging.celat.one
celatone-staging.osmosis.zone
10cf59e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
stargaze-celatone-frontend-staging – ./
stargaze-celatone-frontend-staging.vercel.app
stargaze-celatone-frontend-staging-alleslabs.vercel.app
stargaze-celatone-frontend-staging-git-develop-alleslabs.vercel.app