AWS 移动分析
AWS Mobile Analytics
我已使用仪表板中为我的应用程序定义的说明在 cordova 应用程序中添加了 AWS Mobile Analytics。
<script type="text/javascript" src="js/aws-sdk.min.js"></script>
<script type="text/javascript" src="js/aws-sdk-mobile-analytics.min.js"></script>
document.addEventListener("deviceready", function(){
setUpAWSMobileAnalytics();
}, false);
function setUpAWSMobileAnalytics()
{
console.log("SET UP AWS **********");
AWS.config.region = 'us-east-1';
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'MY_APP_COGNITO_IDENTITY_POOL_ID' //Amazon Cognito Identity Pool ID
});
var options = {
appId : 'MY_APP_AMAZON_MOBILE_ANALYTICS_APP_ID', //Amazon Mobile Analytics App ID
appTitle : 'APP_TITLE'
};
var mobileAnalyticsClient = new AMA.Manager(options);
mobileAnalyticsClient.recordEvent('CUSTOM_EVENT', {
'ATTRIBUTE_1_NAME': 'APP_USAGE'
}, {
'METRIC_1_NAME': 1
});
mobileAnalyticsClient.submitEvents();
console.log("SET UP AWS END **********");
}
两个日志都打印在控制台上,之后我遇到了问题:
Failed to load resource: the server responded with a status of 404 (Not Found) https://cognito-identity.us-east-1.amazonaws.com/
相同的代码适用于 iOS 并记录了事件,但对于 Android,尚未记录任何事件。
听起来它可能是您的 CSP(内容安全策略)。
尝试将其添加到您的应用中:
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
我已使用仪表板中为我的应用程序定义的说明在 cordova 应用程序中添加了 AWS Mobile Analytics。
<script type="text/javascript" src="js/aws-sdk.min.js"></script>
<script type="text/javascript" src="js/aws-sdk-mobile-analytics.min.js"></script>
document.addEventListener("deviceready", function(){
setUpAWSMobileAnalytics();
}, false);
function setUpAWSMobileAnalytics()
{
console.log("SET UP AWS **********");
AWS.config.region = 'us-east-1';
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: 'MY_APP_COGNITO_IDENTITY_POOL_ID' //Amazon Cognito Identity Pool ID
});
var options = {
appId : 'MY_APP_AMAZON_MOBILE_ANALYTICS_APP_ID', //Amazon Mobile Analytics App ID
appTitle : 'APP_TITLE'
};
var mobileAnalyticsClient = new AMA.Manager(options);
mobileAnalyticsClient.recordEvent('CUSTOM_EVENT', {
'ATTRIBUTE_1_NAME': 'APP_USAGE'
}, {
'METRIC_1_NAME': 1
});
mobileAnalyticsClient.submitEvents();
console.log("SET UP AWS END **********");
}
两个日志都打印在控制台上,之后我遇到了问题:
Failed to load resource: the server responded with a status of 404 (Not Found) https://cognito-identity.us-east-1.amazonaws.com/
相同的代码适用于 iOS 并记录了事件,但对于 Android,尚未记录任何事件。
听起来它可能是您的 CSP(内容安全策略)。
尝试将其添加到您的应用中:
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">