Browse Source

Data streams

wfansh 4 months ago
parent
commit
ab01b1a334

+ 1 - 1
src/main/java/com/wechi/adweb/bridge/google/analytics/controller/GAController.java

@@ -73,7 +73,7 @@ public class GAController extends BaseController {
         List<GAPropertyDTO> gaProperties =
                 gaAdminService.listProperties(
                         // Converts to resource name if the account ID is provided by mistake.
-                        GAAccountDTO.toResourceName(accountResourceName));
+                        GAAccountDTO.toResourceName(accountResourceName), true);
         log.info("****** listProperties() ****** duration = {} seconds", getElapsedSeconds(start));
         return OpenAPIResponse.<List<GAPropertyDTO>>builder()
                 .status(APIStatus.SUCCESS)

+ 6 - 2
src/main/java/com/wechi/adweb/bridge/google/analytics/service/GAAdminService.java

@@ -79,7 +79,8 @@ public class GAAdminService {
         }
     }
 
-    public List<GAPropertyDTO> listProperties(String accountResourceName) throws DataException {
+    public List<GAPropertyDTO> listProperties(String accountResourceName, boolean withDataStreams)
+            throws DataException {
         try (AnalyticsAdminServiceClient analyticsAdminServiceClient =
                 AnalyticsAdminServiceClient.create(adminServiceSettings)) {
             List<GAPropertyDTO> gaProperties = Lists.newArrayList();
@@ -108,7 +109,10 @@ public class GAAdminService {
                                 .createTime(property.getCreateTime().getSeconds())
                                 .updateTime(property.getUpdateTime().getSeconds())
                                 // Omits data streams for list request to reduce payload size.
-                                .dataStreams(this.listDataStreams(property.getName()))
+                                .dataStreams(
+                                        withDataStreams
+                                                ? listDataStreams(property.getName())
+                                                : Collections.EMPTY_LIST)
                                 .build();
 
                 // Adds into the list;