Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ViewController: UIViewController {
case .alias:
aliasEvent()
case .none:
print("Failed to establish event type")
analytics?.log(message: "Failed to establish event type", kind: .error)
}

clearAll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ extension LoginViewController: ASAuthorizationControllerDelegate {
analytics?.track(name: "Saved to Keychain")
} catch {
//handle error and optionally track it
print("Unable to save userId to keychain.")
analytics?.log(message: "Unable to save userId to keychain.", kind: .error)
}
}

Expand Down Expand Up @@ -140,7 +140,7 @@ extension LoginViewController: ASAuthorizationControllerDelegate {

func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) {
//handle error
print(error)
analytics?.log(message: error, king: .error)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ struct KeychainItem {
do {
try KeychainItem(service: "co.alancharles.SegmentExtensionsExample", account: "userIdentifier").deleteItem()
} catch {
print("Unable to delete userIdentifier from keychain")
analytics?.log(message: "Unable to delete userIdentifier from keychain", kind: .error)
}
}
}
2 changes: 1 addition & 1 deletion Examples/destination_plugins/AppsFlyerDestination.swift
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ extension AppsFlyerDestination: AppsFlyerLibDelegate {
extension AppsFlyerDestination: DeepLinkDelegate, UIApplicationDelegate {

func didResolveDeepLink(_ result: DeepLinkResult) {
print(result)
analytics?.log(message: "AppsFlyer Deeplink Result: \(result)")
switch result.status {
case .notFound:
analytics?.log(message: "AppsFlyer: Deep link not found")
Expand Down
7 changes: 3 additions & 4 deletions Examples/other_plugins/ConsoleLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,16 @@ class ConsoleLogger: Plugin {
// we want to log every event, so lets override `execute`.
func execute<T: RawEvent>(event: T?) -> T? {
if let json = event?.prettyPrint() {
print("event received on instance: \(name)")
print("\(json)\n")
analytics?.log(message: "event received on instance: \(name)")
analytics?.log(message: "\(json)\n")
}
return event
}

// we also want to know when settings are retrieved or changed.
func update(settings: Settings) {
let json = settings.prettyPrint()
print("settings updated on instance: \(name)")
print("\(json)\n")
analytics?.log(message: "settings updated on instance: \(name)\nPayload: \(json)")
}

}
2 changes: 1 addition & 1 deletion Examples/other_plugins/UIKitScreenTracking.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ extension UIViewController {
guard let top = Self.seg__visibleViewController(activeController()) else { return }

var name = String(describing: top.self.classForCoder).replacingOccurrences(of: "ViewController", with: "")
print(name)
analytics?.log(message: "Auto-tracking Screen: \(name)")
// name could've been just "ViewController"...
if name.count == 0 {
name = top.title ?? "Unknown"
Expand Down
24 changes: 20 additions & 4 deletions Segment.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@
46FE4D1D25A7A850003A7362 /* Storage_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46FE4D1C25A7A850003A7362 /* Storage_Tests.swift */; };
9620862C2575C0C800314F8D /* Events.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9620862B2575C0C800314F8D /* Events.swift */; };
96208650257AA83E00314F8D /* iOSLifecycleMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9620864F257AA83E00314F8D /* iOSLifecycleMonitor.swift */; };
96259F8326CEF526008AE301 /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96259F8226CEF526008AE301 /* Logger.swift */; };
96259F8626CF1D45008AE301 /* ConsoleTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96259F8526CF1D45008AE301 /* ConsoleTarget.swift */; };
966945D7259BDCDD00271339 /* HTTPClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967C40ED259A7311008EB0B6 /* HTTPClient.swift */; };
967C40DA258D472C008EB0B6 /* Logger_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967C40D9258D472C008EB0B6 /* Logger_Tests.swift */; };
967C40E3258D4DAF008EB0B6 /* Metrics_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 967C40E2258D4DAF008EB0B6 /* Metrics_Tests.swift */; };
9692724E25A4E5B7009B5298 /* Startup.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9692724D25A4E5B7009B5298 /* Startup.swift */; };
9692726825A583A6009B5298 /* SegmentDestination.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9692726725A583A6009B5298 /* SegmentDestination.swift */; };
96C33A9C25880A5E00F3D538 /* Logger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96C33A9B25880A5E00F3D538 /* Logger.swift */; };
96C33A9C25880A5E00F3D538 /* SegmentLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96C33A9B25880A5E00F3D538 /* SegmentLogger.swift */; };
96C33AAC25892D6D00F3D538 /* Metrics.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96C33AAB25892D6D00F3D538 /* Metrics.swift */; };
96C33AB1258961F500F3D538 /* Settings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96C33AB0258961F500F3D538 /* Settings.swift */; };
96DBF37B26F39B5500724B0B /* Timeline_Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 96DBF37A26F39B5500724B0B /* Timeline_Tests.swift */; };
Expand Down Expand Up @@ -144,13 +146,15 @@
9620862B2575C0C800314F8D /* Events.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Events.swift; sourceTree = "<group>"; };
962086482579CCC200314F8D /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
9620864F257AA83E00314F8D /* iOSLifecycleMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = iOSLifecycleMonitor.swift; sourceTree = "<group>"; };
96259F8226CEF526008AE301 /* Logger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = "<group>"; };
96259F8526CF1D45008AE301 /* ConsoleTarget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConsoleTarget.swift; sourceTree = "<group>"; };
9679DD6226EFF00800A6933C /* ExampleDestination.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExampleDestination.swift; sourceTree = "<group>"; };
967C40D9258D472C008EB0B6 /* Logger_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logger_Tests.swift; sourceTree = "<group>"; };
967C40E2258D4DAF008EB0B6 /* Metrics_Tests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Metrics_Tests.swift; sourceTree = "<group>"; };
967C40ED259A7311008EB0B6 /* HTTPClient.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HTTPClient.swift; sourceTree = "<group>"; };
9692724D25A4E5B7009B5298 /* Startup.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Startup.swift; sourceTree = "<group>"; };
9692726725A583A6009B5298 /* SegmentDestination.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SegmentDestination.swift; sourceTree = "<group>"; };
96C33A9B25880A5E00F3D538 /* Logger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Logger.swift; sourceTree = "<group>"; };
96C33A9B25880A5E00F3D538 /* SegmentLogger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SegmentLogger.swift; sourceTree = "<group>"; };
96C33AAB25892D6D00F3D538 /* Metrics.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Metrics.swift; sourceTree = "<group>"; };
96C33AB0258961F500F3D538 /* Settings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Settings.swift; sourceTree = "<group>"; };
96DBF37A26F39B5500724B0B /* Timeline_Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Timeline_Tests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -277,8 +281,8 @@
9620864E257AA82900314F8D /* Plugins */ = {
isa = PBXGroup;
children = (
96259F8426CEF534008AE301 /* Logger */,
969A533D25B0D510009227D9 /* Platforms */,
96C33A9B25880A5E00F3D538 /* Logger.swift */,
96C33AAB25892D6D00F3D538 /* Metrics.swift */,
46A018C125E5857D00F9CCD8 /* Context.swift */,
9692726725A583A6009B5298 /* SegmentDestination.swift */,
Expand All @@ -288,6 +292,16 @@
path = Plugins;
sourceTree = "<group>";
};
96259F8426CEF534008AE301 /* Logger */ = {
isa = PBXGroup;
children = (
96259F8226CEF526008AE301 /* Logger.swift */,
96C33A9B25880A5E00F3D538 /* SegmentLogger.swift */,
96259F8526CF1D45008AE301 /* ConsoleTarget.swift */,
);
path = Logger;
sourceTree = "<group>";
};
969A533D25B0D510009227D9 /* Platforms */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -521,6 +535,7 @@
4621080C2605332D00EBC4A8 /* KeyPath.swift in Sources */,
A31A16262576B6F200C9CDDF /* Timeline.swift in Sources */,
96C33AB1258961F500F3D538 /* Settings.swift in Sources */,
96259F8626CF1D45008AE301 /* ConsoleTarget.swift in Sources */,
46E382E72654429A00BA2502 /* Utils.swift in Sources */,
A31A16B225781CB400C9CDDF /* JSON.swift in Sources */,
46022771261F7A4800A9E913 /* Atomic.swift in Sources */,
Expand All @@ -535,12 +550,13 @@
4663C729267A799100ADDD1A /* QueueTimer.swift in Sources */,
46FE4C9C25A3F41C003A7362 /* LinuxLifecycleMonitor.swift in Sources */,
460227422612987300A9E913 /* watchOSLifecycleEvents.swift in Sources */,
96259F8326CEF526008AE301 /* Logger.swift in Sources */,
46F7485E26C718710042798E /* ObjCConfiguration.swift in Sources */,
A31A162F2576B73F00C9CDDF /* State.swift in Sources */,
9692726825A583A6009B5298 /* SegmentDestination.swift in Sources */,
4602276C261E7BF900A9E913 /* iOSDelegation.swift in Sources */,
46A018D425E6C9C200F9CCD8 /* LinuxUtils.swift in Sources */,
96C33A9C25880A5E00F3D538 /* Logger.swift in Sources */,
96C33A9C25880A5E00F3D538 /* SegmentLogger.swift in Sources */,
46FE4C9725A3F35E003A7362 /* macOSLifecycleMonitor.swift in Sources */,
9620862C2575C0C800314F8D /* Events.swift in Sources */,
A3AEE1882581A8F1002386EB /* Deprecations.swift in Sources */,
Expand Down
78 changes: 0 additions & 78 deletions Sources/Segment/Plugins/Logger.swift

This file was deleted.

18 changes: 18 additions & 0 deletions Sources/Segment/Plugins/Logger/ConsoleTarget.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// ConsoleTarget.swift
// ConsoleTarget
//
// Created by Cody Garvin on 8/19/21.
//

import Foundation

class ConsoleTarget: LogTarget {
func parseLog(_ log: LogMessage) {
var metadata = ""
if let function = log.function, let line = log.line {
metadata = " - \(function):\(line)"
}
print("[Segment \(log.kind.toString())\(metadata)]\n\(log.message)\n")
}
}
Loading