Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: #174 As a 'Developer', I want to see a graph on my analytics page showing API calls #221

Merged
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
0d7ae41
feat: #174 - Add AppUsageStats apis + redux store
nphivu414 Feb 6, 2020
116059d
feat: #174 - Add AppUsageStats apis + redux store
nphivu414 Feb 6, 2020
d27de70
feat: #173 create traffic table
Feb 7, 2020
b6009fb
feat: #174 - Build app usages graph
nphivu414 Feb 8, 2020
79bf670
Merge branch 'feat/173' into branch 'feat/174'
nphivu414 Feb 9, 2020
519fa94
Revert package.json
nphivu414 Feb 9, 2020
599d7e0
feat: #174 - Update test for developer traffic chart
nphivu414 Feb 9, 2020
01aea03
feat: #174 - Add util test, fix created date format in traffic table
nphivu414 Feb 10, 2020
97c2b93
feat: #174 - Remove developerId param from appUsageStatsRequest
nphivu414 Feb 10, 2020
0e61b3e
Merge branch 'master' into feat/174-add-a-graph-showing-api-calls-in-…
nphivu414 Feb 10, 2020
83b4299
Merge branch 'master' into feat/174
nphivu414 Feb 11, 2020
723325e
feat: #174 Remove unused logs - Update appId params
nphivu414 Feb 11, 2020
ea49ec2
feat: #174 - Update usage stats test for multiple apps
nphivu414 Feb 11, 2020
c45aa38
feat: #174 - Fix app usage stats test issues
nphivu414 Feb 11, 2020
fde0777
feat: #174 - Update analytic page rendering flow while loading
nphivu414 Feb 11, 2020
fa61272
feat: #174 - Add type for app trafic tooltip label
nphivu414 Feb 11, 2020
c97d1e0
feat: #174 - Update marketplace-api-schema.ts file
nphivu414 Feb 11, 2020
5740d30
feat: #174 - Merge branch 'master into feat/174
nphivu414 Feb 11, 2020
10d0af1
feat: #174 - Merge branch into feat/174
nphivu414 Feb 11, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,832 changes: 916 additions & 916 deletions packages/foundations-ts-definitions/types/marketplace-api-schema.ts

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/marketplace/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@
"last 2 versions",
"not ie <= 10"
]
}
}
17 changes: 17 additions & 0 deletions packages/marketplace/src/actions/__tests__/app-usage-stats.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { appUsageStatsReceiveData, appUsageStatsRequestData, appUsageStatsRequestDataFailure } from '../app-usage-stats'
import ActionTypes from '@/constants/action-types'
import { usageStatsDataStub } from '@/sagas/__stubs__/app-usage-stats'

describe('app-usage-stats actions', () => {
it('should create a appUsageStatsRequestData action', () => {
expect(appUsageStatsRequestData.type).toEqual(ActionTypes.APP_USAGE_STATS_REQUEST_DATA)
expect(appUsageStatsRequestData({ appId: ['1'] }).data).toEqual({ appId: ['1'] })
})
it('should create a appUsageStatsReceiveData action', () => {
expect(appUsageStatsReceiveData.type).toEqual(ActionTypes.APP_USAGE_STATS_RECEIVE_DATA)
expect(appUsageStatsReceiveData(usageStatsDataStub).data).toEqual(usageStatsDataStub)
})
it('should create a appUsageStatsRequestDataFailure action', () => {
expect(appUsageStatsRequestDataFailure.type).toEqual(ActionTypes.APP_USAGE_STATS_REQUEST_DATA_FAILURE)
})
})
14 changes: 14 additions & 0 deletions packages/marketplace/src/actions/app-usage-stats.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { actionCreator } from '../utils/actions'
import ActionTypes from '../constants/action-types'

const { APP_USAGE_STATS_REQUEST_DATA, APP_USAGE_STATS_RECEIVE_DATA, APP_USAGE_STATS_REQUEST_DATA_FAILURE } = ActionTypes

export interface AppUsageStatsParams {
appId?: string[]
dateFrom?: string
dateTo?: string
}

