-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
453 additions
and
227 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
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
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 |
---|---|---|
@@ -1,11 +1,17 @@ | ||
import dotenv from 'dotenv'; | ||
import type IForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'; | ||
const webpack = require('webpack'); | ||
import webpack from 'webpack'; | ||
|
||
const { parsed } = dotenv.config(); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const ForkTsCheckerWebpackPlugin: typeof IForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); | ||
|
||
export const plugins = [ | ||
new ForkTsCheckerWebpackPlugin({ | ||
logger: 'webpack-infrastructure' | ||
}), | ||
new webpack.DefinePlugin({ | ||
REACT_APP_MEASUREMENT_ID: JSON.stringify(parsed!.REACT_APP_MEASUREMENT_ID) | ||
}) | ||
]; |
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 |
---|---|---|
@@ -1,22 +1,56 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { IStorage } from '@tonkeeper/core/dist/Storage'; | ||
import { AccountState } from '@tonkeeper/core/dist/entries/account'; | ||
import { WalletState } from '@tonkeeper/core/dist/entries/wallet'; | ||
import { throttle } from '@tonkeeper/core/dist/utils/common'; | ||
import { Analytics, AnalyticsGroup, toWalletType } from '@tonkeeper/uikit/dist/hooks/analytics'; | ||
import { Amplitude } from '@tonkeeper/uikit/dist/hooks/analytics/amplitude'; | ||
import { GoogleAnalytics4 } from '@tonkeeper/uikit/dist/hooks/analytics/google'; | ||
import { QueryKey } from '@tonkeeper/uikit/dist/libs/queryKey'; | ||
import { useEffect } from 'react'; | ||
import { extensionType } from './appSdk'; | ||
|
||
export const useAppWidth = () => { | ||
useEffect(() => { | ||
const appWidth = throttle(() => { | ||
const doc = document.documentElement; | ||
const app = ( | ||
document.getElementById('root') as HTMLDivElement | ||
).childNodes.item(0) as HTMLDivElement; | ||
useEffect(() => { | ||
const appWidth = throttle(() => { | ||
const doc = document.documentElement; | ||
const app = (document.getElementById('root') as HTMLDivElement).childNodes.item( | ||
0 | ||
) as HTMLDivElement; | ||
|
||
doc.style.setProperty('--app-width', `${app.clientWidth}px`); | ||
}, 50); | ||
window.addEventListener('resize', appWidth); | ||
doc.style.setProperty('--app-width', `${app.clientWidth}px`); | ||
}, 50); | ||
window.addEventListener('resize', appWidth); | ||
|
||
appWidth(); | ||
appWidth(); | ||
|
||
return () => { | ||
window.removeEventListener('resize', appWidth); | ||
}; | ||
}, []); | ||
return () => { | ||
window.removeEventListener('resize', appWidth); | ||
}; | ||
}, []); | ||
}; | ||
|
||
export const useAnalytics = ( | ||
storage: IStorage, | ||
account?: AccountState, | ||
wallet?: WalletState | null | ||
) => { | ||
return useQuery<Analytics>( | ||
[QueryKey.analytics], | ||
async () => { | ||
const tracker = new AnalyticsGroup( | ||
new Amplitude(process.env.REACT_APP_AMPLITUDE!), | ||
new GoogleAnalytics4( | ||
process.env.REACT_APP_MEASUREMENT_ID!, | ||
process.env.REACT_APP_GA_SECRET!, | ||
storage | ||
) | ||
); | ||
|
||
tracker.init(extensionType ?? 'Extension', toWalletType(wallet), account, wallet); | ||
|
||
return tracker; | ||
}, | ||
{ enabled: account != null } | ||
); | ||
}; |
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 |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
"author": "Nikita Kuznetsov <[email protected]>", | ||
"description": "Your telegram mini app wallet on The Open Network", | ||
"dependencies": { | ||
"@tanstack/react-query": "4.3.4", | ||
"@tonkeeper/core": "0.1.0", | ||
"@tonkeeper/locales": "0.1.0", | ||
"@tonkeeper/uikit": "0.1.0", | ||
|
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 |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
"author": "Nikita Kuznetsov <[email protected]>", | ||
"description": "Your web wallet on The Open Network", | ||
"dependencies": { | ||
"@amplitude/analytics-browser": "^2.1.0", | ||
"@tanstack/react-query": "4.3.4", | ||
"@tonkeeper/core": "0.1.0", | ||
"@tonkeeper/locales": "0.1.0", | ||
"@tonkeeper/uikit": "0.1.0", | ||
|
Oops, something went wrong.