Search in sources :

Example 6 with ApplicationInfo

use of com.intellij.openapi.application.ApplicationInfo in project android by JetBrains.

the class AndroidStudioUsageTracker method runDailyReports.

private static void runDailyReports() {
    ApplicationInfo application = ApplicationInfo.getInstance();
    UsageTracker.getInstance().log(AndroidStudioEvent.newBuilder().setCategory(AndroidStudioEvent.EventCategory.PING).setKind(AndroidStudioEvent.EventKind.STUDIO_PING).setProductDetails(ProductDetails.newBuilder().setProduct(ProductDetails.ProductKind.STUDIO).setBuild(application.getBuild().asString()).setVersion(application.getStrictVersion()).setOsArchitecture(CommonMetricsData.getOsArchitecture()).setChannel(lifecycleChannelFromUpdateSettings())).setMachineDetails(CommonMetricsData.getMachineDetails(new File(PathManager.getHomePath()))).setJvmDetails(CommonMetricsData.getJvmDetails()));
}
Also used : ApplicationInfo(com.intellij.openapi.application.ApplicationInfo) File(java.io.File)

Example 7 with ApplicationInfo

use of com.intellij.openapi.application.ApplicationInfo in project flutter-intellij by flutter.

the class FlutterInitializer method getAnalytics.

@NotNull
public static Analytics getAnalytics() {
    if (analytics == null) {
        final PropertiesComponent properties = PropertiesComponent.getInstance();
        String clientId = properties.getValue(analyticsClientIdKey);
        if (clientId == null) {
            clientId = UUID.randomUUID().toString();
            properties.setValue(analyticsClientIdKey, clientId);
        }
        final IdeaPluginDescriptor descriptor = PluginManager.getPlugin(FlutterUtils.getPluginId());
        assert descriptor != null;
        final ApplicationInfo info = ApplicationInfo.getInstance();
        analytics = new Analytics(clientId, descriptor.getVersion(), info.getVersionName(), info.getFullVersion());
        // Set up reporting prefs.
        analytics.setCanSend(getCanReportAnalytics());
        // Send initial loading hit.
        analytics.sendScreenView("main");
        FlutterSettings.getInstance().sendSettingsToAnalytics(analytics);
    }
    return analytics;
}
Also used : ApplicationInfo(com.intellij.openapi.application.ApplicationInfo) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PropertiesComponent(com.intellij.ide.util.PropertiesComponent) Analytics(io.flutter.analytics.Analytics) NotNull(org.jetbrains.annotations.NotNull)

Example 8 with ApplicationInfo

use of com.intellij.openapi.application.ApplicationInfo in project flutter-intellij by flutter.

the class FlutterErrorReportSubmitter method submitAsync.

