Skip to content
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

NR-347309: Introducing UserId #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
public class NREventAttributes {

private Map<String, Map<String, Object>> attributeBuckets;
private String userId;

/**
* Ïnit a new event attributes model.
Expand Down Expand Up @@ -38,6 +39,15 @@ public void setAttribute(String key, Object value, String filter) {

attributeBuckets.get(filter).put(key, value);
}
/**
* Set userId.
*
* @param userId User Id.
*/
public void setUserId(String userId) {
this.userId = userId;
setAttribute("enduser.id", userId, null);
}

/**
* Generate list of attributes for a given action.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ public void trackerReady() {
sendEvent(TRACKER_READY);
}

/**
* Set userId.
*
* @param userId User Id.
*/
public void setUserId(String userId) {
eventAttributes.setUserId(userId);
}

/**
* Set custom attribute for all events.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ private void playVideo(String videoUrl) {
tracker.setAttribute("contentTitle", "This is my test title", "CONTENT_START");
tracker.setAttribute("contentIsLive", true, "CONTENT_START");
tracker.setAttribute("myCustomAttr", "any value", "CONTENT_START");
// Uncomment below to set userId
// tracker.setUserId("myUserId");

trackerId = NewRelicVideoAgent.getInstance().start(tracker);

Expand Down