Skip to content

Commit eccee01

Browse files
Merge pull request #192 from cuappdev/matt/analytics
Analytics + Debug Server
2 parents c26869a + b4a9f09 commit eccee01

7 files changed

Lines changed: 54 additions & 9 deletions

File tree

Siri/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
<key>CFBundlePackageType</key>
1818
<string>XPC!</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>1.2</string>
20+
<string>1.2.2</string>
2121
<key>CFBundleVersion</key>
22-
<string>67</string>
22+
<string>68</string>
2323
<key>NSExtension</key>
2424
<dict>
2525
<key>NSExtensionAttributes</key>

TCAT.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
BF8460AD2172B0F80027FB62 /* SFUIText-Medium.otf in Resources */ = {isa = PBXBuildFile; fileRef = BF8460A92172B0F70027FB62 /* SFUIText-Medium.otf */; };
5555
BF8460AE2172B0F80027FB62 /* SFUIText-Bold.otf in Resources */ = {isa = PBXBuildFile; fileRef = BF8460AA2172B0F80027FB62 /* SFUIText-Bold.otf */; };
5656
BF8460AF2172B0F80027FB62 /* SFUIText-Regular.otf in Resources */ = {isa = PBXBuildFile; fileRef = BF8460AB2172B0F80027FB62 /* SFUIText-Regular.otf */; };
57+
BF8AF5F32206BBF60091AB8C /* Utilities.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8AF5F22206BBF60091AB8C /* Utilities.swift */; };
5758
BFA53FEE1FD45D7000E770DF /* RouteDetailViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFA53FED1FD45D7000E770DF /* RouteDetailViewController.swift */; };
5859
BFB86A07205C614C000794B2 /* OnboardingViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = BFB86A06205C614C000794B2 /* OnboardingViewController.swift */; };
5960
BFC367F321B66E9A00ABD9AC /* Intents.intentdefinition in Sources */ = {isa = PBXBuildFile; fileRef = BFC367F621B66E9A00ABD9AC /* Intents.intentdefinition */; };
@@ -198,6 +199,7 @@
198199
BF8460A92172B0F70027FB62 /* SFUIText-Medium.otf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "SFUIText-Medium.otf"; path = "Supporting Files/Fonts/SFUIText-Medium.otf"; sourceTree = "<group>"; };
199200
BF8460AA2172B0F80027FB62 /* SFUIText-Bold.otf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "SFUIText-Bold.otf"; path = "Supporting Files/Fonts/SFUIText-Bold.otf"; sourceTree = "<group>"; };
200201
BF8460AB2172B0F80027FB62 /* SFUIText-Regular.otf */ = {isa = PBXFileReference; lastKnownFileType = file; name = "SFUIText-Regular.otf"; path = "Supporting Files/Fonts/SFUIText-Regular.otf"; sourceTree = "<group>"; };
202+
BF8AF5F22206BBF60091AB8C /* Utilities.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Utilities.swift; path = Utilities/Utilities.swift; sourceTree = "<group>"; };
201203
BFA53FED1FD45D7000E770DF /* RouteDetailViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = RouteDetailViewController.swift; path = Controllers/RouteDetailViewController.swift; sourceTree = "<group>"; };
202204
BFB86A06205C614C000794B2 /* OnboardingViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = OnboardingViewController.swift; path = Controllers/OnboardingViewController.swift; sourceTree = "<group>"; };
203205
BFC367F521B66E9A00ABD9AC /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.intentdefinition; name = Base; path = Base.lproj/Intents.intentdefinition; sourceTree = "<group>"; };
@@ -315,6 +317,7 @@
315317
isa = PBXGroup;
316318
children = (
317319
2292486721B891A30004279C /* Endpoints.swift */,
320+
BF8AF5F22206BBF60091AB8C /* Utilities.swift */,
318321
2292486821B891A30004279C /* Models.swift */,
319322
DD3D9C201F94297100B164D4 /* Reachability.swift */,
320323
);
@@ -877,6 +880,7 @@
877880
DDB49C9D1E8857FC00A99C35 /* BusPath.swift in Sources */,
878881
DD659C8A20508E1B00506BAC /* WalkWithDistanceIcon.swift in Sources */,
879882
DD36A7001F66378C00E4789E /* PlaceResult.swift in Sources */,
883+
BF8AF5F32206BBF60091AB8C /* Utilities.swift in Sources */,
880884
BF73F0F31F60B0BD003B479D /* LocationObject.swift in Sources */,
881885
BFF41EB2204365E800E0696B /* SummaryView.swift in Sources */,
882886
DDB49CA21E88584B00A99C35 /* DetailIconView.swift in Sources */,

TCAT/Controllers/RouteOptionsViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -921,8 +921,8 @@ extension RouteOptionsViewController: UITableViewDelegate {
921921
if let routeDetailViewController = createRouteDetailViewController(from: indexPath) {
922922
let payload = RouteResultsCellTappedEventPayload()
923923
Analytics.shared.log(payload)
924-
// // MARK: #182 • Place routeSelected Analytics here.
925-
// let tripId = routes[indexPath.row].id
924+
let routeId = routes[indexPath.row].routeId
925+
Network.routeSelected(routeId: routeId)
926926
navigationController?.pushViewController(routeDetailViewController, animated: true)
927927
}
928928
}

TCAT/Model/Route.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ class Route: NSObject, Codable {
5151

5252
/// The time a user arrives at their destination.
5353
var arrivalTime: Date
54+
55+
/// A unique identifier for the route
56+
var routeId: String
5457

5558
/// The amount of time from now until the departure
5659
var timeUntilDeparture: DateComponents {
@@ -99,14 +102,14 @@ class Route: NSObject, Codable {
99102
case boundingBox
100103
case numberOfTransfers
101104
case directions
105+
case routeId
102106
}
103107

104108
required init(from decoder: Decoder) throws {
105-
106-
// MARK: #182 • Get Route ID
107109
let container = try decoder.container(keyedBy: CodingKeys.self)
108110
departureTime = Date.parseDate(try container.decode(String.self, forKey: .departureTime))
109111
arrivalTime = Date.parseDate(try container.decode(String.self, forKey: .arrivalTime))
112+
routeId = try container.decode(String.self, forKey: .routeId)
110113
startCoords = try container.decode(CLLocationCoordinate2D.self, forKey: .startCoords)
111114
endCoords = try container.decode(CLLocationCoordinate2D.self, forKey: .endCoords)
112115
boundingBox = try container.decode(Bounds.self, forKey: .boundingBox)

TCAT/Supporting Files/Info.plist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<key>CFBundlePackageType</key>
1818
<string>APPL</string>
1919
<key>CFBundleShortVersionString</key>
20-
<string>1.2</string>
20+
<string>1.2.2</string>
2121
<key>CFBundleSignature</key>
2222
<string>????</string>
2323
<key>CFBundleURLTypes</key>
@@ -32,7 +32,7 @@
3232
</dict>
3333
</array>
3434
<key>CFBundleVersion</key>
35-
<string>67</string>
35+
<string>68</string>
3636
<key>ITSAppUsesNonExemptEncryption</key>
3737
<false/>
3838
<key>LSApplicationQueriesSchemes</key>

TCAT/Utilities/Endpoints.swift

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class Network {
3333
static let localSource = "http://\(localIPAddress):3000/api/\(apiVersion)/"
3434

3535
/// Test server used for development
36-
static let debugIPAddress = "34.238.157.63"
36+
static let debugIPAddress = "157.230.66.192"
3737
static let debugSource = "http://\(debugIPAddress)/api/\(apiVersion)/"
3838

3939
/// Deployed server instance used for release
@@ -42,6 +42,9 @@ class Network {
4242

4343
/// Network IP address being used for specified networkType
4444
static var ipAddress: String {
45+
if isTestFlight() {
46+
return debugIPAddress
47+
}
4548
switch networkType {
4649
case .local: return localIPAddress
4750
case .debug: return debugIPAddress
@@ -51,6 +54,9 @@ class Network {
5154

5255
/// Network source currently being used
5356
static var address: String {
57+
if isTestFlight() {
58+
return debugSource
59+
}
5460
switch networkType {
5561
case .local: return localSource
5662
case .debug: return debugSource
@@ -143,6 +149,21 @@ class Network {
143149
]
144150
return request
145151
}
152+
153+
@discardableResult
154+
class func routeSelected(routeId: String) -> APIRequest<JSON, Error> {
155+
let request: APIRequest<JSON, Error> = tron.swiftyJSON.request("routeSelected")
156+
request.method = .post
157+
request.parameterEncoding = JSONEncoding.default
158+
request.parameters = ["routeId" : routeId]
159+
160+
// Add unique identifier to request
161+
if let uid = userDefaults.string(forKey: Constants.UserDefaults.uid) {
162+
request.parameters["uid"] = uid
163+
}
164+
165+
return request
166+
}
146167

147168
class func getBusLocations(_ directions: [Direction]) -> APIRequest<BusLocationRequest, Error> {
148169
let request: APIRequest<BusLocationRequest, Error> = tron.codable.request("tracking")

TCAT/Utilities/Utilities.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
//
2+
// Network+Utilities.swift
3+
// TCAT
4+
//
5+
// Created by Matt Barker on 2/3/19.
6+
// Copyright © 2019 cuappdev. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
func isTestFlight() -> Bool {
12+
let sandboxString = "sandboxReceipt"
13+
guard let appStoreReceiptURL = Bundle.main.appStoreReceiptURL else {
14+
return false
15+
}
16+
return appStoreReceiptURL.lastPathComponent == sandboxString
17+
}

0 commit comments

Comments
 (0)