Skip to content

Commit

Permalink
fix: Add missing header and use correct endpoint host (#23982)
Browse files Browse the repository at this point in the history
  • Loading branch information
warrensplayer authored Sep 26, 2022
1 parent 6a40936 commit 3aad5a0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
12 changes: 10 additions & 2 deletions packages/data-context/src/actions/EventCollectorActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ interface CollectableEvent {
cohort?: string
}

const cloudEnv = (process.env.CYPRESS_INTERNAL_EVENT_COLLECTOR_ENV || 'staging') as 'development' | 'staging' | 'production'
/**
* Defaults to staging when doing development. To override to production for development,
* explicitly set process.env.CYPRESS_INTERNAL_ENV to 'production`
*/
const cloudEnv = (process.env.CYPRESS_INTERNAL_EVENT_COLLECTOR_ENV || 'production') as 'development' | 'staging' | 'production'

export class EventCollectorActions {
constructor (private ctx: DataContext) {
Expand All @@ -23,7 +27,11 @@ export class EventCollectorActions {

await this.ctx.util.fetch(
`${dashboardUrl}/anon-collect`,
{ method: 'POST', body: JSON.stringify(event) },
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(event),
},
)

debug(`Recorded event: %o`, event)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('EventCollectorActions', () => {

expect(ctx.util.fetch).to.have.been.calledOnceWith(
sinon.match(/anon-collect$/), // Verify URL ends with expected 'anon-collect' path
{ method: 'POST', body: '{"campaign":"abc","medium":"def","messageId":"ghi","cohort":"123"}' },
{ method: 'POST', headers: { 'Content-Type': 'application/json' }, body: '{"campaign":"abc","medium":"def","messageId":"ghi","cohort":"123"}' },
)
})

Expand Down
10 changes: 10 additions & 0 deletions scripts/gulp/gulpConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ declare global {
}
}

/**
* Gulp is only used for running the application during development. At this point of starting the app,
* process.env.CYPRESS_INTERNAL_ENV has not been set yet unless explicitly set on the command line. If not
* set on the command line, it is set to 'development' [here](https://github.com/cypress-io/cypress/blob/a5ec234005fead97f6cfdf611abf8d9f4ad0565d/packages/server/lib/environment.js#L22)
*
* When running in a production build, a file is written out to set CYPRESS_INTERNAL_ENV to 'production'
* [here](https://github.com/cypress-io/cypress/blob/a5ec234005fead97f6cfdf611abf8d9f4ad0565d/scripts/binary/build.ts#L176).
* However, running in production will not use the code in this file.
*/

export const DEFAULT_INTERNAL_CLOUD_ENV = process.env.CYPRESS_INTERNAL_ENV || 'production'

export const DEFAULT_INTERNAL_EVENT_COLLECTOR_ENV = process.env.CYPRESS_INTERNAL_ENV || 'staging'
Expand Down

5 comments on commit 3aad5a0

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 3aad5a0 Sep 26, 2022

Choose a reason for hiding this comment

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

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.9.0/linux-x64/develop-3aad5a03e9291b11eb86fe68261db84dd87854ea/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 3aad5a0 Sep 26, 2022

Choose a reason for hiding this comment

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

Circle has built the linux arm64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.9.0/linux-arm64/develop-3aad5a03e9291b11eb86fe68261db84dd87854ea/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 3aad5a0 Sep 26, 2022

Choose a reason for hiding this comment

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

Circle has built the darwin arm64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.9.0/darwin-arm64/develop-3aad5a03e9291b11eb86fe68261db84dd87854ea/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 3aad5a0 Sep 26, 2022

Choose a reason for hiding this comment

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

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.9.0/darwin-x64/develop-3aad5a03e9291b11eb86fe68261db84dd87854ea/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on 3aad5a0 Sep 26, 2022

Choose a reason for hiding this comment

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

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/10.9.0/win32-x64/develop-3aad5a03e9291b11eb86fe68261db84dd87854ea/cypress.tgz

Please sign in to comment.