-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFacebookAnalyticsManager.swift
More file actions
54 lines (43 loc) · 1.74 KB
/
FacebookAnalyticsManager.swift
File metadata and controls
54 lines (43 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//
// FacebookAnalyticsManager.swift
// swc
//
// Created by Arsen Gasparyan on 06/03/16.
// Copyright © 2016 SweatCo LTD. All rights reserved.
//
import UIKit
class FacebookAnalyticsManager: NSObject, AnalyticsProtocol {
func appDidBecomeActive() {
FBSDKAppEvents.activateApp()
FBSDKAppEvents.setFlushBehavior(.auto)
}
func app(_ app: UIApplication, launchedWithOptions launchOptions: [AnyHashable: Any]) {
FBSDKApplicationDelegate.sharedInstance().application(app, didFinishLaunchingWithOptions: launchOptions)
}
func appDidEnterBackground() {
FBSDKAppEvents.setFlushBehavior(.explicitOnly)
}
func set(profile: Profile) {}
func removeProfile() {}
func addUserProperty(_ key: String, value: NSObject) { }
func addUserPropertyOnce(_ key: String, value: NSObject) { }
func log(event: String, params: [String: String], outOfSession: Bool) {
var parameters = params
parameters["Title"] = event
FBSDKAppEvents.logEvent("Button Pressed", parameters: parameters)
}
func log(screen: String, params: [String: String]) {
var parameters = params
parameters["Title"] = screen
FBSDKAppEvents.logEvent("Screen Shown", parameters: parameters)
}
func log(revenue: Double, product: String, contentType: String) {
FBSDKAppEvents.logPurchase(Double(revenue), currency: "SWC", parameters:
[FBSDKAppEventParameterNameContentType: contentType,
FBSDKAppEventParameterNameContentID: product])
}
func log(event: AnalyticsEvents) {
let name = event.key.replacingOccurrences(of: ".", with: "_")
FBSDKAppEvents.logEvent(name, parameters: event.params)
}
}