diff --git a/packages/browser/src/browser/__tests__/integrations.integration.test.ts b/packages/browser/src/browser/__tests__/integrations.integration.test.ts index 258d5a85d..e98dbe016 100644 --- a/packages/browser/src/browser/__tests__/integrations.integration.test.ts +++ b/packages/browser/src/browser/__tests__/integrations.integration.test.ts @@ -19,7 +19,6 @@ const mockFetchCdnSettings = (cdnSettings: any = {}) => { .mockImplementation(createMockFetchImplementation(cdnSettings)) } -// TODO: delete this when remove these methods completely. const ogConsoleWarn = console.warn jest.spyOn(console, 'warn').mockImplementation((msg) => { if (msg.includes('deprecate')) { diff --git a/packages/browser/src/core/page/get-page-context.ts b/packages/browser/src/core/page/get-page-context.ts index 24a38eea1..29214572d 100644 --- a/packages/browser/src/core/page/get-page-context.ts +++ b/packages/browser/src/core/page/get-page-context.ts @@ -79,22 +79,24 @@ const formatCanonicalPath = (canonicalUrl: string) => { return a.pathname[0] === '/' ? a.pathname : '/' + a.pathname } -export const createPageContext = ( - buffered: BufferedPageContext -): PageContext => { - const path = buffered.c ? formatCanonicalPath(buffered.c) : buffered.p - const url = buffered.c - ? createCanonicalURL(buffered.c, buffered.s) - : removeHash(buffered.u) - - // Why are we removing the anchor here but not the canonical URL? Also, why don't we include hash or any anchor arguments. (???) - // There's no way for a customer to get access to hash arguments without overriding url =S +export const createPageContext = ({ + c: canonicalUrl, + p: pathname, + s: search, + u: url, + r: referrer, + t: title, +}: BufferedPageContext): PageContext => { + const newPath = canonicalUrl ? formatCanonicalPath(canonicalUrl) : pathname + const newUrl = canonicalUrl + ? createCanonicalURL(canonicalUrl, search) + : removeHash(url) return { - path, - referrer: buffered.r, - search: buffered.s, - title: buffered.t, - url, + path: newPath, + referrer, + search, + title, + url: newUrl, } }