Adding monetization fields to GW#3753
Adding monetization fields to GW#3753HiranyaKavishani merged 2 commits intowso2:monetization-featurefrom
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| requestContext.addMetadataToMap(MetadataConstants.APP_OWNER_KEY, | ||
| AnalyticsUtils.setDefaultIfNull(authContext.getSubscriber())); | ||
| requestContext.addMetadataToMap(MetadataConstants.BILLING_CUSTOMER_ID, | ||
| AnalyticsUtils.setDefaultIfNull(authContext.getBillingCustomerId())); | ||
| requestContext.addMetadataToMap(MetadataConstants.BILLING_SUBSCRIPTION_ID, | ||
| AnalyticsUtils.setDefaultIfNull(authContext.getBillingSubscriptionId())); | ||
|
|
There was a problem hiding this comment.
Log Improvement Suggestion No: 1
| requestContext.addMetadataToMap(MetadataConstants.APP_OWNER_KEY, | |
| AnalyticsUtils.setDefaultIfNull(authContext.getSubscriber())); | |
| requestContext.addMetadataToMap(MetadataConstants.BILLING_CUSTOMER_ID, | |
| AnalyticsUtils.setDefaultIfNull(authContext.getBillingCustomerId())); | |
| requestContext.addMetadataToMap(MetadataConstants.BILLING_SUBSCRIPTION_ID, | |
| AnalyticsUtils.setDefaultIfNull(authContext.getBillingSubscriptionId())); | |
| requestContext.addMetadataToMap(MetadataConstants.APP_OWNER_KEY, | |
| AnalyticsUtils.setDefaultIfNull(authContext.getSubscriber())); | |
| if (log.isDebugEnabled()) { | |
| log.debug("Adding billing metadata - customerId: " + | |
| (authContext.getBillingCustomerId() != null ? "[present]" : "[null]") + | |
| ", subscriptionId: " + | |
| (authContext.getBillingSubscriptionId() != null ? "[present]" : "[null]")); | |
| } |
| map.put(AnalyticsConstants.GATEWAY_URL, gwURL); | ||
| map.put(AnalyticsConstants.DEPLOYMENT_TYPE, deploymentType); | ||
| map.put(AnalyticsConstants.BILLING_CUSTOMER_ID, getValueAsString(fieldsMap, MetadataConstants.BILLING_CUSTOMER_ID)); | ||
| map.put(AnalyticsConstants.BILLING_SUBSCRIPTION_ID, getValueAsString(fieldsMap, MetadataConstants.BILLING_SUBSCRIPTION_ID)); |
There was a problem hiding this comment.
Log Improvement Suggestion No: 2
| map.put(AnalyticsConstants.GATEWAY_URL, gwURL); | |
| map.put(AnalyticsConstants.DEPLOYMENT_TYPE, deploymentType); | |
| map.put(AnalyticsConstants.BILLING_CUSTOMER_ID, getValueAsString(fieldsMap, MetadataConstants.BILLING_CUSTOMER_ID)); | |
| map.put(AnalyticsConstants.BILLING_SUBSCRIPTION_ID, getValueAsString(fieldsMap, MetadataConstants.BILLING_SUBSCRIPTION_ID)); | |
| map.put(AnalyticsConstants.GATEWAY_URL, gwURL); | |
| map.put(AnalyticsConstants.DEPLOYMENT_TYPE, deploymentType); | |
| map.put(AnalyticsConstants.BILLING_CUSTOMER_ID, getValueAsString(fieldsMap, MetadataConstants.BILLING_CUSTOMER_ID)); | |
| map.put(AnalyticsConstants.BILLING_SUBSCRIPTION_ID, getValueAsString(fieldsMap, MetadataConstants.BILLING_SUBSCRIPTION_ID)); | |
| log.debug("Added billing information to analytics properties."); |
| public Map<String, Object> getProperties() { | ||
| Map map = new HashMap(); | ||
| AuthenticationContext authContext = AnalyticsUtils.getAuthenticationContext(requestContext); |
There was a problem hiding this comment.
Log Improvement Suggestion No: 3
| public Map<String, Object> getProperties() { | |
| Map map = new HashMap(); | |
| AuthenticationContext authContext = AnalyticsUtils.getAuthenticationContext(requestContext); | |
| public Map<String, Object> getProperties() { | |
| Map map = new HashMap(); | |
| AuthenticationContext authContext = AnalyticsUtils.getAuthenticationContext(requestContext); | |
| log.debug("Retrieving properties for analytics with billing information"); |
| map.put(AnalyticsConstants.API_METHOD, requestContext.getRequestMethod()); | ||
| map.put(AnalyticsConstants.BILLING_CUSTOMER_ID, billingCustomerId); | ||
| map.put(AnalyticsConstants.BILLING_SUBSCRIPTION_ID, billingSubscriptionId); |
There was a problem hiding this comment.
Log Improvement Suggestion No: 4
| map.put(AnalyticsConstants.API_METHOD, requestContext.getRequestMethod()); | |
| map.put(AnalyticsConstants.BILLING_CUSTOMER_ID, billingCustomerId); | |
| map.put(AnalyticsConstants.BILLING_SUBSCRIPTION_ID, billingSubscriptionId); | |
| map.put(AnalyticsConstants.API_METHOD, requestContext.getRequestMethod()); | |
| map.put(AnalyticsConstants.BILLING_CUSTOMER_ID, billingCustomerId); | |
| map.put(AnalyticsConstants.BILLING_SUBSCRIPTION_ID, billingSubscriptionId); | |
| if (log.isDebugEnabled()) { | |
| log.debug("Added billing details to analytics properties - customerId: " + | |
| (billingCustomerId.isEmpty() ? "not-set" : "set") + | |
| ", subscriptionId: " + (billingSubscriptionId.isEmpty() ? "not-set" : "set")); | |
| } |
| infoDTO.setSubscriberTenantDomain(app.getTenantDomain()); | ||
| infoDTO.setBillingCustomerId(sub.getBillingCustomerId()); |
There was a problem hiding this comment.
Log Improvement Suggestion No: 5
| infoDTO.setSubscriberTenantDomain(app.getTenantDomain()); | |
| infoDTO.setBillingCustomerId(sub.getBillingCustomerId()); | |
| infoDTO.setSubscriberTenantDomain(app.getTenantDomain()); | |
| if (log.isDebugEnabled()) { | |
| log.debug("Setting billing information for subscription: customerId={}, subscriptionId={}", | |
| sub.getBillingCustomerId() != null ? "[REDACTED]" : "null", | |
| sub.getBillingSubscriptionId() != null ? "[REDACTED]" : "null"); | |
| } | |
| infoDTO.setBillingCustomerId(sub.getBillingCustomerId()); |
| newSubscription.setVersionRange(subscription.getVersionRange()); | ||
| newSubscription.setBillingCustomerId(subscription.getBillingCustomerId()); | ||
| newSubscription.setBillingSubscriptionId(subscription.getBillingSubscriptionId()); |
There was a problem hiding this comment.
Log Improvement Suggestion No: 6
| newSubscription.setVersionRange(subscription.getVersionRange()); | |
| newSubscription.setBillingCustomerId(subscription.getBillingCustomerId()); | |
| newSubscription.setBillingSubscriptionId(subscription.getBillingSubscriptionId()); | |
| newSubscription.setVersionRange(subscription.getVersionRange()); | |
| newSubscription.setBillingCustomerId(subscription.getBillingCustomerId()); | |
| newSubscription.setBillingSubscriptionId(subscription.getBillingSubscriptionId()); | |
| log.debug("Added billing information for subscription: {} with customerId: {} and subscriptionId: {}", | |
| newSubscription.getCacheKey(), subscription.getBillingCustomerId(), subscription.getBillingSubscriptionId()); |
There was a problem hiding this comment.
AI Agent Log Improvement Checklist
- The log-related comments and suggestions in this review were generated by an AI tool to assist with identifying potential improvements. Purpose of reviewing the code for log improvements is to improve the troubleshooting capabilities of our products.
- Please make sure to manually review and validate all suggestions before applying any changes. Not every code suggestion would make sense or add value to our purpose. Therefore, you have the freedom to decide which of the suggestions are helpful.
✅ Before merging this pull request:
- Review all AI-generated comments for accuracy and relevance.
- Complete and verify the table below. We need your feedback to measure the accuracy of these suggestions and the value they add. If you are rejecting a certain code suggestion, please mention the reason briefly in the suggestion for us to capture it.
ea5ac50 to
1458836
Compare
Adding missing file adding re generated file adding re generated file fixing formatting issue
1458836 to
28dfc27
Compare
c0d6f33
into
wso2:monetization-feature
Purpose
This PR allows to store the billing information sent by the Control Plane (CP) and include them in the analytics event during API invocation.
Related issue: https://github.com/wso2-enterprise/apim-saas/issues/1631
Issues
Fixes #
Automation tests
Tested environments
Not Tested
Maintainers: Check before merge