Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: support macOS * ci: update test * feat: support macOS (Swift Package Manager) * fix: depend on GrowingUtils 0.0.5 * fix: pod subspec ios deployment_target * fix: pod lint error * ci: update Podfile.lock * fix: platform and deviceModel on Mac Catalyst * fix: 兼容非沙盒化 MacOS App 本地存储 * fix: 没有释放 realtimeEventDB 数据库的空间 (Protobuf 下) * revert: -[GrowingPersistenceDataProvider setString:forKey:] 有在 CDP 中使用 * fix: target conditionals on MacCatalyst * chore: update swift version to 5.6 (Xcode 13.3) * refactor: dummy headers 修改父目录为 include,以便于正常的 headers 的父目录区分 (Public) * chore: update Package.swift dependencies * fix: MobileDebugger 横条添加点击提示 * test: add macOS Demo * ci: same iphoneos deployment target * ci: same iphoneos deployment target * test: demo add macCatalyst support
- Loading branch information
Showing
123 changed files
with
2,479 additions
and
929 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// AppDelegate.swift | ||
// GrowingAnalytics | ||
// | ||
// Created by YoloMao on 2023/4/21. | ||
// Copyright (C) 2022 Beijing Yishu Technology Co., Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
|
||
import Cocoa | ||
|
||
#if canImport(GrowingAnalytics_cdp) | ||
import GrowingAnalytics_cdp | ||
#elseif canImport(GrowingAnalytics) | ||
import GrowingAnalytics | ||
#endif | ||
|
||
@main | ||
class AppDelegate: NSObject, NSApplicationDelegate { | ||
|
||
|
||
|
||
|
||
func applicationDidFinishLaunching(_ aNotification: Notification) { | ||
// Insert code here to initialize your application | ||
let config = GrowingTrackConfiguration(projectId: "bcc4fc9dea27f25d") | ||
config?.dataSourceId = "be46cd165dcc3c7e" | ||
config?.dataCollectionServerHost = "https://run.mocky.io/v3/08999138-a180-431d-a136-051f3c6bd306" | ||
config?.idMappingEnabled = true | ||
config?.debugEnabled = true | ||
GrowingTracker.start(with: config!) | ||
} | ||
|
||
func applicationWillTerminate(_ aNotification: Notification) { | ||
// Insert code here to tear down your application | ||
} | ||
|
||
func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { | ||
return true | ||
} | ||
|
||
|
||
} | ||
|
11 changes: 11 additions & 0 deletions
11
Example/Example-macOS/Assets.xcassets/AccentColor.colorset/Contents.json
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,11 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
Example/Example-macOS/Assets.xcassets/AppIcon.appiconset/Contents.json
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,58 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "16x16" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "16x16" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "32x32" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "32x32" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "128x128" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "128x128" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "256x256" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "256x256" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "512x512" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "512x512" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
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,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Large diffs are not rendered by default.
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,12 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>com.apple.security.app-sandbox</key> | ||
<true/> | ||
<key>com.apple.security.files.user-selected.read-only</key> | ||
<true/> | ||
<key>com.apple.security.network.client</key> | ||
<true/> | ||
</dict> | ||
</plist> |
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,135 @@ | ||
// | ||
// ViewController.swift | ||
// GrowingAnalytics | ||
// | ||
// Created by YoloMao on 2023/4/21. | ||
// Copyright (C) 2022 Beijing Yishu Technology Co., Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
|
||
import Cocoa | ||
|
||
#if canImport(GrowingAnalytics_cdp) | ||
import GrowingAnalytics_cdp | ||
#elseif canImport(GrowingAnalytics) | ||
import GrowingAnalytics | ||
#endif | ||
|
||
class ViewController: NSViewController { | ||
|
||
@IBOutlet weak var userIdTextField: NSTextField! | ||
@IBOutlet weak var userKeyTextField: NSTextField! | ||
@IBOutlet weak var timerEventNameTextField: NSTextField! | ||
@IBOutlet weak var timersPopupButton: NSPopUpButton! | ||
|
||
override func viewDidLoad() { | ||
super.viewDidLoad() | ||
|
||
timersPopupButton.removeAllItems() | ||
} | ||
|
||
override var representedObject: Any? { | ||
didSet { | ||
// Update the view, if already loaded. | ||
} | ||
} | ||
|
||
@IBAction func setDataCollectionEnabled(_ sender: NSSwitch) { | ||
GrowingTracker.sharedInstance().setDataCollectionEnabled(sender.state == .on) | ||
} | ||
|
||
@IBAction func setUserIdAction(_ sender: Any) { | ||
GrowingTracker.sharedInstance().setLoginUserId(userIdTextField.stringValue) | ||
} | ||
|
||
@IBAction func setUserKeyAction(_ sender: Any) { | ||
GrowingTracker.sharedInstance().setLoginUserId(userIdTextField.stringValue, userKey: userKeyTextField.stringValue) | ||
} | ||
|
||
@IBAction func cleanLoginUserIdAction(_ sender: Any) { | ||
GrowingTracker.sharedInstance().cleanLoginUserId() | ||
} | ||
|
||
@IBAction func sendCustomEventAction(_ sender: Any) { | ||
GrowingTracker.sharedInstance().trackCustomEvent("eventName") | ||
} | ||
|
||
@IBAction func sendCustomEventWithAttributesAction(_ sender: Any) { | ||
GrowingTracker.sharedInstance().trackCustomEvent("eventName", withAttributes: ["key": "value"]) | ||
} | ||
|
||
@IBAction func sendLoginUserAttributesEventAction(_ sender: Any) { | ||
GrowingTracker.sharedInstance().setLoginUserAttributes(["key": "value"]) | ||
} | ||
|
||
@IBAction func sendConversionVariablesEventAction(_ sender: Any) { | ||
#if !canImport(GrowingAnalytics_cdp) | ||
GrowingTracker.sharedInstance().setConversionVariables(["key": "value"]) | ||
#endif | ||
} | ||
|
||
@IBAction func sendVisitorAttributesEventAction(_ sender: Any) { | ||
#if !canImport(GrowingAnalytics_cdp) | ||
GrowingTracker.sharedInstance().setVisitorAttributes(["key": "value"]) | ||
#endif | ||
} | ||
|
||
@IBAction func startTimerAction(_ sender: Any) { | ||
let timerId = GrowingTracker.sharedInstance().trackTimerStart(timerEventNameTextField.stringValue) | ||
guard let timerId = timerId else { | ||
return | ||
} | ||
timersPopupButton.addItem(withTitle: timerId) | ||
} | ||
|
||
@IBAction func pauseTimerAction(_ sender: Any) { | ||
let timerId = timersPopupButton.selectedItem?.title | ||
guard let timerId = timerId else { | ||
return | ||
} | ||
GrowingTracker.sharedInstance().trackTimerPause(timerId) | ||
} | ||
|
||
@IBAction func resumeTimerAction(_ sender: Any) { | ||
let timerId = timersPopupButton.selectedItem?.title | ||
guard let timerId = timerId else { | ||
return | ||
} | ||
GrowingTracker.sharedInstance().trackTimerResume(timerId) | ||
} | ||
|
||
@IBAction func endTimerAction(_ sender: Any) { | ||
let timerId = timersPopupButton.selectedItem?.title | ||
guard let timerId = timerId else { | ||
return | ||
} | ||
GrowingTracker.sharedInstance().trackTimerEnd(timerId) | ||
timersPopupButton.removeItem(withTitle: timerId) | ||
} | ||
|
||
@IBAction func endTimerWithAttributesAction(_ sender: Any) { | ||
let timerId = timersPopupButton.selectedItem?.title | ||
guard let timerId = timerId else { | ||
return | ||
} | ||
GrowingTracker.sharedInstance().trackTimerEnd(timerId, withAttributes: ["key": "value"]) | ||
timersPopupButton.removeItem(withTitle: timerId) | ||
} | ||
|
||
@IBAction func clearAllTimersAction(_ sender: Any) { | ||
GrowingTracker.sharedInstance().clearTrackTimer() | ||
timersPopupButton.removeAllItems() | ||
} | ||
} | ||
|
Oops, something went wrong.