Configuration
Configuration of the library is very simple, check out the options.
Initialisation
Initialisation of Streply is performed using the streply
class, which should be placed at the very beginning of the code. The method receives the (string) dsn
as the first parameter.
You can find the DSN code of the project in the Projects tab of your Streply account.
from streply.streply import streply
streply('https://clientPublicKey@api.streply.com/projectId')
The second, optional parameter of the streply
constructor method is the (object) options
in which optional settings can be defined.
Available options:
(string) environment
- Application environment(string) release
- Project version
Example of the option's usage:
from streply.streply import streply
streply('https://clientPublicKey@api.streply.com/projectId', {
'environment': 'local',
'release': 'my-project-name@2.3.12',
})
Also, you can change all options later:
from streply.streply import streply
streply = streply('https://clientPublicKey@api.streply.com/projectId')
streply.set_option('environment', 'local')
streply.set_option('release', 'my-project-name@2.3.12')
Scopes
The scope helper will set up the scope for all events captured by the Streply SDK.
from streply.capture import log
from streply.streply import streply
from streply.scope import configure_scope
# ...
with configure_scope() as scope:
scope.set_channel('my-chanel')
log('test log with channel')
If you want to change the scope for a all events, you can mark scope as global:
from streply.capture import log
from streply.streply import streply
from streply.scope import configure_scope
# ...
with configure_scope() as scope:
scope.set_global_scope(True)
scope.set_channel('my-chanel')
log('some log')
# ...
error('some error')
Available methods in scope:
scope.set_global_scope(bool)
- Setting is global scopescope.set_channel(string channel)
- Setting event channelscope.set_flag(string flag)
- Setting event flagscope.set_release(string release)
- Setting project releasescope.set_environment(string environment)
- Setting project environmentscope.set_url(string url)
- Setting project URL
Adding user data
from streply.streply import streply
streply = streply('https://clientPublicKey@api.streply.com/projectId')
streply.set_user('ID')
# with username
streply.set_user('ID', 'Joey')
or with parameters and name
from streply.streply import streply
streply = streply('https://clientPublicKey@api.streply.com/projectId')
streply.set_user('ID', 'Joey', {
'createdAt': '2022-11-10 15:10:32'
})