Search code examples
iosamazon-web-servicesanalyticsamazon-cognitoamazon-mobile-analytics

Using Amazon Mobile Analytics without configuring Amazon Cognito


Compared to competing analytics services, Amazon Mobile Analytics appear to require many more configuration and integration steps.

For example, in Flurry Analytics, the setup is pretty simple:

[Flurry startSession:@"<app-id>"];
[Flurry logEvent:@"<event-name>"];
// Optionally, set the userID
[Flurry setUserID:@"userid"];

I was hoping the equivalent in Amazon Mobile Analytics would be something like this for unauthenticated users:

[AWSLogger defaultLogger].logLevel = AWSLogLevelVerbose;
AWSMobileAnalytics* analytics = [AWSMobileAnalytics mobileAnalyticsForAppId:@"<app-id>"];
id<AWSMobileAnalyticsEventClient> eventClient = analytics.eventClient;
id<AWSMobileAnalyticsEvent> event = [eventClient createEventWithEventType:@"ScreenView"];
[eventClient recordEvent:event];

However, after running that code and putting the app in the background to upload and send off the event, no errors or other log messages are given.

Both Amazon's quick start guide and this tutorial (http://www.nickyap.info/mobile-analytics/) step you through extra steps configuring Amazon Cognito, even for tracking unauthenticated users. This in turn, requires extra AWS permissions for creating user roles, etc. which my AWS account doesn't have.

Has anyone tried using Amazon Mobile Analytics without configuring Cognito first? Or is that an absolute requirement?


Solution

  • The Amazon Mobile Analytics client requires Cognito to facilitate authentication and authorization when submitting data. This is used to increase the security of submitting data from mobile clients to ensure valid credentials are sending the data for a particular app. If Cognito is not used, the data submission call will fail due to invalid permissions.