Skip to content

Allow adding attachments in a configuration script #320

@limbonaut

Description

@limbonaut

Problem

Adding attachments in a configuration script fails silently. It seems appropriate to add attachments in such place, so it's a bit of a "gotcha" moment. We should allow adding tags and attachments in a configuration script. Same for set_tag() or set_context().

Example of a problematic code:

extends SentryConfiguration

func _configure(options: SentryOptions) -> void:
	var attachment := SentryAttachment.create_with_path("user://some_data.dat")
	SentrySDK.add_attachment(attachment)

The problem is that _configure() is called before the SDK is initialized, and adding attachments fails silently.

Proposed solution

If we implement scopes, we could pass initial_scope into _configure() callback and merge it into the global scope on initialization.

func _configure(options: SentryOptions, initial_scope: SentryScope) -> void:
    var attachment := SentryAttachment.create_with_path("user://some_data.dat")
    initial_scope.add_attachment(attachment)

Calling add_attachment() before the SDK is initialized should result in some kind of warning.

Alternatively, until we implement scopes, we can add an initialized signal to SentrySDK:

func _configure(options: SentryOptions) -> void:
	SentrySDK.initialized.connect(_on_sdk_initialized)

func _on_sdk_initialized():
	var attachment := SentryAttachment.create_with_path("user://some_data.dat")
	SentrySDK.add_attachment(attachment)

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions