From 3047398763b06368526ca3fb86f2df4407ee5e3a Mon Sep 17 00:00:00 2001 From: Zhongyi Zhang Date: Thu, 16 May 2019 14:27:05 +0800 Subject: [PATCH 1/2] add ISV tracking --- brokerserver.js | 2 +- lib/common/index.js | 1 + lib/common/msRestRequest.js | 13 ++++++++++++- pcf-tile/tile.yml | 5 +++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/brokerserver.js b/brokerserver.js index 6b38340..d2a9771 100644 --- a/brokerserver.js +++ b/brokerserver.js @@ -12,7 +12,7 @@ var config = common.getConfigurations(); var broker = new Broker(config); var log = common.getLogger(common.LOG_CONSTANTS.BROKER); -msRestRequest.init(config.azure); +msRestRequest.init(config.azure, config.ISVTrackingGUID); // Brokers listen for '-' ex: 'poll-fb9bc99e-0aa9-11e6-8a8a-000d3a002ed5' var addListeners = function(serviceId, serviceModule) { diff --git a/lib/common/index.js b/lib/common/index.js index 124675b..d6c987b 100644 --- a/lib/common/index.js +++ b/lib/common/index.js @@ -130,6 +130,7 @@ module.exports.getConfigurations = function() { 'clientId': process.env['CLIENT_ID'], 'clientSecret': process.env['CLIENT_SECRET'], }, + 'ISVTrackingGUID': process.env['ISV_TRACKING_GUID'], 'serviceBroker': { 'credentials': { 'authUser': process.env['SECURITY_USER_NAME'], diff --git a/lib/common/msRestRequest.js b/lib/common/msRestRequest.js index 860f619..d691b72 100644 --- a/lib/common/msRestRequest.js +++ b/lib/common/msRestRequest.js @@ -14,9 +14,19 @@ var DEFAULT_RETRY_INTERVAL = 3000; //ms var AZURE_RETRY_ERROR_CODES = [408, 429, 500, 502, 503, 504]; -exports.init = function(azureProperties) { +var DEFAULT_ISV_TRACKING_GUID = '563bbbca-7944-4791-b9c6-8af0928114ac'; + +var ISVTrackingGUID; + +exports.init = function(azureProperties, _ISVTrackingGUID) { var environmentName = azureProperties.environment; var environment = common.getEnvironment(environmentName); + + if (_ISVTrackingGUID !== undefined && _ISVTrackingGUID !== '') { + ISVTrackingGUID = _ISVTrackingGUID; + } else { + ISVTrackingGUID = DEFAULT_ISV_TRACKING_GUID; + } Token.init(environment, azureProperties, common.API_VERSION[environmentName]['AZURE_ACTIVE_DIRECTORY']); }; @@ -26,6 +36,7 @@ function msRestRequest(url, qs, method, headers, data, callback) { var tokenExpired = false; _.extend(headers, {'Authorization': ''}); + _.extend(headers, {'User-Agent': 'pid-' + ISVTrackingGUID}); var requestObject = { url: url, qs: qs, method: method, headers: headers}; if (data) { diff --git a/pcf-tile/tile.yml b/pcf-tile/tile.yml index 2bb9408..dcfb902 100644 --- a/pcf-tile/tile.yml +++ b/pcf-tile/tile.yml @@ -309,6 +309,11 @@ forms: "userRoles": ["db_owner"] } label: Default Parameters of Azure SQL Database Failover Group service + - name: isv_tracking_guid + configurable: false + type: string + label: ISV Tracking GUID + default: f09bfe12-4077-4c05-8801-5038e052f399 # Add any dependencies your tile has on other installed products. # This is often appropriate when using automatic service provisioning From 49fd1f2f9cbf8ae154e662b9d1344a9b00d210b5 Mon Sep 17 00:00:00 2001 From: Zhongyi Zhang Date: Thu, 16 May 2019 15:43:30 +0800 Subject: [PATCH 2/2] fix --- brokerserver.js | 2 +- lib/common/index.js | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/brokerserver.js b/brokerserver.js index d2a9771..92d58f4 100644 --- a/brokerserver.js +++ b/brokerserver.js @@ -12,7 +12,7 @@ var config = common.getConfigurations(); var broker = new Broker(config); var log = common.getLogger(common.LOG_CONSTANTS.BROKER); -msRestRequest.init(config.azure, config.ISVTrackingGUID); +msRestRequest.init(config.azure, common.getISVTrackingGUID()); // Brokers listen for '-' ex: 'poll-fb9bc99e-0aa9-11e6-8a8a-000d3a002ed5' var addListeners = function(serviceId, serviceModule) { diff --git a/lib/common/index.js b/lib/common/index.js index d6c987b..b5d625f 100644 --- a/lib/common/index.js +++ b/lib/common/index.js @@ -119,6 +119,10 @@ var validateConfigurations = function() { }); }; +module.exports.getISVTrackingGUID = function() { + return process.env['ISV_TRACKING_GUID']; +}; + module.exports.getConfigurations = function() { validateConfigurations(); @@ -130,7 +134,6 @@ module.exports.getConfigurations = function() { 'clientId': process.env['CLIENT_ID'], 'clientSecret': process.env['CLIENT_SECRET'], }, - 'ISVTrackingGUID': process.env['ISV_TRACKING_GUID'], 'serviceBroker': { 'credentials': { 'authUser': process.env['SECURITY_USER_NAME'],