-
Notifications
You must be signed in to change notification settings - Fork 2
#88 Umami.Net: impossible to specify unique_id / DistinctId / Id #90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,6 +59,8 @@ public UmamiPayload PopulateFromPayload(UmamiPayload? payload, UmamiEventData? d | |
| if (payload.SessionId != null) | ||
| newPayload.SessionId = payload.SessionId; | ||
|
|
||
| if (payload.DistinctId != null) | ||
| newPayload.DistinctId = payload.DistinctId; | ||
|
|
||
| newPayload.UserAgent = payload.UserAgent ?? DefaultUserAgent; | ||
|
|
||
|
Comment on lines
59
to
66
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -71,9 +71,10 @@ public async Task<HttpResponseMessage> Send( | |
| string? url = "", | ||
| string? title = "", | ||
| UmamiPayload? payload = null, | ||
| UmamiEventData? eventData = null) | ||
| UmamiEventData? eventData = null, | ||
| string? distinctId = null) | ||
| { | ||
| var response = await TrackPageView(url, title, payload, eventData); | ||
| var response = await TrackPageView(url, title, payload, eventData, distinctId); | ||
| return await DecodeResponse(response); | ||
| } | ||
|
|
||
|
|
@@ -82,52 +83,62 @@ public async Task<HttpResponseMessage> TrackPageView( | |
| string? url = "", | ||
| string? title = "", | ||
| UmamiPayload? payload = null, | ||
| UmamiEventData? eventData = null) | ||
| UmamiEventData? eventData = null, | ||
| string? distinctId = null) | ||
| { | ||
| var sendPayload = payload ?? new UmamiPayload(); | ||
| sendPayload.Data = eventData; | ||
| if (!string.IsNullOrEmpty(url)) | ||
| sendPayload.Url = url; | ||
| if (!string.IsNullOrEmpty(title)) | ||
| sendPayload.Title = title; | ||
| if (!string.IsNullOrEmpty(distinctId)) | ||
| sendPayload.DistinctId = distinctId; | ||
| return await Send(sendPayload); | ||
| } | ||
|
|
||
|
|
||
| public async Task<UmamiDataResponse?> TrackAndDecode( | ||
| string eventName, | ||
| UmamiEventData? eventData = null) | ||
| UmamiEventData? eventData = null, | ||
| string? distinctId = null) | ||
| { | ||
| var response = await Track(eventName, eventData); | ||
| var response = await Track(eventName, eventData, distinctId); | ||
| return await DecodeResponse(response); | ||
| } | ||
|
|
||
| public async Task<UmamiDataResponse?> TrackAndDecode( | ||
| UmamiPayload eventObj, | ||
| UmamiEventData? eventData = null) | ||
| UmamiEventData? eventData = null, | ||
| string? distinctId = null) | ||
| { | ||
| var response = await Track(eventObj, eventData); | ||
| var response = await Track(eventObj, eventData, distinctId); | ||
| return await DecodeResponse(response); | ||
| } | ||
|
|
||
| public async Task<HttpResponseMessage> Track( | ||
| string eventName, | ||
| UmamiEventData? eventData = null) | ||
| UmamiEventData? eventData = null, | ||
| string? distinctId = null) | ||
| { | ||
| var thisPayload = new UmamiPayload | ||
| { | ||
| Name = eventName, | ||
| Data = eventData ?? new UmamiEventData() | ||
| Data = eventData ?? new UmamiEventData(), | ||
| DistinctId = distinctId | ||
| }; | ||
| return await Track(thisPayload); | ||
| } | ||
|
|
||
| public async Task<HttpResponseMessage> Track(UmamiPayload eventObj, | ||
| UmamiEventData? eventData = null) | ||
| UmamiEventData? eventData = null, | ||
| string? distinctId = null) | ||
| { | ||
| var payload = eventObj; | ||
| payload.Data = eventData ?? new UmamiEventData(); | ||
| payload.Website = settings.WebsiteId; | ||
| if (!string.IsNullOrEmpty(distinctId)) | ||
| payload.DistinctId = distinctId; | ||
| return await Send(payload); | ||
| } | ||
|
|
||
|
|
@@ -172,9 +183,11 @@ public async Task<HttpResponseMessage> Track(UmamiPayload eventObj, | |
|
|
||
| public async Task<UmamiDataResponse?> IdentifyAndDecode(string sessionId, string? email = null, | ||
| string? username = null, | ||
| string? userId = null, UmamiEventData? eventData = null) | ||
| string? userId = null, | ||
| UmamiEventData? eventData = null, | ||
| string? distinctId = null) | ||
| { | ||
| var response = await Identify(email, username, sessionId, userId, eventData); | ||
| var response = await Identify(email, username, sessionId, userId, eventData, distinctId); | ||
| return await DecodeResponse(response); | ||
| } | ||
|
|
||
|
|
@@ -186,21 +199,22 @@ public async Task<HttpResponseMessage> Identify(UmamiPayload payload, UmamiEvent | |
| } | ||
|
|
||
| public async Task<HttpResponseMessage> Identify(string? email = null, string? username = null, | ||
| string? sessionId = null, string? userId = null, UmamiEventData? eventData = null) | ||
| string? sessionId = null, string? userId = null, UmamiEventData? eventData = null, string? distinctId = null) | ||
| { | ||
|
Comment on lines
201
to
203
|
||
| var emailData = BuildEventData(email, username, userId, eventData); | ||
| var payload = new UmamiPayload | ||
| { | ||
| SessionId = sessionId, | ||
| DistinctId = distinctId, | ||
| Data = emailData | ||
| }; | ||
|
Comment on lines
205
to
210
|
||
|
|
||
| return await Identify(payload, eventData); | ||
| } | ||
|
|
||
| public async Task<HttpResponseMessage> IdentifySession(string sessionId) | ||
| public async Task<HttpResponseMessage> IdentifySession(string sessionId, string? distinctId = null) | ||
| { | ||
| return await Identify(sessionId: sessionId); | ||
| return await Identify(sessionId: sessionId, distinctId: distinctId); | ||
| } | ||
|
|
||
| public async Task<UmamiDataResponse?> IdentifySessionAndDecode(string sessionId) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UmamiPayload.Idis very generic and doesn’t communicate that it represents Umami’s distinct/unique identifier (issue #88). Consider renaming this to something explicit likeDistinctId/UniqueIdand mapping it to the expected JSON field name via[JsonPropertyName("id")](or the exact key Umami expects), so the public API is self-describing without relying on the global naming policy.