Skip to content

Commit

Permalink
feat: Add RB2B tracking script
Browse files Browse the repository at this point in the history
The RB2B tracking script is added in order to enable RB2B tracking functionality. This commit addresses the issue #681.
  • Loading branch information
hellovai committed Jun 14, 2024
1 parent 4cf806b commit 4dba3ba
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions typescript/fiddle-frontend/app/_components/PosthogProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,14 @@ if (typeof window !== 'undefined' && process.env.NODE_ENV === 'production') {
})
}

const RB2BId = process.env.NEXT_PUBLIC_RB2B_ID ?? ''

export function PHProvider({ children }: { children: React.ReactNode }) {
return <PostHogProvider client={posthog}>{children}</PostHogProvider>
}

export function RB2BElement() {
useEffect(() => {
// Directly adding your script content here
function f() {
function foo() {
// @ts-ignore
var reb2b = (window.reb2b = window.reb2b || [])
if (reb2b.invoked) return
Expand All @@ -44,15 +42,13 @@ export function RB2BElement() {
script.async = true
script.src = 'https://s3-us-west-2.amazonaws.com/b2bjsstore/b/' + key + '/reb2b.js.gz'
var first = document.getElementsByTagName('script')[0]
first.parentNode?.insertBefore(script, first)
first.parentNode!.insertBefore(script, first)
}
reb2b.SNIPPET_VERSION = '1.0.1'
if (RB2BId) {
reb2b.load(RB2BId)
}
reb2b.load('1VN080H5R86J')
}

f()
foo()
}, [])

return <></>
Expand Down

0 comments on commit 4dba3ba

Please sign in to comment.