Skip to content
New issue

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

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

Already on GitHub? # to your account

Suppress telemetry #1021

Merged
merged 8 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions .github/workflows/load-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jobs:
env:
SPARK_MASTER: local[*]
ZINGG_HOME: assembly/target
ZINGG_USER: zingg_user
steps:
- name: checkout repo content
uses: actions/checkout@v3 # checkout the repository content to github runner.
Expand Down
18 changes: 13 additions & 5 deletions common/core/src/main/java/zingg/common/core/util/Analytics.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
private static final String API_SECRET = "IYJgNn8KR2Cr0yZIvrMvng";
private static final String API_VERSION = "2";
private static final String MEASUREMENT_ID = "G-MWRMGB9652";
private static final String ZINGG_USER_ENV = "ZINGG_USER";

private static Map<String, String> metrics;
public static final Log LOG = LogFactory.getLog(Analytics.class);
Expand Down Expand Up @@ -77,7 +78,14 @@
track(metricName, getDomain(), collectMetrics);
}


public static String getUserId() {
String userId = System.getenv(ZINGG_USER_ENV); // Fetch the environment variable
if (userId == null || userId.isEmpty()) {
userId = getDomain(); // Default to domain if environment variable is not set
}
return userId;
}


public static void postEvent(String phase, boolean collectMetrics) {

Expand All @@ -101,8 +109,8 @@
eventList = mapper.createArrayNode();
eventList.add(eventNode);
rootNode.set("events", eventList);
rootNode.put("user_id", getDomain());
rootNode.put("user_id", getUserId());

String metricEvent = rootNode.toString();
LOG.warn("event is " + metricEvent);
Analytics.sendEvents(metricEvent);
Expand All @@ -125,7 +133,7 @@
String response = executePostRequest(url.toString(), param);
LOG.warn("Analytics event " + response);
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
if(LOG.isDebugEnabled()) e.printStackTrace();

Check warning

Code scanning / PMD

This statement should have braces

This statement should have braces
}
LOG.warn("Event tracked.");
}
Expand All @@ -151,7 +159,7 @@
os.writeBytes(urlParameters);
os.close();

//Get Response
//Get Response
InputStream is = connection.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
StringBuffer response = new StringBuffer();
Expand Down
Loading