Skip to content

Commit cdc0de8

Browse files
feat: Introducing userid
1 parent b0934b5 commit cdc0de8

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

NewRelicVideoCore/src/main/java/com/newrelic/videoagent/core/model/NREventAttributes.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
public class NREventAttributes {
1111

1212
private Map<String, Map<String, Object>> attributeBuckets;
13+
private String userId;
1314

1415
/**
1516
* Ïnit a new event attributes model.
@@ -39,6 +40,16 @@ public void setAttribute(String key, Object value, String filter) {
3940
attributeBuckets.get(filter).put(key, value);
4041
}
4142

43+
/**
44+
* Set userId.
45+
*
46+
* @param userId User Id.
47+
*/
48+
public void setUserId(String userId) {
49+
this.userId = userId;
50+
setAttribute("enduser.id", userId, null);
51+
}
52+
4253
/**
4354
* Generate list of attributes for a given action.
4455
*

NewRelicVideoCore/src/main/java/com/newrelic/videoagent/core/tracker/NRTracker.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ public void trackerReady() {
3939
sendVideoEvent(TRACKER_READY);
4040
}
4141

42+
/**
43+
* Set userId.
44+
*
45+
* @param userId User Id.
46+
*/
47+
public void setUserId(String userId) {
48+
eventAttributes.setUserId(userId);
49+
}
50+
4251
/**
4352
* Set custom attribute for all events.
4453
*

app/src/main/java/com/newrelic/nrvideoproject/VideoPlayer.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ private void playVideo(String videoUrl) {
6464
tracker.setAttribute("contentTitle", "This is my test title", "CONTENT_START");
6565
tracker.setAttribute("contentIsLive", true, "CONTENT_START");
6666
tracker.setAttribute("myCustomAttr", "any value", "CONTENT_START");
67+
// Uncomment below to set userId
68+
tracker.setUserId("myUserId");
6769

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

0 commit comments

Comments
 (0)