Skip to content

Commit

Permalink
Merge pull request #989 from kuzzleio/4.3.1-proposal
Browse files Browse the repository at this point in the history
# [4.3.1](https://github.com/kuzzleio/kuzzle-admin-console/releases/tag/4.3.1) (2022-03-07)


#### Others

- [ [#987](#987) ] Use Kepler to retrieve product usage metrics   ([alexandrebouthinon](https://github.com/alexandrebouthinon))
---
  • Loading branch information
Aschen authored Mar 7, 2022
2 parents 9909e03 + 172f935 commit 4be3ad0
Show file tree
Hide file tree
Showing 13 changed files with 297 additions and 187 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
build/*.js
config/*.js
test/e2e/nightwatch.conf.js
node_modules/**/*
341 changes: 169 additions & 172 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kuzzle-admin-console",
"version": "4.3.0",
"version": "4.3.1",
"description": "A handy administrative console for Kuzzle",
"author": "The Kuzzle team <[email protected]>",
"scripts": {
Expand Down Expand Up @@ -44,6 +44,7 @@
"eslint-plugin-vue": "^6.0.0",
"execa": "^4.0.2",
"json-formatter-js": "^1.3.0",
"kepler-companion": "^1.1.5",
"kuzzle-sdk-v6": "npm:kuzzle-sdk@^6.2.7",
"kuzzle-sdk-v7": "npm:kuzzle-sdk@^7.7.6",
"leaflet": "^1.7.1",
Expand Down
18 changes: 4 additions & 14 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,7 @@
/>
<modal-delete id="modal-env-delete" :environment-id="environmentId" />
<modal-import id="modal-env-import" />

<b-toast
id="discarded-toast"
title="Request Discarded"
no-auto-hide
no-close-button
variant="danger"
toaster="b-toaster-bottom-right"
append="true"
>
Your request could not be sent to Kuzzle. Check the browser console for
more details.
</b-toast>
<telemetry-banner />
</div>
</template>

Expand All @@ -39,13 +27,15 @@ import {} from './assets/global.scss'
import ModalCreateOrUpdate from './components/Common/Environments/ModalCreateOrUpdate'
import ModalDelete from './components/Common/Environments/ModalDelete'
import ModalImport from './components/Common/Environments/ModalImport'
import TelemetryBanner from './components/TelemetryBanner'
export default {
name: 'KuzzleAdminConsole',
components: {
ModalCreateOrUpdate,
ModalDelete,
ModalImport
ModalImport,
TelemetryBanner
},
data() {
return {
Expand Down
71 changes: 71 additions & 0 deletions src/components/TelemetryBanner.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<template>
<div class="Main">
<b-toast
id="discarded-toast"
title="Request Discarded"
no-auto-hide
no-close-button
variant="danger"
toaster="b-toaster-bottom-right"
append="true"
>
Your request could not be sent to Kuzzle. Check the browser console for
more details.
</b-toast>
<b-toast
id="kepler-banner"
title="Usage telemetry"
no-auto-hide
no-close-button
variant="info"
toaster="b-toaster-bottom-right"
:visible="isBannerVisible"
>
<div align="justify">
We use an Open Source analytics to study the use of our products in
order to improve them. We do not collect any personal data.
</div>
<div align="center" class="mt-2 pa-1">
<b-button
class="mr-1"
variant="outline-danger"
size="sm"
@click="disableTelemetry"
>
Disable telemetry
</b-button>
<b-button
class="ml-1"
variant="success"
size="sm"
@click="enableTelemetry"
>
Accept
</b-button>
</div>
</b-toast>
</div>
</template>

<script>
import telemetryCookies from '../services/telemetryCookies'
export default {
name: 'TelemtryBanner',
computed: {
isBannerVisible() {
return telemetryCookies.get() === null ? true : false
}
},
methods: {
enableTelemetry() {
telemetryCookies.set('true', 30)
this.$bvToast.hide('kepler-banner')
},
disableTelemetry() {
telemetryCookies.set('false', 1)
this.$bvToast.hide('kepler-banner')
}
}
}
</script>
23 changes: 23 additions & 0 deletions src/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import ApiAction from '../components/ApiAction.vue'

import SecuritySubRoutes from './children/security'
import DataSubRoutes from './children/data'
import KeplerCompanion from 'kepler-companion'
import telemetryCookies from '../services/telemetryCookies'

Vue.use(VueRouter)

Expand Down Expand Up @@ -152,5 +154,26 @@ export default function createRoutes(log) {
]
})

const analytics = new KeplerCompanion()
router.afterEach((to, _) => {
const shouldAddTelemetry =
telemetryCookies.get() === null || telemetryCookies.get() === 'false'
? false
: true

if (shouldAddTelemetry) {
analytics
.add({
action: to.name as string,
product: 'admin-console',
version: require('../../package.json').version,
tags: {
environment: window.location.hostname
}
})
.catch(() => {})
}
})

return router
}
21 changes: 21 additions & 0 deletions src/services/telemetryCookies.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export default {
set: (value, expires) => {
let date = new Date()
date.setDate(date.getDate() + expires)

document.cookie = `telemetry=${JSON.stringify(
value
)}; expires=${date.toUTCString()}`
},
get: () => {
const telemetrySetting = document.cookie.split('telemetry=')[1]
if (telemetrySetting !== undefined) {
return JSON.parse(telemetrySetting)
}

return null
},
delete: () => {
document.cookie = 'telemetry=; expires=Thu, 01 Jan 1970 00:00:00 UTC'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ describe('Collection management', function() {
cy.request('POST', `${kuzzleUrl}/${indexName}/_create`)

cy.initLocalEnv(Cypress.env('BACKEND_VERSION'))
cy.setCookie('telemetry', 'false')
})

it('Should render a visual feedback and prevent submitting when input is not valid', () => {
Expand Down
1 change: 1 addition & 0 deletions test/e2e/cypress/integration/single-backend/login.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const validEnvName = 'valid'
describe('Login', function() {
beforeEach(() => {
cy.initLocalEnv(Cypress.env('BACKEND_VERSION'), null)
cy.setCookie('telemetry', 'false')
})

it('Should be able to login as anonymous', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ describe('Profiles', () => {
beforeEach(function() {
cy.request('POST', `${kuzzleUrl}/admin/_resetSecurity`)
cy.initLocalEnv(Cypress.env('BACKEND_VERSION'))
cy.setCookie('telemetry', 'false')
})

it('Should be able to delete a profile', () => {
Expand Down
1 change: 1 addition & 0 deletions test/e2e/cypress/integration/single-backend/roles.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('Roles', () => {
}
})
cy.initLocalEnv(Cypress.env('BACKEND_VERSION'))
cy.setCookie('telemetry', 'false')
})

afterEach(() => {
Expand Down
1 change: 1 addition & 0 deletions test/e2e/cypress/integration/single-backend/search.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ describe('Search', function() {
`search-filter-current:${indexName}/${collectionName}`,
'{}'
)
cy.setCookie('telemetry', 'false')
})

it('perists the Quick Search query in the URL', function() {
Expand Down
1 change: 1 addition & 0 deletions test/e2e/cypress/integration/single-backend/users.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe('Users', function() {
beforeEach(function() {
cy.request('POST', `${kuzzleUrl}/admin/_resetSecurity`)
cy.initLocalEnv(Cypress.env('BACKEND_VERSION'))
cy.setCookie('telemetry', 'false')
})

it('Should be able to search users via the quick search', () => {
Expand Down

0 comments on commit 4be3ad0

Please sign in to comment.