mParticle / mparticle-apple-sdk

mParticle Apple SDK
Apache License 2.0
45 stars 66 forks source link

feat: Identity API response caching #244

Closed einsteinx2 closed 8 months ago

einsteinx2 commented 8 months ago

Summary

This is all behind a feature flag that is currently disabled

Testing Plan

1. Disable feature flag

mParticle -> Identity response code: 200
mParticle -> Identity execution time: 437.32ms
mParticle -> Identity response:
{"context":null,"matched_identities":{"email":"bbaron+abc1@mparticle.com"},"is_ephemeral":false,"mpid":"6167123318226482339","is_logged_in":true}

2. Start app fresh (idenity should save to cache)

mParticle -> Identity Caching - max age header value (in seconds): 86400
mParticle -> Identity Caching - Cached response for endpoint 2, key: 2::8f9e2eefac54a94a33bcfa00512550bf4963e21ee01060a924fc181bd55981a0, expires: 2024-01-10 21:51:30 +0000, bodyData.length: 145

3. Start app again (identity should read from cache)

mParticle -> Identity Caching - Valid cached response found for key: 2::8f9e2eefac54a94a33bcfa00512550bf4963e21ee01060a924fc181bd55981a0, expires: 2024-01-10 21:51:30 +0000, seconds left: 86357.1
mParticle -> Identity execution time: 0.36ms
mParticle -> Identity response:
{"context":null,"matched_identities":{"email":"bbaron+abc1@mparticle.com"},"is_ephemeral":false,"mpid":"6167123318226482339","is_logged_in":true}

4. Manually call identify, then modify, then identify (should save identify, should clear cache on modify, should save identify)

// First identify request
mParticle -> Identity response code: 200
mParticle -> Identity Caching - max age header value (in seconds): 86400
mParticle -> Identity Caching - Cached response for endpoint 2, key: 2::b6fb24420bffaaeded2d230e03aa287d82dbb13a9b5a04832992fa49ca605361, expires: 2024-01-10 21:55:53 +0000, bodyData.length: 145
mParticle -> Identity execution time: 235.59ms

// Modify request
mParticle -> Identity Caching - Removed all cached responses
mParticle -> Identity response code: 200
mParticle -> Identity Caching - max age header value (in seconds): 86400
mParticle -> Identity execution time: 372.21ms

// Second identify request
mParticle -> Identity response code: 200
mParticle -> Identity Caching - max age header value (in seconds): 86400
mParticle -> Identity Caching - Cached response for endpoint 2, key: 2::b6fb24420bffaaeded2d230e03aa287d82dbb13a9b5a04832992fa49ca605361, expires: 2024-01-10 21:55:54 +0000, bodyData.length: 145
mParticle -> Identity execution time: 252.73ms

Reference Issue (For mParticle employees only. Ignore if you are an outside contributor)

mparticle-automation commented 8 months ago

:tada: This PR is included in version 8.18.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: