Skip to content

Commit 7ad58ed

Browse files
authored
Merge pull request #450 from Countly/staging
Version 26.1.1
2 parents 87b15b8 + 40ceae7 commit 7ad58ed

18 files changed

Lines changed: 1164 additions & 34 deletions

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 26.1.1
2+
* Added POST method support for contents.
3+
* Added robust resource loading checks before displaying content
4+
* Added Content feature method `previewContent:(NSString *)contentId` (Experimental!).
5+
* Improved refreshing contents.
6+
17
## 26.1.0
28
* Added server-side listing filters support for controlling what data gets recorded:
39
* Event filters (blacklist/whitelist) to control which events are recorded

Countly-PL.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Countly-PL'
3-
s.version = '26.1.0'
3+
s.version = '26.1.1'
44
s.license = { :type => 'MIT', :file => 'LICENSE' }
55
s.summary = 'Countly is an innovative, real-time, open source mobile analytics platform.'
66
s.homepage = 'https://github.com/Countly/countly-sdk-ios'

Countly.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'Countly'
3-
s.version = '26.1.0'
3+
s.version = '26.1.1'
44
s.license = { :type => 'MIT', :file => 'LICENSE' }
55
s.summary = 'Countly is an innovative, real-time, open source mobile analytics platform.'
66
s.homepage = 'https://github.com/Countly/countly-sdk-ios'

Countly.xcodeproj/project.pbxproj

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@
9292
965A2E9D2DDDCDAC00F28F6A /* CountlyHealthTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 965A2E9A2DDDCDAC00F28F6A /* CountlyHealthTracker.h */; };
9393
9673567F2EC60CD400C742D8 /* TestURLProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9673567E2EC60CD400C742D8 /* TestURLProtocol.swift */; };
9494
968426812BF2302C007B303E /* CountlyConnectionManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 968426802BF2302C007B303E /* CountlyConnectionManagerTests.swift */; };
95+
96CB10A12F04B3A100D1E2F0 /* CountlyContentBuilderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96CB10A02F04B3A100D1E2F0 /* CountlyContentBuilderTests.swift */; };
9596
9691B7652F1FA35500A6ADCB /* CountlyOverlayWindow.h in Headers */ = {isa = PBXBuildFile; fileRef = 9691B7642F1FA35500A6ADCB /* CountlyOverlayWindow.h */; };
9697
9691B7672F1FA35C00A6ADCB /* CountlyOverlayWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 9691B7662F1FA35C00A6ADCB /* CountlyOverlayWindow.m */; };
9798
969E5BCE2ECC4D3200AB406A /* CountlyConsentManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 969E5BCD2ECC4D2C00AB406A /* CountlyConsentManagerTests.swift */; };
@@ -110,6 +111,7 @@
110111
D2CFEF972545FBE80026B044 /* CountlyFeedbacksInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = D2CFEF952545FBE80026B044 /* CountlyFeedbacksInternal.h */; };
111112
D2CFEF982545FBE80026B044 /* CountlyFeedbacksInternal.m in Sources */ = {isa = PBXBuildFile; fileRef = D2CFEF962545FBE80026B044 /* CountlyFeedbacksInternal.m */; };
112113
F041D46C963F3EA85882CB0D /* CountlyRequestCallbackTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7C1C3803ECB0A386136072D6 /* CountlyRequestCallbackTests.swift */; };
114+
69F2F899F8C641418B746050 /* CountlyWebViewManagerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBD1642D826B471A80175BE3 /* CountlyWebViewManagerTests.swift */; };
113115
/* End PBXBuildFile section */
114116

