IOS Rest Logger
Introduction
A very simple library for logging the outcome from REST calls from your app; all it logs are:
- The path part of your REST request URL
- The HTTP response code
- A timestamp
- The device type (i.e. OS version and model)
This means that it involves logging no information that could possibly be used to identify a user, and so should be easily compatibly with privacy legislation like GDPR.
Configuration
In iOS
Records are logged to an AWS S3 bucket to which anonymous access is granted by AWS COGNITO. You need to provide the following information, as keys in your app's .plist
file:
AWS_REGION
: (The AWS region of your S3 bucket)AWS_BUCKET_NAME
: (The bucket's name)AWS_POOL_ID
: The ID for an AWS COGNITO identity pool
On AWS
The identity pool should be configured so it's unauthenticated role has permission for unauthorised access to S3 and write permissions on your bucket. E.g.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"mobileanalytics:PutEvents",
"cognito-sync:*"
],
"Resource": [
"*"
]
},
{
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
"s3:ListBucket",
"s3:DeleteObject",
"s3:GetBucketLocation"
],
"Resource": [
"arn:aws:s3:::<your bucket>",
"arn:aws:s3:::<your bucket>/*"
]
}
]
}
See AWS documentation for more details.
API
The API is extremely simple, consisting of a class RESTLogger
with two static methods:
RESTLogger.Initialise()
initialises the serviceRESTLogger.Log(path: String, httpResponse: Int)
logs that a message with the given path received the given response code (timestamp and platform version are filled in automatically).
E.g.
RESTLogger.Initialise()
RESTLogger.Log(path: "the/house/that/jack/built", httpResponse: 408)