-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: expose js client from nextjs sdk and allow debugger to use next…
…js (#942)
- Loading branch information
Showing
8 changed files
with
90 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { useEffect } from 'react' | ||
import { | ||
initializeDevCycleDebugger, | ||
DebuggerIframeOptions, | ||
} from './src/initializeDevCycleDebugger.js' | ||
import { useDevCycleClient } from '@devcycle/nextjs-sdk' | ||
|
||
export const DevCycleDebugger = (options: DebuggerIframeOptions): null => { | ||
const client = useDevCycleClient() | ||
|
||
useEffect(() => { | ||
const cleanupPromise = initializeDevCycleDebugger(client, options) | ||
return () => { | ||
cleanupPromise.then((cleanup) => cleanup()) | ||
} | ||
}, [client]) | ||
|
||
return 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
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,18 @@ | ||
// Use this file to export React client code (e.g. those with 'use client' directive) | ||
// or other non-server utilities | ||
import { DevCycleClient as JSClient } from '@devcycle/js-client-sdk' | ||
|
||
export { useVariable, useVariableValue } from './src/client/useVariableValue' | ||
export type * from './src/common/types' | ||
export { useUserIdentity } from './src/client/useUserIdentity' | ||
export { useTrack } from './src/client/useTrack' | ||
export { useAllVariables } from './src/client/useAllVariables' | ||
export { useAllFeatures } from './src/client/useAllFeatures' | ||
export { renderIfEnabled } from './src/client/renderIfEnabled' | ||
export { useDevCycleClient } from './src/client/useDevCycleClient' | ||
export { DevCycleClientsideProvider } from './src/client/DevCycleClientsideProvider' | ||
export { DVCVariable, DVCVariableValue } from '@devcycle/react-client-sdk' | ||
|
||
type DevCycleClient = Omit<JSClient, 'identifyUser' | 'resetUser'> | ||
|
||
export type { DevCycleClient } |
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { useDevCycleClient as internalUseClient } from './internal/useDevCycleClient' | ||
import { DevCycleClient } from '@devcycle/js-client-sdk' | ||
|
||
export const useDevCycleClient = (): DevCycleClient => { | ||
return internalUseClient() | ||
} |
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