Skip to content

Commit

Permalink
feat: Backport analyticsUrl from @serverless/utils@4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrzesik committed Mar 23, 2021
1 parent a7b9498 commit a1f6538
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
16 changes: 16 additions & 0 deletions lib/utils/analytics/analyticsUrl.js
@@ -0,0 +1,16 @@
'use strict';

// This whole module is backported from `@serverless/utils@4.0.0` due to
// requirement of Node>=10.x
// Source: https://github.com/serverless/utils/blob/e8c7c419dead52130b4ae7d522bcab793461bc3e/analytics-and-notfications-url.js

if (process.env.SLS_ANALYTICS_URL) {
module.exports = process.env.SLS_ANALYTICS_URL;
return;
}

const isInChina = require('@serverless/utils/is-in-china');

module.exports = isInChina
? 'https://service-9p6tdp4y-1300963013.gz.apigw.tencentcs.com/release/'
: 'https://sp-notifications-and-metrics-v1.serverless-platform.com';
2 changes: 1 addition & 1 deletion lib/utils/analytics/index.js
Expand Up @@ -8,7 +8,7 @@ const BbPromise = require('bluebird');
const pLimit = require('p-limit');
const fetch = require('node-fetch');
const fse = require('fs-extra');
const analyticsUrl = require('@serverless/utils/analytics-and-notfications-url');
const analyticsUrl = require('./analyticsUrl');
const log = require('../log/serverlessLog');
const areAnalyticsDisabled = require('./areDisabled');
const cacheDirPath = require('./cache-path');
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/analytics/index.test.js
Expand Up @@ -30,7 +30,7 @@ describe('analytics', () => {
before(() => {
process.env.SLS_ANALYTICS_URL = analyticsUrl;
({ report, sendPending } = proxyquire('./index.js', {
'@serverless/utils/analytics-and-notfications-url': analyticsUrl,
'./analyticsUrl': analyticsUrl,
'./areDisabled': false,
'node-fetch': url => {
usedUrl = url;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -37,7 +37,7 @@
"cachedir": "^2.3.0",
"chalk": "^2.4.2",
"child-process-ext": "^2.1.1",
"ci-info": "^3.1.1",
"ci-info": "^2.0.0",
"d": "^1.0.1",
"dayjs": "^1.9.5",
"decompress": "^4.2.1",
Expand Down

0 comments on commit a1f6538

Please sign in to comment.