Skip to content

feat: Add telemetry to espressif-ide #1082

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

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
1 change: 1 addition & 0 deletions bundles/com.espressif.idf.core/.classpath
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="lib" path="lib/applicationinsights-core-3.6.2.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-beanutils-1.9.4.jar"/>
<classpathentry exported="true" kind="lib" path="lib/commons-text-1.10.0.jar"/>
<classpathentry exported="true" kind="lib" path="lib/opencsv-5.7.0.jar"/>
Expand Down
3 changes: 2 additions & 1 deletion bundles/com.espressif.idf.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ Bundle-ClassPath: .,
lib/commons-beanutils-1.9.4.jar,
lib/commons-text-1.10.0.jar,
lib/commons-compress-1.21.jar,
lib/xz-1.9.jar
lib/xz-1.9.jar,
lib/applicationinsights-core-3.6.2.jar
Import-Package: org.eclipse.embedcdt.core,
org.eclipse.launchbar.ui.target
3 changes: 2 additions & 1 deletion bundles/com.espressif.idf.core/build.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ bin.includes = META-INF/,\
lib/commons-beanutils-1.9.4.jar,\
lib/commons-text-1.10.0.jar,\
lib/commons-compress-1.21.jar,\
lib/xz-1.9.jar
lib/xz-1.9.jar,\
lib/applicationinsights-core-3.6.2.jar
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*******************************************************************************
* Copyright 2024 Espressif Systems (Shanghai) PTE LTD. All rights reserved.
* Use is subject to license terms.
*******************************************************************************/
package com.espressif.idf.core.logging;

import java.util.Map;

import com.microsoft.applicationinsights.TelemetryClient;

