Skip to content

Commit

Permalink
Merge pull request #260 from Countly/appVerion-metrics
Browse files Browse the repository at this point in the history
Incorporated the addition of the app version to all API requests.
  • Loading branch information
ArtursKadikis committed Oct 18, 2023
2 parents fc6eec7 + f721d5c commit f4c33c4
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 15 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- Added `requestDropAgeHours` initial config property to set a time limit after which the requests would be removed if not sent to the server
- Added a call to enroll users to A/B tests when getting a remote config value: 'getValueAndEnroll'
- Added a call to enroll users to A/B tests when getting all remote config values: 'getAllValuesAndEnroll'
- Added app version in all API requests.

- Fixed sending '--' as carrier name due to platform changes from iOS version 16.4. This version and above will now not send any carrier information due to platform limitations.
- Mitigated an issue where users could not enroll to an A/B tests if enrollment request has failed
Expand Down
2 changes: 2 additions & 0 deletions CountlyConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ extern CLYMetricKey const CLYMetricKeyLocale;
extern CLYMetricKey const CLYMetricKeyHasWatch;
extern CLYMetricKey const CLYMetricKeyInstalledWatchApp;

extern NSString* const kCountlyAppVersionKey;

//NOTE: Attribution keys
typedef NSString* CLYAttributionKey NS_EXTENSIBLE_STRING_ENUM;
extern CLYAttributionKey const CLYAttributionKeyIDFA;
Expand Down
3 changes: 3 additions & 0 deletions CountlyConnectionManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,9 @@ - (void)sendCrashReport:(NSString *)report immediately:(BOOL)immediately;

[CountlyPersistency.sharedInstance saveToFileSync];

queryString = [queryString stringByAppendingFormat:@"&%@=%@",
kCountlyAppVersionKey, CountlyDeviceInfo.appVersion];

NSString* serverInputEndpoint = [self.host stringByAppendingString:kCountlyEndpointI];
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:serverInputEndpoint]];
request.HTTPMethod = @"POST";
Expand Down
2 changes: 2 additions & 0 deletions CountlyDeviceInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
CLYMetricKey const CLYMetricKeyHasWatch = @"_has_watch";
CLYMetricKey const CLYMetricKeyInstalledWatchApp = @"_installed_watch_app";

NSString* const kCountlyAppVersionKey = @"av";

@interface CountlyDeviceInfo ()
@property (nonatomic) BOOL isInBackground;
#if (TARGET_OS_IOS)
Expand Down
6 changes: 6 additions & 0 deletions CountlyFeedbackWidget.m
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ - (NSURLRequest *)dataRequest
kCountlyFBKeyPlatform, CountlyDeviceInfo.osName,
kCountlyFBKeyShown, @"1",
kCountlyFBKeyWidgetID, self.ID];

queryString = [queryString stringByAppendingFormat:@"&%@=%@",
kCountlyAppVersionKey, CountlyDeviceInfo.appVersion];

queryString = [CountlyConnectionManager.sharedInstance appendChecksum:queryString];

Expand Down Expand Up @@ -185,6 +188,9 @@ - (NSURLRequest *)displayRequest
kCountlyFBKeyAppVersion, CountlyDeviceInfo.appVersion,
kCountlyFBKeyPlatform, CountlyDeviceInfo.osName,
kCountlyFBKeyWidgetID, self.ID];

queryString = [queryString stringByAppendingFormat:@"&%@=%@",
kCountlyAppVersionKey, CountlyDeviceInfo.appVersion];

queryString = [CountlyConnectionManager.sharedInstance appendChecksum:queryString];

Expand Down
9 changes: 9 additions & 0 deletions CountlyFeedbacks.m
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ - (NSURLRequest *)widgetCheckURLRequest:(NSString *)widgetID
NSString* queryString = [CountlyConnectionManager.sharedInstance queryEssentials];

queryString = [queryString stringByAppendingFormat:@"&%@=%@", kCountlyFBKeyWidgetID, widgetID];

queryString = [queryString stringByAppendingFormat:@"&%@=%@",
kCountlyAppVersionKey, CountlyDeviceInfo.appVersion];

queryString = [CountlyConnectionManager.sharedInstance appendChecksum:queryString];

Expand Down Expand Up @@ -361,6 +364,9 @@ - (NSURL *)widgetDisplayURL:(NSString *)widgetID
queryString = [queryString stringByAppendingFormat:@"&%@=%@&%@=%@",
kCountlyFBKeyWidgetID, widgetID,
kCountlyFBKeyAppVersion, CountlyDeviceInfo.appVersion];

queryString = [queryString stringByAppendingFormat:@"&%@=%@",
kCountlyAppVersionKey, CountlyDeviceInfo.appVersion];

queryString = [CountlyConnectionManager.sharedInstance appendChecksum:queryString];

Expand Down Expand Up @@ -476,6 +482,9 @@ - (NSURLRequest *)feedbacksRequest
kCountlyQSKeyDeviceID, CountlyDeviceInfo.sharedInstance.deviceID.cly_URLEscaped,
kCountlyQSKeySDKName, CountlyCommon.sharedInstance.SDKName,
kCountlyQSKeySDKVersion, CountlyCommon.sharedInstance.SDKVersion];

