Comments (9)
Hi @hajducak i am kerollos nabil iOS developer at instabug
thank you for communicating with us
at your snippet of code
let hostCollection = [
"https://www.google.com/"
// ... more different hosts alowing to log in instabug
]
let requestPredicate = NSPredicate(format: "URL.host IN %@", hostCollection)
NetworkLogger.setNetworkLoggingRequestFilterPredicate(requestPredicate, responseFilterPredicate: nil)
you are writing the host in the hostCollection list like that "https://www.google.com" and we are running this predicate against an object of type NSURLRequest
and the NSURL
object inside NSURLRequest
(URL) breaks this link into
- protocol: https
- host: www.Google.com
- path: /products
so when we run the predicate he try to find the host " www.Google.com" in your list of hosts it fails to find it
so you only need to remove "https://" from the list of hosts to be like that
let hostCollection = [
"www.google.com"
// ... more different hosts alowing to log in instabug
]
let requestPredicate = NSPredicate(format: "URL.host IN %@", hostCollection)
NetworkLogger.setNetworkLoggingRequestFilterPredicate(requestPredicate, responseFilterPredicate: nil)
this will work as expected
and for the tests you just need to use the predicate against NSURLRequest
object instead of URL
this test for the path will pass
func test_Predicate_1() {
let path = "/products"
let predicate = NSPredicate(format: "URL.path MATCHES %@", path)
let testURL: URL = URL(string: "https://www.google.com/products")!
let urlRequest = NSURLRequest(url: testURL)
let evaluatedUrl: Bool = predicate.evaluate(with: urlRequest)
XCTAssertTrue(evaluatedUrl)
expectation(for: predicate, evaluatedWith: urlRequest, handler: nil)
waitForExpectations(timeout: 10) { error in
if let error = error {
print("expectations has not been fulfullied. Failed with error \(error)")
} else {
print("expectations has been fullfilled.")
}
}
}
and this test for hosts will pass as well
func test_predicate_2() {
let hostCollection = [
"www.google.com"
// ... more different hosts alowing to log in instabug
]
let predicate = NSPredicate(format: "URL.host IN %@", hostCollection)
let testURL: URL = URL(string: "https://www.google.com/products")!
let urlRequest = NSURLRequest(url: testURL)
let evaluatedUrl: Bool = predicate.evaluate(with: urlRequest)
XCTAssertTrue(evaluatedUrl)
expectation(for: predicate, evaluatedWith: urlRequest, handler: nil)
waitForExpectations(timeout: 10) { error in
if let error = error {
print("expectations has not been fulfullied. Failed with error \(error)")
} else {
print("expectations has been fullfilled.")
}
}
}
from instabug-ios.
Hello @KerollosNabil thanks for explanation.
Unfortunately after editing the code Instabug still logging hosts which we don't want to log.
Yeah test passes correctly as you write.
This is my code I am sending to Instabug:
static func setOmittingRequests() {
let hostCollection = [
"login-ppt-a-moje.o2.cz",
"login-a-moje.o2.cz",
"login-e3-a-moje.o2.cz",
"api-ppt-a-moje.o2.cz",
"api-a-moje.o2.cz",
"api-e3-a-moje.o2.cz",
"api-eme-ppt-a-moje.o2.cz",
"api-eme-a-moje.o2.cz",
"api-eme-e3-a-moje.o2.cz",
"api-az-a-moje.o2.cz",
"api-az-ppt-a-moje.o2.cz",
"api-az-e3-a-moje.o2.cz"
]
let predicateFormat = "URL.host IN %@"
let predicate = NSPredicate(format: predicateFormat, argumentArray: hostCollection)
NetworkLogger.setNetworkLoggingRequestFilterPredicate(predicate, responseFilterPredicate: nil)
}
I checked if the code is calling at the beginning of our app. It is. I don't know what is wrong in this case. Can you help with this also?
from instabug-ios.
This issue has been automatically marked as stale due to inactivity. It will be closed if no further activity occurs. Thank you for your contributions.
from instabug-ios.
@KerollosNabil
Instabug SDK still not working in this issue, pls reopen this issue. I would love to see repair from your side. Thanks
from instabug-ios.
@hajducak Could you kindly get in touch with our customer support team so that they can assist you in initiating a ticket for you to able to investigate more in your problem
from instabug-ios.
This issue has been automatically marked as stale due to inactivity. It will be closed if no further activity occurs. Thank you for your contributions.
from instabug-ios.
@KerollosNabil I contact customer support 3 days ago, nobody send me any response.
from instabug-ios.
This issue has been automatically marked as stale due to inactivity. It will be closed if no further activity occurs. Thank you for your contributions.
from instabug-ios.
This issue has been automatically closed due to inactivity.
from instabug-ios.
Related Issues (20)
- EXC_BREAKPOINT: NetworkTasksListener.createTask HOT 12
- App got crashed at launching time HOT 3
- Method swizzling breaks Ktor data form request HOT 7
- Network activity not logged when using async methods of URLSession HOT 2
- App got crashed because fatal exception (Invalid number value (NaN) in JSON write) HOT 2
- Add support of async-await in event handlers HOT 2
- Instabug posts a lot of [Instabug] logs into console HOT 2
- Network Logs not appearing when using Swift Concurrency APIs HOT 11
- App freezes instead of crashing when Kotlin Multiplatform is present HOT 3
- Rare crash on launch: Cannot load NSManagedObjectModel. nil is an illegal URL parameter HOT 7
- Instabug.addFileAttachment(with: URL) does not work as documented HOT 1
- Crash: [InstabugScreenCapturer takeScreenshotWithAnnotator:shouldUseRenderInContext:lastTouchedPoints:shouldApplyMaskingRules:] HOT 2
- Include the response body in the network logs when using Swift Concurrency HOT 5
- [Crash] INSTABUG_SWIZZLER_EXECUTING_ORIGINAL_IMPLEMENTATION HOT 1
- Kotlin KMM iOS support? HOT 2
- [Crash] IBGSwizzlerManager crashes on launch HOT 8
- Instabug IOS SDK script variable/function's names collides with webview's URL script HOT 7
- Unable to install 12.9.2 SDK via SPM HOT 5
- Noisy logs from Method Swizzling with error-level logging enabled: `IBGCore: Coultn't find network log with task Id` HOT 5
- Include privacy info manifest to comply with Apple privacy policy HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from instabug-ios.