Skip to content
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

chore: Make samples be standalone #3480

Merged
merged 4 commits into from
Jul 31, 2024
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
21 changes: 0 additions & 21 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,6 @@
<NO_WINDOWS>true</NO_WINDOWS>
</PropertyGroup>

<!--
Configure Sentry CLI
NOTE: Authentication is not set here. Instead:
- In CI, `SENTRY_AUTH_TOKEN` is set as an environment variable via a GitHub Actions secret.
- In dev, you can either set `SENTRY_AUTH_TOKEN` manually, or you can set an auth token
in your ~/.sentryclirc file. See https://docs.sentry.io/product/cli/configuration/

There is also a a `SentryAuthToken` msbuild property, but it should be used sparingly.
If using it, be careful that the auth token does not get committed to source control.
-->
<PropertyGroup>
<SentryOrg>sentry-sdks</SentryOrg>
<SentryProject>sentry-dotnet</SentryProject>
</PropertyGroup>

<!-- By default we'll only upload with Sentry CLI in Release configuration. -->
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<SentryUploadSymbols>true</SentryUploadSymbols>
<SentryUploadSources>true</SentryUploadSources>
</PropertyGroup>

<!--
Note: The following platform-specific properties need to be set in both Directory.Build.props and DirectoryBuild.targets.
TODO: Figure out how to consolidate to a single location.
Expand Down
22 changes: 0 additions & 22 deletions samples/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,6 @@
<IsPackable>false</IsPackable>
</PropertyGroup>

<!--
This sets the default DSN for all sample projects. Sentry employees and contractors
can view events at https://sentry-sdks.sentry.io/projects/sentry-dotnet.

The DSN can easily be overwritten in the sample application by the end-user.
The order of precedence is:
- SentryOptions.Dsn property set in code
- Sentry:Dsn set in appsettings.json or other config (where applicable)
- SENTRY_DSN environment variable
- This [Sentry.Dsn] attribute

Thus, this DSN is applied only if no other mechanism is used to set the DSN.

Note - The below works because SentryAttributes is already being converted to
actual attributes in src/Sentry/buildTransitive/Sentry.targets.
-->
<ItemGroup>
<SentryAttributes Include="Sentry.DsnAttribute">
<_Parameter1>https://eb18e953812b41c3aeb042e666fd3b5c@o447951.ingest.sentry.io/5428537</_Parameter1>
</SentryAttributes>
</ItemGroup>

