Skip to content

Commit

Permalink
[JN-1533] Consistent env var access (#1323)
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewBemis authored Dec 10, 2024
1 parent 5680da0 commit 18a1595
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,14 @@ public void logEvent(String data) {
}

protected JSONObject buildEvent(JSONObject event) {
MessageBuilder messageBuilder = new MessageBuilder(env.getProperty("mixpanel.token"));
String MIXPANEL_TOKEN_ENV_VAR = "env.mixpanel.token";
MessageBuilder messageBuilder = new MessageBuilder(env.getProperty(MIXPANEL_TOKEN_ENV_VAR));

return messageBuilder.event(
null,
event.getString("event"),
event.getJSONObject("properties")
.put("token", env.getProperty("mixpanel.token"))
.put("token", env.getProperty(MIXPANEL_TOKEN_ENV_VAR))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public void testBuildEvent() {
event.put("properties", properties);

env = mock(Environment.class);
when(env.getProperty("mixpanel.token")).thenReturn("test-token");
when(env.getProperty("env.mixpanel.token")).thenReturn("test-token");
MixpanelService mockedMixpanelService = new MixpanelService(env);

JSONObject result = mockedMixpanelService.buildEvent(event);
Expand Down

0 comments on commit 18a1595

Please sign in to comment.