-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add class and file placeholders
- Loading branch information
1 parent
9978db8
commit d824cf1
Showing
16 changed files
with
704 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
public class Amplitude { | ||
var configuration: Configuration | ||
var instanceName: String | ||
init(configuration: Configuration, instanceName: String = "default") { | ||
self.configuration = configuration | ||
self.instanceName = instanceName | ||
} | ||
|
||
func getInstance(instsanceName: String) -> Amplitude { | ||
return self | ||
} | ||
|
||
func track() -> Amplitude { | ||
return self | ||
} | ||
|
||
func logEvent() -> Amplitude { | ||
return self | ||
} | ||
|
||
func identify(type: String) -> Amplitude { | ||
return self | ||
} | ||
|
||
func identify() -> Amplitude { | ||
return self | ||
} | ||
|
||
func groupIdentify() -> Amplitude { | ||
return self | ||
} | ||
|
||
func groupIdentify(groupType: String, groupName: String, groupProperties: [String: Any], options: [String: Any]) -> Amplitude { | ||
return self | ||
} | ||
|
||
func logRevenue() -> Amplitude { | ||
return self | ||
} | ||
|
||
func revenue() -> Amplitude { | ||
return self | ||
} | ||
|
||
func add(plugin: Plugin) -> Amplitude { | ||
return self | ||
} | ||
|
||
func remove(plugin: Plugin) -> Amplitude { | ||
return self | ||
} | ||
|
||
func flush() -> Amplitude { | ||
return self | ||
} | ||
|
||
func setUserId(userId: String) -> Amplitude { | ||
return self | ||
} | ||
|
||
func setDeviceId(deviceId: String) -> Amplitude { | ||
return self | ||
} | ||
|
||
func reset() -> Amplitude { | ||
return self | ||
} | ||
} | ||
|
||
func amplitude(apiKey: String, configs: Configuration) -> Amplitude { | ||
return Amplitude(configuration: Configuration(flushQueueSize: <#Int#>, flushIntervalMillis: <#Int#>, instanceName: <#String#>, optOut: <#Bool#>, storageProvider: <#Storage#>, logLvel: <#LogLevelEnum#>, loggerProvider: <#Logger#>, flushMaxRetries: <#Int#>, useBatch: <#Bool#>, serverZone: <#ServerZone#>), instanceName: "default") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Marvin Liu on 10/27/22. | ||
// | ||
|
||
import Foundation | ||
|
||
public class Configuration { | ||
var flushQueueSize: Int = 30 | ||
var flushIntervalMillis: Int = 30 * 1000 | ||
var instanceName: String = "default" | ||
var optOut: Bool = false | ||
var storageProvider: Storage = CoreDataStorage() | ||
var logLvel: LogLevelEnum = LogLevelEnum.WARN | ||
var loggerProvider: any Logger = ConsoleLogger() | ||
var minIdLength: Int? | ||
var partnerId: String? | ||
var callback: EventCallBack? | ||
var flushMaxRetries: Int = 5 | ||
var useBatch: Bool = false | ||
var serverZone: ServerZone = ServerZone.US | ||
var serverUrl: String? | ||
var plan: Plan? | ||
var ingestionMetadata: IngestionMetadata? | ||
var trackingOptions: TrackingOptions? | ||
|
||
init(flushQueueSize: Int, flushIntervalMillis: Int, instanceName: String, optOut: Bool, storageProvider: Storage, logLvel: LogLevelEnum, loggerProvider: any Logger, minIdLength: Int? = nil, partnerId: String? = nil, callback: EventCallBack? = nil, flushMaxRetries: Int, useBatch: Bool, serverZone: ServerZone, serverUrl: String? = nil, plan: Plan? = nil, ingestionMetadata: IngestionMetadata? = nil) { | ||
self.flushQueueSize = flushQueueSize | ||
self.flushIntervalMillis = flushIntervalMillis | ||
self.instanceName = instanceName | ||
self.optOut = optOut | ||
self.storageProvider = storageProvider | ||
self.logLvel = logLvel | ||
self.loggerProvider = loggerProvider | ||
self.minIdLength = minIdLength | ||
self.partnerId = partnerId | ||
self.callback = callback | ||
self.flushMaxRetries = flushMaxRetries | ||
self.useBatch = useBatch | ||
self.serverZone = serverZone | ||
self.serverUrl = serverUrl | ||
self.plan = plan | ||
self.ingestionMetadata = ingestionMetadata | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Marvin Liu on 10/27/22. | ||
// | ||
|
||
import Foundation | ||
|
||
enum LogLevelEnum: Int { | ||
case DEBUG | ||
case LOG | ||
case WARN | ||
case ERROR | ||
case OFF | ||
} | ||
|
||
enum ServerZone: String { | ||
case US = "US" | ||
case EU = "EU" | ||
} | ||
|
||
public struct Constants { | ||
let SDK_LIBRARY = "amplitude-swift" | ||
let DEFAULT_API_HOST = "https://api2.amplitude.com/2/httpapi" | ||
let EU_DEFAULT_API_HOST = "https://api.eu.amplitude.com/2/httpapi" | ||
let BATCH_API_HOST = "https://api2.amplitude.com/batch" | ||
let EU_BATCH_API_HOST = "https://api.eu.amplitude.com/batch" | ||
let IDENTIFY_EVENT = "$identify" | ||
let GROUP_IDENTIFY_EVENT = "$groupidentify" | ||
let AMP_REVENUE_EVENT = "revenue_amount" | ||
let MAX_PROPERTY_KEYS = 1024 | ||
let MAX_STRING_LENGTH = 1024 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Marvin Liu on 10/27/22. | ||
// | ||
|
||
import Foundation | ||
|
||
struct Event { | ||
var eventType: String | ||
var eventProperties: [String: Any]? = nil | ||
var userProperties: [String: Any]? = nil | ||
var groups: [String: Any]? = nil | ||
var groupProperties: [String: Any]? = nil | ||
} | ||
|
||
enum EventChannel { | ||
|
||
} | ||
|
||
protocol EventReceiver { | ||
func receive(channel: EventChannel, event: Event) | ||
} | ||
|
||
|
||
protocol EventBridgable { | ||
func sendEvent(channel: EventChannel, event: Event) | ||
func setReceiver(channel: EventChannel, receiver: EventReceiver) | ||
} | ||
|
||
class EventBridge: EventBridgable { | ||
func sendEvent(channel: EventChannel, event: Event) { | ||
<#code#> | ||
} | ||
|
||
func setReceiver(channel: EventChannel, receiver: EventReceiver) { | ||
<#code#> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Marvin Liu on 10/28/22. | ||
// | ||
|
||
import Foundation | ||
|
||
class ConsoleLogger: Logger { | ||
typealias LogLevel = LogLevelEnum | ||
|
||
var logLevel: Int? | ||
|
||
func error(message: String) { | ||
<#code#> | ||
} | ||
|
||
func warn(message: String) { | ||
<#code#> | ||
} | ||
|
||
func log(message: String) { | ||
<#code#> | ||
} | ||
|
||
func debug(message: String) { | ||
<#code#> | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
Sources/Amplitude/Plugins/AmplitudeDestinationPlugin.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Marvin Liu on 10/27/22. | ||
// | ||
|
||
import Foundation | ||
|
||
public class AmplitudeDestinationPlugin: Plugin { | ||
public var type: PluginType = PluginType.Destination | ||
|
||
public var amplitude: Amplitude? | ||
|
||
public func setup(amplitude: Amplitude) { | ||
<#code#> | ||
} | ||
|
||
public func execute(event: BaseEvent) -> BaseEvent? { | ||
<#code#> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Marvin Liu on 10/28/22. | ||
// | ||
|
||
import Foundation | ||
|
||
class ContextPlugin: Plugin { | ||
var type: PluginType = PluginType.Before | ||
|
||
var amplitude: Amplitude? | ||
|
||
func setup(amplitude: Amplitude) { | ||
<#code#> | ||
} | ||
|
||
func execute(event: BaseEvent) -> BaseEvent? { | ||
<#code#> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Marvin Liu on 10/28/22. | ||
// | ||
|
||
import Foundation | ||
|
||
class CoreDataStorage: Storage { | ||
func set(key: String, value: String) async { | ||
<#code#> | ||
} | ||
|
||
func get(key: String) async -> String? { | ||
<#code#> | ||
} | ||
|
||
func saveEvent(event: BaseEvent) async { | ||
<#code#> | ||
} | ||
|
||
func getEvents() async -> [Any]? { | ||
<#code#> | ||
} | ||
|
||
func reset() async { | ||
<#code#> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Marvin Liu on 10/28/22. | ||
// | ||
|
||
import Foundation | ||
|
||
class InMemoryStorage: Storage { | ||
func set(key: String, value: String) async { | ||
<#code#> | ||
} | ||
|
||
func get(key: String) async -> String? { | ||
<#code#> | ||
} | ||
|
||
func saveEvent(event: BaseEvent) async { | ||
<#code#> | ||
} | ||
|
||
func getEvents() async -> [Any]? { | ||
<#code#> | ||
} | ||
|
||
func reset() async { | ||
<#code#> | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Marvin Liu on 10/27/22. | ||
// | ||
|
||
import Foundation | ||
|
||
public class Timeline { | ||
var plugins = [PluginType: [any Plugin]]() | ||
|
||
init() { | ||
|
||
} | ||
|
||
func process(event: BaseEvent) { | ||
|
||
} | ||
|
||
func add(plugin: Plugin) { | ||
|
||
} | ||
|
||
func remove(plugin: Plugin) { | ||
|
||
} | ||
|
||
func apply(event: BaseEvent) -> BaseEvent? { | ||
|
||
} | ||
} |
Oops, something went wrong.