-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathAnalytics.cs
More file actions
80 lines (74 loc) · 2.79 KB
/
Copy pathAnalytics.cs
File metadata and controls
80 lines (74 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ServiceStack;
namespace ServiceStackVS.Common
{
public static class Analytics
{
public const string VERSION = "3.1.0";
private const string ServiceStackStatsUrl = "https://servicestack.net/stats/ssvs{0}/record?name={1}&source=ssvs&version=" + VERSION;
private const string ServiceStackStatsAddRefUrl = "https://servicestack.net/stats/addref/record?name={0}&source=ssvs&version=" + VERSION;
private const string ServiceStackStatsUpdateRefUrl = "https://servicestack.net/stats/updateref/record?name={0}&source=ssvs&version=" + VERSION;
static readonly Dictionary<int, string> VersionAlias = new Dictionary<int, string>
{
{ 11, "2012" },
{ 12, "2013" },
{ 14, "2015" },
{ 15, "2017" },
{ 16, "2019" },
{ 17, "2022"}
};
static string GetVersion(int vsVersion) => VersionAlias.TryGetValue(vsVersion, out var version) ? version : "";
public static void SubmitAnonymousTemplateUsage(int vsVersion, string templatePath)
{
if (Environment.GetEnvironmentVariable("SERVICESTACK_TELEMETRY_OPTOUT") == "1") return;
Task.Run(() =>
{
try
{
var templateName = WizardHelpers.GetTemplateNameFromPath(templatePath);
ServiceStackStatsUrl.Fmt(GetVersion(vsVersion), templateName).GetStringFromUrl();
}
catch
{
//do nothing
}
}).ConfigureAwait(false);
}
public static async Task SubmitAnonymousAddReferenceUsage(string languageName)
{
if (Environment.GetEnvironmentVariable("SERVICESTACK_TELEMETRY_OPTOUT") == "1") return;
if (languageName == null) return;
await Task.Run(() =>
{
try
{
ServiceStackStatsAddRefUrl.Fmt(languageName.ToLower()).GetStringFromUrl();
}
catch
{
//do nothing
}
});
}
public static void SubmitAnonymousUpdateReferenceUsage(string languageName)
{
if (Environment.GetEnvironmentVariable("SERVICESTACK_TELEMETRY_OPTOUT") == "1") return;
if (languageName == null) return;
Task.Run(() =>
{
try
{
ServiceStackStatsUpdateRefUrl.Fmt(languageName.ToLower()).GetStringFromUrl();
}
catch
{
//do nothing
}
});
}
}
}