Reputation: 569
I have recently integrated the AWS Amplify Javascript library with my existing Ionic project. The authentication with Cognito works fine. However when I set the log level to Amplify.Logger.LOG_LEVEL = 'VERBOSE';
I can see that AWS Analytics does not work yet due to a missing region in the configuration. I have a related Mobile Hub project which has analytics enabled and the integrated aws-exports.js in the project looks like this (ids etc are replaced with <> placeholder):
// WARNING: DO NOT EDIT. This file is Auto-Generated by AWS Mobile Hub. It will be overwritten.
// Copyright 2017 Amazon.com, Inc. or its affiliates (Amazon). All Rights Reserved.
// Code generated by AWS Mobile Hub. Amazon gives unlimited permission to
// copy, distribute and modify it.
// AWS Mobile Hub Project Constants
const awsmobile = {
aws_app_analytics : 'enable',
aws_cognito_identity_pool_id : 'eu-central-1:<>',
aws_cognito_region : 'eu-central-1',
aws_content_delivery : 'enable',
aws_content_delivery_bucket : '<>',
aws_content_delivery_bucket_region : 'eu-central-1',
aws_content_delivery_cloudfront : 'enable',
aws_content_delivery_cloudfront_domain : '<>',
aws_mandatory_sign_in : 'enable',
aws_mobile_analytics_app_id : '<>',
aws_project_id : '<>',
aws_project_name : 'Let Me Go',
aws_project_region : 'eu-central-1',
aws_push_pinpoint : 'enable',
aws_resource_name_prefix : '<>',
aws_sign_in_enabled : 'enable',
aws_user_files : 'enable',
aws_user_files_s3_bucket : '<>',
aws_user_files_s3_bucket_region : 'eu-central-1',
aws_user_pools : 'enable',
aws_user_pools_id : '<>',
aws_user_pools_mfa_type : 'OFF',
aws_user_pools_web_client_id : '<>',
aws_user_settings : 'enable',
}
export default awsmobile;
var AWS = require('aws-sdk');
AWS.config.region = awsmobile.aws_project_region;
AWS.config.update({customUserAgent: 'MobileHub v0.1'});
Then in the code I initialize Amplify with the exported aws-export.js like this:
import Amplify from 'aws-amplify';
import aws_exports from '../assets/js/aws-exports';
Amplify.configure(aws_exports);
Running the app gives me the following errors:
Object { "[DEBUG] 37:44.28 AuthClass - Load credentials successfully": {…} }
ConsoleLogger.js:100
Object { "[DEBUG] 37:44.28 AnalyticsClass - set credentials for analytics": {…} }
ConsoleLogger.js:100
[DEBUG] 37:44.30 AWSAnalyticsProvider - configure Analytics": Object { appId: "<>", region: undefined, clientInfo: {…}, … }
ConsoleLogger.js:100
[DEBUG] 37:46.980 AWSAnalyticsProvider - init clients
ConsoleLogger.js:84
[INFO] 37:46.980 Cache - Get item: key is <> with options undefined
ConsoleLogger.js:84
Object { "[DEBUG] 37:46.982 AWSAnalyticsProvider - endpointId from cache": […] }
ConsoleLogger.js:100
Object { "[DEBUG] 37:46.990 AWSAnalyticsProvider - demographic user id: ": "<>" }
ConsoleLogger.js:100
Object { "[DEBUG] 37:46.992 AWSAnalyticsProvider - updateEndpoint with params: ": {…} }
ConsoleLogger.js:100
Object { "[DEBUG] 37:46.996 AWSAnalyticsProvider - Pinpoint ERROR": ConfigError: Missing region in config }
So there is twice a missing region error and I can also see that the region is empty. Even though it sounds eashy I was not able to find out with which property I can set the analytics region in the aws-export.js. Please help!
Upvotes: 0
Views: 686
Reputation: 267
I thinks the 'aws_mobile_analytics_app_region' is missing in your aws_exports file. Maybe you can redownload to see if works or hardcord it into that file. Check this code
Upvotes: 1