-
Notifications
You must be signed in to change notification settings - Fork 687
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
2 changed files
with
32 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,30 @@ | ||
import Home from "./[...slug]"; | ||
import { AnalyticsBrowser } from "@segment/analytics-next"; | ||
import { Analytics as AnalyticsType } from "@segment/analytics-next/dist/types/core/analytics"; | ||
import React, { useEffect, useState } from "react"; | ||
import { useAnalytics } from "~/components/context/analytics"; | ||
import SlugPage from "./[...slug]"; | ||
|
||
function Home(): React.ReactElement { | ||
const [analytics, setAnalytics] = useState<AnalyticsType | undefined>( | ||
undefined | ||
); | ||
|
||
const { analytics: analyticsBrowser } = useAnalytics(); | ||
useEffect(() => { | ||
async function handleAnalyticsLoading(browser: AnalyticsBrowser) { | ||
try { | ||
const [response, ctx] = await browser; | ||
setAnalytics(response); | ||
// @ts-ignore | ||
window.analytics = response; | ||
window.analytics?.identify("'hello world' from segmentio analytics"); | ||
} catch (err) { | ||
console.error(err); | ||
setAnalytics(undefined); | ||
} | ||
} | ||
handleAnalyticsLoading(analyticsBrowser).catch(console.error); | ||
}, [analyticsBrowser]); | ||
return <SlugPage />; | ||
} | ||
export default Home; |
b8e5cd1
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:
chat-bilibili-video – ./
b.jimmylv.cn
chat-bilibili-video-jimmylv.vercel.app
chat-bilibili-video.vercel.app
chat-bilibili-video-git-main-jimmylv.vercel.app
m.bilibili.jimmylv.cn
www.bilibili.jimmylv.cn
bilibili.jimmylv.cn