Skip to content

Commit

Permalink
SOAPUIOS-268-Redirect-analytics-data
Browse files Browse the repository at this point in the history
  • Loading branch information
EkaterinaSorokina authored and EkaterinaSorokina committed Nov 17, 2017
1 parent 8f13914 commit 6b4aa42
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 90 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import com.eviware.soapui.support.StringUtils;
import com.eviware.soapui.support.UISupport;
import com.eviware.soapui.support.components.JFriendlyTextField;
import com.smartbear.analytics.AnalyticsManager;
import com.smartbear.analytics.OSUserDescription;

import javax.swing.JButton;
import javax.swing.JDialog;
Expand Down Expand Up @@ -235,9 +235,8 @@ protected boolean handleOk() {
return false;
}
UniqueUserIdentifier userIdentifier = UniqueUserIdentifier.getInstance();
userIdentifier.setEmail(getUserEMail());
userIdentifier.setName(getUserName());
Analytics.trackAction(AnalyticsManager.Category.MIXPANEL_PROFILE, null, UniqueUserIdentifier.getInstance().prepareUserProfile());
OSUserDescription osUserDescription = new OSUserDescription(getUserName(), getUserEMail(), userIdentifier.getUserId());
Analytics.trackUserInfo(osUserDescription);
return true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.eviware.soapui.analytics;

import com.smartbear.analytics.AnalyticsManager;
import com.smartbear.analytics.OSUserDescription;

import java.util.Map;

Expand Down Expand Up @@ -44,4 +45,8 @@ public static boolean trackSessionStop() {
public static void trackAction(AnalyticsManager.Category category, String actionName, Map<String, String> params) {
com.smartbear.analytics.Analytics.getAnalyticsManager().trackAction(category, actionName, params);
}

public static void trackUserInfo(OSUserDescription osUserDescription) {
com.smartbear.analytics.Analytics.getAnalyticsManager().trackUserInfo(osUserDescription);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import com.eviware.soapui.SoapUI;
import com.eviware.soapui.Version;
import com.eviware.soapui.analytics.providers.OSUserProviderFactory;
import com.eviware.soapui.analytics.providers.StatisticsCollectionConfirmationDialog;
import com.eviware.soapui.model.settings.Settings;
import com.eviware.soapui.settings.UISettings;
Expand Down Expand Up @@ -53,13 +54,15 @@ public static void initializeAnalytics() {
}
initialized = true;
UniqueUserIdentifier userIdentifier = UniqueUserIdentifier.getInstance();
AnalyticsManager manager = com.smartbear.analytics.Analytics.getAnalyticsManager();
manager.setExecutorService(SoapUI.getThreadPool());
SoapUIProductInfo productInfo = SoapUIProductInfo.getInstance();
if (isAnalyticsDisabled()) {
manager.registerAnalyticsProviderFactory(new OSUserProviderFactory(productInfo));
return;
}
AnalyticsManager manager = com.smartbear.analytics.Analytics.getAnalyticsManager();
manager.setExecutorService(SoapUI.getThreadPool());
manager.registerAnalyticsProviderFactory(new SoapUIOSMixpanelProviderFactory(SoapUIProductInfo.getInstance(), userIdentifier, AnalyticsProviderFactory.HandleType.MANDATORY));
manager.registerAnalyticsProviderFactory(new GoogleAnalyticsProviderFactory(SoapUIProductInfo.getInstance()));
manager.registerAnalyticsProviderFactory(new SoapUIOSMixpanelProviderFactory(SoapUIProductInfo.getInstance(), userIdentifier, AnalyticsProviderFactory.HandleType.USER_ALLOWED));
manager.registerAnalyticsProviderFactory(new SoapUIOSMixpanelProviderFactory(productInfo, userIdentifier, AnalyticsProviderFactory.HandleType.MANDATORY));
manager.registerAnalyticsProviderFactory(new GoogleAnalyticsProviderFactory(productInfo));
manager.registerAnalyticsProviderFactory(new SoapUIOSMixpanelProviderFactory(productInfo, userIdentifier, AnalyticsProviderFactory.HandleType.USER_ALLOWED));
}
}
Original file line number Diff line number Diff line change
@@ -1,43 +1,47 @@
/*
* SoapUI, Copyright (C) 2004-2017 SmartBear Software
*
* Licensed under the EUPL, Version 1.1 or - as soon as they will be approved by the European Commission - subsequent
* versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://ec.europa.eu/idabc/eupl
*
* Unless required by applicable law or agreed to in writing, software distributed under the Licence is
* distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the Licence for the specific language governing permissions and limitations
* under the Licence.
*/

