Skip to content

Add disable API boolean#992

Merged
silesky merged 1 commit intomasterfrom
add-disabled-option
Nov 17, 2023
Merged

Add disable API boolean#992
silesky merged 1 commit intomasterfrom
add-disabled-option

Conversation

@silesky
Copy link
Copy Markdown
Contributor

@silesky silesky commented Nov 7, 2023

Docs: segmentio/segment-docs#5681

Add 'disable' boolean / function option to allow for disabling Segment in a testing environment, which will allow us to disable segment.

export const analytics = AnalyticsBrowser.load(
  { writeKey: 'foo' }, 
  { disable: true } // no HTTP Requests, all methods are a no-op
)

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Nov 7, 2023

🦋 Changeset detected

Latest commit: f3979c9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@segment/analytics-next Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@silesky silesky changed the title Add disabled option Add disable API boolean Nov 7, 2023
@silesky silesky force-pushed the add-disabled-option branch from 5600222 to ec1c63e Compare November 8, 2023 00:01
@silesky silesky requested a review from oscb November 8, 2023 00:03
@silesky silesky force-pushed the add-disabled-option branch from 1aebdc1 to 6a23d0b Compare November 8, 2023 00:09
@silesky silesky requested a review from chrisradek November 8, 2023 00:10
@silesky silesky changed the title Add disable API boolean Proposal: Add disable API boolean Nov 8, 2023
@silesky silesky marked this pull request as draft November 13, 2023 18:03
@silesky silesky marked this pull request as ready for review November 15, 2023 20:07
@silesky silesky force-pushed the add-disabled-option branch from 6a23d0b to 71219b4 Compare November 15, 2023 20:09
@silesky silesky changed the title Proposal: Add disable API boolean Add disable API boolean Nov 15, 2023
@silesky silesky force-pushed the add-disabled-option branch from c150979 to f5ee410 Compare November 15, 2023 21:24
@silesky silesky force-pushed the add-disabled-option branch from f5ee410 to f3979c9 Compare November 15, 2023 21:41
Comment on lines +31 to +36
it('integration: should not touch cookies or localStorage', async () => {
const analytics = new NullAnalytics()
await analytics.track('foo')
const storage = getAjsBrowserStorage()
expect(Object.values(storage).every((v) => !v)).toBe(true)
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea for the test!

@silesky silesky merged commit a72f473 into master Nov 17, 2023
@silesky silesky deleted the add-disabled-option branch November 17, 2023 19:10
@github-actions github-actions bot mentioned this pull request Nov 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants