Skip to content

Canvas Replay cannot be lazily loaded #13754

@MIreland

Description

@MIreland

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/react

SDK Version

8.30.0

Framework Version

17.0.2

Link to Sentry event

https://orthly-5a.sentry.io/replays/fe385969b6944552a585205815cc33be/?environment=development&environment=staging&environment=test&project=1730923&query=&referrer=%2Freplays%2F&statsPeriod=1h&yAxis=count%28%29

Reproduction Example/SDK Setup

Not working:

Sentry init config:

        return {
            dsn: SENTRY_DSN,
            enabled: sentryEnabled,
            debug: false,
            attachStacktrace: true,
            environment: this.env,
            release: RELEASE,
            normalizeDepth: 4,
            beforeBreadcrumb: excludeGraphQLFetch,
            ignoreErrors: [/OTLPExporterError/],
            denyUrls: [
                // EPDPOR-1165 - SunCo flakiness
                /smooch\.io/i,
            ],
            integrations: [],
            replaysSessionSampleRate: 1.0,
            replaysOnErrorSampleRate: 1.0,
        };

Later:

export function useEnableSentrySessionReplay(shouldRecord: boolean = true): void {
    React.useEffect(() => {
        const sentryEnabled = !!process.env.ENABLE_SENTRY_SESSION_REPLAY;
        if (shouldRecord && sentryEnabled && !initializedSentrySessionReplay) {
            initializedSentrySessionReplay = true;
            Sentry.addIntegration(
                replayIntegration({
                    maskAllText: false,
                    blockAllMedia: false,
                }),
            );
            Sentry.addIntegration(replayCanvasIntegration());
        }
    }, [shouldRecord]);
}

Working:

return {
            dsn: SENTRY_DSN,
            enabled: sentryEnabled,
            debug: false,
            attachStacktrace: true,
            environment: this.env,
            release: RELEASE,
            normalizeDepth: 4,
            beforeBreadcrumb: excludeGraphQLFetch,
            ignoreErrors: [/OTLPExporterError/],
            denyUrls: [
                // EPDPOR-1165 - SunCo flakiness
                /smooch\.io/i,
            ],
            integrations: [
                replayIntegration({
                    maskAllText: false,
                    blockAllMedia: false,
                }),
                replayCanvasIntegration(),
            ],
            replaysSessionSampleRate: 1.0,
            replaysOnErrorSampleRate: 1.0,
            initialScope: {
                tags: {
                    build_version: DANDY_METADATA.VERSION || 'unknown',
                    sha: DANDY_METADATA.SHA || 'unknown',
                    build_timestamp: DANDY_METADATA.TIMESTAMP || 0,
                },
            },
        };

Steps to Reproduce

Canvas integration for replays works when initialized as 'on', but does not work when added lazily.

This works fine:

{
...restOfSetup,
integrations: [
    replayIntegration({
        maskAllText: false,
        blockAllMedia: false,
    }),
    replayCanvasIntegration(),
],
}

This does not:

{
...restOfSetup,
integrations: [],
}


//....later
Sentry.addIntegration(
    replayIntegration({
        maskAllText: false,
        blockAllMedia: false,
    }),
);
Sentry.addIntegration(replayCanvasIntegration());

Expected Result

Lazily loading canvas replays should still work.

Actual Result

Canvas does not work in replays when lazily loaded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugPackage: reactIssues related to the Sentry React SDK

    Projects

    Status

    Waiting for: Product Owner

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions