snowplow / snowplow-java-tracker

Snowplow event tracker for Java. Add analytics to your Java desktop and server apps, servlets and games. (See also: snowplow-android-tracker)
http://snowplowanalytics.com
Apache License 2.0
24 stars 36 forks source link

Allow Subject method chaining #303

Closed mscwilson closed 9 months ago

mscwilson commented 2 years ago

Currently, adding data to an existing Subject object must be done step by step.

// chain methods as part of the Builder configuration on initialisation
Subject eventSubject = new Subject.SubjectBuilder()
    .useragent("useragent")
    .build();

// can't chain methods afterwards
eventSubject.setUserId("example@snowplowanalytics.com");
eventSubject.setLanguage("EN");
eventSubject.setIpAddress("127.0.0.1");

It would be much nicer to be able to write

eventSubject.setUserId("example@snowplowanalytics.com")
    .setLanguage("EN")
    .setIpAddress("127.0.0.1");

This could be easily fixed by returning this from the Subject setter methods.