Skip to content

Commit

Permalink
Renamed all things to the remote config version
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite committed Dec 3, 2024
1 parent 57d6b77 commit 5a345c9
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 63 deletions.
22 changes: 11 additions & 11 deletions src/__tests__/autocapture.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ describe('Autocapture system', () => {
beforeEach(() => {
posthog.config.rageclick = true
// Trigger proper enabling
autocapture.afterDecideResponse({} as DecideResponse)
autocapture.onRemoteConfig({} as DecideResponse)
})

it('should capture rageclick', () => {
Expand Down Expand Up @@ -502,7 +502,7 @@ describe('Autocapture system', () => {

it('should not capture events when config returns false, when an element matching any of the event selectors is clicked', () => {
posthog.config.autocapture = false
autocapture.afterDecideResponse({} as DecideResponse)
autocapture.onRemoteConfig({} as DecideResponse)

const eventElement1 = document.createElement('div')
const eventElement2 = document.createElement('div')
Expand All @@ -524,7 +524,7 @@ describe('Autocapture system', () => {
})

it('should not capture events when config returns true but server setting is disabled', () => {
autocapture.afterDecideResponse({
autocapture.onRemoteConfig({
autocapture_opt_out: true,
} as DecideResponse)

Expand Down Expand Up @@ -932,7 +932,7 @@ describe('Autocapture system', () => {
type: 'click',
} as unknown as MouseEvent

autocapture.afterDecideResponse({
autocapture.onRemoteConfig({
elementsChainAsString: true,
} as DecideResponse)

Expand Down Expand Up @@ -1003,7 +1003,7 @@ describe('Autocapture system', () => {
beforeEach(() => {
document.title = 'test page'
posthog.config.mask_all_element_attributes = false
autocapture.afterDecideResponse({} as DecideResponse)
autocapture.onRemoteConfig({} as DecideResponse)
})

it('should capture click events', () => {
Expand Down Expand Up @@ -1056,7 +1056,7 @@ describe('Autocapture system', () => {
'when client side config is %p and remote opt out is %p - autocapture enabled should be %p',
(clientSideOptIn, serverSideOptOut, expected) => {
posthog.config.autocapture = clientSideOptIn
autocapture.afterDecideResponse({
autocapture.onRemoteConfig({
autocapture_opt_out: serverSideOptOut,
} as DecideResponse)
expect(autocapture.isEnabled).toBe(expected)
Expand All @@ -1065,29 +1065,29 @@ describe('Autocapture system', () => {

it('should call _addDomEventHandlders if autocapture is true in client config', () => {
posthog.config.autocapture = true
autocapture.afterDecideResponse({} as DecideResponse)
autocapture.onRemoteConfig({} as DecideResponse)
expect(autocapture['_addDomEventHandlers']).toHaveBeenCalled()
})

it('should not call _addDomEventHandlders if autocapture is opted out in server config', () => {
autocapture.afterDecideResponse({ autocapture_opt_out: true } as DecideResponse)
autocapture.onRemoteConfig({ autocapture_opt_out: true } as DecideResponse)
expect(autocapture['_addDomEventHandlers']).not.toHaveBeenCalled()
})

it('should not call _addDomEventHandlders if autocapture is disabled in client config', () => {
expect(autocapture['_addDomEventHandlers']).not.toHaveBeenCalled()
posthog.config.autocapture = false

autocapture.afterDecideResponse({} as DecideResponse)
autocapture.onRemoteConfig({} as DecideResponse)

expect(autocapture['_addDomEventHandlers']).not.toHaveBeenCalled()
})

it('should NOT call _addDomEventHandlders when the token has already been initialized', () => {
autocapture.afterDecideResponse({} as DecideResponse)
autocapture.onRemoteConfig({} as DecideResponse)
expect(autocapture['_addDomEventHandlers']).toHaveBeenCalledTimes(1)

autocapture.afterDecideResponse({} as DecideResponse)
autocapture.onRemoteConfig({} as DecideResponse)
expect(autocapture['_addDomEventHandlers']).toHaveBeenCalledTimes(1)
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('Exception Observer', () => {

describe('when enabled', () => {
beforeEach(() => {
exceptionObserver.afterDecideResponse({ autocaptureExceptions: true } as DecideResponse)
exceptionObserver.onRemoteConfig({ autocaptureExceptions: true } as DecideResponse)
})

it('should instrument handlers when started', () => {
Expand Down Expand Up @@ -173,7 +173,7 @@ describe('Exception Observer', () => {
window!.onerror = originalOnError
window!.onunhandledrejection = originalOnUnhandledRejection

exceptionObserver.afterDecideResponse({ autocaptureExceptions: true } as DecideResponse)
exceptionObserver.onRemoteConfig({ autocaptureExceptions: true } as DecideResponse)
})

it('should wrap original onerror handler if one was present when wrapped', () => {
Expand Down Expand Up @@ -232,7 +232,7 @@ describe('Exception Observer', () => {

describe('when disabled', () => {
beforeEach(() => {
exceptionObserver.afterDecideResponse({ autocaptureExceptions: false } as DecideResponse)
exceptionObserver.onRemoteConfig({ autocaptureExceptions: false } as DecideResponse)
})

it('cannot be started', () => {
Expand Down
Loading

0 comments on commit 5a345c9

Please sign in to comment.