queryString = [queryString stringByAppendingFormat:@"&%@=%@",
kCountlyAppVersionKey, CountlyDeviceInfo.appVersion];

queryString = [CountlyConnectionManager.sharedInstance appendChecksum:queryString];

Expand Down
3 changes: 3 additions & 0 deletions CountlyPersistency.m
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ - (void)addToQueue:(NSString *)queryString

if (!queryString.length || [queryString isEqual:NSNull.null])
return;

queryString = [queryString stringByAppendingFormat:@"&%@=%@",
kCountlyAppVersionKey, CountlyDeviceInfo.appVersion];

@synchronized (self)
{
Expand Down
27 changes: 12 additions & 15 deletions CountlyRemoteConfigInternal.m
Original file line number Diff line number Diff line change
Expand Up @@ -255,14 +255,17 @@ - (NSURLRequest *)remoteConfigRequestForKeys:(NSArray *)keys omitKeys:(NSArray *
queryString = [queryString stringByAppendingFormat:@"&%@=%@", kCountlyRCKeyOmitKeys, [omitKeys cly_JSONify]];
}

if (self.enrollABOnRCDownload) {
queryString = [queryString stringByAppendingFormat:@"&%@=%@", kCountlyRCKeyAutoOptIn, @"1"];
}

if (CountlyConsentManager.sharedInstance.consentForSessions)
{
queryString = [queryString stringByAppendingFormat:@"&%@=%@", kCountlyQSKeyMetrics, [CountlyDeviceInfo metrics]];
}

if (self.enrollABOnRCDownload) {
queryString = [queryString stringByAppendingFormat:@"&%@=%@", kCountlyRCKeyAutoOptIn, @"1"];
}
queryString = [queryString stringByAppendingFormat:@"&%@=%@",
kCountlyAppVersionKey, CountlyDeviceInfo.appVersion];

queryString = [CountlyConnectionManager.sharedInstance appendChecksum:queryString];

Expand Down Expand Up @@ -654,10 +657,8 @@ - (NSURLRequest *)downloadVariantsRequest

queryString = [queryString stringByAppendingFormat:@"&%@=%@", kCountlyQSKeyMethod, kCountlyRCKeyFetchVariant];

if (CountlyConsentManager.sharedInstance.consentForSessions)
{
queryString = [queryString stringByAppendingFormat:@"&%@=%@", kCountlyQSKeyMetrics, [CountlyDeviceInfo metrics]];
}
queryString = [queryString stringByAppendingFormat:@"&%@=%@",
kCountlyAppVersionKey, CountlyDeviceInfo.appVersion];

queryString = [CountlyConnectionManager.sharedInstance appendChecksum:queryString];

Expand Down Expand Up @@ -783,10 +784,8 @@ - (NSURLRequest *)downloadExperimentInfoRequest

queryString = [queryString stringByAppendingFormat:@"&%@=%@", kCountlyQSKeyMethod, kCountlyRCKeyFetchExperiments];

if (CountlyConsentManager.sharedInstance.consentForSessions)
{
queryString = [queryString stringByAppendingFormat:@"&%@=%@", kCountlyQSKeyMetrics, [CountlyDeviceInfo metrics]];
}
queryString = [queryString stringByAppendingFormat:@"&%@=%@",
kCountlyAppVersionKey, CountlyDeviceInfo.appVersion];

queryString = [CountlyConnectionManager.sharedInstance appendChecksum:queryString];

Expand Down Expand Up @@ -824,10 +823,8 @@ - (NSURLRequest *)enrollInVarianRequestForKey:(NSString *)key variantName:(NSStr
queryString = [queryString stringByAppendingFormat:@"&%@=%@", kCountlyRCKeyVariant, variantName.cly_URLEscaped];
}

if (CountlyConsentManager.sharedInstance.consentForSessions)
{
queryString = [queryString stringByAppendingFormat:@"&%@=%@", kCountlyQSKeyMetrics, [CountlyDeviceInfo metrics]];
}
queryString = [queryString stringByAppendingFormat:@"&%@=%@",
kCountlyAppVersionKey, CountlyDeviceInfo.appVersion];

queryString = [CountlyConnectionManager.sharedInstance appendChecksum:queryString];

Expand Down
3 changes: 3 additions & 0 deletions CountlyServerConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ - (NSURLRequest *)serverConfigRequest
kCountlyQSKeySDKName, CountlyCommon.sharedInstance.SDKName,
kCountlyQSKeySDKVersion, CountlyCommon.sharedInstance.SDKVersion];

queryString = [queryString stringByAppendingFormat:@"&%@=%@",
kCountlyAppVersionKey, CountlyDeviceInfo.appVersion];

queryString = [CountlyConnectionManager.sharedInstance appendChecksum:queryString];

NSMutableString* URL = CountlyConnectionManager.sharedInstance.host.mutableCopy;
Expand Down

0 comments on commit f4c33c4

Please sign in to comment.