-
Notifications
You must be signed in to change notification settings - Fork 58
adding privacy and semantic wrappers #1144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e2f79da
adding privacy and semantic wrappers
absaroj 76b0a98
adding comment to constructor
absaroj 8e87193
changing file names
absaroj bcb50df
correcting argument optionals
absaroj 01de056
adding suggestions from pr
absaroj 9642e3f
removing self from the instance references
absaroj a8fa7ae
Merge branch 'main' into absaroj/privacy_sem
absaroj File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,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() | ||
| } | ||
| } |
This file contains hidden or 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,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 | ||
| } | ||
| } | ||
This file contains hidden or 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,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 { | ||
absaroj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private var odwSemanticContext: ODWSemanticContext | ||
absaroj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| /// 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) | ||
| } | ||
| } | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.