115117
/* Begin PBXContainerItemProxy section */
@@ -215,6 +217,7 @@
215217
96681A9B2D97D9B300A4845A /* CountlyTests.xctestplan */ = {isa = PBXFileReference; lastKnownFileType = text; path = CountlyTests.xctestplan; sourceTree = "<group>"; };
216218
9673567E2EC60CD400C742D8 /* TestURLProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestURLProtocol.swift; sourceTree = "<group>"; };
217219
968426802BF2302C007B303E /* CountlyConnectionManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CountlyConnectionManagerTests.swift; sourceTree = "<group>"; };
220+
96CB10A02F04B3A100D1E2F0 /* CountlyContentBuilderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CountlyContentBuilderTests.swift; sourceTree = "<group>"; };
218221
9691B7642F1FA35500A6ADCB /* CountlyOverlayWindow.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CountlyOverlayWindow.h; sourceTree = "<group>"; };
219222
9691B7662F1FA35C00A6ADCB /* CountlyOverlayWindow.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CountlyOverlayWindow.m; sourceTree = "<group>"; };
220223
969E5BCD2ECC4D2C00AB406A /* CountlyConsentManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CountlyConsentManagerTests.swift; sourceTree = "<group>"; };
@@ -230,6 +233,8 @@
230233
D249BF5D254D3D180058A6C2 /* CountlyFeedbackWidget.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CountlyFeedbackWidget.m; sourceTree = "<group>"; };
231234
D2CFEF952545FBE80026B044 /* CountlyFeedbacksInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CountlyFeedbacksInternal.h; sourceTree = "<group>"; };
232235
D2CFEF962545FBE80026B044 /* CountlyFeedbacksInternal.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CountlyFeedbacksInternal.m; sourceTree = "<group>"; };
236+
EBD1642D826B471A80175BE3 /* CountlyWebViewManagerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CountlyWebViewManagerTests.swift; sourceTree = "<group>"; };
237+
265156CB5F59417EA14BAC2F /* CountlyWebViewManager+Tests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CountlyWebViewManager+Tests.h"; sourceTree = "<group>"; };
233238
/* End PBXFileReference section */
234239

235240
/* Begin PBXFrameworksBuildPhase section */
@@ -267,7 +272,10 @@
267272
1A50D7042B3C5AA3009C6938 /* CountlyBaseTestCase.swift */,
268273
1AFD79012B3EF82C00772FBD /* CountlyTests-Bridging-Header.h */,
269274
968426802BF2302C007B303E /* CountlyConnectionManagerTests.swift */,
275+
96CB10A02F04B3A100D1E2F0 /* CountlyContentBuilderTests.swift */,
270276
96E680412BFF89AC0091E105 /* CountlyCrashReporterTests.swift */,
277+
EBD1642D826B471A80175BE3 /* CountlyWebViewManagerTests.swift */,
278+
265156CB5F59417EA14BAC2F /* CountlyWebViewManager+Tests.h */,
271279
3979E47C2C0760E900FA1CA4 /* CountlyUserProfileTests.swift */,
272280
3972EDDA2C08A38D00EB9D3E /* CountlyEventStruct.swift */,
273281
3966DBCE2C11EE270002ED97 /* CountlyDeviceIDTests.swift */,
@@ -546,6 +554,7 @@
546554
1A50D7052B3C5AA3009C6938 /* CountlyBaseTestCase.swift in Sources */,
547555
3979E47D2C0760E900FA1CA4 /* CountlyUserProfileTests.swift in Sources */,
548556
968426812BF2302C007B303E /* CountlyConnectionManagerTests.swift in Sources */,
557+
96CB10A12F04B3A100D1E2F0 /* CountlyContentBuilderTests.swift in Sources */,
549558
96329DE42D952F1500BFD641 /* MockURLProtocol.swift in Sources */,
550559
96329DE02D9426F300BFD641 /* CountlyServerConfigTests.swift in Sources */,
551560
3966DBCF2C11EE270002ED97 /* CountlyDeviceIDTests.swift in Sources */,
@@ -557,6 +566,7 @@
557566
3972EDDB2C08A38D00EB9D3E /* CountlyEventStruct.swift in Sources */,
558567
9673567F2EC60CD400C742D8 /* TestURLProtocol.swift in Sources */,
559568
96E680422BFF89AC0091E105 /* CountlyCrashReporterTests.swift in Sources */,
569+
69F2F899F8C641418B746050 /* CountlyWebViewManagerTests.swift in Sources */,
560570
A431BFDB50E23B1C056F93A1 /* CountlyQueueFlushRunnablesTests.swift in Sources */,
561571
F041D46C963F3EA85882CB0D /* CountlyRequestCallbackTests.swift in Sources */,
562572
CD99EB53BFF33C2DA9C50715 /* CountlyCallbackBaseTestCase.swift in Sources */,
@@ -820,7 +830,7 @@
820830
"@loader_path/Frameworks",
821831
);
822832
MACOSX_DEPLOYMENT_TARGET = 10.14;
823-
MARKETING_VERSION = 26.1.0;
833+
MARKETING_VERSION = 26.1.1;
824834
PRODUCT_BUNDLE_IDENTIFIER = ly.count.CountlyiOSSDK;
825835
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
826836
PROVISIONING_PROFILE_SPECIFIER = "";
@@ -852,7 +862,7 @@
852862
"@loader_path/Frameworks",
853863
);
854864
MACOSX_DEPLOYMENT_TARGET = 10.14;
855-
MARKETING_VERSION = 26.1.0;
865+
MARKETING_VERSION = 26.1.1;
856866
PRODUCT_BUNDLE_IDENTIFIER = ly.count.CountlyiOSSDK;
857867
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
858868
PROVISIONING_PROFILE_SPECIFIER = "";