@SuppressWarnings("deprecation")
@Override
public void submitAsync(@NotNull IdeaLoggingEvent[] events, @Nullable String additionalInfo, @NotNull Component parentComponent, @NotNull Consumer<SubmittedReportInfo> consumer) {
    if (events.length == 0) {
        consumer.consume(new SubmittedReportInfo(null, null, SubmittedReportInfo.SubmissionStatus.FAILED));
        return;
    }
    final DataContext dataContext = DataManager.getInstance().getDataContext(parentComponent);
    Project project = PlatformDataKeys.PROJECT.getData(dataContext);
    if (project == null) {
        project = ProjectManager.getInstance().getDefaultProject();
    }
    final StringBuilder builder = new StringBuilder();
    builder.append("Please file this bug report at https://github.com/flutter/flutter-intellij/issues/new.\n");
    builder.append("\n");
    builder.append("---\n");
    builder.append("\n");
    builder.append("## What happened\n");
    builder.append("\n");
    if (additionalInfo != null) {
        builder.append(additionalInfo.trim()).append("\n");
    } else {
        builder.append("(please describe what you were doing when this exception occurred)\n");
    }
    builder.append("\n");
    builder.append("## Version information\n");
    builder.append("\n");
    // IntelliJ version
    final ApplicationInfo info = ApplicationInfo.getInstance();
    builder.append(info.getVersionName()).append(" `").append(info.getFullVersion()).append("`");
    final PluginId pid = FlutterUtils.getPluginId();
    final IdeaPluginDescriptor flutterPlugin = PluginManager.getPlugin(pid);
    // noinspection ConstantConditions
    builder.append(" • Flutter plugin `").append(pid.getIdString()).append(' ').append(flutterPlugin.getVersion()).append("`");
    final IdeaPluginDescriptor dartPlugin = PluginManager.getPlugin(PluginId.getId("Dart"));
    if (dartPlugin != null) {
        // noinspection ConstantConditions
        builder.append(" • Dart plugin `").append(dartPlugin.getVersion()).append("`");
    }
    builder.append("\n\n");
    final FlutterSdk sdk = FlutterSdk.getFlutterSdk(project);
    if (sdk == null) {
        builder.append("No Flutter sdk configured.\n");
    } else {
        final String flutterVersion = getFlutterVersion(sdk);
        if (flutterVersion != null) {
            builder.append(flutterVersion.trim()).append("\n");
        } else {
            builder.append("Error getting Flutter sdk information.\n");
        }
    }
    builder.append("\n");
    for (IdeaLoggingEvent event : events) {
        builder.append("## Exception\n");
        builder.append("\n");
        builder.append(event.getMessage()).append("\n");
        builder.append("\n");
        if (event.getThrowable() != null) {
            builder.append("```\n");
            builder.append(event.getThrowableText().trim()).append("\n");
            builder.append("```\n");
            builder.append("\n");
            FlutterInitializer.getAnalytics().sendException(event.getThrowable(), false);
        }
    }
    final String text = builder.toString().trim() + "\n";
    // Create scratch file.
    final ScratchRootType scratchRoot = ScratchRootType.getInstance();
    final VirtualFile file = scratchRoot.createScratchFile(project, "bug-report.md", Language.ANY, text);
    if (file != null) {
        // Open the file.
        new OpenFileDescriptor(project, file).navigate(true);
    } else {
        consumer.consume(new SubmittedReportInfo(null, null, SubmittedReportInfo.SubmissionStatus.FAILED));
    }
    consumer.consume(new SubmittedReportInfo(null, "", SubmittedReportInfo.SubmissionStatus.NEW_ISSUE));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ApplicationInfo(com.intellij.openapi.application.ApplicationInfo) IdeaPluginDescriptor(com.intellij.ide.plugins.IdeaPluginDescriptor) PluginId(com.intellij.openapi.extensions.PluginId) IdeaLoggingEvent(com.intellij.openapi.diagnostic.IdeaLoggingEvent) Project(com.intellij.openapi.project.Project) DataContext(com.intellij.openapi.actionSystem.DataContext) FlutterSdk(io.flutter.sdk.FlutterSdk) ScratchRootType(com.intellij.ide.scratch.ScratchRootType) OpenFileDescriptor(com.intellij.openapi.fileEditor.OpenFileDescriptor) SubmittedReportInfo(com.intellij.openapi.diagnostic.SubmittedReportInfo)

Example 9 with ApplicationInfo

use of com.intellij.openapi.application.ApplicationInfo in project android by JetBrains.

the class AndroidStudioInitializer method setupAnalytics.

/*
   * sets up collection of Android Studio specific analytics.
   */
private static void setupAnalytics() {
    AndroidStudioUsageTracker.setup(JobScheduler.getScheduler());
    ApplicationInfo application = ApplicationInfo.getInstance();
    UsageTracker.getInstance().setVersion(application.getStrictVersion());
}
Also used : ApplicationInfo(com.intellij.openapi.application.ApplicationInfo)

Example 10 with ApplicationInfo

use of com.intellij.openapi.application.ApplicationInfo in project android by JetBrains.

the class GoogleCrash method getDefaultParameters.

@NotNull
private static Map<String, String> getDefaultParameters() {
    Map<String, String> map = new HashMap<>();
    ApplicationInfo applicationInfo = getApplicationInfo();
    if (ANONYMIZED_UID != null) {
        map.put("guid", ANONYMIZED_UID);
    }
    RuntimeMXBean runtimeMXBean = ManagementFactory.getRuntimeMXBean();
    map.put("ptime", Long.toString(runtimeMXBean.getUptime()));
    // product specific key value pairs
    map.put(KEY_VERSION, applicationInfo == null ? "0.0.0.0" : applicationInfo.getStrictVersion());
    // must match registration with Crash
    map.put(KEY_PRODUCT_ID, CrashReport.PRODUCT_ANDROID_STUDIO);
    map.put("fullVersion", applicationInfo == null ? "0.0.0.0" : applicationInfo.getFullVersion());
    map.put("osName", StringUtil.notNullize(SystemInfo.OS_NAME));
    map.put("osVersion", StringUtil.notNullize(SystemInfo.OS_VERSION));
    map.put("osArch", StringUtil.notNullize(SystemInfo.OS_ARCH));
    map.put("locale", StringUtil.notNullize(LOCALE));
    map.put("vmName", StringUtil.notNullize(runtimeMXBean.getVmName()));
    map.put("vmVendor", StringUtil.notNullize(runtimeMXBean.getVmVendor()));
    map.put("vmVersion", StringUtil.notNullize(runtimeMXBean.getVmVersion()));
    MemoryUsage usage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
    map.put("heapUsed", Long.toString(usage.getUsed()));
    map.put("heapCommitted", Long.toString(usage.getCommitted()));
    map.put("heapMax", Long.toString(usage.getMax()));
    return map;
}
Also used : HashMap(com.intellij.util.containers.HashMap) ApplicationInfo(com.intellij.openapi.application.ApplicationInfo) RuntimeMXBean(java.lang.management.RuntimeMXBean) MemoryUsage(java.lang.management.MemoryUsage) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ApplicationInfo (com.intellij.openapi.application.ApplicationInfo)20 File (java.io.File)5 IdeaPluginDescriptor (com.intellij.ide.plugins.IdeaPluginDescriptor)3 ConfigurationException (com.intellij.openapi.options.ConfigurationException)3 Project (com.intellij.openapi.project.Project)3 NotNull (org.jetbrains.annotations.NotNull)3 PubRoot (io.flutter.pub.PubRoot)2 MemoryUsage (java.lang.management.MemoryUsage)2 RuntimeMXBean (java.lang.management.RuntimeMXBean)2 AndroidModuleInfo (com.android.tools.idea.model.AndroidModuleInfo)1 MergedManifest (com.android.tools.idea.model.MergedManifest)1 ScratchRootType (com.intellij.ide.scratch.ScratchRootType)1 PropertiesComponent (com.intellij.ide.util.PropertiesComponent)1 DataContext (com.intellij.openapi.actionSystem.DataContext)1 ApplicationNamesInfo (com.intellij.openapi.application.ApplicationNamesInfo)1 ApplicationEx (com.intellij.openapi.application.ex.ApplicationEx)1 IdeaLoggingEvent (com.intellij.openapi.diagnostic.IdeaLoggingEvent)1 SubmittedReportInfo (com.intellij.openapi.diagnostic.SubmittedReportInfo)1 PluginId (com.intellij.openapi.extensions.PluginId)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1