@params)
10 | {
11 | LastDataEnqueued = @params;
12 | }
13 |
14 | public void EnumerateDataEnqueed ( )
15 | {
16 | foreach ( string key in LastDataEnqueued.Keys )
17 | {
18 | System.Diagnostics.Debug.WriteLine( $"{key}='{LastDataEnqueued[key]}'");
19 | }
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Managed/GoogleAnalytics.UnitTests/Package.appxmanifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | GoogleAnalytics.UnitTests
7 | dotnet
8 | Assets\StoreLogo.png
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/Managed/GoogleAnalytics.UnitTests/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("GoogleAnalytics.UnitTests")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("GoogleAnalytics.UnitTests")]
13 | [assembly: AssemblyCopyright("Copyright © 2016")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 | [assembly: AssemblyMetadata("TargetPlatform","UAP")]
17 |
18 | // Version information for an assembly consists of the following four values:
19 | //
20 | // Major Version
21 | // Minor Version
22 | // Build Number
23 | // Revision
24 | //
25 | // You can specify all the values or you can default the Build and Revision Numbers
26 | // by using the '*' as shown below:
27 | // [assembly: AssemblyVersion("1.0.*")]
28 | [assembly: AssemblyVersion("1.0.0.0")]
29 | [assembly: AssemblyFileVersion("1.0.0.0")]
30 | [assembly: ComVisible(false)]
--------------------------------------------------------------------------------
/src/Managed/GoogleAnalytics.UnitTests/Properties/UnitTestApp.rd.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/Managed/GoogleAnalytics.UnitTests/UnitTestApp.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/Managed/GoogleAnalytics.UnitTests/UnitTestApp.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Runtime.InteropServices.WindowsRuntime;
6 | using Windows.ApplicationModel;
7 | using Windows.ApplicationModel.Activation;
8 | using Windows.Foundation;
9 | using Windows.Foundation.Collections;
10 | using Windows.UI.Xaml;
11 | using Windows.UI.Xaml.Controls;
12 | using Windows.UI.Xaml.Controls.Primitives;
13 | using Windows.UI.Xaml.Data;
14 | using Windows.UI.Xaml.Input;
15 | using Windows.UI.Xaml.Media;
16 | using Windows.UI.Xaml.Navigation;
17 |
18 | namespace GoogleAnalytics.UnitTests
19 | {
20 | ///
21 | /// Provides application-specific behavior to supplement the default Application class.
22 | ///
23 | sealed partial class App : Application
24 | {
25 | ///
26 | /// Initializes the singleton application object. This is the first line of authored code
27 | /// executed, and as such is the logical equivalent of main() or WinMain().
28 | ///
29 | public App()
30 | {
31 | this.InitializeComponent();
32 | this.Suspending += OnSuspending;
33 | }
34 |
35 | ///
36 | /// Invoked when the application is launched normally by the end user. Other entry points
37 | /// will be used such as when the application is launched to open a specific file.
38 | ///
39 | /// Details about the launch request and process.
40 | protected override void OnLaunched(LaunchActivatedEventArgs e)
41 | {
42 |
43 | #if DEBUG
44 | if (System.Diagnostics.Debugger.IsAttached)
45 | {
46 | this.DebugSettings.EnableFrameRateCounter = true;
47 | }
48 | #endif
49 |
50 | Frame rootFrame = Window.Current.Content as Frame;
51 |
52 | // Do not repeat app initialization when the Window already has content,
53 | // just ensure that the window is active
54 | if (rootFrame == null)
55 | {
56 | // Create a Frame to act as the navigation context and navigate to the first page
57 | rootFrame = new Frame();
58 |
59 | rootFrame.NavigationFailed += OnNavigationFailed;
60 |
61 | if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
62 | {
63 | //TODO: Load state from previously suspended application
64 | }
65 |
66 | // Place the frame in the current Window
67 | Window.Current.Content = rootFrame;
68 | }
69 |
70 | Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI();
71 |
72 | // Ensure the current window is active
73 | Window.Current.Activate();
74 |
75 | Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(e.Arguments);
76 | }
77 |
78 | ///
79 | /// Invoked when Navigation to a certain page fails
80 | ///
81 | /// The Frame which failed navigation
82 | /// Details about the navigation failure
83 | void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
84 | {
85 | throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
86 | }
87 |
88 | ///
89 | /// Invoked when application execution is being suspended. Application state is saved
90 | /// without knowing whether the application will be terminated or resumed with the contents
91 | /// of memory still intact.
92 | ///
93 | /// The source of the suspend request.
94 | /// Details about the suspend request.
95 | private void OnSuspending(object sender, SuspendingEventArgs e)
96 | {
97 | var deferral = e.SuspendingOperation.GetDeferral();
98 | //TODO: Save application state and stop any background activity
99 | deferral.Complete();
100 | }
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/src/Managed/GoogleAnalytics.UnitTests/project.json:
--------------------------------------------------------------------------------
1 | {
2 | "dependencies": {
3 | "Microsoft.NETCore.UniversalWindowsPlatform": "5.2.2"
4 | },
5 | "frameworks": {
6 | "uap10.0": {}
7 | },
8 | "runtimes": {
9 | "win10-arm": {},
10 | "win10-arm-aot": {},
11 | "win10-x86": {},
12 | "win10-x86-aot": {},
13 | "win10-x64": {},
14 | "win10-x64-aot": {}
15 | }
16 | }
--------------------------------------------------------------------------------
/src/Managed/GoogleAnalytics.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoogleAnalytics.Core", "GoogleAnalytics.Core\GoogleAnalytics.Core.csproj", "{A6BE52D4-4652-4680-8E0D-9D1D1EB3AD1F}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoogleAnalytics.UWP.Managed", "GoogleAnalytics.UWP\GoogleAnalytics.UWP.Managed.csproj", "{EF2863F0-036B-48F1-A402-77570A1A2823}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoogleAnalytics.UnitTests", "GoogleAnalytics.UnitTests\GoogleAnalytics.UnitTests.csproj", "{C5637A31-A489-4A07-B4B3-D34CF0CC1A60}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoogleAnalytics.Sample.Managed", "GoogleAnalytics.Sample\GoogleAnalytics.Sample.Managed.csproj", "{82A33996-59A5-4CA8-BED7-7EDC914B42EF}"
13 | EndProject
14 | Global
15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
16 | Debug|Any CPU = Debug|Any CPU
17 | Debug|ARM = Debug|ARM
18 | Debug|x64 = Debug|x64
19 | Debug|x86 = Debug|x86
20 | Release|Any CPU = Release|Any CPU
21 | Release|ARM = Release|ARM
22 | Release|x64 = Release|x64
23 | Release|x86 = Release|x86
24 | EndGlobalSection
25 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
26 | {A6BE52D4-4652-4680-8E0D-9D1D1EB3AD1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {A6BE52D4-4652-4680-8E0D-9D1D1EB3AD1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {A6BE52D4-4652-4680-8E0D-9D1D1EB3AD1F}.Debug|ARM.ActiveCfg = Debug|Any CPU
29 | {A6BE52D4-4652-4680-8E0D-9D1D1EB3AD1F}.Debug|ARM.Build.0 = Debug|Any CPU
30 | {A6BE52D4-4652-4680-8E0D-9D1D1EB3AD1F}.Debug|x64.ActiveCfg = Debug|Any CPU
31 | {A6BE52D4-4652-4680-8E0D-9D1D1EB3AD1F}.Debug|x64.Build.0 = Debug|Any CPU
32 | {A6BE52D4-4652-4680-8E0D-9D1D1EB3AD1F}.Debug|x86.ActiveCfg = Debug|Any CPU
33 | {A6BE52D4-4652-4680-8E0D-9D1D1EB3AD1F}.Debug|x86.Build.0 = Debug|Any CPU
34 | {A6BE52D4-4652-4680-8E0D-9D1D1EB3AD1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
35 | {A6BE52D4-4652-4680-8E0D-9D1D1EB3AD1F}.Release|Any CPU.Build.0 = Release|Any CPU
36 | {A6BE52D4-4652-4680-8E0D-9D1D1EB3AD1F}.Release|ARM.ActiveCfg = Release|Any CPU
37 | {A6BE52D4-4652-4680-8E0D-9D1D1EB3AD1F}.Release|ARM.Build.0 = Release|Any CPU
38 | {A6BE52D4-4652-4680-8E0D-9D1D1EB3AD1F}.Release|x64.ActiveCfg = Release|Any CPU
39 | {A6BE52D4-4652-4680-8E0D-9D1D1EB3AD1F}.Release|x64.Build.0 = Release|Any CPU
40 | {A6BE52D4-4652-4680-8E0D-9D1D1EB3AD1F}.Release|x86.ActiveCfg = Release|Any CPU
41 | {A6BE52D4-4652-4680-8E0D-9D1D1EB3AD1F}.Release|x86.Build.0 = Release|Any CPU
42 | {EF2863F0-036B-48F1-A402-77570A1A2823}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
43 | {EF2863F0-036B-48F1-A402-77570A1A2823}.Debug|Any CPU.Build.0 = Debug|Any CPU
44 | {EF2863F0-036B-48F1-A402-77570A1A2823}.Debug|ARM.ActiveCfg = Debug|ARM
45 | {EF2863F0-036B-48F1-A402-77570A1A2823}.Debug|ARM.Build.0 = Debug|ARM
46 | {EF2863F0-036B-48F1-A402-77570A1A2823}.Debug|x64.ActiveCfg = Debug|x64
47 | {EF2863F0-036B-48F1-A402-77570A1A2823}.Debug|x64.Build.0 = Debug|x64
48 | {EF2863F0-036B-48F1-A402-77570A1A2823}.Debug|x86.ActiveCfg = Debug|x86
49 | {EF2863F0-036B-48F1-A402-77570A1A2823}.Debug|x86.Build.0 = Debug|x86
50 | {EF2863F0-036B-48F1-A402-77570A1A2823}.Release|Any CPU.ActiveCfg = Release|Any CPU
51 | {EF2863F0-036B-48F1-A402-77570A1A2823}.Release|Any CPU.Build.0 = Release|Any CPU
52 | {EF2863F0-036B-48F1-A402-77570A1A2823}.Release|ARM.ActiveCfg = Release|ARM
53 | {EF2863F0-036B-48F1-A402-77570A1A2823}.Release|ARM.Build.0 = Release|ARM
54 | {EF2863F0-036B-48F1-A402-77570A1A2823}.Release|x64.ActiveCfg = Release|x64
55 | {EF2863F0-036B-48F1-A402-77570A1A2823}.Release|x64.Build.0 = Release|x64
56 | {EF2863F0-036B-48F1-A402-77570A1A2823}.Release|x86.ActiveCfg = Release|Any CPU
57 | {EF2863F0-036B-48F1-A402-77570A1A2823}.Release|x86.Build.0 = Release|Any CPU
58 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Debug|Any CPU.ActiveCfg = Debug|x86
59 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Debug|Any CPU.Build.0 = Debug|x86
60 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Debug|Any CPU.Deploy.0 = Debug|x86
61 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Debug|ARM.ActiveCfg = Debug|ARM
62 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Debug|ARM.Build.0 = Debug|ARM
63 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Debug|ARM.Deploy.0 = Debug|ARM
64 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Debug|x64.ActiveCfg = Debug|x64
65 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Debug|x64.Build.0 = Debug|x64
66 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Debug|x64.Deploy.0 = Debug|x64
67 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Debug|x86.ActiveCfg = Debug|x86
68 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Debug|x86.Build.0 = Debug|x86
69 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Debug|x86.Deploy.0 = Debug|x86
70 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Release|Any CPU.ActiveCfg = Release|x86
71 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Release|Any CPU.Build.0 = Release|x86
72 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Release|Any CPU.Deploy.0 = Release|x86
73 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Release|ARM.ActiveCfg = Release|ARM
74 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Release|ARM.Build.0 = Release|ARM
75 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Release|ARM.Deploy.0 = Release|ARM
76 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Release|x64.ActiveCfg = Release|x64
77 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Release|x64.Build.0 = Release|x64
78 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Release|x64.Deploy.0 = Release|x64
79 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Release|x86.ActiveCfg = Release|x86
80 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Release|x86.Build.0 = Release|x86
81 | {C5637A31-A489-4A07-B4B3-D34CF0CC1A60}.Release|x86.Deploy.0 = Release|x86
82 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Debug|Any CPU.ActiveCfg = Debug|x86
83 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Debug|Any CPU.Build.0 = Debug|x86
84 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Debug|Any CPU.Deploy.0 = Debug|x86
85 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Debug|ARM.ActiveCfg = Debug|ARM
86 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Debug|ARM.Build.0 = Debug|ARM
87 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Debug|ARM.Deploy.0 = Debug|ARM
88 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Debug|x64.ActiveCfg = Debug|x64
89 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Debug|x64.Build.0 = Debug|x64
90 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Debug|x64.Deploy.0 = Debug|x64
91 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Debug|x86.ActiveCfg = Debug|x86
92 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Debug|x86.Build.0 = Debug|x86
93 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Debug|x86.Deploy.0 = Debug|x86
94 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Release|Any CPU.ActiveCfg = Release|x86
95 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Release|Any CPU.Build.0 = Release|x86
96 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Release|Any CPU.Deploy.0 = Release|x86
97 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Release|ARM.ActiveCfg = Release|ARM
98 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Release|ARM.Build.0 = Release|ARM
99 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Release|ARM.Deploy.0 = Release|ARM
100 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Release|x64.ActiveCfg = Release|x64
101 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Release|x64.Build.0 = Release|x64
102 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Release|x64.Deploy.0 = Release|x64
103 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Release|x86.ActiveCfg = Release|x86
104 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Release|x86.Build.0 = Release|x86
105 | {82A33996-59A5-4CA8-BED7-7EDC914B42EF}.Release|x86.Deploy.0 = Release|x86
106 | EndGlobalSection
107 | GlobalSection(SolutionProperties) = preSolution
108 | HideSolutionNode = FALSE
109 | EndGlobalSection
110 | EndGlobal
111 |
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Javascript/GoogleAnalytics.Sample.Javascript.jsproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 |
8 |
9 | Debug
10 | ARM
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Debug
18 | x86
19 |
20 |
21 | Release
22 | AnyCPU
23 |
24 |
25 | Release
26 | ARM
27 | true
28 |
29 |
30 | Release
31 | x64
32 | true
33 |
34 |
35 | Release
36 | x86
37 | true
38 |
39 |
40 |
41 | 9fec82d3-60aa-41ef-adde-1349dfc7e542
42 |
43 |
44 |
45 | 14.0
46 |
47 |
48 |
49 |
50 | UAP
51 | 10.0.14393.0
52 | 10.0.10240.0
53 | $(VersionNumberMajor).$(VersionNumberMinor)
54 | en-US
55 | GoogleAnalytics.Sample.Javascript_TemporaryKey.pfx
56 |
57 |
58 |
59 | Designer
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 | packages\UWP.SDKforGoogleAnalytics.Native.1.5.1\lib\uap10.0\GoogleAnalytics.winmd
77 | true
78 | True
79 | True
80 |
81 |
82 |
83 |
84 |
85 |
86 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
87 |
88 |
89 |
90 |
101 |
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Javascript/GoogleAnalytics.Sample.Javascript.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{262852C6-CD72-467D-83FE-5EEB1973A190}") = "GoogleAnalytics.Sample.Javascript", "GoogleAnalytics.Sample.Javascript.jsproj", "{9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Debug|ARM = Debug|ARM
12 | Debug|x64 = Debug|x64
13 | Debug|x86 = Debug|x86
14 | Release|Any CPU = Release|Any CPU
15 | Release|ARM = Release|ARM
16 | Release|x64 = Release|x64
17 | Release|x86 = Release|x86
18 | EndGlobalSection
19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
20 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
23 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Debug|ARM.ActiveCfg = Debug|ARM
24 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Debug|ARM.Build.0 = Debug|ARM
25 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Debug|ARM.Deploy.0 = Debug|ARM
26 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Debug|x64.ActiveCfg = Debug|x64
27 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Debug|x64.Build.0 = Debug|x64
28 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Debug|x64.Deploy.0 = Debug|x64
29 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Debug|x86.ActiveCfg = Debug|x86
30 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Debug|x86.Build.0 = Debug|x86
31 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Debug|x86.Deploy.0 = Debug|x86
32 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Release|Any CPU.ActiveCfg = Release|Any CPU
33 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Release|Any CPU.Build.0 = Release|Any CPU
34 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Release|Any CPU.Deploy.0 = Release|Any CPU
35 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Release|ARM.ActiveCfg = Release|ARM
36 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Release|ARM.Build.0 = Release|ARM
37 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Release|ARM.Deploy.0 = Release|ARM
38 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Release|x64.ActiveCfg = Release|x64
39 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Release|x64.Build.0 = Release|x64
40 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Release|x64.Deploy.0 = Release|x64
41 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Release|x86.ActiveCfg = Release|x86
42 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Release|x86.Build.0 = Release|x86
43 | {9FEC82D3-60AA-41EF-ADDE-1349DFC7E542}.Release|x86.Deploy.0 = Release|x86
44 | EndGlobalSection
45 | GlobalSection(SolutionProperties) = preSolution
46 | HideSolutionNode = FALSE
47 | EndGlobalSection
48 | EndGlobal
49 |
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Javascript/GoogleAnalytics.Sample.Javascript_TemporaryKey.pfx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/windows-sdk-for-google-analytics/81878f1bb6df95bfd9793224af96592b67995d66/src/Native/GoogleAnalytics.Sample.Javascript/GoogleAnalytics.Sample.Javascript_TemporaryKey.pfx
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Javascript/css/default.css:
--------------------------------------------------------------------------------
1 | body {
2 | /* Uncomment this to enable scrolling and zooming
3 | touch-action: manipulation;
4 | */
5 | margin-left:20px;
6 | margin-right:20px;
7 | overflow-y: auto;
8 | }
9 |
10 | input[type="button"], input[type="submit"] {
11 | width: 200px;
12 | margin-left:20px;
13 | margin-top:15px;
14 | }
15 |
16 | textarea {
17 | width: 80%;
18 | margin-left:50px ;
19 | margin-right:50px ;
20 | height:200px;
21 | overflow-y: auto;
22 | }
23 |
24 | .section
25 | {
26 | margin-top: 10px;
27 | }
28 |
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Javascript/images/LockScreenLogo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/windows-sdk-for-google-analytics/81878f1bb6df95bfd9793224af96592b67995d66/src/Native/GoogleAnalytics.Sample.Javascript/images/LockScreenLogo.scale-200.png
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Javascript/images/SplashScreen.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/windows-sdk-for-google-analytics/81878f1bb6df95bfd9793224af96592b67995d66/src/Native/GoogleAnalytics.Sample.Javascript/images/SplashScreen.scale-200.png
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Javascript/images/Square150x150Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/windows-sdk-for-google-analytics/81878f1bb6df95bfd9793224af96592b67995d66/src/Native/GoogleAnalytics.Sample.Javascript/images/Square150x150Logo.scale-200.png
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Javascript/images/Square44x44Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/windows-sdk-for-google-analytics/81878f1bb6df95bfd9793224af96592b67995d66/src/Native/GoogleAnalytics.Sample.Javascript/images/Square44x44Logo.scale-200.png
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Javascript/images/Square44x44Logo.targetsize-24_altform-unplated.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/windows-sdk-for-google-analytics/81878f1bb6df95bfd9793224af96592b67995d66/src/Native/GoogleAnalytics.Sample.Javascript/images/Square44x44Logo.targetsize-24_altform-unplated.png
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Javascript/images/StoreLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/windows-sdk-for-google-analytics/81878f1bb6df95bfd9793224af96592b67995d66/src/Native/GoogleAnalytics.Sample.Javascript/images/StoreLogo.png
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Javascript/images/Wide310x150Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/windows-sdk-for-google-analytics/81878f1bb6df95bfd9793224af96592b67995d66/src/Native/GoogleAnalytics.Sample.Javascript/images/Wide310x150Logo.scale-200.png
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Javascript/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | GoogleAnalytics.Sample.Javascript
6 |
7 |
8 |
9 |
10 |
11 | Activity to track
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | Request:
20 |
21 |
22 |
23 |
24 | Results:
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Javascript/js/main.js:
--------------------------------------------------------------------------------
1 | // Your code here!
2 | var tracker;
3 |
4 | function parse( hit )
5 | {
6 | var pair;
7 | var result = "";
8 |
9 | var iter = hit.data.first();
10 |
11 | while (iter.hasCurrent)
12 | {
13 | result += iter.current.key ;
14 | result += ":";
15 | result += iter.current.value;
16 | result += "\n";
17 | iter.moveNext();
18 | }
19 |
20 | return result;
21 |
22 | }
23 |
24 | function showResult ( hit, msg )
25 | {
26 | document.getElementById('textResponse').value = msg;
27 | document.getElementById('textRequest').value = parse(hit);
28 | }
29 |
30 |
31 | function onHitMalformed ( args )
32 | {
33 | showResult(args.hit, "**hit malformed** \n" + args.httpStatusCode);
34 | }
35 |
36 | function onHitFailed ( args )
37 | {
38 | showResult(args.hit, "**hit failed**\n" + args.error.message);
39 | }
40 |
41 |
42 | function onHitSent ( args )
43 | {
44 | showResult(args.hit, args.response);
45 | }
46 | function initTracker() {
47 |
48 | tracker = GoogleAnalytics.AnalyticsManager.current.createTracker("UA-39959863-1");
49 | GoogleAnalytics.AnalyticsManager.current.isDebug = true;
50 | GoogleAnalytics.AnalyticsManager.current.reportUncaughtExceptions = true;
51 | GoogleAnalytics.AnalyticsManager.current.autoAppLifetimeMonitoring = true;
52 |
53 |
54 | }
55 |
56 | function sendEvent ()
57 | {
58 | tracker.send(GoogleAnalytics.HitBuilder.createCustomEvent("test", "userclick", "", 0).build());
59 | }
60 |
61 | function sendPageview() {
62 |
63 | tracker.send(GoogleAnalytics.HitBuilder.createScreenView( "index.html").build());
64 |
65 | }
66 |
67 | function sendSocial() {
68 | tracker.send(GoogleAnalytics.HitBuilder.createSocialInteraction("facebook", "share", "index.html" ).build());
69 | }
70 |
71 | function sendTiming ()
72 | {
73 | tracker.send(GoogleAnalytics.HitBuilder.createTiming("pageload", "index.html", 10, "").build());
74 | }
75 |
76 | function sendException ()
77 | {
78 | tracker.send(GoogleAnalytics.HitBuilder.createException("Oops. Something bad happened", false).build());
79 | }
80 |
81 |
82 | function addListeners ()
83 | {
84 | document.getElementById('btnSendEvent').addEventListener("click", sendEvent, false );
85 | document.getElementById('btnSendPageView').addEventListener ("click", sendPageview, false );
86 | document.getElementById('btnSendSocial').addEventListener ("click", sendSocial , false );
87 | document.getElementById('btnSendTiming').addEventListener ("click", sendTiming, false );
88 | document.getElementById('btnSendException').addEventListener ("click", sendException, false );
89 |
90 |
91 | GoogleAnalytics.AnalyticsManager.current.addEventListener("hitfailed", onHitFailed, false );
92 | GoogleAnalytics.AnalyticsManager.current.addEventListener("hitsent", onHitSent , false );
93 | GoogleAnalytics.AnalyticsManager.current.addEventListener("hitmailformed", onHitMalformed, false );
94 |
95 |
96 | }
97 |
98 |
99 |
100 | function init()
101 | {
102 | initTracker();
103 | addListeners();
104 |
105 | }
106 |
107 |
108 | document.onload = init();
109 |
110 |
111 |
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Javascript/package.appxmanifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | GoogleAnalytics.Sample.Javascript
7 | dotnet
8 | images\storelogo.png
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Javascript/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Native/App.xaml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Native/App.xaml.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // App.xaml.cpp
3 | // Implementation of the App class.
4 | //
5 |
6 | #include "pch.h"
7 | #include "MainPage.xaml.h"
8 |
9 | using namespace GoogleAnalytics_Sample_Native;
10 | using namespace GoogleAnalytics;
11 |
12 | using namespace Platform;
13 | using namespace Windows::ApplicationModel;
14 | using namespace Windows::ApplicationModel::Activation;
15 | using namespace Windows::Foundation;
16 | using namespace Windows::Foundation::Collections;
17 | using namespace Windows::UI::Xaml;
18 | using namespace Windows::UI::Xaml::Controls;
19 | using namespace Windows::UI::Xaml::Controls::Primitives;
20 | using namespace Windows::UI::Xaml::Data;
21 | using namespace Windows::UI::Xaml::Input;
22 | using namespace Windows::UI::Xaml::Interop;
23 | using namespace Windows::UI::Xaml::Media;
24 | using namespace Windows::UI::Xaml::Navigation;
25 |
26 | ///
27 | /// Initializes the singleton application object. This is the first line of authored code
28 | /// executed, and as such is the logical equivalent of main() or WinMain().
29 | ///
30 | App::App()
31 | {
32 | InitializeComponent();
33 | Suspending += ref new SuspendingEventHandler(this, &App::OnSuspending);
34 |
35 | UnhandledException += ref new Windows::UI::Xaml::UnhandledExceptionEventHandler(this, &GoogleAnalytics_Sample_Native::App::OnUnhandledException);
36 |
37 | }
38 |
39 |
40 | Tracker^ App::tracker = nullptr;
41 |
42 |
43 |
44 | ///
45 | /// Invoked when the application is launched normally by the end user. Other entry points
46 | /// will be used such as when the application is launched to open a specific file.
47 | ///
48 | /// Details about the launch request and process.
49 | void App::OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e)
50 | {
51 | #if _DEBUG
52 | // Show graphics profiling information while debugging.
53 | if (IsDebuggerPresent())
54 | {
55 | // Display the current frame rate counters
56 | DebugSettings->EnableFrameRateCounter = true;
57 | }
58 | #endif
59 | auto rootFrame = dynamic_cast(Window::Current->Content);
60 |
61 |
62 | if (e->PrelaunchActivated == false)
63 | {
64 | //STEP02: Instantiate tracker
65 | tracker = AnalyticsManager::Current->CreateTracker("UA-39959863-1");
66 | AnalyticsManager::Current->IsDebug = true;
67 | AnalyticsManager::Current->ReportUncaughtExceptions = true;
68 |
69 | AnalyticsManager::Current->AutoAppLifetimeMonitoring = true;
70 |
71 | }
72 |
73 |
74 | // Do not repeat app initialization when the Window already has content,
75 | // just ensure that the window is active
76 | if (rootFrame == nullptr)
77 | {
78 | // Create a Frame to act as the navigation context and associate it with
79 | // a SuspensionManager key
80 | rootFrame = ref new Frame();
81 |
82 | rootFrame->NavigationFailed += ref new Windows::UI::Xaml::Navigation::NavigationFailedEventHandler(this, &App::OnNavigationFailed);
83 |
84 | if (e->PreviousExecutionState == ApplicationExecutionState::Terminated)
85 | {
86 | // TODO: Restore the saved session state only when appropriate, scheduling the
87 | // final launch steps after the restore is complete
88 |
89 | }
90 |
91 | if (e->PrelaunchActivated == false)
92 | {
93 | if (rootFrame->Content == nullptr)
94 | {
95 | // When the navigation stack isn't restored navigate to the first page,
96 | // configuring the new page by passing required information as a navigation
97 | // parameter
98 | rootFrame->Navigate(TypeName(MainPage::typeid), e->Arguments);
99 | }
100 | // Place the frame in the current Window
101 | Window::Current->Content = rootFrame;
102 | // Ensure the current window is active
103 | Window::Current->Activate();
104 | }
105 | }
106 | else
107 | {
108 | if (e->PrelaunchActivated == false)
109 | {
110 |
111 |
112 |
113 |
114 | if (rootFrame->Content == nullptr)
115 | {
116 | // When the navigation stack isn't restored navigate to the first page,
117 | // configuring the new page by passing required information as a navigation
118 | // parameter
119 | rootFrame->Navigate(TypeName(MainPage::typeid), e->Arguments);
120 | }
121 |
122 |
123 |
124 |
125 |
126 | // Ensure the current window is active
127 | Window::Current->Activate();
128 | }
129 | }
130 | }
131 |
132 | ///
133 | /// Invoked when application execution is being suspended. Application state is saved
134 | /// without knowing whether the application will be terminated or resumed with the contents
135 | /// of memory still intact.
136 | ///
137 | /// The source of the suspend request.
138 | /// Details about the suspend request.
139 | void App::OnSuspending(Object^ sender, SuspendingEventArgs^ e)
140 | {
141 | (void) sender; // Unused parameter
142 | (void) e; // Unused parameter
143 |
144 | //TODO: Save application state and stop any background activity
145 | }
146 |
147 | ///
148 | /// Invoked when Navigation to a certain page fails
149 | ///
150 | /// The Frame which failed navigation
151 | /// Details about the navigation failure
152 | void App::OnNavigationFailed(Platform::Object ^sender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^e)
153 | {
154 | throw ref new FailureException("Failed to load Page " + e->SourcePageType.Name);
155 | }
156 |
157 | void GoogleAnalytics_Sample_Native::App::OnUnhandledException(Platform::Object ^sender, Windows::UI::Xaml::UnhandledExceptionEventArgs ^e)
158 | {
159 | e->Handled = true;
160 | }
161 |
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Native/App.xaml.h:
--------------------------------------------------------------------------------
1 | //
2 | // App.xaml.h
3 | // Declaration of the App class.
4 | //
5 |
6 | #pragma once
7 |
8 | #include "App.g.h"
9 |
10 | namespace GoogleAnalytics_Sample_Native
11 | {
12 | ///
13 | /// Provides application-specific behavior to supplement the default Application class.
14 | ///
15 | ref class App sealed
16 | {
17 | protected:
18 | virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs^ e) override;
19 |
20 | internal:
21 | App();
22 |
23 | //STEP01: declare a tracker for our app.
24 | static GoogleAnalytics::Tracker^ tracker;
25 |
26 |
27 |
28 | private:
29 | void OnSuspending(Platform::Object^ sender, Windows::ApplicationModel::SuspendingEventArgs^ e);
30 | void OnNavigationFailed(Platform::Object ^sender, Windows::UI::Xaml::Navigation::NavigationFailedEventArgs ^e);
31 | void Log (GoogleAnalytics::Hit^ hit, Platform::String^ message);
32 |
33 |
34 | public :
35 | static property GoogleAnalytics::Tracker^ Tracker
36 | {
37 | GoogleAnalytics::Tracker^ get() { return tracker; }
38 | }
39 | void OnUnhandledException(Platform::Object ^sender, Windows::UI::Xaml::UnhandledExceptionEventArgs ^e);
40 | };
41 | }
42 |
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Native/Assets/LockScreenLogo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/windows-sdk-for-google-analytics/81878f1bb6df95bfd9793224af96592b67995d66/src/Native/GoogleAnalytics.Sample.Native/Assets/LockScreenLogo.scale-200.png
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Native/Assets/SplashScreen.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/windows-sdk-for-google-analytics/81878f1bb6df95bfd9793224af96592b67995d66/src/Native/GoogleAnalytics.Sample.Native/Assets/SplashScreen.scale-200.png
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Native/Assets/Square150x150Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/windows-sdk-for-google-analytics/81878f1bb6df95bfd9793224af96592b67995d66/src/Native/GoogleAnalytics.Sample.Native/Assets/Square150x150Logo.scale-200.png
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Native/Assets/Square44x44Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/windows-sdk-for-google-analytics/81878f1bb6df95bfd9793224af96592b67995d66/src/Native/GoogleAnalytics.Sample.Native/Assets/Square44x44Logo.scale-200.png
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Native/Assets/Square44x44Logo.targetsize-24_altform-unplated.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/windows-sdk-for-google-analytics/81878f1bb6df95bfd9793224af96592b67995d66/src/Native/GoogleAnalytics.Sample.Native/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Native/Assets/StoreLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/windows-sdk-for-google-analytics/81878f1bb6df95bfd9793224af96592b67995d66/src/Native/GoogleAnalytics.Sample.Native/Assets/StoreLogo.png
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Native/Assets/Wide310x150Logo.scale-200.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/windows-sdk-for-google-analytics/81878f1bb6df95bfd9793224af96592b67995d66/src/Native/GoogleAnalytics.Sample.Native/Assets/Wide310x150Logo.scale-200.png
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Native/GoogleAnalytics.Sample.Native.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 4ce2fc45-ab85-43f1-ac35-a2ba466eea18
6 |
7 |
8 | 94a92c59-7a8b-4e5c-9377-3fb5d461edee
9 | bmp;fbx;gif;jpg;jpeg;tga;tiff;tif;png
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 | Assets
28 |
29 |
30 | Assets
31 |
32 |
33 | Assets
34 |
35 |
36 | Assets
37 |
38 |
39 | Assets
40 |
41 |
42 | Assets
43 |
44 |
45 | Assets
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Native/GoogleAnalytics.Sample.Native_TemporaryKey.pfx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dotnet/windows-sdk-for-google-analytics/81878f1bb6df95bfd9793224af96592b67995d66/src/Native/GoogleAnalytics.Sample.Native/GoogleAnalytics.Sample.Native_TemporaryKey.pfx
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Native/MainPage.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
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 |
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Native/MainPage.xaml.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // MainPage.xaml.cpp
3 | // Implementation of the MainPage class.
4 | //
5 |
6 | #include "pch.h"
7 | #include "MainPage.xaml.h"
8 |
9 | using namespace GoogleAnalytics_Sample_Native;
10 | using namespace GoogleAnalytics;
11 |
12 | using namespace Platform;
13 | using namespace Windows::Foundation;
14 | using namespace Windows::Foundation::Collections;
15 | using namespace Windows::UI::Xaml;
16 | using namespace Windows::UI::Xaml::Controls;
17 | using namespace Windows::UI::Xaml::Controls::Primitives;
18 | using namespace Windows::UI::Xaml::Data;
19 | using namespace Windows::UI::Xaml::Input;
20 | using namespace Windows::UI::Xaml::Media;
21 | using namespace Windows::UI::Xaml::Navigation;
22 |
23 |
24 |
25 | // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
26 |
27 | MainPage::MainPage()
28 | {
29 | InitializeComponent();
30 | isRunningInDebugMode = this->IsDebugRequest->IsChecked->Value;
31 | }
32 |
33 |
34 |
35 | void GoogleAnalytics_Sample_Native::MainPage::OnNavigatedTo( NavigationEventArgs^ args )
36 | {
37 | App::Tracker->ScreenName = "MainPage";
38 | AnalyticsManager::Current->HitSent += ref new Windows::Foundation::EventHandler(this, &GoogleAnalytics_Sample_Native::MainPage::AnalyticsManager_HitSent);
39 | AnalyticsManager::Current->HitMalformed += ref new Windows::Foundation::EventHandler(this, &GoogleAnalytics_Sample_Native::MainPage::AnalyticsManager_HitMalformed);
40 | AnalyticsManager::Current->HitFailed += ref new Windows::Foundation::EventHandler(this, &GoogleAnalytics_Sample_Native::MainPage::AnalyticsManager_HitFailed);
41 |
42 |
43 | }
44 |
45 |
46 | void GoogleAnalytics_Sample_Native::MainPage::ButtonEvent_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
47 | {
48 | App::Tracker->Send ( HitBuilder::CreateCustomEvent("test", "userclick", nullptr, 0)->Build());
49 | }
50 |
51 |
52 | void GoogleAnalytics_Sample_Native::MainPage::ButtonSocial_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
53 | {
54 | App::Tracker->Send( HitBuilder::CreateSocialInteraction("facebook", "share", "http://googleanalyticssdk.codeplex.com")->Build());
55 | }
56 |
57 | void GoogleAnalytics_Sample_Native::MainPage::ButtonView_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
58 | {
59 | App::Tracker->Send(HitBuilder::CreateScreenView()->Build());
60 | }
61 |
62 |
63 | void GoogleAnalytics_Sample_Native::MainPage::ButtonTiming_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
64 | {
65 | TimeSpan timeSpan;
66 | timeSpan.Duration = 20000000L; // 2 seconds
67 | App::Tracker->Send(HitBuilder::CreateTiming("loadtime", "currentPage", timeSpan, "")->Build()) ;
68 | }
69 |
70 |
71 |
72 | void GoogleAnalytics_Sample_Native::MainPage::ButtonException_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
73 | {
74 | App::Tracker->Send(HitBuilder::CreateException("oops, something went wrong", false)->Build());
75 | }
76 |
77 |
78 | void MainPage::ButtonThrowException_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
79 | {
80 | Object^ y = 1;
81 | String^ x = (String^)y;
82 | }
83 |
84 | void MainPage::IsDebugRequest_Checked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
85 | {
86 |
87 |
88 | isRunningInDebugMode = IsDebugRequest->IsChecked->Value;
89 | Windows::UI::Xaml::Visibility visibility = isRunningInDebugMode ? Windows::UI::Xaml::Visibility::Visible : Windows::UI::Xaml::Visibility::Collapsed;
90 |
91 | RequestPanel->Visibility = visibility;
92 | ResponsePanel->Visibility = visibility;
93 |
94 | }
95 |
96 |
97 |
98 | void MainPage::AnalyticsManager_HitSent( Object^ unused, HitSentEventArgs^ e )
99 | {
100 | Log(e->Hit, e->Response );
101 |
102 | }
103 |
104 | void MainPage::AnalyticsManager_HitFailed(Object^ unused, HitFailedEventArgs ^ e)
105 | {
106 |
107 | Log(e->Hit, e->Error );
108 | }
109 |
110 | void MainPage::AnalyticsManager_HitMalformed(Object^ unused, HitMalformedEventArgs ^ e)
111 | {
112 |
113 | String ^error = "Hit malformed. Http code=" + e->HttpStatusCode.ToString();
114 | Log(e->Hit, error );
115 | }
116 |
117 | void MainPage::Log (GoogleAnalytics::Hit^ hit, String^ message)
118 | {
119 |
120 | if ( isRunningInDebugMode )
121 | {
122 | if (AnalyticsManager::Current->DispatchPeriod.Duration > 0)
123 | message = "Using Dispatcher- which batches activity. Here is the last hit sent\n" + message;
124 |
125 | if (Dispatcher->HasThreadAccess)
126 | {
127 | Results->Text = message;
128 | Request->Text = Parse(hit);
129 | }
130 | else
131 | Dispatcher->RunAsync(Windows::UI::Core::CoreDispatcherPriority::Normal,
132 | ref new Windows::UI::Core::DispatchedHandler([this, message, hit]()
133 | {
134 | Results->Text = message;
135 | Request->Text = Parse(hit);
136 | }));
137 | }
138 | // Output to console regardless
139 | ::OutputDebugString(message->Data());
140 | }
141 |
142 |
143 | String^ MainPage::Parse(Hit^ hit)
144 | {
145 | String^ retVal = "";
146 |
147 | if (hit != nullptr )
148 | {
149 | for ( IKeyValuePair^ item : hit->Data )
150 | {
151 | retVal += item->Key + ":" + item->Value + "\n";
152 | }
153 |
154 | }
155 | return retVal;
156 |
157 | }
158 |
159 | /*
160 | private void AnalyticsManager_HitFailed(object sender, HitFailedEventArgs e)
161 | {
162 | Log(e.Hit, $"**Hit Failed** {Environment.NewLine} {e.Error.Message}");
163 |
164 | }
165 |
166 | private void AnalyticsManager_HitMalformed(object sender, HitMalformedEventArgs e)
167 | {
168 | Log(e.Hit, $"**Hit Malformed ** {Environment.NewLine} {e.HttpStatusCode.ToString()}");
169 | }
170 |
171 | private void AnalyticsManager_HitSent(object sender, HitSentEventArgs e)
172 | {
173 | Log(e.Hit, e.Response);
174 | }
175 |
176 | */
177 |
178 |
179 |
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Native/MainPage.xaml.h:
--------------------------------------------------------------------------------
1 | //
2 | // MainPage.xaml.h
3 | // Declaration of the MainPage class.
4 | //
5 |
6 | #pragma once
7 |
8 | #include "MainPage.g.h"
9 |
10 | namespace GoogleAnalytics_Sample_Native
11 | {
12 | ///
13 | /// An empty page that can be used on its own or navigated to within a Frame.
14 | ///
15 | public ref class MainPage sealed
16 | {
17 | public:
18 | MainPage();
19 |
20 |
21 |
22 | private:
23 | bool isRunningInDebugMode;
24 | void ButtonEvent_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
25 | void ButtonView_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
26 | void ButtonSocial_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
27 | void ButtonTiming_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
28 | void ButtonException_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
29 | void ButtonThrowException_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
30 | void IsDebugRequest_Checked(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
31 |
32 |
33 |
34 |
35 | void AnalyticsManager_HitFailed (Object ^ unused, GoogleAnalytics::HitFailedEventArgs ^args);
36 | void AnalyticsManager_HitMalformed (Object ^ unused, GoogleAnalytics::HitMalformedEventArgs ^args);
37 | void AnalyticsManager_HitSent(Object ^ unused, GoogleAnalytics::HitSentEventArgs ^args);
38 |
39 |
40 | protected:
41 | void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
42 | void Log(GoogleAnalytics::Hit^ hit, Platform::String^ message);
43 | Platform::String^ Parse(GoogleAnalytics::Hit ^ hit);
44 |
45 |
46 | };
47 | }
48 |
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Native/Package.appxmanifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | GoogleAnalytics.Sample.Native
7 | dotnet
8 | Assets\StoreLogo.png
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Native/pch.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // pch.cpp
3 | // Include the standard header and generate the precompiled header.
4 | //
5 |
6 | #include "pch.h"
7 |
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.Sample.Native/pch.h:
--------------------------------------------------------------------------------
1 | //
2 | // pch.h
3 | // Header for standard system include files.
4 | //
5 |
6 | #pragma once
7 |
8 | #include
9 | #include
10 |
11 | #include "App.xaml.h"
12 |
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.UWP/DateTimeHelper.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // DateTimeHelper.cpp
3 | // Implementation of the DateTimeHelper class.
4 | //
5 |
6 | #include "pch.h"
7 | #include "DateTimeHelper.h"
8 |
9 | using namespace GoogleAnalytics;
10 | using namespace Platform;
11 | using namespace Windows::Foundation;
12 | using namespace Windows::Globalization;
13 |
14 | DateTime DateTimeHelper::Now()
15 | {
16 | auto calendar = ref new Calendar();
17 | return calendar->GetDateTime();
18 | }
19 |
20 | DateTime DateTimeHelper::FromUniversalTime(long long universalTime)
21 | {
22 | DateTime result = DateTime();
23 | result.UniversalTime = universalTime;
24 | return result;
25 | }
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.UWP/DateTimeHelper.h:
--------------------------------------------------------------------------------
1 | //
2 | // DateTimeHelper.h
3 | // Declaration of the DateTimeHelper class.
4 | //
5 |
6 | #pragma once
7 |
8 | namespace GoogleAnalytics
9 | {
10 | ref class DateTimeHelper sealed
11 | {
12 |
13 | internal:
14 | static Windows::Foundation::DateTime Now();
15 |
16 | static Windows::Foundation::DateTime FromUniversalTime(long long universalTime);
17 |
18 | };
19 | }
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.UWP/Dimensions.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | //
3 | // Dimensions.h
4 | // Declaration of the Dimensions structure .
5 | //
6 |
7 | namespace GoogleAnalytics
8 | {
9 | ///
10 | /// Dimensions in pixels.
11 | ///
12 | public value struct Dimensions sealed
13 | {
14 | public:
15 | ///
16 | /// Creates a new object to store dimensions.
17 | ///
18 | /// The width in pixels.
19 | /// The height in pixels.
20 | /*Dimensions(int width, int height)
21 | {
22 | Width = width;
23 | Height = height;
24 | }*/
25 |
26 |
27 | ///
28 | /// Gets the width in pixels.
29 | ///
30 | float Width;
31 |
32 |
33 | ///
34 | /// Gets the height in pixels.
35 | ///
36 | float Height;
37 | };
38 | }
39 |
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.UWP/Ecommerce/Product.h:
--------------------------------------------------------------------------------
1 | //
2 | // Product.h
3 | // Declaration of the Product class.
4 | //
5 |
6 | #pragma once
7 |
8 | #include
9 | #include "ProductAction.h" // this is needed for Xmldocs :)
10 | namespace GoogleAnalytics
11 | {
12 | namespace Ecommerce
13 | {
14 | ///
15 | /// Class to construct product related information for a Google Analytics hit. Use this class to report information about products sold by merchants or impressions of products seen by users. Instances of this class can be associated with both s via addProduct(Product) and Product Impressions via addImpression(Product, String).
16 | ///
17 | public ref class Product sealed
18 | {
19 |
20 | private:
21 |
22 | Windows::Foundation::Collections::IMap^ customDimensions;
23 |
24 | Windows::Foundation::Collections::IMap^ customMetrics;
25 |
26 | public:
27 |
28 | Product()
29 | : customDimensions(ref new Platform::Collections::Map())
30 | , customMetrics(ref new Platform::Collections::Map())
31 | { }
32 |
33 | ///
34 | /// Gets or sets the brand associated with the product in GA reports.
35 | ///
36 | property Platform::String^ Brand;
37 |
38 | ///
39 | /// Gets or sets the category associated with the product in GA reports.
40 | ///
41 | property Platform::String^ Category;
42 |
43 | ///
44 | /// Gets or sets the coupon code associated with the product.
45 | ///
46 | property Platform::String^ CouponCode;
47 |
48 | ///
49 | /// Gets or sets the custom dimensions associated with the product.
50 | ///
51 | property Windows::Foundation::Collections::IMap^ CustomDimensions
52 | {
53 | Windows::Foundation::Collections::IMap^ get() { return customDimensions; }
54 | }
55 |
56 | ///
57 | /// Gets or sets the custom metrics associated with the product.
58 | ///
59 | property Windows::Foundation::Collections::IMap^ CustomMetrics
60 | {
61 | Windows::Foundation::Collections::IMap^ get() { return customMetrics; }
62 | }
63 |
64 | ///
65 | /// Gets or sets the id that is used to identify a product in GA reports.
66 | ///
67 | property Platform::String^ Id;
68 |
69 | ///
70 | /// Gets or sets the name that is used to identify the product in GA reports.
71 | ///
72 | property Platform::String^ Name;
73 |
74 | ///
75 | /// Gets or sets the position of the product on the page/product impression list etc.
76 | ///
77 | property Platform::IBox^ Position;
78 |
79 | ///
80 | /// Gets or sets the price of the product.
81 | ///
82 | property Platform::IBox^ Price;
83 |
84 | ///
85 | /// Gets or sets the quantity of the product.
86 | ///
87 | property Platform::IBox^ Quantity;
88 |
89 | ///
90 | /// Gets or sets the variant of the product.
91 | ///
92 | property Platform::String^ Variant;
93 |
94 | };
95 | }
96 | }
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.UWP/Ecommerce/ProductAction.h:
--------------------------------------------------------------------------------
1 | //
2 | // ProductAction.h
3 | // Declaration of the ProductAction class.
4 | //
5 | #pragma once
6 |
7 | #include "Product.h" // xmldocs
8 | #include "HitBuilder.h" // xmldocs
9 |
10 | namespace GoogleAnalytics
11 | {
12 | namespace Ecommerce
13 | {
14 | public enum class ActionEnum
15 | {
16 | ///
17 | /// Action to use when a product is added to the cart.
18 | ///
19 | Add,
20 | ///
21 | /// Action to use for hits with checkout data.
22 | ///
23 | Checkout,
24 | ///
25 | /// Action to be used for supplemental checkout data that needs to be provided after a checkout hit.
26 | ///
27 | CheckoutOption,
28 | ///
29 | /// Action to use when the user clicks on a set of products.
30 | ///
31 | Click,
32 | ///
33 | /// Action to use when the user views detailed descriptions of products.
34 | ///
35 | Detail,
36 | ///
37 | /// Action that is used to report all the transaction data to GA.
38 | ///
39 | Purchase,
40 | ///
41 | /// Action to use while reporting refunded transactions to GA.
42 | ///
43 | Refund,
44 | ///
45 | /// Action to use when a product is removed from the cart.
46 | ///
47 | Remove
48 | };
49 |
50 | ref class Product; //xmldocs
51 |
52 | ///
53 | /// Class to construct transaction/checkout or other product interaction related information for a Google Analytics hit. Use this class to report information about products sold, viewed or refunded. This class is intended to be used with . Instances of this class can be associated with HitBuilder::SetProductAction"/>.
54 | ///
55 | public ref class ProductAction sealed
56 | {
57 |
58 | private:
59 |
60 | Platform::String^ action;
61 |
62 | internal:
63 |
64 | static Platform::String^ GetAction(ActionEnum action)
65 | {
66 | switch (action)
67 | {
68 | case ActionEnum::Add:
69 | return "add";
70 | case ActionEnum::Checkout:
71 | return "checkout";
72 | case ActionEnum::CheckoutOption:
73 | return "checkout_option";
74 | case ActionEnum::Click:
75 | return "click";
76 | case ActionEnum::Detail:
77 | return "detail";
78 | case ActionEnum::Purchase:
79 | return "purchase";
80 | case ActionEnum::Refund:
81 | return "refund";
82 | case ActionEnum::Remove:
83 | return "remove";
84 | default:
85 | throw ref new Platform::NotImplementedException();
86 | }
87 | }
88 |
89 | public:
90 |
91 | ///
92 | /// Creates a new instance of with the product action for all the products included in the hit. Valid values include "detail", "click", "add", "remove", "checkout", "checkout_option", "purchase" and "refund". All these values are also defined in this class for ease of use. You also also send additional values with the hit for some specific actions. See the action documentation for details.
93 | ///
94 | /// The action type to send.
95 | ProductAction(ActionEnum action): action(GetAction(action))
96 | { }
97 |
98 | ///
99 | /// Gets the product action for all the products included in the hit.
100 | ///
101 | property Platform::String^ Action
102 | {
103 | Platform::String^ get() { return action; }
104 | }
105 |
106 | ///
107 | /// Gets the label associated with the checkout. This value is used for and actions.
108 | ///
109 | property Platform::String^ CheckoutOptions;
110 |
111 | ///
112 | /// Gets or sets the checkout processes's progress. This value is used for and actions.
113 | ///
114 | property Platform::IBox^ CheckoutStep;
115 |
116 | ///
117 | /// Gets or sets the list name associated with the products in the analytics hit. This value is used for and actions.
118 | ///
119 | property Platform::String^ ProductActionList;
120 |
121 | ///
122 | /// Gets or sets the list source name associated with the products in the analytics hit. This value is used for and actions.
123 | ///
124 | property Platform::String^ ProductListSource;
125 |
126 | ///
127 | /// Gets or sets the transaction's affiliation value. This value is used for and actions.
128 | ///
129 | property Platform::String^ TransactionAffiliation;
130 |
131 | ///
132 | /// Gets or sets the coupon code used in a transaction. This value is used for and actions.
133 | ///
134 | property Platform::String^ TransactionCouponCode;
135 |
136 | ///
137 | /// The unique id associated with the transaction. This value is used for and actions.
138 | ///
139 | property Platform::String^ TransactionId;
140 |
141 | ///
142 | /// Gets or sets the transaction's total revenue. This value is used for and actions.
143 | ///
144 | property Platform::IBox^ TransactionRevenue;
145 |
146 | ///
147 | /// Gets or sets the transaction's shipping costs. This value is used for and actions.
148 | ///
149 | property Platform::IBox^ TransactionShipping;
150 |
151 | ///
152 | /// Gets or sets the transaction's total tax. This value is used for and actions.
153 | ///
154 | property Platform::IBox^ TransactionTax;
155 |
156 | };
157 |
158 | }
159 | }
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.UWP/Ecommerce/Promotion.h:
--------------------------------------------------------------------------------
1 | //
2 | // Product.h
3 | // Declaration of the Product class.
4 | //
5 |
6 | #pragma once
7 |
8 | namespace GoogleAnalytics
9 | {
10 | namespace Ecommerce
11 | {
12 | public enum class PromotionAction
13 | {
14 | Click,
15 | View
16 | };
17 |
18 | public ref class Promotion sealed
19 | {
20 |
21 | internal:
22 |
23 | static Platform::String^ GetAction(PromotionAction action)
24 | {
25 | switch (action)
26 | {
27 | case PromotionAction::Click:
28 | return "click";
29 | case PromotionAction::View:
30 | return "view";
31 | default:
32 | throw ref new Platform::NotImplementedException();
33 | }
34 | }
35 |
36 | public:
37 |
38 | property Platform::String^ Creative;
39 |
40 | property Platform::String^ Id;
41 |
42 | property Platform::String^ Name;
43 |
44 | property Platform::String^ Position;
45 |
46 | };
47 |
48 | }
49 | }
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.UWP/Hit.h:
--------------------------------------------------------------------------------
1 | //
2 | // Payload.h
3 | // Declaration of the Payload class.
4 | //
5 |
6 | #pragma once
7 |
8 | #include "DateTimeHelper.h"
9 |
10 | namespace GoogleAnalytics
11 | {
12 |
13 | ///
14 | /// Represents a single event to track.
15 | ///
16 | public ref class Hit sealed
17 | {
18 | private:
19 | Windows::Foundation::DateTime timeStamp;
20 |
21 | Windows::Foundation::Collections::IMap^ data;
22 |
23 | internal:
24 |
25 | Hit(Windows::Foundation::Collections::IMap^ data)
26 | : data(data)
27 | , timeStamp(DateTimeHelper::Now())
28 | { }
29 |
30 |
31 | public:
32 | ///
33 | /// Gets the key value pairs to send to Google Analytics.
34 | ///
35 | property Windows::Foundation::Collections::IMap^ Data
36 | {
37 | Windows::Foundation::Collections::IMap^ get()
38 | {
39 | return data;
40 | }
41 | }
42 |
43 | ///
44 | /// Gets the timestamp that the event was created.
45 | ///
46 | property Windows::Foundation::DateTime TimeStamp
47 | {
48 | Windows::Foundation::DateTime get()
49 | {
50 | return timeStamp;
51 | }
52 | }
53 |
54 | };
55 | }
56 |
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.UWP/IPlatformInfoProvider.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Dimensions.h"
4 |
5 |
6 | namespace GoogleAnalytics
7 | {
8 | ///
9 | /// Interface to offer a way to provide all environment and platform level information required by Google Analytics.
10 | ///
11 | public interface class IPlatformInfoProvider
12 | {
13 | ///
14 | /// Raised to indicate that the has changed.
15 | ///
16 | event Windows::Foundation::EventHandler^ ViewPortResolutionChanged;
17 |
18 | ///
19 | /// Raised to indicate that the has changed.
20 | ///
21 | event Windows::Foundation::EventHandler^ ScreenResolutionChanged;
22 |
23 | ///
24 | /// Callback that indicates something is about to be logged.
25 | ///
26 | /// This allows lazy loading of values that might not be available immediately.
27 | void OnTracking();
28 |
29 | ///
30 | /// Gets the value that anonymously identifies a particular user, device, or browser instance. For the web, this is generally stored as a first-party cookie with a two-year expiration. For mobile apps, this is randomly generated for each particular instance of an application install. The value of this field should be a random UUID (version 4) as described in .
31 | ///
32 | property Platform::String^ AnonymousClientId
33 | {
34 | Platform::String^ get();
35 | }
36 |
37 | ///
38 | /// Gets the Viewport Resolution.
39 | ///
40 | property Platform::IBox^ ViewPortResolution
41 | {
42 | Platform::IBox^ get();
43 | }
44 |
45 | ///
46 | /// Gets the screen resolution.
47 | ///
48 | property Platform::IBox^ ScreenResolution
49 | {
50 | Platform::IBox^ get();
51 | }
52 |
53 | ///
54 | /// Gets the language (e.g. 'en-us').
55 | ///
56 | property Platform::String^ UserLanguage
57 | {
58 | Platform::String^ get();
59 | }
60 |
61 | ///
62 | /// Gets the screen color depth.
63 | ///
64 | property Platform::IBox^ ScreenColors
65 | {
66 | Platform::IBox^ get();
67 | }
68 |
69 | property Platform::String^ UserAgent
70 | {
71 | Platform::String^ get();
72 | }
73 |
74 | };
75 | }
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.UWP/IServiceManager.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | using namespace Platform;
4 | namespace GoogleAnalytics
5 | {
6 | ///
7 | /// Interface for a service manager used to send hits to Google Analytics.
8 | ///
9 | public interface class IServiceManager
10 | {
11 | void EnqueueHit(Windows::Foundation::Collections::IMap^ params);
12 | };
13 |
14 | }
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.UWP/PlatformInfoProvider.h:
--------------------------------------------------------------------------------
1 | //
2 | // PlatformInfoProvider.h
3 | // Declaration of the PlatformInfoProvider class.
4 | //
5 |
6 | #pragma once
7 |
8 | #include
9 | #include "IPlatformInfoProvider.h"
10 |
11 | namespace GoogleAnalytics
12 | {
13 | ///
14 | /// Windows 10, Universal Platform implementation of .
15 | ///
16 | public ref class PlatformInfoProvider sealed : IPlatformInfoProvider
17 | {
18 | private:
19 |
20 | Platform::Agile coreWindow;
21 |
22 | Windows::Foundation::EventRegistrationToken sizeChangedEventToken;
23 |
24 | static Platform::String^ Key_AnonymousClientId;
25 |
26 | Platform::String^ anonymousClientId;
27 |
28 | bool windowInitialized;
29 |
30 | void InitializeWindow();
31 |
32 | void UninitializeWindow();
33 |
34 | void Window_SizeChanged(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::WindowSizeChangedEventArgs^ e);
35 |
36 | Platform::IBox^ viewPortResolution;
37 |
38 | Platform::IBox^ screenResolution;
39 |
40 | void SetViewPortResolution(Platform::IBox^ value);
41 | void SetScreenResolution(Platform::IBox^ value);
42 |
43 |
44 |
45 | internal:
46 |
47 | static Platform::String^ ConstructUserAgent();
48 |
49 | public:
50 |
51 | PlatformInfoProvider();
52 |
53 | virtual ~PlatformInfoProvider();
54 |
55 | ///
56 | virtual event Windows::Foundation::EventHandler^ ViewPortResolutionChanged;
57 |
58 | ///
59 | virtual event Windows::Foundation::EventHandler^ ScreenResolutionChanged;
60 |
61 | ///
62 | virtual void OnTracking();
63 |
64 | ///
65 | property Platform::String^ AnonymousClientId
66 | {
67 | virtual Platform::String^ get();
68 | void set(Platform::String^ value);
69 | }
70 |
71 | ///
72 | virtual property Platform::IBox^ ViewPortResolution
73 | {
74 | Platform::IBox^ get();
75 | }
76 |
77 | ///
78 | virtual property Platform::IBox^ ScreenResolution
79 | {
80 | Platform::IBox^ get();
81 | }
82 |
83 | ///
84 | virtual property Platform::String^ UserLanguage
85 | {
86 | Platform::String^ get();
87 | }
88 |
89 | ///
90 | virtual property Platform::IBox^ ScreenColors
91 | {
92 | Platform::IBox^ get();
93 | }
94 |
95 | virtual property Platform::String^ UserAgent
96 | {
97 | Platform::String^ get();
98 | }
99 |
100 | };
101 | }
102 |
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.UWP/TimeSpanHelper.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // TimeSpanHelper.cpp
3 | // Implementation of the TimeSpanHelper class.
4 | //
5 |
6 | #include "pch.h"
7 | #include
8 | #include "TimeSpanHelper.h"
9 |
10 | using namespace GoogleAnalytics;
11 | using namespace Platform;
12 | using namespace Windows::Foundation;
13 |
14 | TimeSpan TimeSpanHelper::Min(TimeSpan timeSpan1, TimeSpan timeSpan2)
15 | {
16 | return timeSpan1.Duration < timeSpan2.Duration ? timeSpan1 : timeSpan2;
17 | }
18 |
19 | TimeSpan TimeSpanHelper::Max(TimeSpan timeSpan1, TimeSpan timeSpan2)
20 | {
21 | return timeSpan1.Duration > timeSpan2.Duration ? timeSpan1 : timeSpan2;
22 | }
23 |
24 | TimeSpan TimeSpanHelper::Parse(String^ string)
25 | {
26 | double decimal = 0.0;
27 | long seconds = 0;
28 | long minutes = 0;
29 | long hours = 0;
30 |
31 | std::wstring s(string->Data());
32 | // decimal
33 | size_t di = s.find_last_of('.');
34 | if (di != std::string::npos)
35 | {
36 | std::wstring ds(s.substr(di + 1));
37 | long parsedDecimal = std::wcstol(ds.data(), nullptr, 10);
38 | decimal = parsedDecimal / std::pow(10, ds.length());
39 | }
40 | // seconds
41 | size_t si = s.find_last_of(':');
42 | {
43 | size_t starti = si != std::string::npos ? si : -1;
44 | size_t endi = di != std::string::npos ? di : s.length();
45 | std::wstring ss(s.substr(starti + 1, endi - starti - 1));
46 | seconds = std::wcstol(ss.data(), nullptr, 10);
47 | }
48 | // minutes
49 | if (si != std::string::npos)
50 | {
51 | size_t mi = s.find_last_of(':', si - 1);
52 | size_t starti = mi != std::string::npos ? mi : -1;
53 | std::wstring ms(s.substr(starti + 1, si - starti - 1));
54 | minutes = std::wcstol(ms.data(), nullptr, 10);
55 | // hours
56 | if (mi != std::string::npos)
57 | {
58 | std::wstring hs(s.substr(0, mi));
59 | hours = std::wcstol(hs.data(), nullptr, 10);
60 | }
61 | }
62 |
63 | double totalSeconds = ((hours * 60 + minutes) * 60 + seconds) + decimal;
64 | return TimeSpanHelper::FromSeconds(totalSeconds);
65 | }
66 |
67 | String^ TimeSpanHelper::ConvertToString(TimeSpan timeSpan)
68 | {
69 | long long runningDuration = timeSpan.Duration;
70 |
71 | int hours = (int)(runningDuration / 36000000000);
72 | runningDuration -= hours * 36000000000;
73 |
74 | int minutes = (int)(runningDuration / 600000000);
75 | runningDuration -= minutes * 600000000;
76 |
77 | int seconds = (int)(runningDuration / 10000000);
78 | runningDuration -= seconds * 10000000;
79 |
80 | int milliseconds = (int)(runningDuration / 10000);
81 | runningDuration -= milliseconds * 10000;
82 |
83 | String^ result = "";
84 | // hours
85 | if (hours != 0)
86 | {
87 | result += hours.ToString() + ":";
88 | }
89 | // minutes
90 | if (hours == 0)
91 | {
92 | result += minutes.ToString() + ":";
93 | }
94 | else
95 | {
96 | if (minutes < 10)
97 | {
98 | result += "0" + minutes.ToString();
99 | }
100 | result += minutes.ToString() + ":";
101 | }
102 | // seconds
103 | if (seconds < 10)
104 | {
105 | result += "0" + seconds.ToString();
106 | }
107 | result += seconds.ToString();
108 | // milliseconds
109 | if (milliseconds > 0)
110 | {
111 | result += "." + milliseconds.ToString();
112 | }
113 |
114 | return result;
115 | }
116 |
117 | TimeSpan TimeSpanHelper::FromTicks(long long ticks)
118 | {
119 | TimeSpan ts;
120 | ts.Duration = ticks;
121 | return ts;
122 | }
123 |
124 | TimeSpan TimeSpanHelper::FromHours(double hours)
125 | {
126 | TimeSpan ts;
127 | ts.Duration = (long long)(hours * 36000000000.0);
128 | return ts;
129 | }
130 |
131 | TimeSpan TimeSpanHelper::FromMinutes(double minutes)
132 | {
133 | TimeSpan ts;
134 | ts.Duration = (long long)(minutes * 600000000.0);
135 | return ts;
136 | }
137 |
138 | TimeSpan TimeSpanHelper::FromSeconds(double seconds)
139 | {
140 | TimeSpan ts;
141 | ts.Duration = (long long)(seconds * 10000000.0);
142 | return ts;
143 | }
144 |
145 | TimeSpan TimeSpanHelper::FromMilliseconds(double milliseconds)
146 | {
147 | TimeSpan ts;
148 | ts.Duration = (long long)(milliseconds * 10000.0);
149 | return ts;
150 | }
151 |
152 | double TimeSpanHelper::GetTotalMinutes(TimeSpan timeSpan)
153 | {
154 | return (double)timeSpan.Duration / 600000000.0;
155 | }
156 |
157 | double TimeSpanHelper::GetTotalHours(TimeSpan timeSpan)
158 | {
159 | return (double)timeSpan.Duration / 36000000000.0;
160 | }
161 |
162 | double TimeSpanHelper::GetTotalSeconds(TimeSpan timeSpan)
163 | {
164 | return (double)timeSpan.Duration / 10000000.0;
165 | }
166 |
167 | double TimeSpanHelper::GetTotalMilliseconds(TimeSpan timeSpan)
168 | {
169 | return (double)(timeSpan.Duration) / 10000.0;
170 | }
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.UWP/TimeSpanHelper.h:
--------------------------------------------------------------------------------
1 | //
2 | // TimeSpanHelper.h
3 | // Declaration of the TimeSpanHelper class.
4 | //
5 |
6 | #pragma once
7 |
8 | namespace GoogleAnalytics
9 | {
10 | ref class TimeSpanHelper sealed
11 | {
12 |
13 | internal:
14 | static Windows::Foundation::TimeSpan Min(Windows::Foundation::TimeSpan timeSpan1, Windows::Foundation::TimeSpan timeSpan2);
15 |
16 | static Windows::Foundation::TimeSpan Max(Windows::Foundation::TimeSpan timeSpan1, Windows::Foundation::TimeSpan timeSpan2);
17 |
18 | static Windows::Foundation::TimeSpan FromTicks(long long ticks);
19 |
20 | static Windows::Foundation::TimeSpan FromHours(double seconds);
21 |
22 | static Windows::Foundation::TimeSpan FromMinutes(double seconds);
23 |
24 | static Windows::Foundation::TimeSpan FromSeconds(double seconds);
25 |
26 | static Windows::Foundation::TimeSpan FromMilliseconds(double milliseconds);
27 |
28 | static double GetTotalMinutes(Windows::Foundation::TimeSpan timeSpan);
29 |
30 | static double GetTotalHours(Windows::Foundation::TimeSpan timeSpan);
31 |
32 | static double GetTotalSeconds(Windows::Foundation::TimeSpan timeSpan);
33 |
34 | static double GetTotalMilliseconds(Windows::Foundation::TimeSpan timeSpan);
35 |
36 | static Windows::Foundation::TimeSpan Parse(Platform::String^ string);
37 |
38 | static Platform::String^ ConvertToString(Windows::Foundation::TimeSpan timeSpan);
39 | };
40 | }
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.UWP/TokenBucket.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // TokenBucket.cpp
3 | // Implementation of the TokenBucket class.
4 | //
5 |
6 | #include "pch.h"
7 | #include "TokenBucket.h"
8 | #include "DateTimeHelper.h"
9 | #include "TimeSpanHelper.h"
10 |
11 | using namespace GoogleAnalytics;
12 | using namespace Platform;
13 | using namespace Windows::Foundation;
14 |
15 | TokenBucket::TokenBucket(double tokens, double fillRate) :
16 | capacity(tokens),
17 | tokens(tokens),
18 | fillRate(fillRate)
19 | {
20 | timeStamp = DateTimeHelper::Now();
21 | }
22 |
23 | bool TokenBucket::Consume(double tokens)
24 | {
25 | std::lock_guard lg(locker); // make thread safe
26 | if (GetTokens() - tokens > 0)
27 | {
28 | this->tokens -= tokens;
29 | return true;
30 | }
31 | else
32 | {
33 | return false;
34 | }
35 | }
36 |
37 | double TokenBucket::GetTokens()
38 | {
39 | auto now = DateTimeHelper::Now();
40 | if (tokens < capacity)
41 | {
42 | auto delta = fillRate * TimeSpanHelper::GetTotalSeconds(TimeSpanHelper::FromTicks(now.UniversalTime - timeStamp.UniversalTime));
43 | tokens = capacity < tokens + delta ? capacity : tokens + delta;
44 | timeStamp = now;
45 | }
46 | return tokens;
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.UWP/TokenBucket.h:
--------------------------------------------------------------------------------
1 | //
2 | // TokenBucket.h
3 | // Declaration of the TokenBucket class.
4 | //
5 |
6 | #pragma once
7 |
8 | #include
9 |
10 | namespace GoogleAnalytics
11 | {
12 |
13 | ref class TokenBucket sealed
14 | {
15 | private:
16 |
17 | double capacity;
18 |
19 | double tokens;
20 |
21 | double fillRate;
22 |
23 | Windows::Foundation::DateTime timeStamp;
24 |
25 | std::mutex locker;
26 |
27 | double GetTokens();
28 |
29 | internal:
30 |
31 | TokenBucket(double tokens, double fillRate);
32 |
33 | bool Consume(double tokens = 1.0);
34 |
35 | };
36 | }
37 |
--------------------------------------------------------------------------------
/src/Native/GoogleAnalytics.UWP/Tracker.cpp:
--------------------------------------------------------------------------------
1 | //
2 | // Tracker.cpp
3 | // Implementation of the Tracker class.
4 | //
5 |
6 | #include "pch.h"
7 | #include "Tracker.h"
8 | #include "TokenBucket.h"
9 |
10 | using namespace GoogleAnalytics;
11 | using namespace Platform;
12 | using namespace Platform::Collections;
13 | using namespace Windows::Foundation::Collections;
14 | using namespace Windows::Foundation;
15 |
16 | Tracker::Tracker(String^ propertyId, IPlatformInfoProvider^ platformInfoProvider, IServiceManager^ analyticsManager)
17 | {
18 | this->propertyId = propertyId;
19 | this->platformInfoProvider = platformInfoProvider;
20 | this->analyticsManager = analyticsManager;
21 | SampleRate = 100.0F;
22 | data = ref new Map();
23 |
24 | if (platformInfoProvider != nullptr)
25 | {
26 | ClientId = platformInfoProvider->AnonymousClientId;
27 | ScreenColors = platformInfoProvider->ScreenColors;
28 | ScreenResolution = platformInfoProvider->ScreenResolution;
29 | Language = platformInfoProvider->UserLanguage;
30 | ViewportSize = platformInfoProvider->ViewPortResolution;
31 | viewPortResolutionChangedEventToken = platformInfoProvider->ViewPortResolutionChanged += ref new EventHandler