Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Amp 84156 java groups example #97

Merged
merged 4 commits into from
Sep 7, 2023
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
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
Loading