Skip to content

Commit 8032b1a

Browse files
absarojlalitb
andauthored
adding swift wrapper for DiagnosticDataViewer (#1148)
* adding diagnostic wrapper for swift * adding suggestions from pr * making it final * adding vars instead of methods * correcting var * fixing build issues --------- Co-authored-by: Lalit Kumar Bhasin <[email protected]>
1 parent 90020d5 commit 8032b1a

File tree

3 files changed

+86
-1
lines changed

3 files changed

+86
-1
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
//
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
// SPDX-License-Identifier: Apache-2.0
4+
//
5+
6+
/// Wrapper class over `ODWDiagnosticDataViewer` representing Diagnostic Data Viewer Hook.
7+
public final class DiagnosticDataViewer {
8+
9+
/// MARK: Initialization Methods
10+
11+
/**
12+
Initializes Data Viewer with a specified machine identifier.
13+
14+
- Parameters:
15+
- machineIdentifier: `String` that contains the machine identifier.
16+
*/
17+
public static func initViewerWithMachineIdentifier(machineIdentifier: String) {
18+
ODWDiagnosticDataViewer.initializeViewer(withMachineIdentifier: machineIdentifier)
19+
}
20+
21+
/// MARK: Behavior Methods
22+
23+
/**
24+
Enables Data Viewer.
25+
26+
- Parameters:
27+
- endpoint: A `String` that contains endpoint to route events.
28+
- completionWithResult: Code to execute when enable is completed.
29+
- Note: This value can be null.
30+
31+
Execution is dispatched to queue with default priority.
32+
*/
33+
public static func enableRemoteViewer(endpoint: String, completionWithResult completion: @escaping (Bool) -> Void) {
34+
ODWDiagnosticDataViewer.enableRemoteViewer(endpoint, completionWithResult: completion)
35+
}
36+
37+
/**
38+
Enables Data Viewer.
39+
40+
- Parameters:
41+
- endpoint: A `String` that contains endpoint to route events.
42+
*/
43+
public static func enableRemoteViewer(endpoint: String) -> Bool {
44+
return ODWDiagnosticDataViewer.enableRemoteViewer(endpoint)
45+
}
46+
47+
/**
48+
Disables Data Viewer.
49+
50+
- Parameters:
51+
- completionWithResult: Code to execute when disable is completed.
52+
- Note: This value can be null.
53+
54+
Execution is dispatched to queue with default priority.
55+
*/
56+
public static func disableViewer(completionWithResult completion: @escaping (Bool) -> Void) {
57+
ODWDiagnosticDataViewer.disableViewer(completion)
58+
}
59+
60+
/// Disables Data Viewer.
61+
public static func disableViewer() -> Bool {
62+
return ODWDiagnosticDataViewer.disableViewer()
63+
}
64+
65+
/// `True` if Data Viewer is enabled, `False` otherwise.
66+
public static var viewerEnabled: Bool {
67+
return ODWDiagnosticDataViewer.viewerEnabled()
68+
}
69+
70+
/// current endpoint if it is set, empty `String` otherwise.
71+
public static var currentEndpoint: String? {
72+
return ODWDiagnosticDataViewer.currentEndpoint()
73+
}
74+
75+
/**
76+
Sets callback for OnDisableNotification event.
77+
78+
- Parameters:
79+
- run: Code to execute when OnDisableNotification event occurs.
80+
*/
81+
public static func onDisableNotification(run callback: @escaping () -> Void) {
82+
ODWDiagnosticDataViewer.register(onDisableNotification: callback)
83+
}
84+
}

wrappers/swift/SemanticContext.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public class SemanticContext {
8181
- userAdvertisingID: A `String` that contains the unique user advertising identifier.
8282
*/
8383
public func setUserAdvertisingID(_ userAdvertisingID: String) {
84-
odwSemanticContext.setUserAdvertisingId(userAdvertixingID)
84+
odwSemanticContext.setUserAdvertisingId(userAdvertisingID)
8585
}
8686

8787
/**

wrappers/swift/Swift_Wrapper-Bridging-Header.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#import <Foundation/Foundation.h>
99

10+
#import "../obj-c/ODWDiagnosticDataViewer.h"
1011
#import "../obj-c/ODWEventProperties.h"
1112
#import "../obj-c/ODWLogConfiguration.h"
1213
#import "../obj-c/ODWLogger.h"

0 commit comments

Comments
 (0)