Skip to content

Commit

Permalink
fix: empty query param when calling external dependency toolbar.js (#…
Browse files Browse the repository at this point in the history
…1456)

Co-authored-by: Paul D'Ambra <[email protected]>
  • Loading branch information
lucasra1 and pauldambra authored Oct 28, 2024
1 parent 3cbd118 commit 5413bed
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/__tests__/utils/external-scripts-loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ describe('external-scripts-loader', () => {
assignableWindow.__PosthogExtensions__.loadExternalDependency(mockPostHog, 'toolbar', callback)
const scripts = document!.getElementsByTagName('script')
const new_script = scripts[0]
expect(new_script.src).toMatchInlineSnapshot(
`"https://us-assets.i.posthog.com/static/toolbar.js?v=1.0.0?&=1726067100000"`
)
expect(new_script.src).toBe('https://us-assets.i.posthog.com/static/toolbar.js?v=1.0.0&t=1726067100000')
})
})
})
2 changes: 1 addition & 1 deletion src/entrypoints/external-scripts-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ assignableWindow.__PosthogExtensions__.loadExternalDependency = (
// this ensures that we bust the cache periodically
const timestampToNearestFiveMinutes = Math.floor(Date.now() / fiveMinutesInMillis) * fiveMinutesInMillis

scriptUrlToLoad = `${scriptUrlToLoad}?&=${timestampToNearestFiveMinutes}`
scriptUrlToLoad = `${scriptUrlToLoad}&t=${timestampToNearestFiveMinutes}`
}
const url = posthog.requestRouter.endpointFor('assets', scriptUrlToLoad)

Expand Down

0 comments on commit 5413bed

Please sign in to comment.