Skip to content

Allow a url path name for lazyLoadIntegration / cdnBaseUrl #17042

@TheDelta

Description

@TheDelta

Problem Statement

I implemented latest sentry-js into an angular application and noticed some issues (going to open a discussion about this soon).

During that integration, I wanted to use lazyLoadIntegration with cdnBaseUrl to my self hosted sentry instance.
I created an issue on the on premise repo getsentry/self-hosted#3777 and it might be helpful for some context and my motivation.

The key issue atm is, that the self hosted instance serves the client files under a sub path, like https://sentry.example.test/js-sdk/.
I'm totally aware that this is more likely a on-premise issue and could also be fixed by the user with some custom proxy url, but I wanted to highlight this issue anyways so that a dev could have a look at this.

cdnBaseUrl (which is totally correct btw!) only works with a base url:

const baseURL = client?.getOptions()?.cdnBaseUrl || 'https://browser.sentry-cdn.com';

There is currently no way to use a path, so /js-sdk/ is omitted in the end and it can't fetch the bundle from the on-premise instance.
This is all in theory, because officially the on-premise instance doesn't serve any sub bundles which the lazyLoadIntegration would actually load (thats an issue on the on-premise instance atm).

Long story short: Is it possible to get a feature where the user can define a baseUrl with path or is this beyond what the SDK should support.

Solution Brainstorm

Rewrite the code to use the cdnBaseUrl as URL directly and append the bundle path, or o allow some other variable to define the sub path, like cdnPathName.

cdnBaseUrl: 'https://sentry.example.test',
cdnPathName: '/js-sdk/'
const baseUrlPath = new URL(cdnPathName ?? '', cdnBaseUrl);`
return `${baseUrlPath}/${SDK_VERSION}/${bundle}.min.js`;

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions