-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dw-scroll-tabs
- Loading branch information
Showing
58 changed files
with
4,519 additions
and
2,249 deletions.
There are no files selected for viewing
657 changes: 537 additions & 120 deletions
657
ee/clickhouse/views/test/__snapshots__/test_clickhouse_experiments.ambr
Large diffs are not rendered by default.
Oops, something went wrong.
564 changes: 282 additions & 282 deletions
564
ee/session_recordings/queries/test/__snapshots__/test_session_recording_list_from_query.ambr
Large diffs are not rendered by default.
Oops, something went wrong.
65 changes: 65 additions & 0 deletions
65
frontend/src/lib/integrations/IntegrationScopesWarning.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import api from 'lib/api' | ||
import { LemonBanner } from 'lib/lemon-ui/LemonBanner' | ||
import { Link } from 'lib/lemon-ui/Link' | ||
import { useMemo } from 'react' | ||
|
||
import { HogFunctionInputSchemaType, IntegrationType } from '~/types' | ||
|
||
export function IntegrationScopesWarning({ | ||
integration, | ||
schema, | ||
}: { | ||
integration: IntegrationType | ||
schema?: HogFunctionInputSchemaType | ||
}): JSX.Element { | ||
const getScopes = useMemo((): string[] => { | ||
const scopes: any[] = [] | ||
const possibleScopeLocation = [integration.config.scope, integration.config.scopes] | ||
|
||
possibleScopeLocation.map((scope) => { | ||
if (typeof scope === 'string') { | ||
scopes.push(scope.split(' ')) | ||
scopes.push(scope.split(',')) | ||
} | ||
if (typeof scope === 'object') { | ||
scopes.push(scope) | ||
} | ||
}) | ||
return scopes | ||
.filter((scope: any) => typeof scope === 'object') | ||
.reduce((a, b) => (a.length > b.length ? a : b), []) | ||
}, [integration.config]) | ||
|
||
const requiredScopes = schema?.requiredScopes?.split(' ') || [] | ||
const missingScopes = requiredScopes.filter((scope: string) => !getScopes.includes(scope)) | ||
|
||
if (missingScopes.length === 0 || getScopes.length === 0) { | ||
return <></> | ||
} | ||
return ( | ||
<div className="p-2"> | ||
<LemonBanner | ||
type="error" | ||
action={{ | ||
children: 'Reconnect', | ||
disableClientSideRouting: true, | ||
to: api.integrations.authorizeUrl({ | ||
kind: integration.kind, | ||
next: window.location.pathname, | ||
}), | ||
}} | ||
> | ||
<span>Required scopes are missing: [{missingScopes.join(', ')}].</span> | ||
{integration.kind === 'hubspot' ? ( | ||
<span> | ||
Note that some features may not be available on your current HubSpot plan. Check out{' '} | ||
<Link to="https://developers.hubspot.com/beta-docs/guides/apps/authentication/scopes"> | ||
this page | ||
</Link>{' '} | ||
for more details. | ||
</span> | ||
) : null} | ||
</LemonBanner> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 113 additions & 22 deletions
135
frontend/src/scenes/dashboard/newDashboardLogic.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,132 @@ | ||
import { NodeKind } from '~/queries/schema' | ||
|
||
import { applyTemplate } from './newDashboardLogic' | ||
|
||
describe('template function in newDashboardLogic', () => { | ||
it('ignores unused variables', () => { | ||
expect( | ||
applyTemplate({ a: 'hello', b: 'hi' }, [ | ||
{ | ||
id: 'VARIABLE_1', | ||
name: 'a', | ||
default: { | ||
event: '$pageview', | ||
applyTemplate( | ||
{ a: 'hello', b: 'hi' }, | ||
[ | ||
{ | ||
id: 'VARIABLE_1', | ||
name: 'a', | ||
default: { | ||
event: '$pageview', | ||
}, | ||
description: 'The description of the variable', | ||
required: true, | ||
type: 'event', | ||
}, | ||
description: 'The description of the variable', | ||
required: true, | ||
type: 'event', | ||
}, | ||
]) | ||
], | ||
null | ||
) | ||
).toEqual({ a: 'hello', b: 'hi' }) | ||
}) | ||
it('uses identified variables', () => { | ||
expect( | ||
applyTemplate({ a: '{VARIABLE_1}', b: 'hi' }, [ | ||
{ | ||
id: 'VARIABLE_1', | ||
name: 'a', | ||
default: { | ||
event: '$pageview', | ||
applyTemplate( | ||
{ a: '{VARIABLE_1}', b: 'hi' }, | ||
[ | ||
{ | ||
id: 'VARIABLE_1', | ||
name: 'a', | ||
default: { | ||
event: '$pageview', | ||
}, | ||
description: 'The description of the variable', | ||
required: true, | ||
type: 'event', | ||
}, | ||
description: 'The description of the variable', | ||
required: true, | ||
type: 'event', | ||
}, | ||
]) | ||
], | ||
null | ||
) | ||
).toEqual({ | ||
a: { | ||
event: '$pageview', | ||
}, | ||
b: 'hi', | ||
}) | ||
}) | ||
|
||
it('replaces variables in query based tiles', () => { | ||
expect( | ||
applyTemplate( | ||
{ a: '{VARIABLE_1}' }, | ||
[ | ||
{ | ||
id: 'VARIABLE_1', | ||
name: 'a', | ||
default: { | ||
id: '$pageview', | ||
}, | ||
description: 'The description of the variable', | ||
required: true, | ||
type: 'event', | ||
}, | ||
], | ||
NodeKind.TrendsQuery | ||
) | ||
).toEqual({ | ||
a: { | ||
event: '$pageview', | ||
kind: 'EventsNode', | ||
math: 'total', | ||
}, | ||
}) | ||
}) | ||
|
||
it("removes the math property from query based tiles that don't support it", () => { | ||
expect( | ||
applyTemplate( | ||
{ a: '{VARIABLE_1}' }, | ||
[ | ||
{ | ||
id: 'VARIABLE_1', | ||
name: 'a', | ||
default: { | ||
id: '$pageview', | ||
}, | ||
description: 'The description of the variable', | ||
required: true, | ||
type: 'event', | ||
}, | ||
], | ||
NodeKind.LifecycleQuery | ||
) | ||
).toEqual({ | ||
a: { | ||
event: '$pageview', | ||
kind: 'EventsNode', | ||
}, | ||
}) | ||
}) | ||
|
||
it('removes the math property from retention insight tiles', () => { | ||
expect( | ||
applyTemplate( | ||
{ a: '{VARIABLE_1}' }, | ||
[ | ||
{ | ||
id: 'VARIABLE_1', | ||
name: 'a', | ||
default: { | ||
id: '$pageview', | ||
math: 'dau' as any, | ||
type: 'events' as any, | ||
}, | ||
description: 'The description of the variable', | ||
required: true, | ||
type: 'event', | ||
}, | ||
], | ||
NodeKind.RetentionQuery | ||
) | ||
).toEqual({ | ||
a: { | ||
id: '$pageview', | ||
type: 'events', | ||
}, | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.