Skip to content

Commit 5ea3aa9

Browse files
Create README.md for installer insights (#5265)
1 parent f254a90 commit 5ea3aa9

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed

installer/README.md

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# Installer Insights Flow
2+
3+
This document illustrates how insight events flow through the Windows App SDK installer — from
4+
initialization to structured events of success, warnings, and failures. It highlights where and how
5+
`StopWithResult()` is called, what triggers the WIL failure callback, and how different failure
6+
types are handled.
7+
8+
---
9+
10+
## Summary: How Insights Work
11+
12+
### Setup
13+
14+
- `main.cpp` initializes TraceLogging by:
15+
- Setting a global WIL failure logging callback with `wil::SetResultLoggingCallback()`.
16+
- Instantiating the process-wide `InstallActivity::Context`, which tracks current install stage,
17+
error metadata, resource ID, and logging state.
18+
19+
### Installer Logic Runs
20+
21+
- The installer calls `Deploy()` → which calls `InstallLicenses()` and `DeployPackages()`.
22+
- Each of these stages updates the shared `Context` with its current install stage (e.g.
23+
`AddPackage`, `ProvisionPackage`, etc.).
24+
- Errors are reported using WIL macros like `THROW_IF_FAILED`, `LOG_IF_FAILED`, or
25+
`RETURN_IF_FAILED`.
26+
27+
### Insights on Failure
28+
29+
- WIL errors (e.g. HRESULT failures, file/line context) trigger the global
30+
`wilResultLoggingCallback()`.
31+
- The callback logs events via TraceLogging and sometimes logs to Windows Event Log using
32+
`ReportEventW()`.
33+
- There are different branches depending on severity:
34+
- Non-blocking errors (e.g. provisioning or push notification restarts) are logged but don’t halt
35+
the install.
36+
- Fail-fast or final install errors result in a call to `StopWithResult()` to emit the full
37+
insights payload.
38+
39+
---
40+
41+
## Insights Flow Overview
42+
This diagram shows when events are logged based on install success or failure and how different
43+
failure types are handled.
44+
45+
```mermaid
46+
flowchart TD
47+
A[Start in main.cpp]
48+
B[SetActivity - Start insights activity]
49+
C[Register WIL failure callback]
50+
D["Call Deploy()"]
51+
E{Failure during install?}
52+
F["Call StopWithResult(S_OK)"]
53+
G[Log success TraceLogging and Event Log]
54+
H["wilResultLoggingCallback()"]
55+
I{FailureType}
56+
J1["Log warning<br/>(e.g. ProvisioningFailed)"]
57+
J2[Save failure in Context]
58+
J3[Log StopWithResult<br/>immediately]
59+
X[Exit process immediately]
60+
K[Continue install]
61+
L{"Deploy() completed?"}
62+
M[main.cpp reads Context failure]
63+
N["Call StopWithResult(failure)"]
64+
O[Log failure insights<br/>and Event Log]
65+
66+
A --> B
67+
B --> C
68+
C --> D
69+
D --> E
70+
71+
E -- No --> F
72+
F --> G
73+
74+
E -- Yes --> H
75+
H --> I
76+
77+
I -- FailureLog --> J1
78+
J1 --> K
79+
80+
I -- Exception/Return --> J2
81+
J2 --> K
82+
83+
I -- FailFast --> J3
84+
J3 --> X
85+
86+
K --> L
87+
L -- Yes --> M
88+
M --> N
89+
N --> O
90+
```
91+
## `InstallActivity::Context` Overview
92+
93+
The `InstallActivity::Context` is a shared object used across the installer to track insights state.
94+
It holds info such as the current install stage, package/resource ID, error HRESULTs, and
95+
TraceLogging activity ID.
96+
97+
This diagram shows how it's accessed, updated, and ultimately used to log structured events:
98+
99+
```mermaid
100+
flowchart TD
101+
102+
%% Startup Phase
103+
subgraph "Startup (main.cpp)"
104+
A["main.cpp starts installer"]
105+
B["Context::Get() → singleton Context instance"]
106+
C["Context::SetActivity()"]
107+
D["Call Deploy(options)"]
108+
A --> B --> C --> D
109+
end
110+
111+
%% Install Phase
112+
subgraph "Install logic"
113+
D --> E["InstallLicenses()"]
114+
D --> F["DeployPackages()"]
115+
F --> G["DeployPackageFromResource()"]
116+
G --> H1["Context::SetInstallStage()"]
117+
G --> H2["Context::SetCurrentResourceId()"]
118+
G --> H3["THROW_IF_FAILED(), LOG_IF_FAILED()"]
119+
end
120+
121+
%% WIL Failure Callback
122+
subgraph "Failure handling (WIL callback)"
123+
H3 --> I["wilResultLoggingCallback()"]
124+
I --> J1["Context::SetLastFailure()"]
125+
I --> J2["Context::SetDeploymentErrorInfo()"]
126+
end
127+
128+
%% Final Outcome
129+
D --> K{"Install succeeded?"}
130+
K -- Yes --> L1["Context::GetActivity().StopWithResult(S_OK)"]
131+
K -- No --> L2["Context::Get() for error info"]
132+
L2 --> L3["Context::GetLastFailure(), GetInstallStage(), etc."]
133+
L3 --> L4["Context::GetActivity().StopWithResult(failure)"]
134+
135+
%% Logging Phase
136+
subgraph "Event output"
137+
L1 --> M1["StopWithResult() logs final TraceLogging event"]
138+
L4 --> M1
139+
M1 --> M2["Also logs to Windows Event Log"]
140+
end

0 commit comments

Comments
 (0)