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

WIP: Full roll out of Remoteconfig #1609

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 14 additions & 6 deletions cypress/e2e/capture.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ describe('Event capture', () => {
},
advanced_disable_feature_flags: true,
},
waitForDecide: false,
waitForFeatureFlags: false,
})

cy.intercept(
Expand Down Expand Up @@ -240,13 +240,17 @@ describe('Event capture', () => {
it('makes a single decide request', () => {
start({})

cy.get('@decide.all').then((calls) => {
cy.get('@remote-config.all').then((calls) => {
expect(calls.length).to.equal(1)
})

cy.get('@feature-flags.all').then((calls) => {
expect(calls.length).to.equal(1)
})

cy.phCaptures().should('include', '$pageview')
// @ts-expect-error - TS is wrong that get returns HTMLElement here
cy.get('@decide').should(({ request }) => {
cy.get('@feature-flags').should(({ request }) => {
const payload = getBase64EncodedPayload(request)
expect(payload.token).to.equal('test_token')
expect(payload.groups).to.deep.equal({})
Expand All @@ -255,7 +259,7 @@ describe('Event capture', () => {

describe('when disabled', () => {
it('captures pageviews, custom events when autocapture disabled', () => {
start({ options: { autocapture: false }, waitForDecide: false })
start({ options: { autocapture: false }, waitForRemoteConfig: false })

cy.wait(50)
cy.get('[data-cy-custom-event-button]').click()
Expand Down Expand Up @@ -328,7 +332,7 @@ describe('Event capture', () => {

describe('advanced_disable_decide config', () => {
it('does not autocapture anything when /decide is disabled', () => {
start({ options: { autocapture: false, advanced_disable_decide: true }, waitForDecide: false })
start({ options: { autocapture: false, advanced_disable_decide: true }, waitForFeatureFlags: false })

cy.get('body').click(100, 100)
cy.get('body').click(98, 102)
Expand All @@ -342,7 +346,11 @@ describe('Event capture', () => {
})

it('does not capture session recordings', () => {
start({ options: { advanced_disable_decide: true }, waitForDecide: false })
start({
options: { advanced_disable_decide: true },
waitForRemoteConfig: false,
waitForFeatureFlags: false,
})

cy.get('[data-cy-custom-event-button]').click()
cy.wait('@capture')
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/error-tracking.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { start } from '../support/setup'
describe('Exception capture', () => {
it('manual exception capture', () => {
start({
decideResponseOverrides: {
remoteConfigOverrides: {
autocaptureExceptions: false,
},
url: './playground/cypress',
Expand Down Expand Up @@ -33,7 +33,7 @@ describe('Exception capture', () => {
})

start({
decideResponseOverrides: {
remoteConfigOverrides: {
autocaptureExceptions: true,
},
url: './playground/cypress',
Expand Down
81 changes: 33 additions & 48 deletions cypress/e2e/opting-out.cy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { assertWhetherPostHogRequestsWereCalled, pollPhCaptures } from '../support/assertions'
import { start } from '../support/setup'
import { interceptRemoteConfig, start } from '../support/setup'

function assertThatRecordingStarted() {
cy.phCaptures({ full: true }).then((captures) => {
Expand All @@ -15,16 +15,13 @@ function assertThatRecordingStarted() {
describe('opting out', () => {
describe('session recording', () => {
beforeEach(() => {
cy.intercept('POST', '/decide/*', {
editorParams: {},
featureFlags: ['session-recording-player'],
isAuthenticated: false,
interceptRemoteConfig({
sessionRecording: {
endpoint: '/ses/',
},
capture_performance: true,
capturePerformance: true,
autocapture_opt_out: true,
}).as('decide')
})

cy.visit('./playground/cypress')
})
Expand All @@ -34,7 +31,7 @@ describe('opting out', () => {

assertWhetherPostHogRequestsWereCalled({
'@recorder-script': false,
'@decide': false,
'@remote-config': false,
'@session-recording': false,
})

Expand All @@ -52,7 +49,7 @@ describe('opting out', () => {

assertWhetherPostHogRequestsWereCalled({
'@recorder-script': false,
'@decide': true,
'@remote-config': true,
'@session-recording': false,
})

Expand All @@ -70,7 +67,7 @@ describe('opting out', () => {

assertWhetherPostHogRequestsWereCalled({
'@recorder-script': false,
'@decide': true,
'@remote-config': true,
'@session-recording': false,
})

Expand All @@ -88,7 +85,7 @@ describe('opting out', () => {

assertWhetherPostHogRequestsWereCalled({
'@recorder-script': false,
'@decide': true,
'@remote-config': true,
'@session-recording': false,
})

Expand All @@ -102,7 +99,7 @@ describe('opting out', () => {

assertWhetherPostHogRequestsWereCalled({
'@recorder-script': true,
'@decide': true,
'@remote-config': true,
// no call to session-recording yet
})

Expand All @@ -118,7 +115,7 @@ describe('opting out', () => {

assertWhetherPostHogRequestsWereCalled({
'@recorder-script': false,
'@decide': true,
'@remote-config': true,
'@session-recording': false,
})

Expand All @@ -135,7 +132,7 @@ describe('opting out', () => {

assertWhetherPostHogRequestsWereCalled({
'@recorder-script': true,
'@decide': true,
'@remote-config': true,
// no call to session-recording yet
})

Expand All @@ -147,24 +144,22 @@ describe('opting out', () => {
})

it('can override sampling when starting session recording', () => {
cy.intercept('POST', '/decide/*', {
autocapture_opt_out: true,
editorParams: {},
isAuthenticated: false,
interceptRemoteConfig({
sessionRecording: {
endpoint: '/ses/',
// will never record a session with rate of 0
sampleRate: '0',
},
}).as('decide')
autocapture_opt_out: true,
})

cy.posthogInit({
opt_out_capturing_by_default: true,
})

assertWhetherPostHogRequestsWereCalled({
'@recorder-script': false,
'@decide': true,
'@remote-config': true,
'@session-recording': false,
})

Expand All @@ -178,7 +173,7 @@ describe('opting out', () => {

assertWhetherPostHogRequestsWereCalled({
'@recorder-script': true,
'@decide': true,
'@remote-config': true,
// no call to session-recording yet
})

Expand All @@ -190,24 +185,22 @@ describe('opting out', () => {
})

it('can override linked_flags when starting session recording', () => {
cy.intercept('POST', '/decide/*', {
autocapture_opt_out: true,
editorParams: {},
isAuthenticated: false,
interceptRemoteConfig({
sessionRecording: {
endpoint: '/ses/',
// a flag that doesn't exist, can never be recorded
linkedFlag: 'i am a flag that does not exist',
},
}).as('decide')
autocapture_opt_out: true,
})

cy.posthogInit({
opt_out_capturing_by_default: true,
})

assertWhetherPostHogRequestsWereCalled({
'@recorder-script': false,
'@decide': true,
'@remote-config': true,
'@session-recording': false,
})

Expand All @@ -221,7 +214,7 @@ describe('opting out', () => {

assertWhetherPostHogRequestsWereCalled({
'@recorder-script': true,
'@decide': true,
'@remote-config': true,
// no call to session-recording yet
})

Expand All @@ -244,26 +237,24 @@ describe('opting out', () => {
})

it('respects sampling when overriding linked_flags when starting session recording', () => {
cy.intercept('POST', '/decide/*', {
interceptRemoteConfig({
autocapture_opt_out: true,
editorParams: {},
isAuthenticated: false,
sessionRecording: {
endpoint: '/ses/',
// a flag that doesn't exist, can never be recorded
linkedFlag: 'i am a flag that does not exist',
// will never record a session with rate of 0
sampleRate: '0',
},
}).as('decide')
})

cy.posthogInit({
opt_out_capturing_by_default: true,
})

assertWhetherPostHogRequestsWereCalled({
'@recorder-script': false,
'@decide': true,
'@remote-config': true,
'@session-recording': false,
})

Expand All @@ -277,7 +268,7 @@ describe('opting out', () => {

assertWhetherPostHogRequestsWereCalled({
'@recorder-script': true,
'@decide': true,
'@remote-config': true,
// no call to session-recording yet
})

Expand Down Expand Up @@ -305,26 +296,24 @@ describe('opting out', () => {
})

it('can override all ingestion controls when starting session recording', () => {
cy.intercept('POST', '/decide/*', {
interceptRemoteConfig({
autocapture_opt_out: true,
editorParams: {},
isAuthenticated: false,
sessionRecording: {
endpoint: '/ses/',
// a flag that doesn't exist, can never be recorded
linkedFlag: 'i am a flag that does not exist',
// will never record a session with rate of 0
sampleRate: '0',
},
}).as('decide')
})

cy.posthogInit({
opt_out_capturing_by_default: true,
})

assertWhetherPostHogRequestsWereCalled({
'@recorder-script': false,
'@decide': true,
'@remote-config': true,
'@session-recording': false,
})

Expand All @@ -338,7 +327,7 @@ describe('opting out', () => {

assertWhetherPostHogRequestsWereCalled({
'@recorder-script': true,
'@decide': true,
'@remote-config': true,
// no call to session-recording yet
})

Expand All @@ -361,16 +350,14 @@ describe('opting out', () => {
})

it('sends a $pageview event when opting in', () => {
cy.intercept('POST', '/decide/*', {
interceptRemoteConfig({
autocapture_opt_out: true,
editorParams: {},
isAuthenticated: false,
sessionRecording: {
endpoint: '/ses/',
// will never record a session with rate of 0
sampleRate: '0',
},
}).as('decide')
})

cy.posthogInit({
opt_out_capturing_by_default: true,
Expand All @@ -389,16 +376,14 @@ describe('opting out', () => {
})

it('does not send a duplicate $pageview event when opting in', () => {
cy.intercept('POST', '/decide/*', {
interceptRemoteConfig({
autocapture_opt_out: true,
editorParams: {},
isAuthenticated: false,
sessionRecording: {
endpoint: '/ses/',
// will never record a session with rate of 0
sampleRate: '0',
},
}).as('decide')
})

cy.posthogInit({})
// Wait for the pageview timeout
Expand Down
Loading
Loading