Skip to content

Commit

Permalink
Fix: Validate PrivacyInfo.xcprivacy and warn of missing privacy (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-zimerman committed May 1, 2024
1 parent be29090 commit d48cb0f
Show file tree
Hide file tree
Showing 12 changed files with 289 additions and 19 deletions.
77 changes: 76 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,80 @@
# Changelog

## Unreleased

### Fixes

- Validate PrivacyInfo.xcprivacy and warn users of required missing privacy parameters ([#152](https://github.com/getsentry/sentry-xamarin/pull/152))

Due to a requirement by apple, all Projects will require a ([Privacy Manifest file](https://developer.apple.com/documentation/bundleresources/privacy_manifest_files)). Sentry will automatically patch your project with the required fields by Sentry if no privacy manifest file is provided. Otherwise, it will validate your privacy manifest file for the required fields by Sentry and warn you during the build time if the required keys are present or not when building an iOS project.
Below you can find a snippet of the minimum required privacy manifest required by Sentry Xamarin:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyCollectedDataTypes</key>
<array>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypeCrashData</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<false/>
<key>NSPrivacyCollectedDataTypeTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
</array>
</dict>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypePerformanceData</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<false/>
<key>NSPrivacyCollectedDataTypeTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
</array>
</dict>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypeOtherDiagnosticData</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<false/>
<key>NSPrivacyCollectedDataTypeTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
</array>
</dict>
</array>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>C617.1</string>
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategorySystemBootTime</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>35F9.1</string>
</array>
</dict>
</array>
</dict>
</plist>
```

## 2.0.0

### Sentry Self-hosted Compatibility
Expand Down Expand Up @@ -411,4 +486,4 @@ Also available via NuGet:

[Sentry](https://www.nuget.org/packages/Sentry/)
[Sentry.Xamarin](https://www.nuget.org/packages/Sentry.Xamarin)
[Sentry.Xamarin.Forms](https://www.nuget.org/packages/Sentry.Xamarin.Forms)
[Sentry.Xamarin.Forms](https://www.nuget.org/packages/Sentry.Xamarin.Forms)
1 change: 1 addition & 0 deletions Samples/Sample.Xamarin.Core/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<!--Automatic upward search ends when first file found. From here we need to manually import parent props/targets
https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build -->
<Import Project="..\..\Directory.Build.props" />
<Import Project="..\..\Src\Sentry.Xamarin\buildTransitive\Sentry.Xamarin.targets" />

</Project>
1 change: 1 addition & 0 deletions Samples/Sample.Xamarin.Droid/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<!--Automatic upward search ends when first file found. From here we need to manually import parent props/targets
https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build -->
<Import Project="..\..\Directory.Build.props" />
<Import Project="..\..\Src\Sentry.Xamarin\buildTransitive\Sentry.Xamarin.targets" />

</Project>
1 change: 1 addition & 0 deletions Samples/Sample.Xamarin.Mac/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<!--Automatic upward search ends when first file found. From here we need to manually import parent props/targets
https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build -->
<Import Project="..\..\Directory.Build.props" />
<Import Project="..\..\Src\Sentry.Xamarin\buildTransitive\Sentry.Xamarin.targets" />

</Project>
1 change: 1 addition & 0 deletions Samples/Sample.Xamarin.UWP/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<!--Automatic upward search ends when first file found. From here we need to manually import parent props/targets
https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build -->
<Import Project="..\..\Directory.Build.props" />
<Import Project="..\..\Src\Sentry.Xamarin\buildTransitive\Sentry.Xamarin.targets" />

</Project>
1 change: 1 addition & 0 deletions Samples/Sample.Xamarin.iOS/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
<!--Automatic upward search ends when first file found. From here we need to manually import parent props/targets
https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build -->
<Import Project="..\..\Directory.Build.props" />
<Import Project="..\..\Src\Sentry.Xamarin\buildTransitive\Sentry.Xamarin.targets" />

</Project>
49 changes: 49 additions & 0 deletions Samples/Sample.Xamarin.iOS/PrivacyInfo.xcprivacy
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Some Key Group</key>
<array>
<dict>
<key>test</key>
<string>test</string>
</dict>
<dict>
<key>test</key>
<string>test</string>
</dict>
</array>

<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>C617.1</string>
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategorySystemBootTime</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>35F9.1</string>
</array>
</dict>
</array>

<key>Another Key Group</key>
<array>
<dict>
<key>test</key>
<string>test</string>
</dict>
<dict>
<key>test</key>
<string>test</string>
</dict>
</array>
</dict>
</plist>
39 changes: 21 additions & 18 deletions Samples/Sample.Xamarin.iOS/Sample.Xamarin.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,28 @@
<MtouchDebug>true</MtouchDebug>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<!-- Configure Sentry org and project -->
<!-- for more information: https://docs.sentry.io/platforms/dotnet/guides/xamarin/configuration/msbuild-->
<SentryOrg>sentry-sdks</SentryOrg>
<SentryProject>sentry-xamarin</SentryProject>
<!--
<!-- Configure Sentry org and project -->
<!-- for more information: https://docs.sentry.io/platforms/dotnet/guides/xamarin/configuration/msbuild-->
<SentryOrg>sentry-sdks</SentryOrg>
<SentryProject>sentry-xamarin</SentryProject>
<!--
Each of the below features are opt-in.
Enable the features you wish to use.
-->
<!-- Sends symbols to Sentry, enabling symbolication of stack traces. -->
<SentryUploadSymbols>true</SentryUploadSymbols>
<!-- Sends sources to Sentry, enabling display of source context. -->
<SentryUploadSources>true</SentryUploadSources>
<SentryCLIUploadOptions>--wait</SentryCLIUploadOptions>
<!-- Sends symbols to Sentry, enabling symbolication of stack traces. -->
<SentryUploadSymbols>true</SentryUploadSymbols>
<!-- Sends sources to Sentry, enabling display of source context. -->
<SentryUploadSources>true</SentryUploadSources>
<SentryCLIUploadOptions>--wait</SentryCLIUploadOptions>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<MtouchLink>None</MtouchLink>
<MtouchArch>x86_64</MtouchArch>
<!-- Configure Sentry org and project -->
<!-- for more information: https://docs.sentry.io/platforms/dotnet/guides/xamarin/configuration/msbuild-->
<!-- Configure Sentry org and project -->
<!-- for more information: https://docs.sentry.io/platforms/dotnet/guides/xamarin/configuration/msbuild-->
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -76,9 +76,9 @@
Each of the below features are opt-in.
Enable the features you wish to use.
-->
<!-- Sends symbols to Sentry, enabling symbolication of stack traces. -->
<SentryUploadSymbols>true</SentryUploadSymbols>
<!-- Sends sources to Sentry, enabling display of source context. -->
<!-- Sends symbols to Sentry, enabling symbolication of stack traces. -->
<SentryUploadSymbols>true</SentryUploadSymbols>
<!-- Sends sources to Sentry, enabling display of source context. -->
<SentryUploadSources>true</SentryUploadSources>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
Expand All @@ -88,8 +88,8 @@
<MtouchArch>ARM64</MtouchArch>
<CodesignKey>iPhone Developer</CodesignKey>
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
<!-- Configure Sentry org and project -->
<!-- for more information: https://docs.sentry.io/platforms/dotnet/guides/xamarin/configuration/msbuild-->
<!-- Configure Sentry org and project -->
<!-- for more information: https://docs.sentry.io/platforms/dotnet/guides/xamarin/configuration/msbuild-->
</PropertyGroup>
<PropertyGroup Condition=" '$(RunConfiguration)' == 'Default' ">
<AppExtensionDebugBundleId />
Expand All @@ -101,6 +101,9 @@
<None Include="Entitlements.plist" />
<None Include="Info.plist" />
<Compile Include="Properties\AssemblyInfo.cs" />
<BundleResource Include="PrivacyInfo.xcprivacy">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</BundleResource>
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="Resources\LaunchScreen.storyboard" />
Expand Down Expand Up @@ -193,4 +196,4 @@
<UserProperties TriggeredFromHotReload="False" />
</VisualStudio>
</ProjectExtensions>
</Project>
</Project>
1 change: 1 addition & 0 deletions Src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<!--Automatic upward search ends when first file found. From here we need to manually import parent props/targets
https://docs.microsoft.com/en-us/visualstudio/msbuild/customize-your-build -->
<Import Project="..\Directory.Build.props" />
<Import Project="..\Src\Sentry.Xamarin\buildTransitive\Sentry.Xamarin.targets" />

<PropertyGroup>
<!--Generate xml docs for all projects under 'src'-->
Expand Down
64 changes: 64 additions & 0 deletions Src/Sentry.Xamarin/Privacy/SentryPrivacyInfo.xcprivacy
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyCollectedDataTypes</key>
<array>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypeCrashData</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<false/>
<key>NSPrivacyCollectedDataTypeTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
</array>
</dict>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypePerformanceData</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<false/>
<key>NSPrivacyCollectedDataTypeTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
</array>
</dict>
<dict>
<key>NSPrivacyCollectedDataType</key>
<string>NSPrivacyCollectedDataTypeOtherDiagnosticData</string>
<key>NSPrivacyCollectedDataTypeLinked</key>
<false/>
<key>NSPrivacyCollectedDataTypeTracking</key>
<false/>
<key>NSPrivacyCollectedDataTypePurposes</key>
<array>
<string>NSPrivacyCollectedDataTypePurposeAppFunctionality</string>
</array>
</dict>
</array>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>C617.1</string>
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategorySystemBootTime</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>35F9.1</string>
</array>
</dict>
</array>
</dict>
</plist>
3 changes: 3 additions & 0 deletions Src/Sentry.Xamarin/Sentry.Xamarin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
<None Include="Internals\**\*.mac*.cs" />
<None Include="Internals\**\*.droid*.cs" />
<None Include="Internals\**\*.uwp*.cs" />
<None Include="Privacy\SentryPrivacyInfo.xcprivacy" Pack="true" PackagePath="Privacy\SentryPrivacyInfo.xcprivacy"/>
<None Include="buildTransitive\Sentry.Xamarin.targets" Pack="true" PackagePath="buildTransitive\Sentry.Xamarin.targets" />
<None Include="buildTransitive\Sentry.Xamarin.targets" Pack="true" PackagePath="build\Sentry.Xamarin.targets" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit d48cb0f

Please sign in to comment.