<!-- Workaround for hang on compile issue. See https://github.com/xamarin/xamarin-macios/issues/17825#issuecomment-1478568270. -->
<PropertyGroup Condition="'$(Configuration)' == 'Release' And '$(TargetFramework)' == 'net7.0-ios' And '$([System.Runtime.InteropServices.RuntimeInformation]::OSArchitecture)' == 'Arm64'">
<MtouchUseLlvm>false</MtouchUseLlvm>
Expand Down
12 changes: 6 additions & 6 deletions samples/Sentry.Samples.Android/MainActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ public class MainActivity : Activity
{
protected override void OnCreate(Bundle? savedInstanceState)
{
SentrySdk.Init(o =>
SentrySdk.Init(options =>
{
o.Dsn = "https://eb18e953812b41c3aeb042e666fd3b5c@o447951.ingest.sentry.io/5428537";
o.SendDefaultPii = true; // adds the user's IP address automatically
options.Dsn = "https://eb18e953812b41c3aeb042e666fd3b5c@o447951.ingest.sentry.io/5428537";
options.SendDefaultPii = true; // adds the user's IP address automatically

// Android specific .NET features are under the Android properties:
o.Android.LogCatIntegration = LogCatIntegrationType.Errors; // Get logcat logs for both handled and unhandled errors; default is unhandled only
o.Android.LogCatMaxLines = 1000; // Defaults to 1000
options.Android.LogCatIntegration = LogCatIntegrationType.Errors; // Get logcat logs for both handled and unhandled errors; default is unhandled only
options.Android.LogCatMaxLines = 1000; // Defaults to 1000

// All the native Android SDK options are available below
// https://docs.sentry.io/platforms/android/configuration/
// Enable Native Android SDK ANR detection
o.Native.AnrEnabled = true;
options.Native.AnrEnabled = true;
});

// Here's an example of adding custom scope information.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
In a real app, you probably only want to do this on Release builds.
-->
<PropertyGroup>
<SentryOrg>sentry-sdks</SentryOrg>
<SentryProject>sentry-dotnet</SentryProject>
<SentryUploadSources>true</SentryUploadSources>
<SentryUploadSymbols>true</SentryUploadSymbols>
<!-- Use ProGuard (R8), and upload mapping to Sentry-->
Expand Down
8 changes: 4 additions & 4 deletions samples/Sentry.Samples.AspNetCore.Basic/Program.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
var builder = WebApplication.CreateBuilder(args);

builder.WebHost.UseSentry(o =>
builder.WebHost.UseSentry(options =>
{
// A DSN is required. You can set it here, or in configuration, or in an environment variable.
o.Dsn = "https://eb18e953812b41c3aeb042e666fd3b5c@o447951.ingest.sentry.io/5428537";
options.Dsn = "https://eb18e953812b41c3aeb042e666fd3b5c@o447951.ingest.sentry.io/5428537";

// Enable Sentry performance monitoring
o.TracesSampleRate = 1.0;
options.TracesSampleRate = 1.0;

#if DEBUG
// Log debug information about the Sentry SDK
o.Debug = true;
options.Debug = true;
#endif
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<SentryOrg>sentry-sdks</SentryOrg>
<SentryProject>sentry-dotnet</SentryProject>
<SentryUploadSymbols>true</SentryUploadSymbols>
<SentryUploadSources>true</SentryUploadSources>
<SentryCreateRelease>true</SentryCreateRelease>
<SentrySetCommits>true</SentrySetCommits>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Sentry.AspNetCore\Sentry.AspNetCore.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<SentryOrg>sentry-sdks</SentryOrg>
<SentryProject>sentry-dotnet</SentryProject>
<SentryUploadSymbols>true</SentryUploadSymbols>
<SentryUploadSources>true</SentryUploadSources>
<SentryCreateRelease>true</SentryCreateRelease>
bitsandfoxes marked this conversation as resolved.
Show resolved Hide resolved
<SentrySetCommits>true</SentrySetCommits>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Sentry.AspNetCore.Blazor.WebAssembly\Sentry.AspNetCore.Blazor.WebAssembly.csproj" />
<ProjectReference Include="..\..\src\Sentry.AspNetCore\Sentry.AspNetCore.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
<RunAOTCompilation>true</RunAOTCompilation>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<SentryOrg>sentry-sdks</SentryOrg>
<SentryProject>sentry-dotnet</SentryProject>
<SentryUploadSymbols>true</SentryUploadSymbols>
<SentryUploadSources>true</SentryUploadSources>
<SentryCreateRelease>true</SentryCreateRelease>
<SentrySetCommits>true</SentrySetCommits>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.3"/>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.3" PrivateAssets="all"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@
<PackageReference Include="Grpc.Tools" Version="2.54.0" PrivateAssets="All" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Sentry.AspNetCore.Grpc\Sentry.AspNetCore.Grpc.csproj" />
</ItemGroup>

<ItemGroup>
<Protobuf Include="Proto\sample.proto" GrpcServices="Server" />
</ItemGroup>
Expand All @@ -25,4 +21,15 @@
</Content>
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<SentryOrg>sentry-sdks</SentryOrg>
<SentryProject>sentry-dotnet</SentryProject>
<SentryUploadSymbols>true</SentryUploadSymbols>
<SentryUploadSources>true</SentryUploadSources>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Sentry.AspNetCore.Grpc\Sentry.AspNetCore.Grpc.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
<RootNamespace>Samples.AspNetCore.Mvc</RootNamespace>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<SentryOrg>sentry-sdks</SentryOrg>
<SentryProject>sentry-dotnet</SentryProject>
<SentryUploadSymbols>true</SentryUploadSymbols>
<SentryUploadSources>true</SentryUploadSources>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Sentry.AspNetCore\Sentry.AspNetCore.csproj" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion samples/Sentry.Samples.AspNetCore.Mvc/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// All Sentry settings can also be configured via code or environment variables:
"Sentry": {
// The DSN can also be set via environment variable
"Dsn": "https://b887218a80114d26a9b1a51c5f88e0b4@o447951.ingest.sentry.io/6601807",
"Dsn": "https://eb18e953812b41c3aeb042e666fd3b5c@o447951.ingest.sentry.io/5428537",
// Opt-in for payload submission
"MaxRequestBodySize": "Always",
// Sends Cookies, User Id when one is logged on and user IP address to sentry. It's turned off by default.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@
<PackageReference Include="Serilog.AspNetCore" Version="6.1.0" />
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<SentryOrg>sentry-sdks</SentryOrg>
<SentryProject>sentry-dotnet</SentryProject>
<SentryUploadSymbols>true</SentryUploadSymbols>
<SentryUploadSources>true</SentryUploadSources>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Sentry.AspNetCore\Sentry.AspNetCore.csproj" />
<ProjectReference Include="..\..\src\Sentry.Serilog\Sentry.Serilog.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
<AWSProjectType>Lambda</AWSProjectType>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Amazon.Lambda.AspNetCoreServer" Version="7.3.0" />
<PackageReference Include="AWSSDK.Extensions.NETCore.Setup" Version="3.7.7" />
</ItemGroup>

<ItemGroup>
<Folder Include="Controllers" />
</ItemGroup>

<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<SentryOrg>sentry-sdks</SentryOrg>
<SentryProject>sentry-dotnet</SentryProject>
<SentryUploadSymbols>true</SentryUploadSymbols>
<SentryUploadSources>true</SentryUploadSources>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Sentry.AspNetCore\Sentry.AspNetCore.csproj" />
</ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion samples/Sentry.Samples.Azure.Functions.Worker/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
{
builder.UseSentry(host, options =>
{
options.Dsn = "https://eb18e953812b41c3aeb042e666fd3b5c@o447951.ingest.sentry.io/5428537";
options.TracesSampleRate = 1.0;
// options.Debug = true;
options.Debug = true;
});
})
.Build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
</ItemGroup>

<ItemGroup>
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
<SentryOrg>sentry-sdks</SentryOrg>
<SentryProject>sentry-dotnet</SentryProject>
<SentryUploadSymbols>true</SentryUploadSymbols>
<SentryUploadSources>true</SentryUploadSources>
</PropertyGroup>

<ItemGroup>
<!-- TODO: Replace with a package reference -->
<ProjectReference Include="..\..\src\Sentry.Azure.Functions.Worker\Sentry.Azure.Functions.Worker.csproj" />
</ItemGroup>
Expand Down
5 changes: 2 additions & 3 deletions samples/Sentry.Samples.Console.Basic/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@

SentrySdk.Init(options =>
{
// TODO: Configure a Sentry Data Source Name (DSN).
// You can set here in code, or you can set it in the SENTRY_DSN environment variable.
// See https://docs.sentry.io/product/sentry-basics/dsn-explainer/
// You can set it in the SENTRY_DSN environment variable, or you can set it in code here.
options.Dsn = "... Your DSN ...";
options.Dsn = "https://eb18e953812b41c3aeb042e666fd3b5c@o447951.ingest.sentry.io/5428537";

// When debug is enabled, the Sentry client will emit detailed debugging information to the console.
// This might be helpful, or might interfere with the normal operation of your application.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,43 @@

<PropertyGroup>
<!--
We set the SentryOrg and SentryProject globally in our root Directory.Build.props.
In your own project, uncomment the following block and set the values for your Sentry configuration.
Also note, these options do nothing if you are not authenticated.
See https://docs.sentry.io/platforms/dotnet/configuration/msbuild/
Note, these options do nothing if you are not authenticated.
See https://docs.sentry.io/platforms/dotnet/configuration/msbuild/#authentication
-->
<!--
<SentryUrl>...your Sentry URL if self-hosted, or omit this line if using sentry.io...</SentryUrl>
<SentryOrg>...your org...</SentryOrg>
<SentryProject>...your project...</SentryProject>
-->
<SentryOrg>sentry-sdks</SentryOrg>
<SentryProject>sentry-dotnet</SentryProject>

<!--
After the above properties are configured, you can use the following features.
Uploading sources to Sentry during the build will enable Source Context in the Sentry issue details page.
Uploading symbols to Sentry will enable server-side symbolication (i.e. when the PDB is not present at runtime, or for AOT published programs).
Uploading sources to Sentry during the build will enable Source Context in the Sentry issue details page.
-->
<SentryUploadSources>true</SentryUploadSources>
<SentryUploadSymbols>true</SentryUploadSymbols>
</PropertyGroup>
<SentryUploadSources>true</SentryUploadSources>

<!--
You can automatically create releases via sentry-cli and control their creation via these properties
See https://docs.sentry.io/cli/releases/#creating-releases
-->
<SentryCreateRelease>true</SentryCreateRelease>

<!--
To associate commits with releases
See https://docs.sentry.io/cli/releases/#commit-integration
-->
<SentrySetCommits>true</SentrySetCommits>
<SentrySetCommitOptions>--local</SentrySetCommitOptions>

<!--
To associate commits with releases
See https://docs.sentry.io/cli/releases/#commit-integration
-->
<!-- <SentrySetCommits>true</SentrySetCommits>-->
<!-- <SentrySetCommitOptions>&#45;&#45;local</SentrySetCommitOptions>-->
</PropertyGroup>

<!-- In your own project, this would be a PackageReference to the latest version of Sentry. -->
<ItemGroup>
Expand All @@ -41,6 +58,7 @@
<ItemGroup>
<TrimmerRootAssembly Include="Sentry" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net462'">
<PackageReference Include="System.Net.Http" Version="4.3.4" />
</ItemGroup>
Expand Down
Loading
Loading