Include new/previous push token types as dimensions on "account created" counter
This commit is contained in:
parent
b32e67ff9e
commit
66783c9381
|
@ -292,6 +292,18 @@ public class AccountsManager extends RedisPubSubAdapter<String, String> implemen
|
||||||
|
|
||||||
String accountCreationType = maybeRecentlyDeletedAccountIdentifier.isPresent() ? "recently-deleted" : "new";
|
String accountCreationType = maybeRecentlyDeletedAccountIdentifier.isPresent() ? "recently-deleted" : "new";
|
||||||
|
|
||||||
|
final String pushTokenType;
|
||||||
|
|
||||||
|
if (primaryDeviceSpec.apnRegistrationId().isPresent()) {
|
||||||
|
pushTokenType = "apns";
|
||||||
|
} else if (primaryDeviceSpec.gcmRegistrationId().isPresent()) {
|
||||||
|
pushTokenType = "fcm";
|
||||||
|
} else {
|
||||||
|
pushTokenType = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
String previousPushTokenType = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
accounts.create(account, keysManager.buildWriteItemsForNewDevice(account.getIdentifier(IdentityType.ACI),
|
accounts.create(account, keysManager.buildWriteItemsForNewDevice(account.getIdentifier(IdentityType.ACI),
|
||||||
account.getIdentifier(IdentityType.PNI),
|
account.getIdentifier(IdentityType.PNI),
|
||||||
|
@ -303,6 +315,14 @@ public class AccountsManager extends RedisPubSubAdapter<String, String> implemen
|
||||||
} catch (final AccountAlreadyExistsException e) {
|
} catch (final AccountAlreadyExistsException e) {
|
||||||
accountCreationType = "re-registration";
|
accountCreationType = "re-registration";
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(e.getExistingAccount().getPrimaryDevice().getApnId())) {
|
||||||
|
previousPushTokenType = "apns";
|
||||||
|
} else if (StringUtils.isNotBlank(e.getExistingAccount().getPrimaryDevice().getGcmId())) {
|
||||||
|
previousPushTokenType = "fcm";
|
||||||
|
} else {
|
||||||
|
previousPushTokenType = "none";
|
||||||
|
}
|
||||||
|
|
||||||
final UUID aci = e.getExistingAccount().getIdentifier(IdentityType.ACI);
|
final UUID aci = e.getExistingAccount().getIdentifier(IdentityType.ACI);
|
||||||
final UUID pni = e.getExistingAccount().getIdentifier(IdentityType.PNI);
|
final UUID pni = e.getExistingAccount().getIdentifier(IdentityType.PNI);
|
||||||
|
|
||||||
|
@ -352,11 +372,17 @@ public class AccountsManager extends RedisPubSubAdapter<String, String> implemen
|
||||||
|
|
||||||
redisSet(account);
|
redisSet(account);
|
||||||
|
|
||||||
Metrics.counter(CREATE_COUNTER_NAME, Tags.of(UserAgentTagUtil.getPlatformTag(userAgent),
|
Tags tags = Tags.of(UserAgentTagUtil.getPlatformTag(userAgent),
|
||||||
Tag.of("type", accountCreationType),
|
Tag.of("type", accountCreationType),
|
||||||
Tag.of("hasPushToken", String.valueOf(
|
Tag.of("hasPushToken", String.valueOf(
|
||||||
primaryDeviceSpec.apnRegistrationId().isPresent() || primaryDeviceSpec.gcmRegistrationId().isPresent()))))
|
primaryDeviceSpec.apnRegistrationId().isPresent() || primaryDeviceSpec.gcmRegistrationId().isPresent())),
|
||||||
.increment();
|
Tag.of("pushTokenType", pushTokenType));
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(previousPushTokenType)) {
|
||||||
|
tags = tags.and(Tag.of("previousPushTokenType", previousPushTokenType));
|
||||||
|
}
|
||||||
|
|
||||||
|
Metrics.counter(CREATE_COUNTER_NAME, tags).increment();
|
||||||
|
|
||||||
accountAttributes.recoveryPassword().ifPresent(registrationRecoveryPassword ->
|
accountAttributes.recoveryPassword().ifPresent(registrationRecoveryPassword ->
|
||||||
registrationRecoveryPasswordsManager.storeForCurrentNumber(account.getNumber(), registrationRecoveryPassword));
|
registrationRecoveryPasswordsManager.storeForCurrentNumber(account.getNumber(), registrationRecoveryPassword));
|
||||||
|
|
|
@ -853,6 +853,7 @@ class AccountsManagerTest {
|
||||||
when(existingAccount.getNumber()).thenReturn(e164);
|
when(existingAccount.getNumber()).thenReturn(e164);
|
||||||
when(existingAccount.getPhoneNumberIdentifier()).thenReturn(requestedAccount.getIdentifier(IdentityType.PNI));
|
when(existingAccount.getPhoneNumberIdentifier()).thenReturn(requestedAccount.getIdentifier(IdentityType.PNI));
|
||||||
when(existingAccount.getIdentifier(IdentityType.PNI)).thenReturn(requestedAccount.getIdentifier(IdentityType.PNI));
|
when(existingAccount.getIdentifier(IdentityType.PNI)).thenReturn(requestedAccount.getIdentifier(IdentityType.PNI));
|
||||||
|
when(existingAccount.getPrimaryDevice()).thenReturn(mock(Device.class));
|
||||||
|
|
||||||
throw new AccountAlreadyExistsException(existingAccount);
|
throw new AccountAlreadyExistsException(existingAccount);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue