Skip to content
Merged
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 @@ -4,6 +4,7 @@
import com.devcycle.sdk.server.local.api.DVCLocalClient;
import com.devcycle.sdk.server.common.model.User;
import com.devcycle.sdk.server.common.model.Variable;
import com.devcycle.sdk.server.common.model.Event;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
Expand Down Expand Up @@ -57,6 +58,13 @@ public String homePageActivatedFlagLocal(Model model) {
return "fragments/flagData :: value ";
}

@GetMapping("/local/track")
public String trackLocal(Model model) {
dvcLocal.track(getUser(true), Event.builder().type("java-local-custom").build());
model.addAttribute("trackSuccessMessage", "Custom event tracked!");
return "fragments/trackData :: value ";
}

private User getUser(boolean isLocal) {
return isLocal ?
User.builder()
Expand Down
7 changes: 7 additions & 0 deletions example/src/main/resources/templates/fragments/trackData.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div th:fragment="value">
<H2 class="display-5 fw-bold">DevCycle Track</H2>
<div>
<label>Local Track</label>
<span th:text="${trackSuccessMessage}"></span>
</div>
</div>
13 changes: 13 additions & 0 deletions example/src/main/resources/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ <h1 class="display-5 fw-bold">Example app for the DevCycle Java SDK</h1>
<button type="button" class="btn btn-primary btn-lg px-4 gap-3" th:onclick="getVariableLocal()">
Local - Get Variable
</button>
<button type="button" class="btn btn-primary btn-lg px-4 gap-3" th:onclick="trackLocal()">
Local - Track
</button>
</div>
</div>
<div class="p-5 mb-4 bg-light rounded-3">
Expand Down Expand Up @@ -55,6 +58,16 @@ <h1 class="display-5 fw-bold">Example app for the DevCycle Java SDK</h1>
console.warn('Something went wrong.', err);
});
}

const trackLocal = () => {
fetch('local/track').then(function (response) {
return response.text();
}).then(function (html) {
document.getElementById("variablePlaceholder").innerHTML = html;
}).catch(function (err) {
console.warn('Something went wrong.', err);
});
}
</script>
</body>
</html>