Skip to content

Commit

Permalink
chore: Amp 84156 java groups example (#97)
Browse files Browse the repository at this point in the history
* chore: add setGroup and groupIdentify example to LocalUploadDemo

* chore: update codeql to v2

* chore: group example clean up

* chore: update checkout actions to v3 (node16)
  • Loading branch information
justin-fiedler authored Sep 7, 2023
1 parent e7bf795 commit 72a10fd
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 6 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]


jobs:
analyze:
Expand All @@ -38,11 +38,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -53,7 +53,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -67,4 +67,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
2 changes: 1 addition & 1 deletion .github/workflows/pull-request-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
with:
java-version: '8'
distribution: 'zulu'
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Test with Gradle
run: ./gradlew test:test --stacktrace

30 changes: 30 additions & 0 deletions src/demo/java/com/demo/amplitude/LocalUploadDemo.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class LocalUploadDemo {

public static void main(String[] args) throws InterruptedException {
// Create and initialize Amplitude client
String userId = "java_sdk_demo_user";
Amplitude client = Amplitude.getInstance();
client.init("");

Expand Down Expand Up @@ -40,6 +41,35 @@ public void onLogEventServerResponse(Event event, int status, String message) {
}
};
client.setCallbacks(callback);

// GROUPS AND GROUP PROPERTIES
JSONObject groups = new JSONObject()
.put("org", "engineering")
.put("department", "sdk");
JSONObject groupProps = new JSONObject()
.put("technology", "java")
.put("location", "toronto");

// Set group (setGroup)
// This assigns a user to a group or groups
Event setGroupEvent = new Event("$identify", userId);
setGroupEvent.groups = groups;
setGroupEvent.userProperties = groups;
client.logEvent(setGroupEvent);

// Set group properties (groupIdentify)
// This sets properties to a group or groups
Event groupIdentifyEvent = new Event("$groupidentify", userId);
groupIdentifyEvent.groups = groups;
groupIdentifyEvent.groupProperties = groupProps;
client.logEvent(groupIdentifyEvent);

// Track an event
client.logEvent(new Event("Test Event 1", userId));

// Flush events to the server
client.flushEvents();

for (int i = 0; i < 10000000; i++) {
Event ampEvent = new Event("General" + (i % 20), "Test_UserID_B" + (i % 5000));
while (client.shouldWait(ampEvent)) {
Expand Down

0 comments on commit 72a10fd

Please sign in to comment.