Skip to content

Commit b349266

Browse files
authored
Removed AppCenter key from App.xaml.cs (#2060)
1 parent 5d34f20 commit b349266

File tree

5 files changed

+47
-3
lines changed

5 files changed

+47
-3
lines changed

Files/App.xaml.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
using Microsoft.Toolkit.Uwp.Notifications;
3131
using Windows.UI.Notifications;
3232
using Files.UserControls.MultiTaskingControl;
33+
using Newtonsoft.Json.Linq;
3334

3435
namespace Files
3536
{
@@ -73,9 +74,24 @@ public App()
7374
Windows.Storage.StorageFolder storageFolder = Windows.Storage.ApplicationData.Current.LocalFolder;
7475
NLog.LogManager.Configuration.Variables["LogPath"] = storageFolder.Path;
7576

76-
#if !DEBUG
77-
AppCenter.Start("682666d1-51d3-4e4a-93d0-d028d43baaa0", typeof(Analytics), typeof(Crashes));
78-
#endif
77+
StartAppCenter();
78+
}
79+
80+
private async void StartAppCenter()
81+
{
82+
JObject obj;
83+
try
84+
{
85+
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(@"ms-appx:///Resources/AppCenterKey.txt"));
86+
var lines = await FileIO.ReadTextAsync(file);
87+
obj = JObject.Parse(lines);
88+
}
89+
catch (Exception e)
90+
{
91+
return;
92+
}
93+
94+
AppCenter.Start((string)obj.SelectToken("key"), typeof(Analytics), typeof(Crashes));
7995
}
8096

8197
private void OnLeavingBackground(object sender, LeavingBackgroundEventArgs e)

Files/Files.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@
367367
<None Include="Assets\terminal\terminal.json">
368368
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
369369
</None>
370+
<Content Include="Resources\AppCenterKey.txt" />
370371
<Content Include="Resources\BingMapsKey.txt" />
371372
<None Include="NLog.config">
372373
<CopyToOutputDirectory>Always</CopyToOutputDirectory>

Files/Resources/AppCenterKey.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+


builds/azure-pipelines-release.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ steps:
3535
TargetFolder: '$(Build.SourcesDirectory)\Files\Resources'
3636
overWrite: true
3737

38+
- task: DownloadSecureFile@1
39+
name: appCenterDevKey
40+
displayName: 'Download AppCenter Dev Key'
41+
inputs:
42+
secureFile: 'AppCenterKey.txt'
43+
44+
- task: CopyFiles@2
45+
inputs:
46+
SourceFolder: '$(Agent.TempDirectory)'
47+
Contents: '$(appCenterDevKey.secureFilePath)'
48+
TargetFolder: '$(Build.SourcesDirectory)\Files\Resources'
49+
overWrite: true
50+
3851
- task: NuGetToolInstaller@1
3952

4053
- task: NuGetCommand@2

builds/azure-pipelines.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ steps:
3535
TargetFolder: '$(Build.SourcesDirectory)\Files\Resources'
3636
overWrite: true
3737

38+
- task: DownloadSecureFile@1
39+
name: appCenterDevKey
40+
displayName: 'Download AppCenter Dev Key'
41+
inputs:
42+
secureFile: 'AppCenterKey.txt'
43+
44+
- task: CopyFiles@2
45+
inputs:
46+
SourceFolder: '$(Agent.TempDirectory)'
47+
Contents: '$(appCenterDevKey.secureFilePath)'
48+
TargetFolder: '$(Build.SourcesDirectory)\Files\Resources'
49+
overWrite: true
50+
3851
- task: NuGetToolInstaller@1
3952

4053
- task: NuGetCommand@2

0 commit comments

Comments
 (0)