Skip to content

Commit

Permalink
Merge pull request #99 from apivideo/analytics-updates
Browse files Browse the repository at this point in the history
Analytics updates
  • Loading branch information
bot-api-video authored Nov 6, 2024
2 parents 19d9474 + 8a9856d commit 630c1a6
Show file tree
Hide file tree
Showing 30 changed files with 295 additions and 87 deletions.
2 changes: 1 addition & 1 deletion .openapi-generator/oas_apivideo.yaml-defaut-cli.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3c9f9d1c48428c25a16b809ddeab072c978d6d1c689903a76e3d66a69a36a233
589578120105165c9f58683fbe2fb917dabfaf9392187865f30956f8e4964d5a
4 changes: 2 additions & 2 deletions ApiVideoClient.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Pod::Spec.new do |s|
s.tvos.deployment_target = '10.0'
# Add back when CocoaPods/CocoaPods#11558 is released
#s.watchos.deployment_target = '3.0'
s.version = '1.3.5'
s.source = { :git => 'https://github.com/apivideo/api.video-swift-client', :tag => 'v1.3.5' }
s.version = '1.3.6'
s.source = { :git => 'https://github.com/apivideo/api.video-swift-client', :tag => 'v1.3.6' }
s.authors = { 'Ecosystem Team' => '[email protected]' }
s.license = { :type => 'MIT' }
s.homepage = 'https://docs.api.video'
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Changelog
All changes to this project will be documented in this file.

## [1.3.6] - 2024-11-04
- Analytics updates (ccv, views, ...)

## [1.3.5] - 2024-10-21
- Add summary feature
- Add support for Alamofire 5.10
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ api.video's Swift API client for iOS, macOS and tvOS streamlines the coding proc
Specify it in your `Cartfile`:

```
github "apivideo/api.video-swift-client" ~> 1.3.5
github "apivideo/api.video-swift-client" ~> 1.3.6
```

Run `carthage update`

#### CocoaPods

Add `pod 'ApiVideoClient', '1.3.5'` in your `Podfile`
Add `pod 'ApiVideoClient', '1.3.6'` in your `Podfile`

Run `pod install`

Expand Down
2 changes: 1 addition & 1 deletion Sources/APIs.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Foundation
public class ApiVideoClient {
public static var apiKey: String? = nil
public static var basePath = "https://ws.api.video"
internal static var customHeaders:[String: String] = ["AV-Origin-Client": "swift:1.3.5"]
internal static var customHeaders:[String: String] = ["AV-Origin-Client": "swift:1.3.6"]
private static var chunkSize: Int = 50 * 1024 * 1024
internal static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory()
internal static var credential = ApiVideoCredential()
Expand Down
150 changes: 108 additions & 42 deletions Sources/APIs/AnalyticsAPI.swift

Large diffs are not rendered by default.

13 changes: 12 additions & 1 deletion Sources/Models/AnalyticsAggregatedMetricsResponseContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ public struct AnalyticsAggregatedMetricsResponseContext: Codable, Hashable {
case impression = "impression"
case impressionTime = "impression-time"
case watchTime = "watch-time"
case ccv = "ccv"
case uniqueCcv = "unique-ccv"
case view3 = "view-3"
case view5 = "view-5"
case view10 = "view-10"
case view30 = "view-30"
case uniqueView = "unique-view"
case uniqueView3 = "unique-view-3"
case uniqueView5 = "unique-view-5"
case uniqueView10 = "unique-view-10"
case uniqueView30 = "unique-view-30"
}
public enum Aggregation: String, Codable, CaseIterable {
case count = "count"
Expand All @@ -27,7 +38,7 @@ public struct AnalyticsAggregatedMetricsResponseContext: Codable, Hashable {
case average = "average"
case sum = "sum"
}
/** Returns the metric you selected. */
/** Returns the metric and relevant parameters you selected. */
public var metric: Metric?
/** Returns the aggregation you selected. */
public var aggregation: Aggregation?
Expand Down
15 changes: 14 additions & 1 deletion Sources/Models/AnalyticsMetricsBreakdownResponseContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,19 @@ public struct AnalyticsMetricsBreakdownResponseContext: Codable, Hashable {
case start = "start"
case end = "end"
case impression = "impression"
case ccvAverage = "ccv-average"
case ccvPeak = "ccv-peak"
case uniqueCcvAverage = "unique-ccv-average"
case uniqueCcvPeak = "unique-ccv-peak"
case view3 = "view-3"
case view5 = "view-5"
case view10 = "view-10"
case view30 = "view-30"
case uniqueView = "unique-view"
case uniqueView3 = "unique-view-3"
case uniqueView5 = "unique-view-5"
case uniqueView10 = "unique-view-10"
case uniqueView30 = "unique-view-30"
}
public enum Breakdown: String, Codable, CaseIterable {
case mediaId = "media-id"
Expand All @@ -28,7 +41,7 @@ public struct AnalyticsMetricsBreakdownResponseContext: Codable, Hashable {
case operatingSystem = "operating-system"
case browser = "browser"
}
/** Returns the metric you selected. */
/** Returns the metric and relevant parameters you selected. */
public var metric: Metric?
/** Returns the dimension you selected. */
public var breakdown: Breakdown?
Expand Down
2 changes: 1 addition & 1 deletion Sources/Models/AnalyticsMetricsOverTimeResponse.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import AnyCodable
public struct AnalyticsMetricsOverTimeResponse: Codable, Hashable {

public var context: AnalyticsMetricsOverTimeResponseContext
/** Returns an array of metrics and the timestamps . */
/** Returns an array of metrics and the timestamps. */
public var data: [AnalyticsMetricsOverTimeResponseData]
public var pagination: Pagination

Expand Down
16 changes: 15 additions & 1 deletion Sources/Models/AnalyticsMetricsOverTimeResponseContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,26 @@ public struct AnalyticsMetricsOverTimeResponseContext: Codable, Hashable {
case start = "start"
case end = "end"
case impression = "impression"
case ccvAverage = "ccv-average"
case ccvPeak = "ccv-peak"
case uniqueCcvAverage = "unique-ccv-average"
case uniqueCcvPeak = "unique-ccv-peak"
case view3 = "view-3"
case view5 = "view-5"
case view10 = "view-10"
case view30 = "view-30"
case uniqueView = "unique-view"
case uniqueView3 = "unique-view-3"
case uniqueView5 = "unique-view-5"
case uniqueView10 = "unique-view-10"
case uniqueView30 = "unique-view-30"
}
public enum Interval: String, Codable, CaseIterable {
case minute = "minute"
case hour = "hour"
case day = "day"
}
/** Returns the metric you selected. */
/** Returns the metric and relevant parameters you selected. */
public var metric: Metric?
/** Returns the interval you selected. */
public var interval: Interval?
Expand Down
12 changes: 11 additions & 1 deletion Sources/Models/FilterBy.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ public struct FilterBy: Codable, Hashable {
public var browser: [String]?
/** Returns analytics for videos using this tag. This filter only accepts a single value and is case sensitive. Read more about tagging your videos [here](https://docs.api.video/vod/tags-metadata). */
public var tag: String?
/** Filters data based on the URL where the view is originating from. This filter parameter accepts an empty string to filter view events where no referrer is available. - The API filters for exact matches. Include the trailing `/` characters if needed. - The URLs you add must be URL encoded. */
public var referrer: [String]?

public init(mediaId: [String]? = nil, mediaType: MediaType? = nil, continent: [Continent]? = nil, country: [String]? = nil, deviceType: [String]? = nil, operatingSystem: [String]? = nil, browser: [String]? = nil, tag: String? = nil) {
public init(mediaId: [String]? = nil, mediaType: MediaType? = nil, continent: [Continent]? = nil, country: [String]? = nil, deviceType: [String]? = nil, operatingSystem: [String]? = nil, browser: [String]? = nil, tag: String? = nil, referrer: [String]? = nil) {
self.mediaId = mediaId
self.mediaType = mediaType
self.continent = continent
Expand All @@ -50,6 +52,7 @@ public struct FilterBy: Codable, Hashable {
self.operatingSystem = operatingSystem
self.browser = browser
self.tag = tag
self.referrer = referrer
}

public enum CodingKeys: String, CodingKey, CaseIterable {
Expand All @@ -61,6 +64,7 @@ public struct FilterBy: Codable, Hashable {
case operatingSystem
case browser
case tag
case referrer
}

public func encodeToQueryParams() -> [URLQueryItem] {
Expand Down Expand Up @@ -102,6 +106,11 @@ public struct FilterBy: Codable, Hashable {
if let tag = tag {
queryItems.append(URLQueryItem(name: "filterBy[tag]", value: tag))
}
if let referrer = referrer, !referrer.isEmpty {
for (index, val) in referrer.enumerated() {
queryItems.append(URLQueryItem(name: "filterBy[referrer][\(index)]", value: val))
}
}

return queryItems
}
Expand All @@ -117,6 +126,7 @@ public struct FilterBy: Codable, Hashable {
try container.encodeIfPresent(operatingSystem, forKey: .operatingSystem)
try container.encodeIfPresent(browser, forKey: .browser)
try container.encodeIfPresent(tag, forKey: .tag)
try container.encodeIfPresent(referrer, forKey: .referrer)
}
}

12 changes: 11 additions & 1 deletion Sources/Models/FilterBy1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ public struct FilterBy1: Codable, Hashable {
public var browser: [String]?
/** Returns analytics for videos using this tag. This filter only accepts a single value and is case sensitive. Read more about tagging your videos [here](https://docs.api.video/vod/tags-metadata). */
public var tag: String?
/** Filters data based on the URL where the view is originating from. This filter parameter accepts an empty string to filter view events where no referrer is available. - The API filters for exact matches. Include the trailing `/` characters if needed. - The URLs you add must be URL encoded. */
public var referrer: [String]?

public init(mediaId: [String]? = nil, mediaType: MediaType? = nil, continent: [Continent]? = nil, country: [String]? = nil, deviceType: [String]? = nil, operatingSystem: [String]? = nil, browser: [String]? = nil, tag: String? = nil) {
public init(mediaId: [String]? = nil, mediaType: MediaType? = nil, continent: [Continent]? = nil, country: [String]? = nil, deviceType: [String]? = nil, operatingSystem: [String]? = nil, browser: [String]? = nil, tag: String? = nil, referrer: [String]? = nil) {
self.mediaId = mediaId
self.mediaType = mediaType
self.continent = continent
Expand All @@ -50,6 +52,7 @@ public struct FilterBy1: Codable, Hashable {
self.operatingSystem = operatingSystem
self.browser = browser
self.tag = tag
self.referrer = referrer
}

public enum CodingKeys: String, CodingKey, CaseIterable {
Expand All @@ -61,6 +64,7 @@ public struct FilterBy1: Codable, Hashable {
case operatingSystem
case browser
case tag
case referrer
}

public func encodeToQueryParams() -> [URLQueryItem] {
Expand Down Expand Up @@ -102,6 +106,11 @@ public struct FilterBy1: Codable, Hashable {
if let tag = tag {
queryItems.append(URLQueryItem(name: "filterBy[tag]", value: tag))
}
if let referrer = referrer, !referrer.isEmpty {
for (index, val) in referrer.enumerated() {
queryItems.append(URLQueryItem(name: "filterBy[referrer][\(index)]", value: val))
}
}

return queryItems
}
Expand All @@ -117,6 +126,7 @@ public struct FilterBy1: Codable, Hashable {
try container.encodeIfPresent(operatingSystem, forKey: .operatingSystem)
try container.encodeIfPresent(browser, forKey: .browser)
try container.encodeIfPresent(tag, forKey: .tag)
try container.encodeIfPresent(referrer, forKey: .referrer)
}
}

12 changes: 11 additions & 1 deletion Sources/Models/FilterBy2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ public struct FilterBy2: Codable, Hashable {
public var browser: [String]?
/** Returns analytics for videos using this tag. This filter only accepts a single value and is case sensitive. Read more about tagging your videos [here](https://docs.api.video/vod/tags-metadata). */
public var tag: String?
/** Filters data based on the URL where the view is originating from. This filter parameter accepts an empty string to filter view events where no referrer is available. - The API filters for exact matches. Include the trailing `/` characters if needed. - The URLs you add must be URL encoded. */
public var referrer: [String]?

public init(mediaId: [String]? = nil, mediaType: MediaType? = nil, continent: [Continent]? = nil, country: [String]? = nil, deviceType: [String]? = nil, operatingSystem: [String]? = nil, browser: [String]? = nil, tag: String? = nil) {
public init(mediaId: [String]? = nil, mediaType: MediaType? = nil, continent: [Continent]? = nil, country: [String]? = nil, deviceType: [String]? = nil, operatingSystem: [String]? = nil, browser: [String]? = nil, tag: String? = nil, referrer: [String]? = nil) {
self.mediaId = mediaId
self.mediaType = mediaType
self.continent = continent
Expand All @@ -50,6 +52,7 @@ public struct FilterBy2: Codable, Hashable {
self.operatingSystem = operatingSystem
self.browser = browser
self.tag = tag
self.referrer = referrer
}

public enum CodingKeys: String, CodingKey, CaseIterable {
Expand All @@ -61,6 +64,7 @@ public struct FilterBy2: Codable, Hashable {
case operatingSystem
case browser
case tag
case referrer
}

public func encodeToQueryParams() -> [URLQueryItem] {
Expand Down Expand Up @@ -102,6 +106,11 @@ public struct FilterBy2: Codable, Hashable {
if let tag = tag {
queryItems.append(URLQueryItem(name: "filterBy[tag]", value: tag))
}
if let referrer = referrer, !referrer.isEmpty {
for (index, val) in referrer.enumerated() {
queryItems.append(URLQueryItem(name: "filterBy[referrer][\(index)]", value: val))
}
}

return queryItems
}
Expand All @@ -117,6 +126,7 @@ public struct FilterBy2: Codable, Hashable {
try container.encodeIfPresent(operatingSystem, forKey: .operatingSystem)
try container.encodeIfPresent(browser, forKey: .browser)
try container.encodeIfPresent(tag, forKey: .tag)
try container.encodeIfPresent(referrer, forKey: .referrer)
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type" : "https://docs.api.video/reference/request-invalid-query-parameter",
"title" : "A query parameter is invalid.",
"status" : 400,
"detail" : "This value should not contain more than 2048 characters.",
"name" : "filterBy[referrer]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type" : "https://docs.api.video/reference/request-invalid-query-parameter",
"title" : "A query parameter is invalid.",
"status" : 400,
"detail" : "This view duration is invalid. Use one of \"3s\", \"5s\", \"10s\", \"30s\".",
"name" : "viewDuration"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type" : "https://docs.api.video/reference/request-invalid-query-parameter",
"title" : "A query parameter is invalid.",
"status" : 400,
"detail" : "This value should not contain more than 2048 characters.",
"name" : "filterBy[referrer]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type" : "https://docs.api.video/reference/request-invalid-query-parameter",
"title" : "A query parameter is invalid.",
"status" : 400,
"detail" : "This view duration is invalid. Use one of \"3s\", \"5s\", \"10s\", \"30s\".",
"name" : "viewDuration"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type" : "https://docs.api.video/reference/request-invalid-query-parameter",
"title" : "A query parameter is invalid.",
"status" : 400,
"detail" : "This interval is invalid. Use one of \"minute\", \"hour\", \"day\".",
"name" : "interval"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type" : "https://docs.api.video/reference/request-invalid-query-parameter",
"title" : "A query parameter is invalid.",
"status" : 400,
"detail" : "This interval cannot be used with a timeframe over 60 minutes.",
"name" : "interval"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type" : "https://docs.api.video/reference/request-invalid-query-parameter",
"title" : "A query parameter is invalid.",
"status" : 400,
"detail" : "This value should not contain more than 2048 characters.",
"name" : "filterBy[referrer]"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type" : "https://docs.api.video/reference/request-invalid-query-parameter",
"title" : "A query parameter is invalid.",
"status" : 400,
"detail" : "This view duration is invalid. Use one of \"3s\", \"5s\", \"10s\", \"30s\".",
"name" : "viewDuration"
}
Loading

0 comments on commit 630c1a6

Please sign in to comment.