package com.eviware.soapui.analytics.providers;

/**
* Created by avdeev on 02.02.2015.
*/
public class OSUserProvider {
/* final private static String ANALYTICS_SERVER_URL = "https://analytics01.smartbear.com/open-source-analytics-server/analytics";
import com.eviware.soapui.SoapUI;
import com.eviware.soapui.settings.ProxySettings;
import com.smartbear.analytics.api.ProductInfo;
import com.smartbear.analytics.impl.SoapUIOSUserProvider;

@Override
public void trackUserInfo(OSUserDescription osUserDescription) {
String requestParams = prepareRequestParams(osUserDescription);
sendRecord(ANALYTICS_SERVER_URL, requestParams);
import java.net.*;

public class OSUserProvider extends SoapUIOSUserProvider {

public OSUserProvider(ProductInfo productInfo) {
super(productInfo);
}

@Override
public void trackAction(ActionDescription actionDescription) {
}
protected HttpURLConnection initializeConnection(String connectionURL) {
HttpURLConnection connection;
try {
URL url = new URL(connectionURL);
String host = SoapUI.getSettings().getString(ProxySettings.HOST, "");
int port = 0;

private String prepareRequestParams (OSUserDescription osUserDescription){
StringBuilder sb = new StringBuilder();
sb.append("name=");
sb.append(HttpUtils.urlEncodeWithUtf8(osUserDescription.getName()));
sb.append("&email=");
sb.append(HttpUtils.urlEncodeWithUtf8(osUserDescription.getEmail()));
return sb.toString();
}*/
try {
port = Integer.parseInt(SoapUI.getSettings().getString(ProxySettings.PORT, "0"));
} catch (NumberFormatException ex) {
}

if (SoapUI.getSettings().getBoolean(ProxySettings.ENABLE_PROXY, false) && host.compareTo("") != 0 && port != 0) {
SocketAddress sa = new InetSocketAddress(host, port);
Proxy proxy = new Proxy(Proxy.Type.HTTP, sa);
connection = (HttpURLConnection) url.openConnection(proxy);
} else {
connection = (HttpURLConnection) url.openConnection();
}

connection.setRequestMethod("POST");
connection.setDoOutput(true);
connection.setRequestProperty("Content-Type", "text/plain; charset=utf-8");

return connection;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,56 +1,19 @@
/*
* SoapUI, Copyright (C) 2004-2017 SmartBear Software
*
* Licensed under the EUPL, Version 1.1 or - as soon as they will be approved by the European Commission - subsequent
* versions of the EUPL (the "Licence");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://ec.europa.eu/idabc/eupl
*
* Unless required by applicable law or agreed to in writing, software distributed under the Licence is
* distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the Licence for the specific language governing permissions and limitations
* under the Licence.
*/

package com.eviware.soapui.analytics.providers;


import com.smartbear.analytics.api.AnalyticsProvider;
import com.smartbear.analytics.api.AnalyticsProviderFactory;
import com.smartbear.analytics.api.ProductInfo;
import com.smartbear.analytics.impl.SoapUIOSUserProviderFactory;

/**
* Created by avdeev on 02.02.2015.
*/
public class OSUserProviderFactory implements AnalyticsProviderFactory {
@Override
public String getName() {
return null;
}
public class OSUserProviderFactory extends SoapUIOSUserProviderFactory {
private ProductInfo productInfo;

@Override
public String getDescription() {
return null;
public OSUserProviderFactory(ProductInfo productInfo) {
super(productInfo);
this.productInfo = productInfo;
}

@Override
public AnalyticsProvider allocateProvider() {
return null;
}
/* @Override
public String getName() {
return "OS User Contact Info Provider";
return new OSUserProvider(productInfo);
}
@Override
public String getDescription() {
return "Allow to track OS user contact information";
}
@Override
public AnalyticsProvider allocateProvider() {
return new OSUserProvider();
}*/

}
}

0 comments on commit 6b4aa42

Please sign in to comment.