CountlyCommon.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ @interface CountlyCommon ()
2929
#endif
3030
@end
3131

32-
NSString* const kCountlySDKVersion = @"26.1.0";
32+
NSString* const kCountlySDKVersion = @"26.1.1";
3333
NSString* const kCountlySDKName = @"objc-native-ios";
3434

3535
NSString* const kCountlyErrorDomain = @"ly.count.ErrorDomain";

CountlyContentBuilder.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ NS_ASSUME_NONNULL_BEGIN
3535
*/
3636
- (void)refreshContentZone;
3737

38+
/**
39+
* This is an experimental feature and it can have breaking changes
40+
* Previews a specific content by its ID.
41+
* This performs a one-time fetch for the given content
42+
* without starting periodic content updates.
43+
*
44+
* @param contentId the ID of the content to preview
45+
*/
46+
- (void)previewContent:(NSString *)contentId;
47+
3848
#endif
3949
NS_ASSUME_NONNULL_END
4050
@end

CountlyContentBuilder.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,5 +51,16 @@ - (void)changeContent:(NSArray<NSString *> *)tags
5151
[CountlyContentBuilder.sharedInstance changeContent:tags];
5252
}
5353

54+
- (void)previewContent:(NSString *)contentId
55+
{
56+
if (!contentId || contentId.length == 0)
57+
{
58+
CLY_LOG_W(@"%s contentId is null or empty, skipping", __FUNCTION__);
59+
return;
60+
}
61+
62+
[CountlyContentBuilderInternal.sharedInstance previewContent:contentId];
63+
}
64+
5465
#endif
5566
@end

CountlyContentBuilderInternal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ NS_ASSUME_NONNULL_BEGIN
1717
@property (nonatomic) ContentCallback contentCallback;
1818
@property (nonatomic, assign) WebViewDisplayOption webViewDisplayOption;
1919
@property (nonatomic, assign) int contentInitialDelay;
20-
@property (nonatomic, assign) NSUInteger refreshContentZoneDelay;
2120

2221
+ (instancetype)sharedInstance;
2322

@@ -26,6 +25,7 @@ NS_ASSUME_NONNULL_BEGIN
2625
- (void)changeContent:(NSArray<NSString *> *)tags;
2726
- (void)refreshContentZone;
2827
- (void)refreshContentZoneJTE;
28+
- (void)previewContent:(NSString *)contentId;
2929

3030
#endif
3131
NS_ASSUME_NONNULL_END

CountlyContentBuilderInternal.m

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ - (instancetype)init
3737
_isCurrentlyContentShown = NO;
3838
_contentQueue = dispatch_queue_create("ly.countly.content.queue", DISPATCH_QUEUE_SERIAL);
3939
_contentInitialDelay = 4;
40-
_refreshContentZoneDelay = 2.5;
4140
}
4241

4342
return self;
@@ -120,6 +119,10 @@ - (void)changeContent:(NSArray<NSString *> *)tags {
120119
}
121120
}
122121

122+
- (void)previewContent:(NSString *)contentId {
123+
[self fetchContents:nil contentId:contentId];
124+
}
125+
123126
- (void)refreshContentZone {
124127
if (![CountlyServerConfig.sharedInstance refreshContentZoneEnabled])
125128
{
@@ -130,13 +133,12 @@ - (void)refreshContentZone {
130133
return;
131134
}
132135

133-
[self exitContentZone];
134-
[CountlyConnectionManager.sharedInstance attemptToSendStoredRequests];
135-
136-
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(_refreshContentZoneDelay * NSEC_PER_SEC)), dispatch_get_main_queue(), ^
137-
{
136+
[CountlyConnectionManager.sharedInstance addQueueFlushRunnable:^{
137+
CLY_LOG_I(@"%s queue flueshed, will re-fetch contents" ,__FUNCTION__);
138+
[self exitContentZone];
138139
[self enterContentZone];
139-
});
140+
}];
141+
[CountlyConnectionManager.sharedInstance attemptToSendStoredRequests];
140142
}
141143

142144
- (void)refreshContentZoneJTE {
@@ -170,7 +172,7 @@ - (void)fetchContentsForJourneyWithMaxAttempts:(NSInteger)maxAttempts currentAtt
170172
[self enterContentZone];
171173
});
172174
}
173-
}];
175+
} contentId:nil];
174176
}
175177

176178
#pragma mark - Private Methods
@@ -186,10 +188,10 @@ - (void)clearContentState {
186188
}
187189

188190
- (void)fetchContents {
189-
[self fetchContents:nil];
191+
[self fetchContents:nil contentId:nil];
190192
}
191193

192-
- (void)fetchContents:(void (^)(void))failureCallback {
194+
- (void)fetchContents:(void (^)(void))failureCallback contentId:(NSString *)contentId {
193195
if (!CountlyConsentManager.sharedInstance.consentForContent)
194196
return;
195197

@@ -207,7 +209,7 @@ - (void)fetchContents:(void (^)(void))failureCallback {
207209

208210
[self setRequestQueueLockedThreadSafe:YES];
209211

210-
NSURLSessionTask *dataTask = [CountlyCommon.sharedInstance.URLSession dataTaskWithRequest:[self fetchContentsRequest] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
212+
NSURLSessionTask *dataTask = [CountlyCommon.sharedInstance.URLSession dataTaskWithRequest:[self fetchContentsRequest: contentId] completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
211213
if (error) {
212214
CLY_LOG_I(@"%s fetch content details failed: [%@]", __FUNCTION__, error);
213215
[self setRequestQueueLockedThreadSafe:NO];
@@ -242,7 +244,7 @@ - (void)fetchContents:(void (^)(void))failureCallback {
242244
[dataTask resume];
243245
}
244246

245-
- (NSURLRequest *)fetchContentsRequest
247+
- (NSURLRequest *)fetchContentsRequest:(NSString *)contentId
246248
{
247249
NSString *queryString = [CountlyConnectionManager.sharedInstance queryEssentials];
248250
NSString *resolutionJson = [self resolutionJson];
@@ -258,12 +260,28 @@ - (NSURLRequest *)fetchContentsRequest
258260
queryString = [queryString stringByAppendingFormat:@"&%@=%@", @"dt", deviceType];
259261
}
260262

263+
if (contentId) {
264+
queryString = [queryString stringByAppendingFormat:@"&%@=%@", @"content_id", contentId.cly_URLEscaped];
265+
queryString = [queryString stringByAppendingFormat:@"&%@=%@", @"preview", @"true"];
266+
}
267+
261268
queryString = [CountlyConnectionManager.sharedInstance appendChecksum:queryString];
262269

263-
NSString *URLString = [NSString stringWithFormat:@"%@%@?%@", CountlyConnectionManager.sharedInstance.host, kCountlyEndpointContent, queryString];
270+
NSString *contentEndpoint = [NSString stringWithFormat:@"%@%@", CountlyConnectionManager.sharedInstance.host, kCountlyEndpointContent];
264271

265-
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:URLString]];
266-
return request;
272+
if (queryString.length > kCountlyGETRequestMaxLength || CountlyConnectionManager.sharedInstance.alwaysUsePOST)
273+
{
274+
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:contentEndpoint]];
275+
request.HTTPMethod = @"POST";
276+
request.HTTPBody = [queryString cly_dataUTF8];
277+
return request.copy;
278+
}
279+
else
280+
{
281+
NSString* withQueryString = [contentEndpoint stringByAppendingFormat:@"?%@", queryString];
282+
NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:withQueryString]];
283+
return request;
284+
}
267285
}
268286

269287
- (NSString *)resolutionJson {

0 commit comments

Comments
 (0)