Share via


ConnectionProfile.GetAttributedNetworkUsageAsync Method

Definition

Retrieves per-attribution (application or bucket) usage (bytes sent / received and connected duration) over a specified time window with optional NetworkUsageStates filtering.

public:
 virtual IAsyncOperation<IVectorView<AttributedNetworkUsage ^> ^> ^ GetAttributedNetworkUsageAsync(DateTime startTime, DateTime endTime, NetworkUsageStates states) = GetAttributedNetworkUsageAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<IVectorView<AttributedNetworkUsage>> GetAttributedNetworkUsageAsync(DateTime const& startTime, DateTime const& endTime, NetworkUsageStates const& states);
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<IReadOnlyList<AttributedNetworkUsage>> GetAttributedNetworkUsageAsync(System.DateTimeOffset startTime, System.DateTimeOffset endTime, NetworkUsageStates states);
function getAttributedNetworkUsageAsync(startTime, endTime, states)
Public Function GetAttributedNetworkUsageAsync (startTime As DateTimeOffset, endTime As DateTimeOffset, states As NetworkUsageStates) As IAsyncOperation(Of IReadOnlyList(Of AttributedNetworkUsage))

Parameters

startTime
DateTime DateTimeOffset

The start time of the usage window.

endTime
DateTime DateTimeOffset

The end time of the usage window.

states
NetworkUsageStates

The state of the connection profile for which usage data should be returned.

Returns

A list of AttributedNetworkUsage entries. Each entry includes bytes sent, bytes received, and connected duration for its attribution context during the interval.

Attributes

Windows requirements

App capabilities
networkDataPlanProvisioning

Remarks

This method returns per-application (or attribution bucket) usage over the specified window.

For general usage API best practices (time window management, incremental collection, avoiding double counting), see GetNetworkUsageAsync.

Attribution-specific considerations

Data completeness

  • Empty result: Valid when no usage is recorded or attribution data is unavailable.
  • Aggregate reconciliation: Summing all attributed usage entries may not exactly equal the aggregate usage returned by GetNetworkUsageAsync; some traffic can reside in non-attributed or system buckets.
  • Residual usage: Treat (aggregate - sum(attributed)) as a separate logical bucket if you need a complete picture; do not force attribution of those bytes retroactively.

Attribution stability

  • Attribution identifiers can change across resets or provisioning changes; avoid treating them as permanent keys.
  • Identifier churn: Implement a mapping layer so if an AttributionId disappears you can finalize its prior totals without assuming deletion implies uninstall.

Reconciliation

  • Double counting avoidance: When reconciling, compute deltas per AttributionId between the last committed snapshot and the new snapshot of the same closed bucket range.
  • Apply the same incremental collection patterns as GetNetworkUsageAsync, but track per-attribution totals.

Attribution-aggregate reconciliation workflow

  1. Query aggregate (GetNetworkUsageAsync) and attributed (GetAttributedNetworkUsageAsync) for the same aligned window.
  2. Compute per-id deltas since the previous snapshot for fully closed buckets only.
  3. Sum attributed totals; compute residual = aggregateTotal - attributedTotal (if positive) and track it under an internal "unattributed" key.
  4. Persist updated per-id cumulative totals and new cursor boundary.
  5. Periodically (e.g., hourly) re-query the most recent closed bucket to adjust for late provider accounting; apply only positive deltas.

This pattern yields stable cumulative accounting without retroactive double counting and gracefully handles late adjustments and identifier changes.

Applies to

See also