Skip to content

Commit

Permalink
Merge pull request #304 from NikCharlebois/Dev
Browse files Browse the repository at this point in the history
Telemetry updates
  • Loading branch information
NikCharlebois authored Dec 11, 2019
2 parents 3a966ca + 97c81ad commit fb57c7c
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
* Initial Release;
* SPOPropertyBag
* Added multithreading;
* SPOSharingSettings
* Added ExistingExternalUserSharingOnly as a supported value
for SharingCapabilities;
* SPOTheme
* Fixed an issue with the Set-TargetResource
still using SPO management shell cmdlets instead of PnP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function Get-TargetResource

[Parameter()]
[System.String]
[ValidateSet("ExternalUserAndGuestSharing", "Disabled", "ExternalUserSharingOnly")]
[ValidateSet("ExistingExternalUserSharingOnly", "ExternalUserAndGuestSharing", "Disabled", "ExternalUserSharingOnly")]
$SharingCapability,

[Parameter()]
Expand Down Expand Up @@ -192,7 +192,7 @@ function Set-TargetResource

[Parameter()]
[System.String]
[ValidateSet("ExternalUserAndGuestSharing", "Disabled", "ExternalUserSharingOnly")]
[ValidateSet("ExistingExternalUserSharingOnly", "ExternalUserAndGuestSharing", "Disabled", "ExternalUserSharingOnly")]
$SharingCapability,

[Parameter()]
Expand Down Expand Up @@ -353,7 +353,7 @@ function Test-TargetResource

[Parameter()]
[System.String]
[ValidateSet("ExternalUserAndGuestSharing", "Disabled", "ExternalUserSharingOnly")]
[ValidateSet("ExistingExternalUserSharingOnly", "ExternalUserAndGuestSharing", "Disabled", "ExternalUserSharingOnly")]
$SharingCapability,

[Parameter()]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
class MSFT_SPOSharingSettings : OMI_BaseResource
{
[Key, Description("Specifies the resource is a single instance, the value must be 'Yes'"),ValueMap{"Yes"},Values{"Yes"}] String IsSingleInstance;
[Write, Description("Configures anonymous link types for folders"),ValueMap{"ExternalUserAndGuestSharing","Disabled","ExternalUserSharingOnly"},Values{"ExternalUserAndGuestSharing","Disabled","ExternalUserSharingOnly"}] string SharingCapability;
[Write, Description("Configures anonymous link types for folders"),ValueMap{"ExistingExternalUserSharingOnly","ExternalUserAndGuestSharing","Disabled","ExternalUserSharingOnly"},Values{"ExistingExternalUserSharingOnly","ExternalUserAndGuestSharing","Disabled","ExternalUserSharingOnly"}] string SharingCapability;
[Write, Description("Enables the administrator to hide the Everyone claim in the People Picker.")] boolean ShowEveryoneClaim;
[Write, Description("Enables the administrator to hide the All Users claim groups in People Picker.")] boolean ShowAllUsersClaim;
[Write, Description("Enables the administrator to hide the Everyone except external users claim in the People Picker.")] boolean ShowEveryoneExceptExternalUsersClaim;
Expand Down
44 changes: 42 additions & 2 deletions Modules/Office365DSC/Modules/O365DSCTelemetryEngine.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,21 @@ function Add-O365DSCTelemetryEvent
$Metrics
)

if ($null -eq $env:O365DSCTelemetryEnabled -or $env:O365DSCTelemetryEnabled)
$TelemetryEnabled = [System.Environment]::GetEnvironmentVariable('O365DSCTelemetryEnabled', `
[System.EnvironmentVariableTarget]::Machine)
if ($null -eq $TelemetryEnabled -or $TelemetryEnabled)
{
$TelemetryClient = Get-ApplicationInsightsTelemetryClient

try
{
$ProjectName = [System.Environment]::GetEnvironmentVariable('O365DSCTelemetryProjectName', `
[System.EnvironmentVariableTarget]::Machine)

if ($null -ne $ProjectName)
{
$Data.Add("ProjectName", $ProjectName)
}
$TelemetryClient.TrackEvent($Type, $Data, $Metrics)
$TelemetryClient.Flush()
}
Expand All @@ -64,7 +73,11 @@ function Set-O365DSCTelemetryOption

[Parameter()]
[System.String]
$InstrumentationKey
$InstrumentationKey,

[Parameter()]
[System.String]
$ProjectName
)

if ($null -ne $Enabled)
Expand All @@ -78,4 +91,31 @@ function Set-O365DSCTelemetryOption
[System.Environment]::SetEnvironmentVariable('O365DSCTelemetryInstrumentationKey', $InstrumentationKey, `
[System.EnvironmentVariableTarget]::Machine)
}

if ($null -ne $ProjectName)
{
[System.Environment]::SetEnvironmentVariable('O365DSCTelemetryProjectName', $ProjectName, `
[System.EnvironmentVariableTarget]::Machine)
}
}

function Get-O365DSCTelemetryOption
{
[CmdletBinding()]
param()

try
{
return @{
Enabled = [System.Environment]::GetEnvironmentVariable('O365DSCTelemetryEnabled', `
[System.EnvironmentVariableTarget]::Machine)
InstrumentationKey = [System.Environment]::GetEnvironmentVariable('O365DSCTelemetryInstrumentationKey', `
[System.EnvironmentVariableTarget]::Machine)
ProjectName = [System.Environment]::GetEnvironmentVariable('O365DSCTelemetryProjectName', `
[System.EnvironmentVariableTarget]::Machine)
}
}
catch {
throw $_
}
}
12 changes: 8 additions & 4 deletions Modules/Office365DSC/Modules/Office365DSCUtil.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -1373,7 +1373,7 @@ function Test-Office365DSCParameterState
[System.String]
$Source = 'Generic'
)
$VerbosePreference = "SilentlyContinue"
$VerbosePreference = "Continue"
$WarningPreference = "SilentlyContinue"
#region Telemetry
$data = [System.Collections.Generic.Dictionary[[String], [String]]]::new()
Expand Down Expand Up @@ -1617,13 +1617,17 @@ function Test-Office365DSCParameterState
$driftedValue = ''
foreach ($key in $DriftedParameters.Keys)
{
$driftedValue += $key + "|"
Write-Verbose -Message "Detected Drifted Parameter [$Source]$key"
#region Telemetry
$driftedData = [System.Collections.Generic.Dictionary[[String], [String]]]::new()
$driftedData.Add("Event", "DriftedParameter")
$driftedData.Add("Parameter", "[$Source]$key")
Add-O365DSCTelemetryEvent -Type "DriftInfo" -Data $driftedData
#endregion
$EventMessage += " <Param Name=`"$key`">" + $DriftedParameters.$key + "</Param>`r`n"
}
#region Telemetry
$driftedValue = $driftedValue.Remove($driftedValue.Length -1, 1)
$data.Add("Event", "ConfigurationDrift")
$data.Add("Parameters", $driftedValue)
#endregion
$EventMessage += " </ParametersNotInDesiredState>`r`n"
$EventMessage += " </ConfigurationDrift>`r`n"
Expand Down

0 comments on commit fb57c7c

Please sign in to comment.