-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(widget): google analytics dimension for injected widget app id #3272
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,19 +5,19 @@ import { DEFAULT_APP_CODE, SAFE_APP_CODE } from '@cowprotocol/common-const' | |
import { isInjectedWidget } from '@cowprotocol/common-utils' | ||
import { useIsSafeApp } from '@cowprotocol/wallet' | ||
|
||
import { useInjectedWidgetMetaData } from 'modules/injectedWidget' | ||
|
||
import { addAppDataToUploadQueueAtom, appDataHooksAtom, appDataInfoAtom } from './state/atoms' | ||
import { AppDataInfo } from './types' | ||
|
||
import { injectedWidgetMetaDataAtom } from '../injectedWidget/state/injectedWidgetMetaDataAtom' | ||
|
||
const APP_CODE = process.env.REACT_APP_APP_CODE | ||
|
||
export function useAppData(): AppDataInfo | null { | ||
return useAtomValue(appDataInfoAtom) | ||
} | ||
|
||
export function useAppCode(): string | null { | ||
const injectedWidgetMetaData = useAtomValue(injectedWidgetMetaDataAtom) | ||
const injectedWidgetMetaData = useInjectedWidgetMetaData() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nitpick not comming from this PR, but in principle not sure we want to make all modules aware there's an injected mode and instead is the client of this module informing one time whats the appKey This way, in injected mode, it will inject the appData, otherwise it will get it from the env. Otherwise, we leak a lot of CoW Swap logic here. Imagine we want to promote this module to a lib and use for other projects, then the injected mode would be bothering us. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I also feel it's not the best solution. However, I don't see any better ways |
||
const isSafeApp = useIsSafeApp() | ||
|
||
return useMemo(() => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { useAtomValue } from 'jotai' | ||
|
||
import { InjectedWidgetMetaData, injectedWidgetMetaDataAtom } from '../state/injectedWidgetMetaDataAtom' | ||
|
||
export function useInjectedWidgetMetaData(): InjectedWidgetMetaData | null { | ||
return useAtomValue(injectedWidgetMetaDataAtom) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './updaters/InjectedWidgetUpdater' | ||
export * from './hooks/useInjectedWidgetParams' | ||
export { InjectedWidgetUpdater } from './updaters/InjectedWidgetUpdater' | ||
export { useInjectedWidgetParams } from './hooks/useInjectedWidgetParams' | ||
export { useInjectedWidgetMetaData } from './hooks/useInjectedWidgetMetaData' |
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.
Do we need to add it also in Google Analytics side?
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.
I thought it was your idea at the last meeting 😄