Skip to content

Commit

Permalink
Merge pull request #124 from Microsoft/abaranch/fixDateTime
Browse files Browse the repository at this point in the history
DateTime is not set for unconfigured experience.
  • Loading branch information
abaranch committed Nov 23, 2015
2 parents 8ba658b + 607cce2 commit 0cae65d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
10 changes: 10 additions & 0 deletions Test/CoreSDK.Test/Shared/TelemetryClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ public void TrackEventWillSendPropertiesIfProvidedInline()
Assert.Equal("yoyo", eventTelemetry.Properties["blah"]);
}

[TestMethod]
public void InitializeSetsDateTime()
{
EventTelemetry telemetry = new EventTelemetry("TestEvent");

new TelemetryClient().Initialize(telemetry);

Assert.True(telemetry.Timestamp != default(DateTimeOffset));
}

#endregion

#region TrackMetric
Expand Down
10 changes: 5 additions & 5 deletions src/Core/Managed/Shared/TelemetryClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,6 @@ public void Track(ITelemetry telemetry)
return;
}

if (telemetry.Timestamp == default(DateTimeOffset))
{
telemetry.Timestamp = Clock.Instance.Time;
}

// invokes the Process in the first processor in the chain
this.configuration.TelemetryProcessors.Process(telemetry);

Expand Down Expand Up @@ -376,6 +371,11 @@ public void Initialize(ITelemetry telemetry)
exception));
}
}

if (telemetry.Timestamp == default(DateTimeOffset))
{
telemetry.Timestamp = Clock.Instance.Time;
}
}

/// <summary>
Expand Down

0 comments on commit 0cae65d

Please sign in to comment.