mirror of
https://mirror.skon.top/github.com/langgenius/dify.git
synced 2026-04-20 15:20:15 +08:00
- Added AmplitudeProvider to the main layout for analytics tracking. - Removed redundant AmplitudeProvider instances from common layouts. - Introduced a new init module to handle Amplitude initialization and session replay plugin setup. - Updated tests to ensure proper initialization behavior and prevent multiple initializations.
25 lines
617 B
TypeScript
25 lines
617 B
TypeScript
'use client'
|
|
|
|
import type { FC } from 'react'
|
|
import type { AmplitudeInitializationOptions } from './init'
|
|
import * as React from 'react'
|
|
import { useEffect } from 'react'
|
|
import { ensureAmplitudeInitialized } from './init'
|
|
|
|
export type IAmplitudeProps = AmplitudeInitializationOptions
|
|
|
|
const AmplitudeProvider: FC<IAmplitudeProps> = ({
|
|
sessionReplaySampleRate = 0.5,
|
|
}) => {
|
|
useEffect(() => {
|
|
ensureAmplitudeInitialized({
|
|
sessionReplaySampleRate,
|
|
})
|
|
}, [sessionReplaySampleRate])
|
|
|
|
// This is a client component that renders nothing
|
|
return null
|
|
}
|
|
|
|
export default React.memo(AmplitudeProvider)
|