-
-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce options in flutter templates
- Loading branch information
Showing
5 changed files
with
190 additions
and
14 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
import { | ||
pubspecOptions, | ||
sentryProperties, | ||
initSnippet, | ||
} from '../../src/flutter/templates'; | ||
|
||
describe('Flutter code templates', () => { | ||
describe('pubspec', () => { | ||
it('generates pubspec with project and org', () => { | ||
const template = pubspecOptions( | ||
'fixture-project', | ||
'fixture-org', | ||
); | ||
expect(template).toMatchInlineSnapshot(` | ||
"sentry: | ||
upload_source_maps: true | ||
upload_sources: true | ||
project: fixture-project | ||
org: fixture-org | ||
" | ||
`); | ||
}); | ||
}); | ||
describe('sentry.properties', () => { | ||
it('generates sentry.properties with token', () => { | ||
const template = sentryProperties( | ||
'fixture-token', | ||
); | ||
expect(template).toMatchInlineSnapshot(`"auth_token=fixture-token"`); | ||
}); | ||
}); | ||
describe('init', () => { | ||
it('generates Sentry config with all features enabled', () => { | ||
const template = initSnippet( | ||
'my-dsn', | ||
{ | ||
tracing: true, | ||
profiling: true, | ||
replay: true, | ||
}, | ||
'const MyApp()', | ||
); | ||
expect(template).toMatchInlineSnapshot(` | ||
"await SentryFlutter.init( | ||
(options) { | ||
options.dsn = 'my-dsn'; | ||
// Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing. | ||
// We recommend adjusting this value in production. | ||
options.tracesSampleRate = 1.0; | ||
// The sampling rate for profiling is relative to tracesSampleRate | ||
// Setting to 1.0 will profile 100% of sampled transactions: | ||
options.profilesSampleRate = 1.0; | ||
options.experimental.replay.sessionSampleRate = 1.0; | ||
options.experimental.replay.onErrorSampleRate = 1.0; | ||
}, | ||
appRunner: () => runApp(const MyApp()), | ||
); | ||
// TODO: Remove this line after sending the first sample event to sentry. | ||
await Sentry.captureMessage('This is a sample exception.');" | ||
`); | ||
}); | ||
|
||
it('generates Sentry config with replay disabled', () => { | ||
const template = initSnippet( | ||
'my-dsn', | ||
{ | ||
tracing: true, | ||
profiling: true, | ||
replay: false, | ||
}, | ||
'const MyApp()', | ||
); | ||
expect(template).toMatchInlineSnapshot(` | ||
"await SentryFlutter.init( | ||
(options) { | ||
options.dsn = 'my-dsn'; | ||
// Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing. | ||
// We recommend adjusting this value in production. | ||
options.tracesSampleRate = 1.0; | ||
// The sampling rate for profiling is relative to tracesSampleRate | ||
// Setting to 1.0 will profile 100% of sampled transactions: | ||
options.profilesSampleRate = 1.0; | ||
}, | ||
appRunner: () => runApp(const MyApp()), | ||
); | ||
// TODO: Remove this line after sending the first sample event to sentry. | ||
await Sentry.captureMessage('This is a sample exception.');" | ||
`); | ||
}); | ||
|
||
it('generates Sentry config with profiling disabled', () => { | ||
const template = initSnippet( | ||
'my-dsn', | ||
{ | ||
tracing: true, | ||
profiling: false, | ||
replay: false, | ||
}, | ||
'const MyApp()', | ||
); | ||
expect(template).toMatchInlineSnapshot(` | ||
"await SentryFlutter.init( | ||
(options) { | ||
options.dsn = 'my-dsn'; | ||
// Set tracesSampleRate to 1.0 to capture 100% of transactions for tracing. | ||
// We recommend adjusting this value in production. | ||
options.tracesSampleRate = 1.0; | ||
}, | ||
appRunner: () => runApp(const MyApp()), | ||
); | ||
// TODO: Remove this line after sending the first sample event to sentry. | ||
await Sentry.captureMessage('This is a sample exception.');" | ||
`); | ||
}); | ||
|
||
it('generates Sentry config with tracing disabled', () => { | ||
const template = initSnippet( | ||
'my-dsn', | ||
{ | ||
tracing: false, | ||
profiling: false, | ||
replay: false, | ||
}, | ||
'const MyApp()', | ||
); | ||
expect(template).toMatchInlineSnapshot(` | ||
"await SentryFlutter.init( | ||
(options) { | ||
options.dsn = 'my-dsn'; | ||
}, | ||
appRunner: () => runApp(const MyApp()), | ||
); | ||
// TODO: Remove this line after sending the first sample event to sentry. | ||
await Sentry.captureMessage('This is a sample exception.');" | ||
`); | ||
}); | ||
}); | ||
}); |