|
@@ -8,7 +8,6 @@ import jakarta.annotation.PostConstruct;
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
-import org.apache.commons.lang3.reflect.TypeUtils;
|
|
|
import org.apache.commons.lang3.tuple.Pair;
|
|
|
import org.jeecg.common.util.FastJsonUtil;
|
|
|
import org.jeecg.modules.adweb.common.databridge.OpenAPIRequest;
|
|
@@ -116,15 +115,13 @@ public class GTMAdminService {
|
|
|
.displayName(siteName)
|
|
|
.url(siteUrl)
|
|
|
.build());
|
|
|
- OpenAPIResponse<GAPropertyDTO> createGAPropertyResponse =
|
|
|
-
|
|
|
+ GAPropertyDTO gaProperty =
|
|
|
RestTemplateUtil.postForObject(
|
|
|
restTemplate,
|
|
|
dataBridgeApiHost + GA_PROPERTY_CREATE_API_PATH,
|
|
|
createGAPropertyRequest,
|
|
|
new ParameterizedTypeReference<OpenAPIResponse<GAPropertyDTO>>() {})
|
|
|
- ;
|
|
|
- GAPropertyDTO gaProperty
|
|
|
+ .getData();
|
|
|
log.info("为站点 {} 创建GA property: {}", siteCode, FastJsonUtil.toJSONString(gaProperty));
|
|
|
|
|
|
// 2. 创建Matomo site - 通过data-bridge API
|
|
@@ -166,12 +163,12 @@ public class GTMAdminService {
|
|
|
googleGTM.setUid(null); // TODO
|
|
|
googleGTM.setGtmAccountId(gtmAccountId);
|
|
|
googleGTM.setGtmContainerId(gtmContainer.getId());
|
|
|
- googleGTM.setGtmTagId(gtmContainer.getPublicId());
|
|
|
+ googleGTM.setGtmPublicId(gtmContainer.getPublicId());
|
|
|
googleGTM.setGaAccountId(gaAccountId);
|
|
|
googleGTM.setGaPropertyId(gaProperty.getId());
|
|
|
googleGTM.setGaVersion("V4"); // GA4 https://support.google.com/analytics/answer/10089681
|
|
|
googleGTM.setGaSiteUrl(siteUrl);
|
|
|
- googleGTM.setGaTagId(gaProperty.getDataStreams().get(0).getStreamMeasurementId());
|
|
|
+ googleGTM.setGaMeasurementId(gaProperty.getDataStreams().get(0).getStreamMeasurementId());
|
|
|
googleGTM.setMatomoSiteId(matomoSite.getSiteId());
|
|
|
googleGTMService.save(googleGTM);
|
|
|
|
|
@@ -187,11 +184,7 @@ public class GTMAdminService {
|
|
|
restTemplate,
|
|
|
dataBridgeApiHost + GA_ACCOUNT_LIST_API_PATH,
|
|
|
listGAAccountsRequest,
|
|
|
- ParameterizedTypeReference.forType(
|
|
|
- TypeUtils.parameterize(
|
|
|
- OpenAPIResponse.class,
|
|
|
- TypeUtils.parameterize(List.class, GAAccountDTO.class))));
|
|
|
- log.info("获取GA accounts: {}", FastJsonUtil.toJSONString(listGAAccountsResponse.getData()));
|
|
|
+ new ParameterizedTypeReference<OpenAPIResponse<List<GAAccountDTO>>>() {});
|
|
|
|
|
|
return listGAAccountsResponse.getData().stream()
|
|
|
.filter(gaAccount -> gaAccountIds.contains(gaAccount.getId()))
|
|
@@ -201,13 +194,13 @@ public class GTMAdminService {
|
|
|
/**
|
|
|
* 返回GTM container的head + body snippet代码
|
|
|
*
|
|
|
- * @param gtmTagId
|
|
|
+ * @param gtmPublic
|
|
|
* @return
|
|
|
*/
|
|
|
- public Pair<String, String> getSnippets(String gtmTagId) {
|
|
|
+ public Pair<String, String> getSnippets(String gtmPublic) {
|
|
|
return Pair.of(
|
|
|
- String.format(headSnippetTemplate, gtmTagId),
|
|
|
- String.format(bodySnippetTemplate, gtmTagId));
|
|
|
+ String.format(headSnippetTemplate, gtmPublic),
|
|
|
+ String.format(bodySnippetTemplate, gtmPublic));
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -239,7 +232,7 @@ public class GTMAdminService {
|
|
|
|
|
|
// 2. 删除Matomo site - 通过data-bridge API
|
|
|
OpenAPIRequest<String> deleteMatomoSiteRequest =
|
|
|
- this.buildOpenAPIRequest(GAPropertyDTO.toResourceName(googleGTM.getMatomoSiteId()));
|
|
|
+ this.buildOpenAPIRequest(googleGTM.getMatomoSiteId());
|
|
|
String matomoSiteId =
|
|
|
RestTemplateUtil.postForObject(
|
|
|
restTemplate,
|