Giter Site home page Giter Site logo

journey's Introduction

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.

journey's People

Contributors

hengyu avatar

Watchers

James Cloos avatar  avatar  avatar

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.