Swiftpack.co - Hengyu/Journey as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by Hengyu.
Hengyu/Journey 3.1.0
A swift package for event logging
⭐️ 0
🕓 6 weeks ago
iOS tvOS macCatalyst
.package(url: "https://github.com/Hengyu/Journey.git", from: "3.1.0")

Journey

Journey is a package for logging. It contains two libraries: The one is JourneyInterface which defines a set of protocols. And the other is Journey which provides a base implementation of the previous protocols.

Table of contents

Requirements

  • iOS 11.0+, macCatalyst 13.0+, tvOS 11.0+

Installation

Journey could be installed via Swift Package Manager. Open Xcode and go to File -> Add Packages..., search https://github.com/hengyu/Journey.git, and add the package as one of your project's dependency.

Usage

There are two types of logger protocols: NetworkLoggingService and OndiskLoggingService.

  • The DatadogService is a pre-built network logger on the NetworkLoggingService. You should add the dd-sdk-ios to your project dependencies when you try to use it.

  • The DefaultOndiskService is a pre-built local logger on the OndiskLoggingService. It simply prints logging info to the console.

import Journey
import JourneyInterface

public final class CustomJourneyDependencies: JourneyDependencies {

    private class CustomOndiskLoggingService: OndiskLoggingService {

        func logEvent(_ name: String, content: String, attributes: [String: Encodable]) { }
    }

    public let datadogContext: DatadogContext

    public init(datadogContext: DatadogContext) {
        self.datadogContext = datadogContext
    }

    public var networkLoggingService: NetworkLoggingService {
        DatadogService(context: datadogContext)
    }

    public var ondiskLoggingService: OndiskLoggingService {
        CustomOndiskLoggingService()
    }
}

extension BaseJourneyLogger {

    public static let sharedLogger: JourneyLogger = {
        BaseJourneyLoggerBuilder(
            dependencies: CustomJourneyDependencies(
                datadogContext: DatadogContext(
                    serviceName: <#T##String#>,
                    environment: <#T##String#>,
                    token: <#T##String#>,
                    sendNetworkInfo: true
                )
            )
        ).build()
    }()
}

// when you want to log
BaseJourneyLogger.sharedLogger.logEvent(JourneyPageImpressionEvent(page: _page_))

License

Journey is released under the MIT License.

GitHub

link
Stars: 0
Last commit: 6 weeks ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Dependencies

Related Packages

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics