<commit_before>@(form: Form[_])(implicit lang: Lang, request: Request[AnyContent], messages: play.api.i18n.Messages)

@import utils.helpers.CarersCrypto
@import utils.helpers.GAHelper._
@import app.ConfigProperties._

@gaTrack(key: String, errorMessage: String)  = @{
    if (getBooleanProperty("analytics.enabled")) {
        trackEvent(request.path, "Error", Some(s"${trimDate(key)} - $errorMessage"))
    } else {
        ""
    }
}

@gaTrackError(errorMessage: String)  = @{
    if (getBooleanProperty("analytics.enabled")) {
        trackEvent(request.path, "Error", Some(s"$errorMessage"))
    } else {
        ""
    }
}

@trimDate(key: String) = @{
    val result = ".*\\b(before \\d+|after \\d+|since \\d+|ers \\d+|cyn \\d+)\\b".r.findFirstMatchIn(key)
    if (result.isDefined) {
        key.substring(0, result.get.end(0) - 2) + "?"
    } else key
}

@if(form.hasErrors) {
    <div class="validation-summary">
        <h2 class="heading-small">@Html(messages("error.title"))</h2>
        <p>@Html(messages("error.label"))</p>
        <ol class="list-bullet">
        @for(error <- form.errors) {
            <li>
                <a href="#@CarersCrypto.encryptAES(form(error.key).id)">
                    @if(messages(error.key + ".error") != error.key + ".error") {
                        @Html(messages(error.message, error.args: _*))
                    } else {
                        @Html(messages(error.key, error.args: _*)) - @Html(messages(error.message, error.args: _*))
                    }<commit_msg>CADS-1285 : Error messages sent to google may contain dpname so we global replace dpname to @dpname in errors when sending to track ga.<commit_after>@(form: Form[_])(implicit claim: models.domain.Claim, lang: Lang, request: Request[AnyContent], messages: play.api.i18n.Messages)

@import utils.helpers.CarersCrypto
@import utils.helpers.GAHelper._
@import app.ConfigProperties._
@import models.domain.TheirPersonalDetails

@gaTrack(key: String, errorMessage: String)  = @{
    if (getBooleanProperty("analytics.enabled")) {
        trackEvent(request.path, "Error", Some(s"${stripDpname(trimDate(key))} - $errorMessage"))
    } else {
        ""
    }
}

@gaTrackError(errorMessage: String)  = @{
    if (getBooleanProperty("analytics.enabled")) {
        trackEvent(request.path, "Error", Some(s"$errorMessage"))
    } else {
        ""
    }
}

@theirPersonalDetails = @{claim.questionGroup[TheirPersonalDetails].getOrElse(TheirPersonalDetails())}
@dpname=@{theirPersonalDetails.firstName+" "+theirPersonalDetails.surname}

@stripDpname(key: String) = @{
    key.replaceAll(dpname, "@dpname")
}

@trimDate(key: String) = @{
    val result = ".*\\b(before \\d+|after \\d+|since \\d+|ers \\d+|cyn \\d+)\\b".r.findFirstMatchIn(key)
    if (result.isDefined) {
        key.substring(0, result.get.end(0) - 2) + "?"
    } else key
}

@if(form.hasErrors) {
    <div class="validation-summary">
        <h2 class="heading-small">@Html(messages("error.title"))</h2>
        <p>@Html(messages("error.label"))</p>
        <ol class="list-bullet">
        @for(error <- form.errors) {
            <li>
                <a href="#@CarersCrypto.encryptAES(form(error.key).id)">
                    @if(messages(error.key + ".error") != error.key + ".error") {
                        @Html(messages(error.message, error.args: _*))
                    } else {
                        @Html(messages(error.key, error.args: _*)) - @Html(messages(error.message, error.args: _*))
                    }
{'fraction_non_alphanumeric': 0.17819527469399374, 'fraction_numerical': 0.005123825789923143, 'mean_word_length': 2.8404371584699453, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 19, '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': '967489', 'n_tokens_mistral': 1178, 'n_tokens_neox': 1141, 'n_words': 182}