Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Ability to pass in URLSession to Mixpanel #619

Open
RamblinWreck77 opened this issue Nov 20, 2023 · 0 comments
Open

Feature request: Ability to pass in URLSession to Mixpanel #619

RamblinWreck77 opened this issue Nov 20, 2023 · 0 comments
Labels

Comments

@RamblinWreck77
Copy link
Contributor

Generally speaking the fewer URLSession's the better, and some apps need to go beyond URLSession.shared to access advanced configuration that benefits their use case.

Currently, inside Network.swift tasks are queued up on URLSession.shared.dataTask { }

While this makes perfect sense as the default, it would be nice to be able to optionally provide your app's custom URLSession on mixpanel init and reuse that.

Perhaps something like:

    @discardableResult
    open class func initialize(token apiToken: String,
                               trackAutomaticEvents: Bool,
                               flushInterval: Double = 60,
                               instanceName: String? = nil,
                               optOutTrackingByDefault: Bool = false,
                               useUniqueDistinctId: Bool = false,
                               superProperties: Properties? = nil,
                               urlSession: URLSession = URLSession.shared,                  // By not passing in, .shared is used
                               serverURL: String? = nil) -> MixpanelInstance {
        return MixpanelManager.sharedInstance.initialize(token: apiToken,
                                                         flushInterval: flushInterval,
                                                         instanceName: ((instanceName != nil) ? instanceName! : apiToken),
                                                         trackAutomaticEvents: trackAutomaticEvents,
                                                         optOutTrackingByDefault: optOutTrackingByDefault,
                                                         useUniqueDistinctId: useUniqueDistinctId,
                                                         superProperties: superProperties,
                                                         serverURL: serverURL)
    }
@zihejia zihejia added the feature label Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants