Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Add option to override default apiUrl and authHeader #41

Open
capybarahero opened this issue Oct 1, 2024 · 5 comments
Open
Assignees

Comments

@capybarahero
Copy link

capybarahero commented Oct 1, 2024

🚀 Feature request

Is your feature request related to a problem?

Hi all, thanks for maintaining this lib!

We use today self-hosted Glitchtip, and we are considering migrating from @sentry/browser to micro-sentry on the frontend. However, we noticed that you follow a very specific apiUrl structure and have a pre-defined authHeader, so that custom DSNs won't match this pattern and will fail.

Describe the solution you'd like

Add option to override the default apiUrl and authHeader.

This would also be beneficial for people using tunnel.

Thanks!

Additional context

Here is the snippet I refer to:

  constructor(options: SentryClientOptions) {
    if (options && options.dsn) {
      const searched = DSN_REGEXP.exec(options.dsn);
      const dsn = searched ? searched.slice(1) : [];
      const pathWithProjectId = dsn[5].split('/');
      const path = pathWithProjectId.slice(0, -1).join('/');

      this.apiUrl =
        dsn[0] +
        '://' +
        dsn[3] +
        (dsn[4] ? ':' + dsn[4] : '') +
        (path ? '/' + path : '') +
        '/api/' +
        pathWithProjectId.pop() +
        '/store/';

      this.authHeader =
        'Sentry sentry_version=7,sentry_key=' +
        dsn[1] +
        (dsn[2] ? ',sentry_secret=' + dsn[2] : '');
    }

Source: https://github.com/taiga-family/micro-sentry/blob/main/libs/core/src/lib/service/micro-sentry-client.ts

@sevaru
Copy link
Contributor

sevaru commented Oct 8, 2024

Hi!

Would extending and overriding the MicroSentryClient class be a feasible solution for you? Additionally, could you provide details on the specific DSN format used by Glitchtip and any custom headers you need? Understanding the format and headers will help us identify any compatibility issues and see how micro-sentry might better accommodate your setup.

@sevaru sevaru assigned sevaru and unassigned MarsiBarsi Oct 8, 2024
@capybarahero
Copy link
Author

Hi sevaru,

Overriding the MicroSentryClient should indeed work.

The Glitchtip DNS looks like this: https://[email protected]/12345. The long string refers to the username, app.glitchtip.com is the host (if you're using their official solution), and 12345 is the project id.

The username is passed as sentry_key when calling the sentry-based glitchtip API.

Thanks again!

@sevaru
Copy link
Contributor

sevaru commented Oct 10, 2024

As far as I understand, using this DSN https://[email protected]/12345 should result in https://app.glitchtip.com/api/12345/store/ and include sentry_key=v7mp44vih7hbapmexkz3fdvpxle3m3ii in the header. This setup seems compatible with the Sentry API and likely with Glitchtip as well.

Aside from the tunnel option, could you clarify what specific issues you’re encountering with the default DSN parsing? Understanding where it diverges from this expected behavior could help pinpoint any necessary adjustments.

@capybarahero
Copy link
Author

Hi Sevaru,

I took a look and it seems that the "store endpoint" is deprecated. Sentry now uses "Envelopes", as per here.

I haven't found any mentions of the store endpoint on the Glitchtip documentation or codebase, so I assume it works only with "Envelopes". The resulting URL looks like this: https://${host}/api/${projectId}/envelope/?sentry_key=${username}

@sevaru
Copy link
Contributor

sevaru commented Oct 21, 2024

  1. Store API: Yeah, store api seams to be deprecated but is indeed still functional. Here is an example of how it works in practice: microsentry + glitchtip.
  2. Envelope API: As for the Envelope API, you’re absolutely right—this is something we currently do not support, and we will need to develop a feature to enable it. I’ll make sure we add this feature to our backlog. [FEATURE] Support envelopes sentry endpoint #56

Thanks again for your feedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants