Skip to content

Commit 0ea2385

Browse files
authored
Add ParseAnalytics (#148)
* Add analytics * testcases * add testcases and playgrounds * Use for iOS only * test cases use iOS * Test debugDescritption * prep * Add == query * only run on iOS * Fix ACL debugDescription * another fix to ACL unit test * Fix delete file. Increase codecov. Improve playground examples * Add app tracking check. Make properties public. Make types Hashable when possible. * Fix macOS Analytics tests * nits * Add non-mutating version of tracking an event * nit * nit testcases
1 parent 11b48a7 commit 0ea2385

27 files changed

+1196
-102
lines changed

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
11
# Parse-Swift Changelog
22

33
### main
4-
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.7.2...main)
4+
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.8.0...main)
55
* _Contributing to this repo? Add info about your change here to be included in the next release_
66

7+
### 1.8.0
8+
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.7.2...1.8.0)
9+
10+
__New features__
11+
- Add ParseAnalytics. Requires app tracking authorization in latest OS's ([#147](https://github.com/parse-community/Parse-Swift/pull/147)), thanks to [Corey Baker](https://github.com/cbaker6).
12+
713
__Improvements__
14+
- Adds the ability to directly use == as a QueryConstraint on a field that's a ParseObject ([#147](https://github.com/parse-community/Parse-Swift/pull/147)), thanks to [Corey Baker](https://github.com/cbaker6).
815
- Future proof SDK by always sending client version header. Also added http method PATCH to API for future use ([#146](https://github.com/parse-community/Parse-Swift/pull/146)), thanks to [Corey Baker](https://github.com/cbaker6).
916

17+
__Fixes__
18+
- Fixed an error that occured when deleting a ParseFile which resulted in the file being downloaded locally ([#147](https://github.com/parse-community/Parse-Swift/pull/147)), thanks to [Corey Baker](https://github.com/cbaker6).
19+
1020
### 1.7.2
1121
[Full Changelog](https://github.com/parse-community/Parse-Swift/compare/1.7.1...1.7.2)
1222

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//: [Previous](@previous)
2+
3+
//: For this page, make sure your build target is set to ParseSwift (macOS) and targeting
4+
//: `My Mac` or whatever the name of your mac is. Also be sure your `Playground Settings`
5+
//: in the `File Inspector` is `Platform = macOS`. This is because
6+
//: Keychain in iOS Playgrounds behaves differently. Every page in Playgrounds should
7+
//: be set to build for `macOS` unless specified.
8+
9+
import PlaygroundSupport
10+
import Foundation
11+
import ParseSwift
12+
13+
PlaygroundPage.current.needsIndefiniteExecution = true
14+
initializeParse()
15+
16+
//: To track when the app has been opened, do the following.
17+
ParseAnalytics.trackAppOpened { result in
18+
if case .success = result {
19+
print("Saved analytics for app opened.")
20+
}
21+
}
22+
23+
//: To track any event, do the following.
24+
var friendEvent = ParseAnalytics(name: "openedFriendList")
25+
friendEvent.track { result in
26+
if case .success = result {
27+
print("Saved analytics for custom event.")
28+
}
29+
}
30+
31+
//: You can also add dimensions to your analytics.
32+
friendEvent.track(dimensions: ["more": "info"]) { result in
33+
if case .success = result {
34+
print("Saved analytics for custom event with dimensions.")
35+
}
36+
}
37+
38+
PlaygroundPage.current.finishExecution()
39+
40+
//: [Next](@next)

ParseSwift.playground/Pages/8 - Pointers.xcplaygroundpage/Contents.swift

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ struct Author: ParseObject {
4747
}
4848
}
4949

50-
let newBook = Book(title: "hello")
50+
var newBook = Book(title: "hello")
5151
let author = Author(name: "Alice", book: newBook)
5252

5353
author.save { result in
@@ -114,6 +114,9 @@ let query2 = Author.query("name" == "Bruce")
114114
query2.first { results in
115115
switch results {
116116
case .success(let author):
117+
//: Save the book to use later
118+
newBook = author.book
119+
117120
print("Found author and included \"book\": \(author)")
118121

119122
case .failure(let error):
@@ -139,5 +142,23 @@ query3.first { results in
139142
}
140143
}
141144

145+
//: You can also check if a field is equal to a ParseObject.
146+
do {
147+
let query4 = try Author.query("book" == newBook)
148+
.includeAll()
149+
150+
query4.first { results in
151+
switch results {
152+
case .success(let author):
153+
print("Found author and included all: \(author)")
154+
155+
case .failure(let error):
156+
assertionFailure("Error querying: \(error)")
157+
}
158+
}
159+
} catch {
160+
print("\(error)")
161+
}
162+
142163
PlaygroundPage.current.finishExecution()
143164
//: [Next](@next)

ParseSwift.playground/contents.xcplayground

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<playground version='6.0' target-platform='macos' display-mode='raw' buildActiveScheme='true' timelineScrubberEnabled='true' last-migration='1130'>
2+
<playground version='6.0' target-platform='macos' display-mode='raw' buildActiveScheme='true' last-migration='1130'>
33
<pages>
44
<page name='1 - Your first Object'/>
55
<page name='2 - Finding Objects'/>
@@ -16,5 +16,6 @@
1616
<page name='13 - Operations'/>
1717
<page name='14 - Config'/>
1818
<page name='15 - Custom ObjectId'/>
19+
<page name='16 - Analytics'/>
1920
</pages>
20-
</playground>
21+
</playground>

ParseSwift.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = "ParseSwift"
3-
s.version = "1.7.2"
3+
s.version = "1.8.0"
44
s.summary = "Parse Pure Swift SDK"
55
s.homepage = "https://github.com/parse-community/Parse-Swift"
66
s.authors = {

0 commit comments

Comments
 (0)