I want to use okhttp interceptor (build inside retrofit class) to add logs to sentry where several tags can be added along with error, for example i add the user(name) who was handling the app(which is stored in sharedpreferences) with an example code like
eventBuilder.withTag(SentryConstants.TYPE_CUSTOMER_NAME, customer.getFirstname());
I have a static Retrofit class so that i can build it once and use for every api call, Since to access the user i need the applicationcontext for sharedpreferences i have 3 ways of adding logs
1) from the activity where i call the api pass context using getApplicationContext()
to retrofit class
- This makes me create a non static class as i have to pass context as parameter
2) before making the api(retrofit) call in the activity i can log it to sentry
- I get the advantage of static retrofit class but lose central logging system(i have to make sure i log everytime)
3) make a static class with context as mentioned here
- Not a recommended way, also in future i may have other options which fragment is calling the api
What would be the recommended approach