docs: 🚑 call amplitude when user is logged in
Signed-off-by: jffarge <jf@dagger.io>
This commit is contained in:
parent
8753295169
commit
4f37745f6d
@ -22,17 +22,6 @@ function DocPageCustom({ location, userAccessStatus, setUserAccessStatus }) {
|
|||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
import('amplitude-js').then(amplitude => {
|
|
||||||
if (userAccessStatus?.login) {
|
|
||||||
var amplitudeInstance = amplitude.getInstance().init(process.env.REACT_APP_AMPLITUDE_ID, userAccessStatus?.login.toLowerCase(), {
|
|
||||||
apiEndpoint: `${window.location.hostname}/t`
|
|
||||||
});
|
|
||||||
amplitude.getInstance().logEvent('Docs Viewed', { "hostname": window.location.hostname, "path": location.pathname });
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}, [location.pathname, userAccessStatus])
|
|
||||||
|
|
||||||
if (isLoading) return <Spinner />
|
if (isLoading) return <Spinner />
|
||||||
|
|
||||||
if (userAccessStatus?.permission === false) {
|
if (userAccessStatus?.permission === false) {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* This source code is licensed under the MIT license found in the
|
* This source code is licensed under the MIT license found in the
|
||||||
* LICENSE file in the root directory of this source tree.
|
* LICENSE file in the root directory of this source tree.
|
||||||
*/
|
*/
|
||||||
import React, { useState, useCallback } from 'react';
|
import React, { useState, useCallback, useEffect } from 'react';
|
||||||
import { MDXProvider } from '@mdx-js/react';
|
import { MDXProvider } from '@mdx-js/react';
|
||||||
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
||||||
import renderRoutes from '@docusaurus/renderRoutes';
|
import renderRoutes from '@docusaurus/renderRoutes';
|
||||||
@ -163,6 +163,17 @@ function DocPage(props) {
|
|||||||
if (typeof window !== "undefined") return JSON.parse(window.localStorage.getItem('user'))
|
if (typeof window !== "undefined") return JSON.parse(window.localStorage.getItem('user'))
|
||||||
})())
|
})())
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
import('amplitude-js').then(amplitude => {
|
||||||
|
if (userAccessStatus?.login) {
|
||||||
|
var amplitudeInstance = amplitude.getInstance().init(process.env.REACT_APP_AMPLITUDE_ID, userAccessStatus?.login.toLowerCase(), {
|
||||||
|
apiEndpoint: `${window.location.hostname}/t`
|
||||||
|
});
|
||||||
|
amplitude.getInstance().logEvent('Docs Viewed', { "hostname": window.location.hostname, "path": location.pathname });
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}, [location.pathname, userAccessStatus])
|
||||||
|
|
||||||
if (process.env.OAUTH_ENABLE == 'true' && userAccessStatus?.permission !== true && userAgent !== 'Algolia DocSearch Crawler') {
|
if (process.env.OAUTH_ENABLE == 'true' && userAccessStatus?.permission !== true && userAgent !== 'Algolia DocSearch Crawler') {
|
||||||
return <DocPageCustom location={location} userAccessStatus={userAccessStatus} setUserAccessStatus={setUserAccessStatus} />
|
return <DocPageCustom location={location} userAccessStatus={userAccessStatus} setUserAccessStatus={setUserAccessStatus} />
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user