<commit_before>package in.ac.amu.zhcet.configuration;

import in.ac.amu.zhcet.data.model.user.UserAuth;
import in.ac.amu.zhcet.service.UserService;
import io.sentry.Sentry;
import io.sentry.event.helper.EventBuilderHelper;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class SentryConfiguration {

    @Data
    private static class User {
        private String userId;
        private String name;
        private String departmentName;
        private String email;
        private String[] roles;
        private String type;
    }

    @Autowired
    public SentryConfiguration(UserService userService, ModelMapper modelMapper) {
        EventBuilderHelper myEventBuilderHelper = eventBuilder -> {
            UserAuth loggedInUser = userService.getLoggedInUser();

            if (loggedInUser != null) {
                eventBuilder.withExtra("user", modelMapper.map(loggedInUser, User.class));
            } else {
                eventBuilder.withExtra("user", "UNAUTHORIZED");
            }
        };

        Sentry.getStoredClient().addBuilderHelper(myEventBuilderHelper);
    }

}<commit_msg>fix: Add forward address resolver to sentry<commit_after>package in.ac.amu.zhcet.configuration;

import in.ac.amu.zhcet.data.model.user.UserAuth;
import in.ac.amu.zhcet.service.UserService;
import io.sentry.Sentry;
import io.sentry.SentryClient;
import io.sentry.event.helper.ContextBuilderHelper;
import io.sentry.event.helper.EventBuilderHelper;
import io.sentry.event.helper.ForwardedAddressResolver;
import io.sentry.event.helper.HttpEventBuilderHelper;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class SentryConfiguration {

    @Data
    private static class User {
        private String userId;
        private String name;
        private String departmentName;
        private String email;
        private String[] roles;
        private String type;
    }

    @Autowired
    public SentryConfiguration(UserService userService, ModelMapper modelMapper) {
        EventBuilderHelper myEventBuilderHelper = eventBuilder -> {
            UserAuth loggedInUser = userService.getLoggedInUser();

            if (loggedInUser != null) {
                eventBuilder.withExtra("user", modelMapper.map(loggedInUser, User.class));
            } else {
                eventBuilder.withExtra("user", "UNAUTHORIZED");
            }
        };

        SentryClient sentryClient = Sentry.getStoredClient();
        sentryClient.addBuilderHelper(myEventBuilderHelper);
        sentryClient.addBuilderHelper(new HttpEventBuilderHelper(new ForwardedAddressResolver()));
        sentryClient.addBuilderHelper(new ContextBuilderHelper(sentryClient));
    }

}
{'fraction_non_alphanumeric': 0.08886686488272216, 'fraction_numerical': 0.0019821605550049554, 'mean_word_length': 3.4011627906976742, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7321786', 'n_tokens_mistral': 861, 'n_tokens_neox': 856, 'n_words': 162}