Skip to content

Commit

Permalink
removed analytics param; added disableAnalytics bool param
Browse files Browse the repository at this point in the history
  • Loading branch information
SamueleA committed Jan 31, 2024
1 parent f0fbf30 commit 533d276
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import{ EMAIL_CONNECTOR_LOCAL_STORAGE_KEY } from '@0xsequence/kit-connectors'
import { ExtendedWalletList } from './ExtendedWalletList'
import { Banner } from './Banner'

import { useAnalyticsContext } from '../../../contexts'
import { KitConfig } from '../../index'
import { defaultSignInOptions } from '../../../constants'
import { isEmailValid } from '../../../utils'
Expand Down
18 changes: 8 additions & 10 deletions packages/kit/src/components/KitProvider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export interface EthAuthSettings {
}

export interface KitConfig {
analytics?: SequenceClient["analytics"]
disableAnalytics?: boolean,
projectAccessKey: string,
defaultTheme?: Theme,
position?: ModalPosition,
Expand All @@ -64,7 +64,7 @@ export interface KitConfig {
useMock?: boolean
},
displayedAssets?: DisplayedAsset[],
ethAuth?: EthAuthSettings
ethAuth?: EthAuthSettings,
}

export type KitConnectProviderProps = {
Expand All @@ -81,7 +81,7 @@ export const KitProvider = (props: KitConnectProviderProps) => {
position = 'center',
displayedAssets: displayedAssetsSetting = [],
ethAuth = {} as EthAuthSettings,
analytics: analyticsParams,
disableAnalytics = false,
} = config

const defaultAppName = signIn.projectName || 'app'
Expand All @@ -96,11 +96,7 @@ export const KitProvider = (props: KitConnectProviderProps) => {
const [analytics, setAnalytics] = useState<SequenceClient["analytics"]>()
const { address, isConnected } = useAccount()

const setupAnalytics = (projectAccessKey: string, analyticsObj?: SequenceClient["analytics"]) => {
if (analyticsObj) {
setAnalytics(analyticsObj)
return
}
const setupAnalytics = (projectAccessKey: string) => {
const s = sequence.initWallet(projectAccessKey)
const sequenceAnalytics = s.client.analytics
setAnalytics(sequenceAnalytics)
Expand All @@ -121,9 +117,11 @@ export const KitProvider = (props: KitConnectProviderProps) => {
}

useEffect(() => {
setupAnalytics(projectAccessKey, analyticsParams)
if (!disableAnalytics) {
setupAnalytics(projectAccessKey)
}
localStorage.setItem(LocalStorageKey.ProjectAccessKey, projectAccessKey)
}, [projectAccessKey, analyticsParams])
}, [projectAccessKey])

useEffect(() => {
if (theme !== defaultTheme) {
Expand Down

0 comments on commit 533d276

Please sign in to comment.