Browse Source

API quota

wfansh 2 months ago
parent
commit
0d982d70b1

+ 4 - 0
.gitignore

@@ -1,9 +1,13 @@
+### Gradle ###
 .gradle
 build/
 !gradle/wrapper/gradle-wrapper.jar
 !**/src/main/**/build/
 !**/src/test/**/build/
 
+### Logs ###
+logs/
+
 ### STS ###
 .apt_generated
 .classpath

+ 1 - 1
src/main/java/com/wechi/adweb/bridge/google/gtm/controller/GTMController.java

@@ -121,7 +121,7 @@ public class GTMController extends BaseController {
                         createContainerRequest.getAccountResourceName(),
                         createContainerRequest.getDisplayName());
 
-        // 3. Initializes the container in ASYNC mode.
+        // 3. Initializes the container.
         gtmService.initContainerAccess(
                 createContainerRequest.getAccountResourceName(), gtmContainer.getId());
         gtmService.initContainerSetups(

+ 12 - 5
src/main/java/com/wechi/adweb/bridge/google/gtm/service/GTMService.java

@@ -21,7 +21,6 @@ import org.apache.commons.lang3.BooleanUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
 import java.io.IOException;
@@ -273,8 +272,12 @@ public class GTMService {
         }
     }
 
-    /** Executes in async mode after the container is created to improve API efficiency. */
-    @Async
+    /**
+     * Turns off async mode to prevent problems with API quota limitations.
+     *
+     * <p>See https://developers.google.com/tag-platform/tag-manager/api/v2/limits-quotas
+     */
+    // @Async
     public void initContainerAccess(String accountResourceName, String containerId)
             throws DataException {
         try {
@@ -314,8 +317,12 @@ public class GTMService {
         }
     }
 
-    /** Executes in async mode after the container is created to improve API efficiency. */
-    @Async
+    /**
+     * Turns off async mode to prevent problems with API quota limitations.
+     *
+     * <p>See https://developers.google.com/tag-platform/tag-manager/api/v2/limits-quotas
+     */
+    // @Async
     public void initContainerSetups(
             String containerResourceName, String gaMeasurementId, String matomoSiteId)
             throws DataException {

+ 0 - 3
src/main/resources/logback-spring.xml

@@ -1,9 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <configuration>
 
-    <!-- Load default configuration from Spring Boot -->
-    <include resource="org/springframework/boot/logging/logback/base.xml"/>
-
     <!-- Define properties -->
     <property name="LOG_HOME" value="./logs"/>
     <property name="LOG_FILE" value="data-bridge"/>

+ 0 - 2
src/test/java/com/wechi/adweb/bridge/google/gtm/service/GTMServiceTest.java

@@ -29,9 +29,7 @@ public class GTMServiceTest {
                 gtmService.createContainer(
                         accountResourceName, "AdWeb3 Test #" + RandomStringUtils.randomNumeric(5));
 
-        // ASYNC methods
         gtmService.initContainerAccess(accountResourceName, gtmContainer.getId());
-        Thread.sleep(3000);
         gtmService.initContainerSetups(gtmContainer.getResourceName(), gaMeasurementId, "111");
 
         System.out.println(JsonUtils.toJson(gtmContainer));