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

Suppress telemetry #1021

Merged
merged 8 commits into from
Feb 4, 2025
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
2 changes: 2 additions & 0 deletions .github/workflows/junits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on: [push]
jobs:
build:
runs-on: ubuntu-latest
env:
ZINGG_USER: zingg_user

steps:
- uses: actions/checkout@v2
Expand Down
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
19 changes: 13 additions & 6 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 @@ public class Analytics {
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 @@ public static void trackDomain(String metricName, boolean collectMetrics){
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,7 @@ public static void postEvent(String phase, boolean collectMetrics) {
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 @@ -124,8 +131,8 @@ private static void sendEvents(String param) {
URL url = uri.toURL();
String response = executePostRequest(url.toString(), param);
LOG.warn("Analytics event " + response);
} catch (IOException | URISyntaxException e) {
e.printStackTrace();
} catch (IOException | URISyntaxException e) {
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 +158,7 @@ private static String executePostRequest(String targetURL, String urlParameters)
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