Skip to content

Commit 596b5fc

Browse files
committed
Merge branch 'feature/qa-antes-de-mas-features'
2 parents 1729c03 + 676acb7 commit 596b5fc

21 files changed

Lines changed: 1693 additions & 47 deletions

File tree

README.md

Lines changed: 118 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import Traceback
2929
lazy var traceback: TracebackSDK = {
3030
let config = TracebackConfiguration(
3131
mainAssociatedHost: URL(string: "https://your-project-traceback.firebaseapp.com")!,
32-
useClipboard: true,
32+
useClipboard: false,
3333
logLevel: .error
3434
)
3535
return TracebackSDK.live(config: config)
@@ -51,7 +51,7 @@ let config = TracebackConfiguration(
5151
associatedHosts: [
5252
URL(string: "https://your-custom-domain.com")!
5353
],
54-
useClipboard: true,
54+
useClipboard: false,
5555
logLevel: .debug
5656
)
5757
```
@@ -69,35 +69,52 @@ struct PreLandingView: View {
6969
/* ... */
7070
.onAppear {
7171
Task {
72-
// 1.- Search for post-install link and proceed if available
73-
guard let result = try? await traceback.postInstallSearchLink(),
74-
let tracebackURL = result.url else {
75-
return
72+
do {
73+
// 1.- Search for post-install link and proceed if available
74+
let result = try await traceback.postInstallSearchLink()
75+
if let tracebackURL = result.url {
76+
proceed(onOpenURL: tracebackURL)
77+
}
78+
} catch {
79+
// Handle error - network issues, configuration problems, etc.
80+
logger.error("Failed to search for post-install link: \(error)")
7681
}
77-
proceed(onOpenURL: tracebackURL)
7882
}
7983
}
8084
.onOpenURL { url in
8185
proceed(onOpenURL: url)
8286
}
8387
}
84-
88+
8589
// This method is to be called from onOpenURL or after post install link search
86-
func proceed(
87-
onOpenURL: URL
88-
) {
89-
// 2.- Grab the correct url
90-
// URL is either a post-install link (detected after app download on onAppear above),
91-
// or an opened url (direct open in installed app)
92-
guard let linkResult = try? traceback.extractLinkFromURL(url),
93-
let linkURL = linkResult.url else {
94-
return assertionFailure("Could not find a valid traceback/universal url in \(url)")
90+
func proceed(onOpenURL url: URL) {
91+
// 2.- Check if this is a Traceback URL
92+
guard traceback.isTracebackURL(url) else {
93+
// Not a Traceback URL, handle it elsewhere
94+
handleDeepLink(linkURL)
95+
return
96+
}
97+
98+
Task {
99+
do {
100+
// 3.- Check if dynamic campaign link exists (resolves the deep link from the URL)
101+
let linkResult = try await traceback.campaignSearchLink(url)
102+
103+
guard let linkURL = linkResult.url else {
104+
// No deep link found in this URL, so we normally continue opening the app Landing screen
105+
return
106+
}
107+
108+
// 4.- Handle the url, opening the right content indicated by linkURL
109+
// Use linkURL to navigate to the appropriate content in your app
110+
// You can also access linkResult.analytics for tracking purposes
111+
handleDeepLink(linkURL)
112+
sendAnalytics(linkResult.analytics)
113+
} catch {
114+
// Handle error - network issues, invalid URL, etc.
115+
logger.error("Failed to resolve campaign link: \(error)")
116+
}
95117
}
96-
97-
// 3.- Handle the url, opening the right content indicated by linkURL
98-
// Use linkURL to navigate to the appropriate content in your app
99-
// You can also access linkResult.analytics for tracking purposes
100-
YOUR CODE HERE
101118
}
102119
}
103120
```
@@ -114,13 +131,17 @@ class YourAppDelegate: NSObject, UIApplicationDelegate {
114131
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil
115132
) -> Bool {
116133
Task {
117-
// 1.- Trigger a search for installation links
118-
// if a link is found successfully, it will be sent to proceed(openURL:) below
119-
guard let result = try? await traceback.postInstallSearchLink(),
120-
let tracebackURL = result.url else {
121-
return
134+
do {
135+
// 1.- Trigger a search for installation links
136+
// if a link is found successfully, it will be sent to proceed(openURL:) below
137+
let result = try await traceback.postInstallSearchLink()
138+
if let tracebackURL = result.url {
139+
proceed(onOpenURL: tracebackURL)
140+
}
141+
} catch {
142+
// Handle error - network issues, configuration problems, etc.
143+
logger.error("Failed to search for post-install link: \(error)")
122144
}
123-
proceed(onOpenURL: tracebackURL)
124145
}
125146
return true
126147
}
@@ -135,23 +156,36 @@ class YourAppDelegate: NSObject, UIApplicationDelegate {
135156
proceed(onOpenURL: url)
136157
return true
137158
}
138-
159+
139160
// This method is to be called from application(open:options:) or after post install link search
140-
func proceed(
141-
onOpenURL: URL
142-
) {
143-
// 2.- Grab the correct url
144-
// URL is either a post-install link (detected after app launch above),
145-
// or an opened url (direct open in installed app)
146-
guard let linkResult = try? traceback.extractLinkFromURL(url),
147-
let linkURL = linkResult.url else {
148-
return assertionFailure("Could not find a valid traceback/universal url in \(url)")
161+
func proceed(onOpenURL url: URL) {
162+
// 2.- Check if this is a Traceback URL
163+
guard traceback.isTracebackURL(url) else {
164+
// Not a Traceback URL, handle it elsewhere
165+
handleDeepLink(linkURL)
166+
return
167+
}
168+
169+
Task {
170+
do {
171+
// 3.- Check if dynamic campaign link exists (resolves the deep link from the URL)
172+
let linkResult = try await traceback.campaignSearchLink(url)
173+
174+
guard let linkURL = linkResult.url else {
175+
// No deep link found in this URL, so we normally continue opening the app Landing screen
176+
return
177+
}
178+
179+
// 4.- Handle the url, opening the right content indicated by linkURL
180+
// Use linkURL to navigate to the appropriate content in your app
181+
// You can also access linkResult.analytics for tracking purposes
182+
handleDeepLink(linkURL)
183+
sendAnalytics(linkResult.analytics)
184+
} catch {
185+
// Handle error - network issues, invalid URL, etc.
186+
logger.error("Failed to resolve campaign link: \(error)")
187+
}
149188
}
150-
151-
// 3.- Handle the url, opening the right content indicated by linkURL
152-
// Use linkURL to navigate to the appropriate content in your app
153-
// You can also access linkResult.analytics for tracking purposes
154-
YOUR CODE HERE
155189
}
156190
}
157191
```
@@ -191,12 +225,26 @@ The diagnostics will categorize issues as:
191225

192226
## API Reference
193227

228+
### TracebackSDK Methods
229+
230+
#### `postInstallSearchLink() async throws -> TracebackSDK.Result`
231+
Searches for the deep link that triggered the app installation. Call this once during app launch.
232+
233+
#### `campaignSearchLink(_ url: URL) async throws -> TracebackSDK.Result`
234+
Resolves a Traceback URL opened via Universal Link or custom URL scheme into a deep link.
235+
236+
#### `isTracebackURL(_ url: URL) -> Bool`
237+
Validates if the given URL matches any of the configured Traceback domains.
238+
239+
#### `performDiagnostics()`
240+
Runs comprehensive validation of your Traceback configuration and outputs diagnostic information.
241+
194242
### TracebackSDK.Result
195243

196-
The result object returned by `postInstallSearchLink()` and `extractLinkFromURL()` contains:
244+
The result object returned by `postInstallSearchLink()` and `campaignSearchLink()` contains:
197245

198246
- `url: URL?` - The extracted deep link URL to navigate to
199-
- `matchType: MatchType` - How the link was detected (`.unique`, `.heuristics`, `.ambiguous`, `.intent`, `.none`)
247+
- `matchType: MatchType` - How the link was detected (`.unique`, `.heuristics`, `.ambiguous`, `.intent`, `.none`, `.unknown`)
200248
- `analytics: [TracebackAnalyticsEvent]` - Analytics events you can send to your preferred platform
201249

202250
### TracebackConfiguration
@@ -220,14 +268,18 @@ public struct TracebackConfiguration {
220268

221269
## Error Handling
222270

223-
The SDK uses Swift's error handling mechanisms:
271+
The SDK uses Swift's error handling mechanisms. Both `postInstallSearchLink()` and `campaignSearchLink()` can throw errors:
272+
273+
### Post-Install Link Search
224274

225275
```swift
226276
do {
227277
let result = try await traceback.postInstallSearchLink()
228278
if let url = result.url {
229279
// Handle successful link detection
230280
handleDeepLink(url)
281+
// Send analytics events
282+
sendAnalytics(result.analytics)
231283
} else {
232284
// No link found - normal app startup
233285
handleNormalStartup()
@@ -239,6 +291,26 @@ do {
239291
}
240292
```
241293

294+
### Campaign Link Resolution
295+
296+
```swift
297+
do {
298+
let result = try await traceback.campaignSearchLink(url)
299+
if let deepLink = result.url {
300+
// Handle successful link resolution
301+
handleDeepLink(deepLink)
302+
// Send analytics events
303+
sendAnalytics(result.analytics)
304+
} else {
305+
// URL is valid Traceback URL but no deep link found
306+
handleNormalStartup()
307+
}
308+
} catch {
309+
// Handle network or configuration errors
310+
logger.error("Failed to resolve campaign link: \(error)")
311+
}
312+
```
313+
242314
## Troubleshooting
243315

244316
### Common Issues

Sources/Traceback/Documentation.docc/Articles/Usage-article.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import Traceback
2525

2626
let config = TracebackConfiguration(
2727
mainAssociatedHost: URL(string: "https://my-firebase-project-traceback.firebaseapp.com")!,
28-
useClipboard: true,
28+
useClipboard: false,
2929
logLevel: .error
3030
)
3131
let traceback = TracebackSDK.live(config: config)

agents.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Traceback ios is a companion sdk to communicate with traceback firebase extension
2+
This sdk is installed via SPM in other projects
3+
4+
README.md shuold give enough onboarding information
5+
6+
don't make authoring header files or commit messages with agent information

e2e/flows/fresh_install.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# fresh_install.yaml
2+
3+
appId: ${BUNDLE_ID}
4+
---
5+
- launchApp
6+
- tapOn: 'Permitir pegar'
7+
- assertVisible:
8+
text: '.*${DESTINATION_URL}'
9+
index: 0

e2e/flows/open_link_in_safari.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# flow.yaml
2+
3+
appId: com.apple.mobilesafari
4+
---
5+
- launchApp
6+
- extendedWaitUntil:
7+
visible: "OPEN"
8+
timeout: 10000
9+
- tapOn: "OPEN"
10+
- tapOn: "OK"

samples/README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Traceback iOS SDK - Sample Applications
2+
3+
This directory contains sample applications demonstrating how to integrate and use the Traceback iOS SDK in different scenarios.
4+
5+
## Available Samples
6+
7+
### [swiftui-basic](./swiftui-basic/)
8+
A basic SwiftUI application demonstrating:
9+
- Standard Traceback SDK configuration
10+
- Post-install link detection
11+
- Universal Link handling with campaign resolution
12+
- Deep link navigation
13+
- Analytics event tracking
14+
- Diagnostics setup
15+
16+
**Best for:** Getting started with Traceback in a SwiftUI project
17+
18+
### Coming Soon
19+
20+
- **uikit-basic** - Basic UIKit implementation
21+
- **advanced-analytics** - Advanced analytics integration
22+
- **custom-domains** - Multiple domain configuration
23+
- **clipboard-disabled** - Privacy-focused setup without clipboard
24+
25+
## Prerequisites
26+
27+
Before running any sample:
28+
29+
1. **Install the Traceback Firebase Extension** in your Firebase project
30+
- Follow instructions at: https://github.com/InQBarna/firebase-traceback-extension
31+
32+
2. **Configure Firebase** for your sample app
33+
- Create an iOS app in your Firebase Console
34+
- Download `GoogleService-Info.plist`
35+
36+
3. **Set up Associated Domains**
37+
- Configure your Apple Developer account
38+
- Enable Associated Domains capability
39+
- Add the Traceback domain from your Firebase extension
40+
41+
## Running a Sample
42+
43+
Each sample includes its own README with specific setup instructions. Generally:
44+
45+
1. Navigate to the sample directory
46+
2. Follow the README to configure Firebase settings
47+
3. Open the `.xcodeproj` or `.xcworkspace` in Xcode
48+
4. Update the bundle identifier and signing team
49+
5. Run the app on a physical device (Universal Links don't work in Simulator)
50+
51+
## Testing Deep Links
52+
53+
### Create a Test Link
54+
55+
Use the Traceback Firebase extension to create a test deep link:
56+
57+
```bash
58+
# Example: Create a link to open /products/123 in your app
59+
https://your-project-traceback.firebaseapp.com/campaign-name?link=https://mydomain.com/products/123
60+
```
61+
62+
### Test Post-Install Flow
63+
64+
1. Copy the Traceback link to clipboard
65+
2. Delete the app from your device
66+
3. Install and launch the app
67+
4. The app should detect and open the deep link
68+
69+
### Test Campaign Links
70+
71+
1. Send yourself the Traceback link via Messages/Email
72+
2. Open the link with the app already installed
73+
3. The app should resolve and open the deep link
74+
75+
## Need Help?
76+
77+
- Check the main [README](../README.md) for SDK documentation
78+
- Review the [Troubleshooting](../README.md#troubleshooting) section
79+
- Run `traceback.performDiagnostics()` to validate your setup
80+
- Report issues at: https://github.com/InQBarna/traceback-iOS/issues

0 commit comments

Comments
 (0)