Skip to content

Commit

Permalink
fix: stats fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sattvikc committed Sep 15, 2023
1 parent 3cf7fdc commit 586df49
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [unreleased]

## [6.0.13] - 2023-09-15

- Fixes paid stats reporting for multitenancy

## [6.0.12] - 2023-09-04

- Fixes randomly occurring `serialization error for concurrent update` in `verifySession` API
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ compileTestJava { options.encoding = "UTF-8" }
// }
//}

version = "6.0.12"
version = "6.0.13"


repositories {
Expand Down
34 changes: 34 additions & 0 deletions ee/src/main/java/io/supertokens/ee/EEFeatureFlag.java
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,26 @@ public void syncFeatureFlagWithLicenseKey()
licenseKey = this.getLicenseKeyFromDb();
this.isLicenseKeyPresent = true;
} catch (NoLicenseKeyFoundException ex) {
try {
// Need to check if multitenancy is enabled on the base app and then report paid usage stats
EE_FEATURES[] features = FeatureFlag.getInstance(main, new AppIdentifier(null, null))
.getEnabledFeatures();
for (EE_FEATURES feature : features) {
if (feature.equals(EE_FEATURES.MULTI_TENANCY)) {
licenseKey = this.getRootLicenseKeyFromDb();
verifyLicenseKey(licenseKey); // also sends paid user stats for the app
try {
// small delay between license checks so that we have a delay for each license key check calls
Thread.sleep(5);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
break;
}
}
} catch (NoLicenseKeyFoundException ex2) {
// follow through below
}
this.isLicenseKeyPresent = false;
this.setEnabledEEFeaturesInDb(new EE_FEATURES[]{});
return;
Expand Down Expand Up @@ -489,4 +509,18 @@ public String getLicenseKeyFromDb()
Logging.debug(main, appIdentifier.getAsPublicTenantIdentifier(), "Fetched license key from db: " + info.value);
return info.value;
}

private String getRootLicenseKeyFromDb()
throws TenantOrAppNotFoundException, StorageQueryException, NoLicenseKeyFoundException {
Logging.debug(main, TenantIdentifier.BASE_TENANT, "Attempting to fetch license key from db");
KeyValueInfo info = StorageLayer.getStorage(TenantIdentifier.BASE_TENANT, main)
.getKeyValue(TenantIdentifier.BASE_TENANT, LICENSE_KEY_IN_DB);
if (info == null || info.value.equals(LICENSE_KEY_IN_DB_NOT_PRESENT_VALUE)) {
Logging.debug(main, appIdentifier.getAsPublicTenantIdentifier(), "No license key found in db");
throw new NoLicenseKeyFoundException();
}
Logging.debug(main, TenantIdentifier.BASE_TENANT, "Fetched license key from db: " + info.value);
return info.value;

}
}

0 comments on commit 586df49

Please sign in to comment.