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

Draft: Upgrading from raven-js to sentry/browser #2417

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

BenzeneAlcohol
Copy link
Contributor

@BenzeneAlcohol BenzeneAlcohol commented Jul 19, 2024

Which problem is this PR solving?

Resolves #2412

Description of the changes

I've migrated a part of the things, but I want to know whether the approach is correct or it needs to be different. Hence a draft MR. The names of files, variables etc haven't been changed, this is just in progress.

How was this change tested?

Test cases for now, the old ones with the same payload.

Checklist

Signed-off-by: Muthukumar <[email protected]>
@BenzeneAlcohol BenzeneAlcohol requested a review from a team as a code owner July 19, 2024 10:32
@BenzeneAlcohol BenzeneAlcohol requested review from pavolloffay and removed request for a team July 19, 2024 10:32
@BenzeneAlcohol BenzeneAlcohol marked this pull request as draft July 19, 2024 10:32
package.json Outdated Show resolved Hide resolved
@BenzeneAlcohol
Copy link
Contributor Author

If you see packages/jaeger-ui/src/utils/tracking/ga.tsx, autoBreadcrumbs there are configured to accept location as well to be recorded for eveyr event. However , from sentry's docs for breadcrumbs, it seems like the location param is absent. What do we do we here?

https://docs.sentry.io/platforms/javascript/configuration/integrations/breadcrumbs/

Migration in progress

Signed-off-by: Muthukumar <[email protected]>
Copy link

codecov bot commented Jul 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.61%. Comparing base (322fd98) to head (7b1ad96).
Report is 16 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2417      +/-   ##
==========================================
+ Coverage   96.60%   96.61%   +0.01%     
==========================================
  Files         254      254              
  Lines        7662     7688      +26     
  Branches     1996     1993       -3     
==========================================
+ Hits         7402     7428      +26     
  Misses        260      260              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: Muthukumar <[email protected]>
@BenzeneAlcohol
Copy link
Contributor Author

The PR is almost over, I need to change file names and function names. For now the existing unit tests pass, but any other ways to test this properly? @yurishkuro

@BenzeneAlcohol BenzeneAlcohol marked this pull request as ready for review July 23, 2024 10:43
@yurishkuro
Copy link
Member

You can set up your own property in GA and test that Jaeger UI generates the desired events, as well as compare them with events generated by the UI before your change. You will probably need to induce some exceptions, e.g. by using Upload function in Search tab and uploading a malformed text.

@BenzeneAlcohol
Copy link
Contributor Author

You can set up your own property in GA and test that Jaeger UI generates the desired events, as well as compare them with events generated by the UI before your change. You will probably need to induce some exceptions, e.g. by using Upload function in Search tab and uploading a malformed text.

Alright, I'll try that. Meanwhile, can you review the code and see if there are any obvious mistakes?

@yurishkuro yurishkuro added the changelog:bugfix-or-minor-feature 🐞 Bug fixes, Minor Improvements label Jul 23, 2024
packages/jaeger-ui/package.json Show resolved Hide resolved
packages/jaeger-ui/src/types/tracking.tsx Outdated Show resolved Hide resolved
@@ -169,9 +160,7 @@ function convNav(to: string) {
// "dp" - fetch the dependency data
// And, "NNN" is a non-200 status code.
type TCrumbData = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you explain what "breadcrumb" means in this context? I saw a link you posted to sentry docs, but they didn't explain it either, just started talking details.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will explain this tomorrow, late night here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

breadcrumb in this context is basically any event that is captured. Everything is referred to as a breadcrumb. It basically lets us capture everything leading up to that event/error.

packages/jaeger-ui/src/utils/tracking/ga.tsx Outdated Show resolved Hide resolved
packages/jaeger-ui/src/utils/tracking/ga.tsx Show resolved Hide resolved
Signed-off-by: Muthukumar <[email protected]>
README has to be updated, removing
the old raven-sdk information.

Signed-off-by: Muthukumar <[email protected]>
Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will you be able to test against Google Analytics?

@@ -22,7 +22,7 @@ export interface IWebAnalyticsFunc {

export default interface IWebAnalytics {
init: () => void;
context: boolean | RavenStatic | null;
context: boolean | typeof BrowserClient | null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field is rather confusing to me. Is it a readable property for the user of IWebAnalytics interface? Or is it an input to the implementation of the interface? If it's the latter, why does it need to be exposed in the interface?

Not specifically related to the PR, but I am trying to understand the structure of the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So here, IWebAnalytics is an interface of the object that is returned by the function IWebAnalyticsFunc that takes in 3 variables as the input.

This is used in ga.tsx as function GA. There, if you notice, context is assigned to BrowserClient, and not an instance of it. That is why I have kept context as either a boolean, null, or a type of BrowserClient object, and not an instance of it.

Even I am a little confused as to the places it being used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is set depending on whether error tracking is enabled on not. It needs to be there on the interface because depending on the config, this needs to be set.

It is used in L56-57 in packages/jaeger-ui/src/utils/tracking/index.tsx

packages/jaeger-ui/src/utils/tracking/fixtures.js Outdated Show resolved Hide resolved
@@ -247,20 +236,14 @@ function compressCssSelector(selector: string) {
// The chronological ordering of the breadcrumbs is older events precede newer
// events. This ordering was kept because it's easier to see which page events
// occurred on.
interface ICrumb {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems like we used an abstraction over Raven type (even though abstraction itself is a bit coupled, but an abstraction nonetheless, i.e. could be implemented by something other than Raven). What's the reason to remove it instead of just adapting? Adapting seems to only require optionality on the fields, which would minimize the changes throughout this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does make sense. But why I thought of using the Breadcrumb interface from Sentry was because this function convSentryToGa is called from trackSentryError in L192, packages/jaeger-ui/src/utils/tracking/ga.tsx.

So there, the transport options come from the Event interface in Sentry, which has a breadcrumb field which uses the Breadcrumb interface. I just thought of keeping it uniform everywhere and since that field already uses the same interface, used it here as well.

@BenzeneAlcohol
Copy link
Contributor Author

will you be able to test against Google Analytics?

Could be better if someone who already has an idea about GA does it. Can you do it? Else I can go through the docs and setup, but will need one or two days.

Signed-off-by: Muthukumar <[email protected]>
@yurishkuro
Copy link
Member

Could be better if someone who already has an idea about GA does it. Can you do it? Else I can go through the docs and setup, but will need one or two days.

I don't have any of that set up either. At minimum you can enable debug mode and see what the tracking logs into console and compare it with the before version.

@BenzeneAlcohol
Copy link
Contributor Author

i'll do.

@BenzeneAlcohol
Copy link
Contributor Author

Hey, I got caught up with a bit of work stuff. I'll test this PR tomorrow and day after, and hopefully by this weekend we can get this done. @yurishkuro

@BenzeneAlcohol
Copy link
Contributor Author

I tried, but couldn't really find a way to troubleshoot using just the console.log statements. I went through a bunch of tests that use this config in a lot of places, so since they have passed, I am 90% sure this works. It is just the other 10% I'm a little concerned about.

@yurishkuro
Copy link
Member

Is it possible to test with a real GA account / property? There's also a Chrome extension that claims to help with testing.

@BenzeneAlcohol
Copy link
Contributor Author

Is it possible to test with a real GA account / property? There's also a Chrome extension that claims to help with testing.

Will checkt that out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog:bugfix-or-minor-feature 🐞 Bug fixes, Minor Improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Help upgrading from raven-js
3 participants