Skip to content

Commit

Permalink
feat: add support for channel object in individual payload (#41)
Browse files Browse the repository at this point in the history
Now `channel = server` will be added along with each message payload.
  • Loading branch information
1abhishekpandey authored Dec 19, 2022
1 parent d149901 commit 97ca4ca
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ protected AliasMessage realBuild(
Type type,
String messageId,
Date sentAt,
String channel,
Date timestamp,
Map<String, ?> context,
String anonymousId,
Expand All @@ -67,6 +68,7 @@ protected AliasMessage realBuild(
type,
messageId,
sentAt,
channel,
timestamp,
context,
anonymousId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ protected GroupMessage realBuild(
Type type,
String messageId,
Date sentAt,
String channel,
Date timestamp,
Map<String, ?> context,
String anonymousId,
Expand All @@ -87,6 +88,7 @@ protected GroupMessage realBuild(
type,
messageId,
sentAt,
channel,
timestamp,
context,
anonymousId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ protected IdentifyMessage realBuild(
Type type,
String messageId,
Date sentAt,
String channel,
Date timestamp,
Map<String, ?> context,
String anonymousId,
Expand All @@ -72,7 +73,7 @@ protected IdentifyMessage realBuild(
}

return new AutoValue_IdentifyMessage(
type, messageId, sentAt, timestamp, context, anonymousId, userId, integrations, traits);
type, messageId, sentAt, channel, timestamp, context, anonymousId, userId, integrations, traits);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public interface Message {
@Nullable
Date sentAt();

@Nonnull
String channel();

@Nonnull
Date timestamp();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ protected abstract T realBuild(
Message.Type type,
String messageId,
Date sentAt,
String channel,
Date timestamp,
Map<String, ?> context,
String anonymousId,
Expand Down Expand Up @@ -231,6 +232,8 @@ public T build() {
messageId = UUID.randomUUID().toString();
}

String channel = "server";

Map<String, Object> integrations;
if (this.integrations == null) {
integrations = Collections.emptyMap();
Expand All @@ -247,7 +250,7 @@ public T build() {
}

return realBuild(
type, messageId, sentAt, timestamp, context, anonymousId, userId, integrations);
type, messageId, sentAt, channel, timestamp, context, anonymousId, userId, integrations);
}

/** Returns the {@link Message.Type} of the message this builder is constructing. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ protected PageMessage realBuild(
Type type,
String messageId,
Date sentAt,
String channel,
Date timestamp,
Map<String, ?> context,
String anonymousId,
Expand All @@ -103,6 +104,7 @@ protected PageMessage realBuild(
type,
messageId,
sentAt,
channel,
timestamp,
context,
anonymousId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ protected ScreenMessage realBuild(
Type type,
String messageId,
Date sentAt,
String channel,
Date timestamp,
Map<String, ?> context,
String anonymousId,
Expand All @@ -90,6 +91,7 @@ protected ScreenMessage realBuild(
type,
messageId,
sentAt,
channel,
timestamp,
context,
anonymousId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ protected TrackMessage realBuild(
Type type,
String messageId,
Date sentAt,
String channel,
Date timestamp,
Map<String, ?> context,
String anonymousId,
Expand All @@ -90,6 +91,7 @@ protected TrackMessage realBuild(
type,
messageId,
sentAt,
channel,
timestamp,
context,
anonymousId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ public Date sentAt() {
throw new UnsupportedOperationException();
}

@Nonnull
@Override
public String channel() {
throw new UnsupportedOperationException();
}

@Nonnull
@Override
public Date timestamp() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ public Date sentAt() {
throw new UnsupportedOperationException();
}

@Nonnull
@Override
public String channel() {
throw new UnsupportedOperationException();
}

@Nonnull
@Override
public Date timestamp() {
Expand Down

0 comments on commit 97ca4ca

Please sign in to comment.