/**
* Azure Telemetry logger
*
* @author Kondal Kolipaka <[email protected]>
*
*/
public class TelemetryLogger
{
private static final TelemetryClient telemetryClient = new TelemetryClient();

public static void logEvent(String eventName, Map<String, String> properties)
{
telemetryClient.trackEvent(eventName, properties, null);
telemetryClient.flush();
}
}
21 changes: 21 additions & 0 deletions bundles/com.espressif.idf.telemetry/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" output="bin" path="src">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions bundles/com.espressif.idf.telemetry/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target/
34 changes: 34 additions & 0 deletions bundles/com.espressif.idf.telemetry/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>com.espressif.idf.telemetry</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
encoding/<project>=UTF-8
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=21
org.eclipse.jdt.core.compiler.compliance=21
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=21
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
9 changes: 9 additions & 0 deletions bundles/com.espressif.idf.telemetry/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Telemetry
Bundle-SymbolicName: com.espressif.idf.telemetry
Bundle-Version: 1.0.0.qualifier
Eclipse-BundleShape: dir
Bundle-Vendor: Espressif Systems
Automatic-Module-Name: com.espressif.idf.telemetry
Bundle-RequiredExecutionEnvironment: JavaSE-17
7 changes: 7 additions & 0 deletions bundles/com.espressif.idf.telemetry/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
rootfiles/
root=rootfiles
root.files=rootfiles/**
13 changes: 13 additions & 0 deletions bundles/com.espressif.idf.telemetry/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>com.espressif.idf.telemetry</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>

<parent>
<groupId>com.espressif.idf</groupId>
<artifactId>com.espressif.idf.bundles</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

</project>
Git LFS file not shown
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"connectionString": "InstrumentationKey=912cbb4e-e606-4c4f-9a00-1731acb15117;IngestionEndpoint=https://eastasia-0.in.applicationinsights.azure.com/;LiveEndpoint=https://eastasia.livediagnostics.monitor.azure.com/;ApplicationId=1efdbec9-ed3f-4e75-a44d-67c6708b6d79",
"role": {
"name": "Espressif-IDE"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
package com.espressif.idf.ui.wizard;

import java.io.File;
import java.util.HashMap;
import java.util.Map;

import org.eclipse.cdt.debug.internal.core.InternalDebugCoreMessages;
import org.eclipse.core.resources.IProject;
Expand Down Expand Up @@ -40,8 +42,10 @@
import com.espressif.idf.core.LaunchBarTargetConstants;
import com.espressif.idf.core.build.IDFLaunchConstants;
import com.espressif.idf.core.logging.Logger;
import com.espressif.idf.core.logging.TelemetryLogger;
import com.espressif.idf.core.util.ClangFormatFileHandler;
import com.espressif.idf.core.util.ClangdConfigFileHandler;
import com.espressif.idf.core.util.EclipseIniUtil;
import com.espressif.idf.core.util.LaunchUtil;
import com.espressif.idf.ui.UIPlugin;
import com.espressif.idf.ui.handlers.EclipseHandler;
Expand Down Expand Up @@ -113,6 +117,11 @@
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
selProvider.setSelection(new StructuredSelection(project));
updateClangFiles(project);

//update telemetry
Map<String, String> properties = new HashMap<String, String>();
properties.put("platform", "eclipse");
TelemetryLogger.logEvent("New project creation", properties);
}
}

Expand Down Expand Up @@ -201,7 +210,7 @@
}

IDFProjectGenerator generator = new IDFProjectGenerator(manifest, selectedTemplate, true,
projectCreationWizardPage.getSelectedTarget());

Check warning on line 213 in bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java

View workflow job for this annotation

GitHub Actions / spotbugs

NP_NULL_ON_SOME_PATH

Possible null pointer dereference of NewIDFProjectWizard.projectCreationWizardPage in com.espressif.idf.ui.wizard.NewIDFProjectWizard.getGenerator()
Raw output
There is a branch of statement that, if executed, guarantees that a null value will be dereferenced, which would generate a NullPointerException when the code is executed. Of course, the problem might be that the branch or statement is infeasible and that the null pointer exception cannot ever be executed; deciding that is beyond the ability of SpotBugs.
generator.setProjectName(projectCreationWizardPage.getProjectName());
if (!projectCreationWizardPage.useDefaults())
{
Expand All @@ -216,73 +225,73 @@
private String target;

public TargetSwitchJob(String target)
{
super(TARGET_SWITCH_JOB);
this.target = target;
launchBarManager = UIPlugin.getService(ILaunchBarManager.class);
}

private Job findInternalJob()
{
for (Job job : Job.getJobManager().find(null))
{
if (job.getName().equals(InternalDebugCoreMessages.CoreBuildLaunchBarTracker_Job))
{
return job;
}
}

return null;
}

@Override
protected IStatus run(IProgressMonitor monitor)
{
Job job = findInternalJob();
if (job != null)
{
try
{
job.join();
}
catch (InterruptedException e1)
{
Logger.log(e1);
}
}

Display.getDefault().syncExec(() -> {
ILaunchTarget launchTarget = findSuitableTargetForSelectedTargetString();
try
{
launchBarManager.setActiveLaunchTarget(launchTarget);
}
catch (CoreException e)
{
Logger.log(e);
}
});

return Status.OK_STATUS;

}

private ILaunchTarget findSuitableTargetForSelectedTargetString()
{
ILaunchTargetManager launchTargetManager = UIPlugin.getService(ILaunchTargetManager.class);
ILaunchTarget[] targets = launchTargetManager
.getLaunchTargetsOfType(IDFLaunchConstants.ESP_LAUNCH_TARGET_TYPE);

for (ILaunchTarget iLaunchTarget : targets)
{
String idfTarget = iLaunchTarget.getAttribute(LaunchBarTargetConstants.TARGET, null);
if (idfTarget.contentEquals(target))
{
return iLaunchTarget;
}
}

return null;

Check warning on line 294 in bundles/com.espressif.idf.ui/src/com/espressif/idf/ui/wizard/NewIDFProjectWizard.java

View workflow job for this annotation

GitHub Actions / spotbugs

SIC_INNER_SHOULD_BE_STATIC

Should com.espressif.idf.ui.wizard.NewIDFProjectWizard$TargetSwitchJob be a _static_ inner class?
Raw output
This class is an inner class, but does not use its embedded reference to the object which created it.  This reference makes the instances of the class larger, and may keep the reference to the creator object alive longer than necessary.  If possible, the class should be made static.
}
}
}
1 change: 1 addition & 0 deletions bundles/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<module>com.espressif.idf.wokwi</module>
<module>com.espressif.idf.lsp</module>
<module>com.espressif.idf.swt.custom</module>
<module>com.espressif.idf.telemetry</module>
</modules>

<build>
Expand Down
4 changes: 4 additions & 0 deletions features/com.espressif.idf.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -165,4 +165,8 @@ You may add additional accurate notices of copyright ownership.
id="com.espressif.idf.swt.custom"
version="0.0.0"/>

<plugin
id="com.espressif.idf.telemetry"
version="0.0.0"/>

</feature>
8 changes: 5 additions & 3 deletions releng/com.espressif.idf.product/idf.product
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@
</configIni>

<launcherArgs>
<vmArgsLin>-Xms2048m -Xmx4096m -Dosgi.requiredJavaVersion=17 [email protected]/workspace
<vmArgsLin>-javaagent:resources/applicationinsights-agent-3.6.2.jar
-Xms2048m -Xmx4096m -Dosgi.requiredJavaVersion=17 [email protected]/workspace
</vmArgsLin>
<vmArgsMac>-Xms2048m -Xmx4096m -Xdock:icon=../Resources/espressif.icns -XstartOnFirstThread -Dosgi.requiredJavaVersion=17 -Dorg.eclipse.swt.internal.carbon.smallFonts [email protected]/workspace
<vmArgsMac>-javaagent:resources/applicationinsights-agent-3.6.2.jar
-Xms2048m -Xmx4096m -Xdock:icon=../Resources/espressif.icns -XstartOnFirstThread -Dosgi.requiredJavaVersion=17 -Dorg.eclipse.swt.internal.carbon.smallFonts [email protected]/workspace
</vmArgsMac>
<vmArgsWin>-Xms2048m -Xmx4096m -Dosgi.requiredJavaVersion=17 [email protected]/workspace
<vmArgsWin>-javaagent:resources/applicationinsights-agent-3.6.2.jar -Xms2048m -Xmx4096m -Dosgi.requiredJavaVersion=17 [email protected]/workspace
</vmArgsWin>
</launcherArgs>

Expand Down
Loading