Skip to content

Commit

Permalink
telemetry/nextApi clean up (#220)
Browse files Browse the repository at this point in the history
  • Loading branch information
DumpySquare authored Jun 21, 2023
1 parent 9a0dc6c commit 95f4875
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 123 deletions.
62 changes: 32 additions & 30 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches: [main]

env:
NODE_VERSION: 16.x
NODE_VERSION: 16

jobs:

Expand All @@ -29,16 +29,18 @@ jobs:

package-release-publish:
runs-on: ubuntu-latest
permissions:
contents: write
environment: publishing
# needs: test
name: Package-Release-Publish
steps:

- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: setup node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}

Expand All @@ -51,10 +53,11 @@ jobs:
- name: install open-vsix marketplace cli (ovsx)
run: npm install -g ovsx

- name: install teem keys
run: echo "${{ secrets.TEEM_KEY }}" >> TEEM_KEY
# - name: install teem keys
# run: echo "${{ secrets.TEEM_KEY }}" >> TEEM_KEY

- name: package extension
id: vsce
run: vsce package

- name: get extension path
Expand All @@ -66,43 +69,42 @@ jobs:
- name: get extension version
run: echo "PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV

- name: capture latest release notes
run: |
echo "RELEASE_NOTE<<EOF" >> $GITHUB_ENV
echo "$(node src/scripts/changelog.js)" >> $GITHUB_ENV
echo "" >> $GITHUB_ENV
echo "See [CHANGE LOG](https://github.com/f5devcentral/vscode-f5/blob/main/README.md) for full details and history." >> $GITHUB_ENV
echo "" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
# https://github.com/marketplace/actions/changelog-reader
- name: Get Changelog Entry
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
with:
validation_level: warn
version: ${{ env.PACKAGE_VERSION }}
path: ./CHANGELOG.md

- name: create upload artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
path: ${{ env.VSIX_PATH }}
name: ${{ env.VSIX_NAME }}

- name: create github release
uses: actions/create-release@v1
uses: ncipollo/release-action@v1
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ env.PACKAGE_VERSION }}
release_name: ${{ env.VSIX_NAME }}
body: "${{env.RELEASE_NOTE}}"
tag: v${{ env.PACKAGE_VERSION }}
name: ${{ env.VSIX_NAME }}
body: "${{ steps.changelog_reader.outputs.changes }}"
artifacts: ${{ env.VSIX_NAME }}
draft: false
prerelease: false

- name: upload releases
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PUBLISH_TOKEN: ${{ secrets.MARKETPLACE_PUBLISH_KEY }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ env.VSIX_PATH }}
asset_name: ${{ env.VSIX_NAME }}
asset_content_type: application/zip
# - name: upload releases
# uses: actions/upload-release-asset@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# PUBLISH_TOKEN: ${{ secrets.MARKETPLACE_PUBLISH_KEY }}
# with:
# upload_url: ${{ steps.create_release.outputs.upload_url }}
# asset_path: ${{ env.VSIX_PATH }}
# asset_name: ${{ env.VSIX_NAME }}
# asset_content_type: application/zip

- name: publish to marketplace
run: vsce publish -i ${{ env.VSIX_PATH }} -p ${{ secrets.MARKETPLACE_PUBLISH_KEY }}
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how

---

## [3.13.1] - (06-21-2023)

### Changed

- updated github actions for testing/building/deployment of extension to marketplace

### Fixed

- [BUG] Error running command f5.addHost: command 'f5.addHost' not found. #206 (continued...)
- more nextApi and telemetry clean up

---

## [3.13.0] - (06-20-2023)

### Added
Expand Down
18 changes: 1 addition & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"displayName": "The F5 Extension",
"description": "Supercharge your F5 automation development",
"publisher": "F5DevCentral",
"version": "3.13.0",
"version": "3.13.1",
"keywords": [
"F5",
"F5Networks",
Expand Down Expand Up @@ -181,10 +181,6 @@
{
"view": "cfgTree",
"contents": "Import TMOS Config to explore.\n[Import .conf/UCS/QKVIEW from local file](command:f5.cfgExplore)\n[Documentation](https://f5devcentral.github.io/vscode-f5/#/config_explorer)"
},
{
"view": "nxtApiView",
"contents": "Connect to a NEXT instance to explore OpenAPI.\n[Browse CM OPENAPI (local)](command:f5.refreshNextApiTreeLocal)"
}
],
"views": {
Expand Down Expand Up @@ -640,13 +636,6 @@
"category": "F5",
"icon": "$(refresh)"
},
{
"command": "f5.refreshNextApiTree",
"title": "Refresh NEXT OPENAPI View",
"enablement": "false",
"category": "F5",
"icon": "$(refresh)"
},
{
"command": "f5.cfgExploreRefresh",
"title": "Refresh Config Explorer",
Expand Down Expand Up @@ -1079,11 +1068,6 @@
"when": "view == iqView",
"group": "navigation"
},
{
"command": "f5.refreshNextApiTree",
"when": "view == nxtApiView",
"group": "navigation"
},
{
"command": "f5.refreshTclTree",
"when": "view == as3Tasks",
Expand Down
2 changes: 1 addition & 1 deletion src/devicesCore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export default function devicesCore(context: ExtensionContext, f5OutputChannel:

ext.as3Tree.refresh();
// nextApiProvider.refresh();
commands.executeCommand('f5.refreshNextApiTree');
// commands.executeCommand('f5.refreshNextApiTree');
})
.catch(err => {
logger.error('Connect/Discover failed', err);
Expand Down
54 changes: 19 additions & 35 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
/**
* Copyright 2021 F5 Networks, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

import {
Expand Down Expand Up @@ -62,10 +46,10 @@ import { getText } from './utils/utils';
import { CfCore } from './cfCore';
import { As3Core } from './as3Core';
import { Telemetry } from './telemetry';
import { XcDiag } from './tmosXcDiag';
import { NextApi } from './nextApi';
// import { XcDiag } from './tmosXcDiag';
// import { NextApi } from './nextApi';
import { CodeLensProvider } from './codeLens';
import { createRequire } from 'module';
// import { createRequire } from 'module';

// turn off console logging
logger.console = false;
Expand All @@ -82,6 +66,11 @@ logger.output = function (log: string) {
// provide extension functions for activation
export async function activate(context: ExtensionContext) {

// create the telemetry service
ext.telemetry = new Telemetry(context);
// initialize telemetry service
// await ext.telemetry.init();

process.on('unhandledRejection', error => {
logger.error('--- unhandledRejection ---', error);
ext.telemetry.capture({ unhandledRejection: JSON.stringify(error) });
Expand Down Expand Up @@ -124,11 +113,6 @@ export async function activate(context: ExtensionContext) {
// do we prefer the class style of importing core blocks?
new ChangeVersion(context, ext.extHttp);

// create the telemetry service
ext.telemetry = new Telemetry(context);
// initialize telemetry service
await ext.telemetry.init();

logger.debug(`telemtry instance details`, ext.telemetry.telemetryBase());

new Hovers(context, ext.eventEmitterGlobal);
Expand Down Expand Up @@ -981,18 +965,18 @@ export async function activate(context: ExtensionContext) {

}),

qp.onDidAccept(a => {
qp.onDidAccept(a => {

// main quick pick object
const b = qp;
// if new item typed in
const bv = b.value;
// if existing item selected;
const bs = b.selectedItems[0]?.label;
// main quick pick object
const b = qp;
// if new item typed in
const bv = b.value;
// if existing item selected;
const bs = b.selectedItems[0]?.label;

resolve(bv || bs);
qp.hide();
})
resolve(bv || bs);
qp.hide();
})

qp.show();
}) as string;
Expand Down Expand Up @@ -1022,7 +1006,7 @@ export async function activate(context: ExtensionContext) {
const idx = histary.indexOf(cmd)

// command is not in history
if(idx < 0) {
if (idx < 0) {

// add the cmd to the top of the history array
histary.unshift(cmd)
Expand Down
4 changes: 2 additions & 2 deletions src/nextApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ export class NextApi {
const nextApiTreeView = window.createTreeView('nxtApiView', {
treeDataProvider: this.nextApiTreeProvider,
});
context.subscriptions.push(commands.registerCommand('f5.refreshNextApiTree', () => this.nextApiTreeProvider.refresh()));
// context.subscriptions.push(commands.registerCommand('f5.refreshNextApiTree', () => this.nextApiTreeProvider.refresh()));

context.subscriptions.push(commands.registerCommand('f5.refreshNextApiTreeLocal', () => this.nextApiTreeProvider.refresh('local')));
// context.subscriptions.push(commands.registerCommand('f5.refreshNextApiTreeLocal', () => this.nextApiTreeProvider.refresh('local')));


// not registered in pjson file...
Expand Down
81 changes: 43 additions & 38 deletions src/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ export class Telemetry {
https: ExtHttp;
ctx: ExtensionContext;

apiKey: string | undefined;
apiKey = Buffer.from([
'bW1oSlUyc0Nk',
'NjNCem5YQVh',
'EaDRreExJ',
'eWZJTW0zQXI='
].join(''), 'base64').toString();

/**
* standard vscode f5 document type param
Expand Down Expand Up @@ -136,43 +141,43 @@ export class Telemetry {
}


/**
* loads api key from file or secret
*/
async init() {

const keyFileName = 'F5_TEEM';
const keyFileNamePath = path.join(this.ctx.extensionPath, keyFileName);

// console.log(`Looking for ${keyFileName} file at`, keyFileNamePath);

await fs.promises.readFile(keyFileNamePath)
.then(key => {
this.ctx.secrets.store(keyFileName, key.toString());
// console.log(`${keyFileName} FILE FOUND AND KEY STORED AS SECRET:`, key.toString());
})
.then(() => {
// console.log(`Deleting ${keyFileName} FILE`);
fs.unlinkSync(keyFileNamePath);
})
.catch( async e => {
// console.log(`${keyFileName} FILE NOT FOUND`, e.message);
const str = [
'bW1oSlUyc0Nk',
'NjNCem5YQVh',
'EaDRreExJ',
'eWZJTW0zQXI='
].join('');
await this.ctx.secrets.store(keyFileName, Buffer.from(str, 'base64').toString());
});

// set the api key
this.apiKey = await this.ctx.secrets.get(keyFileName);

// console.log(`---${this.apiKey}---`);

return;
}
// /**
// * loads api key from file or secret
// */
// async init() {

// const keyFileName = 'F5_TEEM';
// const keyFileNamePath = path.join(this.ctx.extensionPath, keyFileName);

// // console.log(`Looking for ${keyFileName} file at`, keyFileNamePath);

// await fs.promises.readFile(keyFileNamePath)
// .then(key => {
// this.ctx.secrets.store(keyFileName, key.toString());
// // console.log(`${keyFileName} FILE FOUND AND KEY STORED AS SECRET:`, key.toString());
// })
// .then(() => {
// // console.log(`Deleting ${keyFileName} FILE`);
// fs.unlinkSync(keyFileNamePath);
// })
// .catch( async e => {
// // console.log(`${keyFileName} FILE NOT FOUND`, e.message);
// const str = [
// 'bW1oSlUyc0Nk',
// 'NjNCem5YQVh',
// 'EaDRreExJ',
// 'eWZJTW0zQXI='
// ].join('');
// await this.ctx.secrets.store(keyFileName, Buffer.from(str, 'base64').toString());
// });

// // set the api key
// this.apiKey = await this.ctx.secrets.get(keyFileName);

// // console.log(`---${this.apiKey}---`);

// return;
// }

private createExtHttps() {

Expand Down

0 comments on commit 95f4875

Please sign in to comment.