diff --git a/CHANGELOG.md b/CHANGELOG.md index a858ddb5a..ab165dc52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/build.gradle b/build.gradle index 9d329dff7..5ae32374e 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ compileTestJava { options.encoding = "UTF-8" } // } //} -version = "6.0.12" +version = "6.0.13" repositories { diff --git a/ee/src/main/java/io/supertokens/ee/EEFeatureFlag.java b/ee/src/main/java/io/supertokens/ee/EEFeatureFlag.java index 8efe42552..17c5a513b 100644 --- a/ee/src/main/java/io/supertokens/ee/EEFeatureFlag.java +++ b/ee/src/main/java/io/supertokens/ee/EEFeatureFlag.java @@ -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; @@ -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; + + } } \ No newline at end of file