Skip to content

Commit

Permalink
fix(metrics): hardcode calling metric and fix version injection in we…
Browse files Browse the repository at this point in the history
…bex plugin (#3173)
  • Loading branch information
sreenara authored Oct 31, 2023
1 parent 1b061c4 commit d0744a5
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 84 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
"url": "https://github.com/webex/webex-js-sdk"
},
"scripts": {
"clean": "rimraf packages/**/.coverage packages/**/dist packages/**/types",
"clean": "rimraf packages/**/dist packages/**/types",
"prebuild": "yarn run clean",
"build:publish": "yarn workspaces foreach --parallel --verbose run build:src && yarn build:package",
"build:publish": "yarn build:package && yarn workspaces foreach --parallel --verbose run build:src",
"build:local": "yarn workspaces foreach --parallel --verbose run build:src && yarn run samples:build",
"build": "yarn workspace @webex/calling run build:src && node ./tooling/index.js build && yarn && yarn ws:tools build && yarn run build:tsc",
"build:tsc": "yarn workspace @webex/plugin-meetings run build && yarn run tsc -p ./config/tsconfig.typecheck.json --noEmit",
Expand Down Expand Up @@ -65,7 +65,7 @@
"release:dry-run": "standard-version --dry-run",
"depcheck": "./tooling/depcheck.js",
"postinstall": "patch-package && husky install",
"ws:tools": "yarn workspaces foreach --parallel --recursive --topological-dev --verbose --from '@webex/*-tools' run",
"ws:tools": "yarn workspaces foreach --parallel --recursive --topological-dev --verbose --from '@webex/*-tools' run build:src",
"package-tools": "webex-package-tools"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('webex-core', () => {
assert.property(options.headers, 'spark-user-agent');
assert.equal(
options.headers['spark-user-agent'],
`webex-js-sdk/${pkg.version} (${typeof window === 'undefined' ? 'node' : 'web'})`
`webex-js-sdk/development (${typeof window === 'undefined' ? 'node' : 'web'})`
);
});

Expand All @@ -47,7 +47,7 @@ describe('webex-core', () => {
assert.property(options.headers, 'spark-user-agent');
assert.equal(
options.headers['spark-user-agent'],
`webex-js-sdk/${pkg.version} (${typeof window === 'undefined' ? 'node' : 'web'})`
`webex-js-sdk/development (${typeof window === 'undefined' ? 'node' : 'web'})`
);
});

Expand All @@ -74,7 +74,7 @@ describe('webex-core', () => {
assert.property(options.headers, 'spark-user-agent');
assert.equal(
options.headers['spark-user-agent'],
`webex-js-sdk/${pkg.version} (${
`webex-js-sdk/development (${
typeof window === 'undefined' ? 'node' : 'web'
}) sample/1.0.0`
);
Expand Down Expand Up @@ -104,7 +104,7 @@ describe('webex-core', () => {
assert.property(options.headers, 'spark-user-agent');
assert.equal(
options.headers['spark-user-agent'],
`webex-js-sdk/${pkg.version} (${
`webex-js-sdk/development (${
typeof window === 'undefined' ? 'node' : 'web'
}) sample/1.0.0 custom-label/1.0.0`
);
Expand All @@ -128,7 +128,7 @@ describe('webex-core', () => {
assert.property(options.headers, 'spark-user-agent');
assert.equal(
options.headers['spark-user-agent'],
`webex/${pkg.version} (${typeof window === 'undefined' ? 'node' : 'web'})`
`webex/development (${typeof window === 'undefined' ? 'node' : 'web'})`
);
});

Expand All @@ -149,7 +149,7 @@ describe('webex-core', () => {
assert.property(options.headers, 'spark-user-agent');
assert.equal(
options.headers['spark-user-agent'],
`webex/${pkg.version} (${typeof window === 'undefined' ? 'node' : 'web'})`
`webex/development (${typeof window === 'undefined' ? 'node' : 'web'})`
);
});
});
Expand Down
7 changes: 3 additions & 4 deletions packages/calling/src/CallingClient/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export const VERSION = '1.71.1';
export const REPO_NAME = 'web-calling-sdk';
export const CALLING_FEATURE = 'web-calling';
export const CALLING_USER_AGENT = `${REPO_NAME}/${VERSION} (${CALLING_FEATURE})`;
export const VERSION = 'beta';
export const REPO_NAME = 'webex-calling';
export const CALLING_USER_AGENT = `${REPO_NAME}/${VERSION}`;
export const CALL_ENDPOINT_RESOURCE = 'call';
export const CALL_STATUS_RESOURCE = 'status';
export const CALLS_ENDPOINT_RESOURCE = 'calls';
Expand Down
2 changes: 1 addition & 1 deletion packages/calling/src/common/testUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export const getMockRequestTemplate = () => {
headers: {
'cisco-device-url':
'https://wdm-intb.ciscospark.com/wdm/api/v1/devices/c5ae3b86-1bb7-40f1-a6a9-c296ee7e61d5',
'spark-user-agent': 'web-calling-sdk/1.71.1 (web-calling)',
'spark-user-agent': 'webex-calling/beta',
},
service: 'mobius',
};
Expand Down
53 changes: 0 additions & 53 deletions packages/calling/versionPlugin.js

This file was deleted.

7 changes: 0 additions & 7 deletions packages/calling/web-dev-server.config.js

This file was deleted.

6 changes: 0 additions & 6 deletions packages/calling/webpack.yml

This file was deleted.

12 changes: 10 additions & 2 deletions packages/legacy/babel/static/plugins/inject-package-version.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
/*!
* Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.
* Copyright (c) 2015-2023 Cisco Systems, Inc. See LICENSE file.
*/

const t = require('@babel/types');
const fs = require('fs');
const pathPack = require('path');

/**
* Simple babel transform for ensuring that every WebexPlugin (and WebexCore)
* have the correct version property
* @returns {Object}
*/
module.exports = function injectPackageVersion() {
const version = 'modern';
const packagePath = pathPack.resolve(process.cwd(), 'package.json');
let version;
if (fs.existsSync(packagePath)) {
// eslint-disable-next-line import/no-dynamic-require, global-require
const packageJSON = require(packagePath);
version = packageJSON.version || '0.0.0';
}

return {
visitor: {
Expand Down
4 changes: 2 additions & 2 deletions packages/webex/test/unit/spec/webex.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ describe('webex', () => {
describe('.version', () => {
it('exists', () => {
assert.property(Webex, 'version');
assert.equal(Webex.version, "modern");
assert.equal(Webex.version, "0.0.0");
});
});

Expand All @@ -21,7 +21,7 @@ describe('webex', () => {
const webex = new Webex();

assert.property(webex, 'version');
assert.equal(webex.version, "modern");
assert.equal(webex.version, "0.0.0");
});
});

Expand Down

0 comments on commit d0744a5

Please sign in to comment.