export const appUsageStatsRequestData = actionCreator<AppUsageStatsParams>(APP_USAGE_STATS_REQUEST_DATA)
export const appUsageStatsReceiveData = actionCreator<AppUsageStatsParams>(APP_USAGE_STATS_RECEIVE_DATA)
export const appUsageStatsRequestDataFailure = actionCreator<void>(APP_USAGE_STATS_REQUEST_DATA_FAILURE)
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ exports[`AdminApps should match a snapshot when LOADING false 1`] = `
data={
Array [
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://google.com/abc",
Expand All @@ -147,6 +148,7 @@ exports[`AdminApps should match a snapshot when LOADING false 1`] = `
"summary": "nXXT2zaK807ysWgy8F0WEhIYRP3TgosAtfuiLtQCImoSx0kynxbIF0nkGHU36Oz13kM3DG0Bcsicr8L6eWFKLBg4axlmiOEWcvwHAbBP9LRvoFkCl58k1wjhOExnpaZItEyOT1AXVKv8PE44aMGtVz",
},
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://www.contoso.com/path",
Expand Down Expand Up @@ -266,6 +268,7 @@ exports[`AdminApps should match a snapshot when LOADING true 1`] = `
data={
Array [
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://google.com/abc",
Expand All @@ -287,6 +290,7 @@ exports[`AdminApps should match a snapshot when LOADING true 1`] = `
"summary": "nXXT2zaK807ysWgy8F0WEhIYRP3TgosAtfuiLtQCImoSx0kynxbIF0nkGHU36Oz13kM3DG0Bcsicr8L6eWFKLBg4axlmiOEWcvwHAbBP9LRvoFkCl58k1wjhOExnpaZItEyOT1AXVKv8PE44aMGtVz",
},
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://www.contoso.com/path",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,130 @@ exports[`AnalyticsPage should match snapshot 1`] = `
/>
</Component>
<Component>
<DeveloperTrafficChart />
<Component
apps={
Object {
"data": Array [
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://google.com/abc",
"iconUri": "https://reapit-app-store-app-media.s3.eu-west-2.amazonaws.com/d10e790c-2bf2-40ae-9c43-82c1534bde31.png",
"id": "09043eb8-9e5e-4650-b7f1-f0cb62699027",
"links": Array [
Object {
"action": "GET",
"href": "http://platformdemo.reapit.net/marketplace/apps/09043eb8-9e5e-4650-b7f1-f0cb62699027",
"rel": "self",
},
Object {
"action": "GET",
"href": "http://platformdemo.reapit.net/marketplace/developers/28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"rel": "developer",
},
],
"name": "test",
"summary": "nXXT2zaK807ysWgy8F0WEhIYRP3TgosAtfuiLtQCImoSx0kynxbIF0nkGHU36Oz13kM3DG0Bcsicr8L6eWFKLBg4axlmiOEWcvwHAbBP9LRvoFkCl58k1wjhOExnpaZItEyOT1AXVKv8PE44aMGtVz",
},
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://www.contoso.com/path",
"iconUri": "https://reapit-app-store-app-media.s3.eu-west-2.amazonaws.com/1d38c5ec-e3c0-4138-9fe0-e77bce4034d1.octet-stream",
"id": "261da083-cee2-4f5c-a18f-8f9375f1f5af",
"links": Array [
Object {
"action": "GET",
"href": "http://platformdemo.reapit.net/marketplace/apps/261da083-cee2-4f5c-a18f-8f9375f1f5af",
"rel": "self",
},
Object {
"action": "GET",
"href": "http://platformdemo.reapit.net/marketplace/developers/28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"rel": "developer",
},
],
"name": "asd",
"summary": "asdQiiAJTmXGxPin7pwUiCsepZWXz1EJS71eGlvgPKH4hpE6J8DRDpzP2kDdOwpQPr4aHCCwWwxBJwzARLa7wMpJh5J61GhmQjLfKZkcDd47L9WEfQYVYAj0DTPJP0BuUMAAg2",
},
],
"pageCount": 2,
"pageNumber": 1,
"pageSize": 2,
"totalCount": 6,
}
}
stats={Object {}}
/>
</Component>
</Component>
<DeveloperTrafficTable
apps={
Object {
"data": Array [
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://google.com/abc",
"iconUri": "https://reapit-app-store-app-media.s3.eu-west-2.amazonaws.com/d10e790c-2bf2-40ae-9c43-82c1534bde31.png",
"id": "09043eb8-9e5e-4650-b7f1-f0cb62699027",
"links": Array [
Object {
"action": "GET",
"href": "http://platformdemo.reapit.net/marketplace/apps/09043eb8-9e5e-4650-b7f1-f0cb62699027",
"rel": "self",
},
Object {
"action": "GET",
"href": "http://platformdemo.reapit.net/marketplace/developers/28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"rel": "developer",
},
],
"name": "test",
"summary": "nXXT2zaK807ysWgy8F0WEhIYRP3TgosAtfuiLtQCImoSx0kynxbIF0nkGHU36Oz13kM3DG0Bcsicr8L6eWFKLBg4axlmiOEWcvwHAbBP9LRvoFkCl58k1wjhOExnpaZItEyOT1AXVKv8PE44aMGtVz",
},
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://www.contoso.com/path",
"iconUri": "https://reapit-app-store-app-media.s3.eu-west-2.amazonaws.com/1d38c5ec-e3c0-4138-9fe0-e77bce4034d1.octet-stream",
"id": "261da083-cee2-4f5c-a18f-8f9375f1f5af",
"links": Array [
Object {
"action": "GET",
"href": "http://platformdemo.reapit.net/marketplace/apps/261da083-cee2-4f5c-a18f-8f9375f1f5af",
"rel": "self",
},
Object {
"action": "GET",
"href": "http://platformdemo.reapit.net/marketplace/developers/28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"rel": "developer",
},
],
"name": "asd",
"summary": "asdQiiAJTmXGxPin7pwUiCsepZWXz1EJS71eGlvgPKH4hpE6J8DRDpzP2kDdOwpQPr4aHCCwWwxBJwzARLa7wMpJh5J61GhmQjLfKZkcDd47L9WEfQYVYAj0DTPJP0BuUMAAg2",
},
],
"pageCount": 2,
"pageNumber": 1,
"pageSize": 2,
"totalCount": 6,
}
}
stats={Object {}}
/>
<Component
developer={
Object {
"developerData": Object {
"data": Object {
"data": Array [
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://google.com/abc",
Expand All @@ -73,6 +187,7 @@ exports[`AnalyticsPage should match snapshot 1`] = `
"summary": "nXXT2zaK807ysWgy8F0WEhIYRP3TgosAtfuiLtQCImoSx0kynxbIF0nkGHU36Oz13kM3DG0Bcsicr8L6eWFKLBg4axlmiOEWcvwHAbBP9LRvoFkCl58k1wjhOExnpaZItEyOT1AXVKv8PE44aMGtVz",
},
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://www.contoso.com/path",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ exports[`Client should match a snapshot when LOADING false 1`] = `
Object {
"data": Array [
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://google.com/abc",
Expand All @@ -34,6 +35,7 @@ exports[`Client should match a snapshot when LOADING false 1`] = `
"summary": "nXXT2zaK807ysWgy8F0WEhIYRP3TgosAtfuiLtQCImoSx0kynxbIF0nkGHU36Oz13kM3DG0Bcsicr8L6eWFKLBg4axlmiOEWcvwHAbBP9LRvoFkCl58k1wjhOExnpaZItEyOT1AXVKv8PE44aMGtVz",
},
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://www.contoso.com/path",
Expand Down Expand Up @@ -118,6 +120,7 @@ exports[`Client should match a snapshot when featured apps is empty [] 1`] = `
Object {
"data": Array [
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://google.com/abc",
Expand All @@ -139,6 +142,7 @@ exports[`Client should match a snapshot when featured apps is empty [] 1`] = `
"summary": "nXXT2zaK807ysWgy8F0WEhIYRP3TgosAtfuiLtQCImoSx0kynxbIF0nkGHU36Oz13kM3DG0Bcsicr8L6eWFKLBg4axlmiOEWcvwHAbBP9LRvoFkCl58k1wjhOExnpaZItEyOT1AXVKv8PE44aMGtVz",
},
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://www.contoso.com/path",
Expand Down Expand Up @@ -204,6 +208,7 @@ exports[`Client should match a snapshot when featured apps is undefined 1`] = `
Object {
"data": Array [
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://google.com/abc",
Expand All @@ -225,6 +230,7 @@ exports[`Client should match a snapshot when featured apps is undefined 1`] = `
"summary": "nXXT2zaK807ysWgy8F0WEhIYRP3TgosAtfuiLtQCImoSx0kynxbIF0nkGHU36Oz13kM3DG0Bcsicr8L6eWFKLBg4axlmiOEWcvwHAbBP9LRvoFkCl58k1wjhOExnpaZItEyOT1AXVKv8PE44aMGtVz",
},
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://www.contoso.com/path",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ exports[`DeveloperHome should match a snapshot 1`] = `
list={
Array [
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://google.com/abc",
Expand All @@ -31,6 +32,7 @@ exports[`DeveloperHome should match a snapshot 1`] = `
"summary": "nXXT2zaK807ysWgy8F0WEhIYRP3TgosAtfuiLtQCImoSx0kynxbIF0nkGHU36Oz13kM3DG0Bcsicr8L6eWFKLBg4axlmiOEWcvwHAbBP9LRvoFkCl58k1wjhOExnpaZItEyOT1AXVKv8PE44aMGtVz",
},
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://www.contoso.com/path",
Expand Down Expand Up @@ -87,6 +89,7 @@ exports[`DeveloperHome should match a snapshot 3`] = `
list={
Array [
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://google.com/abc",
Expand All @@ -108,6 +111,7 @@ exports[`DeveloperHome should match a snapshot 3`] = `
"summary": "nXXT2zaK807ysWgy8F0WEhIYRP3TgosAtfuiLtQCImoSx0kynxbIF0nkGHU36Oz13kM3DG0Bcsicr8L6eWFKLBg4axlmiOEWcvwHAbBP9LRvoFkCl58k1wjhOExnpaZItEyOT1AXVKv8PE44aMGtVz",
},
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://www.contoso.com/path",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ exports[`InstalledApps should match a snapshot when LOADING false 1`] = `
list={
Array [
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://google.com/abc",
Expand All @@ -28,6 +29,7 @@ exports[`InstalledApps should match a snapshot when LOADING false 1`] = `
"summary": "nXXT2zaK807ysWgy8F0WEhIYRP3TgosAtfuiLtQCImoSx0kynxbIF0nkGHU36Oz13kM3DG0Bcsicr8L6eWFKLBg4axlmiOEWcvwHAbBP9LRvoFkCl58k1wjhOExnpaZItEyOT1AXVKv8PE44aMGtVz",
},
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://www.contoso.com/path",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ exports[`MyApps should match a snapshot when LOADING false 1`] = `
list={
Array [
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://google.com/abc",
Expand All @@ -28,6 +29,7 @@ exports[`MyApps should match a snapshot when LOADING false 1`] = `
"summary": "nXXT2zaK807ysWgy8F0WEhIYRP3TgosAtfuiLtQCImoSx0kynxbIF0nkGHU36Oz13kM3DG0Bcsicr8L6eWFKLBg4axlmiOEWcvwHAbBP9LRvoFkCl58k1wjhOExnpaZItEyOT1AXVKv8PE44aMGtVz",
},
Object {
"created": "2020-02-02T10:45:57",
"developer": "Pete's Proptech World Ltd",
"developerId": "28c9ea52-7f73-4814-9e00-4e3714b8adeb",
"homePage": "http://www.contoso.com/path",
Expand Down
24 changes: 21 additions & 3 deletions packages/marketplace/src/components/pages/__tests__/analytics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { appsDataStub } from '@/sagas/__stubs__/apps'
import { ReduxState } from '@/types/core'
import { DeveloperState } from '@/reducers/developer'
import { AppInstallationsState } from '@/reducers/app-installations'
import { AppUsageStatsState } from '@/reducers/app-usage-stats'

jest.mock('@reapit/elements', () => ({
...jest.requireActual('@reapit/elements'),
Expand All @@ -37,23 +38,40 @@ const installations = {
},
} as AppInstallationsState

const appUsageStats: AppUsageStatsState = {
loading: false,
appUsageStatsData: {},
}

describe('AnalyticsPage', () => {
it('should match snapshot', () => {
expect(shallow(<AnalyticsPage installations={installations} developer={developer} />)).toMatchSnapshot()
expect(
shallow(<AnalyticsPage installations={installations} developer={developer} appUsageStats={appUsageStats} />),
).toMatchSnapshot()
})

it('should match when loading', () => {
const installationsLoading = { ...installations, loading: true }
const developerLoading = { ...developer, loading: true }
expect(
shallow(<AnalyticsPage installations={installationsLoading} developer={developerLoading} />),
shallow(
<AnalyticsPage
installations={installationsLoading}
developer={developerLoading}
appUsageStats={appUsageStats}
/>,
),
).toMatchSnapshot()
})
})

describe('mapStateToProps', () => {
it('should return correct value', () => {
expect(mapStateToProps({ installations, developer } as ReduxState)).toEqual({ installations, developer })
expect(mapStateToProps({ installations, developer, appUsageStats } as ReduxState)).toEqual({
installations,
developer,
appUsageStats,
})
})
})

Expand Down
Loading