Additional registration metrics
This commit is contained in:
parent
c95a0c86b3
commit
30e834744d
|
@ -176,6 +176,8 @@ public class AccountController {
|
|||
smsSender.deliverVoxVerification(number, verificationCode.getVerificationCode(), locale);
|
||||
}
|
||||
|
||||
metricRegistry.meter(name(AccountController.class, "create", Util.getCountryCode(number))).mark();
|
||||
|
||||
return Response.ok().build();
|
||||
}
|
||||
|
||||
|
@ -231,6 +233,8 @@ public class AccountController {
|
|||
}
|
||||
|
||||
createAccount(number, password, userAgent, accountAttributes);
|
||||
|
||||
metricRegistry.meter(name(AccountController.class, "verify", Util.getCountryCode(number))).mark();
|
||||
} catch (InvalidAuthorizationHeaderException e) {
|
||||
logger.info("Bad Authorization Header", e);
|
||||
throw new WebApplicationException(Response.status(401).build());
|
||||
|
|
|
@ -24,9 +24,13 @@ import java.security.SecureRandom;
|
|||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class Util {
|
||||
|
||||
private static final Pattern COUNTRY_CODE_PATTERN = Pattern.compile("^\\+([17]|2[07]|3[0123469]|4[013456789]|5[12345678]|6[0123456]|8[1246]|9[0123458]|\\d{3})");
|
||||
|
||||
public static byte[] getContactToken(String number) {
|
||||
try {
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA1");
|
||||
|
@ -55,6 +59,13 @@ public class Util {
|
|||
number.matches("^\\+689[0-9]{6}"); // French Polynesia
|
||||
}
|
||||
|
||||
public static String getCountryCode(String number) {
|
||||
Matcher matcher = COUNTRY_CODE_PATTERN.matcher(number);
|
||||
|
||||
if (matcher.find()) return matcher.group(1);
|
||||
else return "0";
|
||||
}
|
||||
|
||||
public static String encodeFormParams(Map<String, String> params) {
|
||||
try {
|
||||
StringBuffer buffer = new StringBuffer();
|
||||
|
|
Loading…
Reference in New Issue