Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions wrappers/swift/PrivacyGuard.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//

/// Wrapper to `ODWPrivacyGuard` representing Privacy Guard Hook.
public final class PrivacyGuard {
// MARK: Behavior methods

/**
Set Privacy Guard enabled.

- Parameters:
- enable: `True` to enable Privacy Guard, `False` otherwise.
*/
public static func setEnabled(_ enable: Bool) {
ODWPrivacyGuard.setEnabled(enable)
}

/// Checks if Privacy Guard is enabled, returns `True` if it is, `False` otherwise.
public static func enabled() -> Bool {
return ODWPrivacyGuard.enabled()
}

/**
Append fresh Common Data Contexts to the existing instance of Privacy Guard.

- Parameters:
- freshCommonDataContext: Fresh Common Data Contexts instance.
*/
public static func appendCommonDataContext(freshCommonDataContext: ODWCommonDataContext) {
ODWPrivacyGuard.append(freshCommonDataContext)
}

/**
Add ignored concern to prevent generate of notification signals when this concern is found
for the given EventName and Field combination.

- Parameters:
- eventName: Event name that the ignored concern should apply to.
- Note: If the ignored concern applies to the Semantic Context Feild, set the Event name to `SemanticContext`.
- fieldName: Field that the ignored concern should apply to.
- ignoredConcern: The concern that is expected and should be ignored.
*/
public static func addIgnoredConcern(eventName: String, fieldName: String, ignoredConcern: ODWDataConcernType) {
ODWPrivacyGuard.addIgnoredConcern(eventName, with: fieldName, with: ignoredConcern)
}

/// Resets the Priavcy Guard instance.
public static func resetPrivacyGuardInstance() {
ODWPrivacyGuard.resetPrivacyGuardInstance()
}
}
18 changes: 18 additions & 0 deletions wrappers/swift/PrivacyGuardInitConfig.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//

public class PrivacyGuardInitConfig {
public let odwPrivacyGuardInitConfig: ODWPrivacyGuardInitConfig

/**
Constructor which inits with the `ODWPrivacyGuardInitConfig` object.

- Parameters:
- privacyGuardInitConfig: `ODWPrivacyGuardInitConfig` object which would be wrapped around.
*/
public init(privacyGuardInitConfig: ODWPrivacyGuardInitConfig) {
self.odwPrivacyGuardInitConfig = privacyGuardInitConfig
}
}
131 changes: 131 additions & 0 deletions wrappers/swift/SemanticContext.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
//

/// Wrapper over `ODWSemanticContext` class that manages the inclusion of semantic context values on logged events.
public class SemanticContext {
private var odwSemanticContext: ODWSemanticContext

/// Contructs the object with ODWSemanticContext object to be wrapped around.
public init(semanticContext: ODWSemanticContext) {
self.odwSemanticContext = semanticContext
}

/**
Specifies an app id to be included with every event.

- Parameters:
- appID: A `String` that contains the application identifier.
*/
public func setAppID(_ appID: String) {
odwSemanticContext.setAppId(appID)
}

/**
Set the application version context information of the telemetery event.

- Parameters:
- appVersion: Version of the application, retrieved programmatically where possible and is app/platform specific.
*/
public func setAppVersion(_ appVersion: String) {
odwSemanticContext.setAppVersion(appVersion)
}

/**
Set the application language context information of the telemetry event.

- Parameters:
- appLanguage: A `String` that contains the spoken/written language used in the application.
*/
public func setAppLanguage(_ appLanguage: String) {
odwSemanticContext.setAppLanguage(appLanguage)
}

/**
Specifies a unique user id to be included with every event.

- Parameters:
- userID: A `String` that contains the unique user identifier.
- withPiiKind: A PIIKind of the userID. Set it to PiiKind_None t odenote it as non-PII.
- Note: Default value is `ODWPiiKind.identity`.
*/
public func setUserID(_ userID: String, withPiiKind piiKind: ODWPiiKind = ODWPiiKind.identity) {
odwSemanticContext.setUserId(userID)
}

/**
Set the device identifier context information of the telemetry event.

- Parameters:
- deviceID: A unique device identifier, retrieved programmatically where possible and is app/platform speicific.
*/
public func setDeviceID(_ deviceID: String) {
odwSemanticContext.setDeviceId(deviceID)
}

/**
Set the user time zone context information of telemetry event.

- Parameters:
- userTimeZone: User's time zone relative to UTC, in ISO 8601 time zone format.
*/
public func setUserTimeZone(_ userTimeZone: String) {
odwSemanticContext.setUserTimeZone(userTimeZone)
}

/**
Specifies a unique user advertising id to be included with every event.

- Parameters:
- userAdvertisingID: A `String` that contains the unique user advertising identifier.
*/
public func setUserAdvertisingID(_ userAdvertisingID: String) {
odwSemanticContext.setUserAdvertisingId(userAdvertixingID)
}

/**
Sets the experimentation IDs for determining the deployment configuration.

- Parameters:
- experimentIDs: A `String` that contains the experimentation IDs.
*/
public func setAppExperimentIDs(_ experimentIDs: String) {
odwSemanticContext.setAppExperimentIds(experimentIDs)
}

/**
Sets the experimentation IDs for the specified telemetry event.

- Parameters:
- experimentIDs: A `String` that contains the experimentation IDs.
- eventName: A `String` that contains the name of the event.
*/
public func setAppExperimentIDs(_ experimentIDs: String, forEvent eventName: String) {
odwSemanticContext.setAppExperimentIds(experimentIDs, forEvent: eventName)
}

/**
Sets the experiment tag (experiment configuration) context information for telemetry events.

- Note: This method removes any previously stored experiment IDs that were set using `setAppExperimentEtag`.

- Parameters:
- eTag: A `String` that contains the ETag which is a hash of the set of experiments.
*/
public func setAppExperimentETag(_ eTag: String) {
odwSemanticContext.setAppExperimentETag(eTag)
}

/**
Sets the impression ID (an identifier of the currently running flights) for an experiment.

- Parameters:
- impressionID: A `String` that contains the impression ID for the currently active configuration.

- Note: Calling this method removes the previously stored experimentation IDs and flight IDs.
*/
public func setAppExperimentImpressionID(_ impressionID: String) {
odwSemanticContext.setAppExperimentImpressionId(impressionID)
}
}
6 changes: 6 additions & 0 deletions wrappers/swift/Swift_Wrapper-Bridging-Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@
#import <Foundation/Foundation.h>

#import "../obj-c/ODWEventProperties.h"
#import "../obj-c/ODWLogConfiguration.h"
#import "../obj-c/ODWLogger.h"
#import "../obj-c/ODWLogManager.h"
#import "../obj-c/ODWPrivacyGuard.h"
#import "../obj-c/ODWPrivacyGuardInitConfig.h"
#import "../obj-c/ODWSemanticContext.h"