-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
57 changed files
with
1,170 additions
and
158 deletions.
There are no files selected for viewing
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
12 changes: 12 additions & 0 deletions
12
.../browser-integration-tests/suites/integrations/lazyLoad/moduleMetadataIntegration/init.js
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,12 @@ | ||
import * as Sentry from '@sentry/browser'; | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
integrations: [], | ||
}); | ||
|
||
window.Sentry = { | ||
...Sentry, | ||
// Ensure this is _not_ set | ||
moduleMetadataIntegration: undefined, | ||
}; |
7 changes: 7 additions & 0 deletions
7
...owser-integration-tests/suites/integrations/lazyLoad/moduleMetadataIntegration/subject.js
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,7 @@ | ||
window._testLazyLoadIntegration = async function run() { | ||
const integration = await window.Sentry.lazyLoadIntegration('moduleMetadataIntegration'); | ||
|
||
window.Sentry.getClient()?.addIntegration(integration()); | ||
|
||
window._integrationLoaded = true; | ||
}; |
33 changes: 33 additions & 0 deletions
33
.../browser-integration-tests/suites/integrations/lazyLoad/moduleMetadataIntegration/test.ts
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,33 @@ | ||
import { expect } from '@playwright/test'; | ||
import { SDK_VERSION } from '@sentry/browser'; | ||
|
||
import { sentryTest } from '../../../../utils/fixtures'; | ||
|
||
sentryTest('it allows to lazy load the moduleMetadata integration', async ({ getLocalTestUrl, page }) => { | ||
const url = await getLocalTestUrl({ testDir: __dirname }); | ||
|
||
await page.route(`https://browser.sentry-cdn.com/${SDK_VERSION}/modulemetadata.min.js`, route => { | ||
return route.fulfill({ | ||
status: 200, | ||
contentType: 'application/javascript;', | ||
body: "window.Sentry.moduleMetadataIntegration = () => ({ name: 'ModuleMetadata' })", | ||
}); | ||
}); | ||
|
||
await page.goto(url); | ||
|
||
const hasIntegration = await page.evaluate('!!window.Sentry.getClient()?.getIntegrationByName("ModuleMetadata")'); | ||
expect(hasIntegration).toBe(false); | ||
|
||
const scriptTagsBefore = await page.evaluate<number>('document.querySelectorAll("script").length'); | ||
|
||
await page.evaluate('window._testLazyLoadIntegration()'); | ||
await page.waitForFunction('window._integrationLoaded'); | ||
|
||
const scriptTagsAfter = await page.evaluate<number>('document.querySelectorAll("script").length'); | ||
|
||
const hasIntegration2 = await page.evaluate('!!window.Sentry.getClient()?.getIntegrationByName("ModuleMetadata")'); | ||
expect(hasIntegration2).toBe(true); | ||
|
||
expect(scriptTagsAfter).toBe(scriptTagsBefore + 1); | ||
}); |
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
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
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
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
23 changes: 23 additions & 0 deletions
23
dev-packages/node-integration-tests/suites/tracing/knex/docker-compose.yml
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,23 @@ | ||
version: '3.9' | ||
|
||
services: | ||
db_postgres: | ||
image: postgres:13 | ||
restart: always | ||
container_name: integration-tests-knex-postgres | ||
ports: | ||
- '5445:5432' | ||
environment: | ||
POSTGRES_USER: test | ||
POSTGRES_PASSWORD: test | ||
POSTGRES_DB: tests | ||
|
||
db_mysql2: | ||
image: mysql:8 | ||
restart: always | ||
container_name: integration-tests-knex-mysql2 | ||
ports: | ||
- '3307:3306' | ||
environment: | ||
MYSQL_ROOT_PASSWORD: docker | ||
MYSQL_DATABASE: tests |
53 changes: 53 additions & 0 deletions
53
dev-packages/node-integration-tests/suites/tracing/knex/scenario-withMysql2.js
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,53 @@ | ||
const { loggingTransport } = require('@sentry-internal/node-integration-tests'); | ||
const Sentry = require('@sentry/node'); | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
release: '1.0', | ||
tracesSampleRate: 1.0, | ||
transport: loggingTransport, | ||
integrations: [Sentry.knexIntegration()], | ||
}); | ||
|
||
// Stop the process from exiting before the transaction is sent | ||
setInterval(() => {}, 1000); | ||
|
||
const knex = require('knex').default; | ||
|
||
const mysql2Client = knex({ | ||
client: 'mysql2', | ||
connection: { | ||
host: 'localhost', | ||
port: 3307, | ||
user: 'root', | ||
password: 'docker', | ||
database: 'tests', | ||
}, | ||
}); | ||
|
||
async function run() { | ||
await Sentry.startSpan( | ||
{ | ||
name: 'Test Transaction', | ||
op: 'transaction', | ||
}, | ||
async () => { | ||
try { | ||
await mysql2Client.schema.createTable('User', table => { | ||
table.increments('id').notNullable().primary({ constraintName: 'User_pkey' }); | ||
table.timestamp('createdAt', { precision: 3 }).notNullable().defaultTo(mysql2Client.fn.now(3)); | ||
table.text('email').notNullable(); | ||
table.text('name').notNullable(); | ||
}); | ||
|
||
await mysql2Client('User').insert({ name: 'jane', email: '[email protected]' }); | ||
await mysql2Client('User').select('*'); | ||
} finally { | ||
await mysql2Client.destroy(); | ||
} | ||
}, | ||
); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
run(); |
53 changes: 53 additions & 0 deletions
53
dev-packages/node-integration-tests/suites/tracing/knex/scenario-withPostgres.js
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,53 @@ | ||
const { loggingTransport } = require('@sentry-internal/node-integration-tests'); | ||
const Sentry = require('@sentry/node'); | ||
|
||
Sentry.init({ | ||
dsn: 'https://[email protected]/1337', | ||
release: '1.0', | ||
tracesSampleRate: 1.0, | ||
transport: loggingTransport, | ||
integrations: [Sentry.knexIntegration()], | ||
}); | ||
|
||
// Stop the process from exiting before the transaction is sent | ||
setInterval(() => {}, 1000); | ||
|
||
const knex = require('knex').default; | ||
|
||
const pgClient = knex({ | ||
client: 'pg', | ||
connection: { | ||
host: 'localhost', | ||
port: 5445, | ||
user: 'test', | ||
password: 'test', | ||
database: 'tests', | ||
}, | ||
}); | ||
|
||
async function run() { | ||
await Sentry.startSpan( | ||
{ | ||
name: 'Test Transaction', | ||
op: 'transaction', | ||
}, | ||
async () => { | ||
try { | ||
await pgClient.schema.createTable('User', table => { | ||
table.increments('id').notNullable().primary({ constraintName: 'User_pkey' }); | ||
table.timestamp('createdAt', { precision: 3 }).notNullable().defaultTo(pgClient.fn.now(3)); | ||
table.text('email').notNullable(); | ||
table.text('name').notNullable(); | ||
}); | ||
|
||
await pgClient('User').insert({ name: 'bob', email: '[email protected]' }); | ||
await pgClient('User').select('*'); | ||
} finally { | ||
await pgClient.destroy(); | ||
} | ||
}, | ||
); | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
run(); |
Oops, something went wrong.