GithubHelp home page GithubHelp logo

Comments (9)

KerollosNabil avatar KerollosNabil commented on June 9, 2024 1

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

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.

hajducak avatar hajducak commented on June 9, 2024

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.

stale avatar stale commented on June 9, 2024

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.

hajducak avatar hajducak commented on June 9, 2024

@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.

KerollosNabil avatar KerollosNabil commented on June 9, 2024

@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.

stale avatar stale commented on June 9, 2024

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.

hajducak avatar hajducak commented on June 9, 2024

@KerollosNabil I contact customer support 3 days ago, nobody send me any response.

from instabug-ios.

stale avatar stale commented on June 9, 2024

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.

stale avatar stale commented on June 9, 2024

This issue has been automatically closed due to inactivity.

from instabug-ios.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.