Skip to content

Typescript: ReplayCanvas integration type doesn't have "snapshot" method #11971

Closed
@pahuta

Description

@pahuta

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

7.114.0

Framework Version

7.114.0

Link to Sentry event

No response

SDK Setup

Sentry.init({
    dsn: config.SENTRY_DSN as string,
    integrations: [
      Sentry.browserTracingIntegration(),
      Sentry.replayIntegration({
        minReplayDuration: 1000,
        networkDetailAllowUrls: [
          config.API_URL as string,
        ],
        networkCaptureBodies: true,
        maskAllText: false,
        maskAllInputs: false,
        blockAllMedia: false,
      }),
      // The following is all you need to enable canvas recording with Replay
      Sentry.replayCanvasIntegration({
        enableManualSnapshot: true,
      }),
    ],
    // adjust in case of too many samples
    tracesSampleRate: 0.2,

    // This sets the sample rate to be 0%. You may want this to be 100% while
    // in development and sample at a lower rate in production
    replaysSessionSampleRate: 0,

    // If the entire session is not sampled, use the below sample rate to sample
    // sessions when an error occurs.
    replaysOnErrorSampleRate: 1.0,
  });

Steps to Reproduce

I use modified code snippet from documentation, step 2:

export const sendCanvasSnapshotToSentry = (canvasEl: HTMLCanvasElement) => {
  const sentryClient = Sentry.getClient();

  if (!sentryClient) {
    return;
  }

  const replayCanvasIntegration = sentryClient.getIntegrationByName('ReplayCanvas');

  if (!replayCanvasIntegration) {
    return;
  }

  replayCanvasIntegration.snapshot(canvasEl); // replayCanvasIntegration has interface "Integration"
};
Screenshot 2024-05-10 at 11 40 53

typescript@5.3.3

Expected Result

Sentry provides interface like ReplayCanvasIntegration which extends interface Integration and defines methods of integrations (I guess the same as _replayCanvasIntegration from @sentry-internal/replay-canvas/types/canvas.d.ts). Then I'll be able to use it as a generic type like:

      const replayCanvasIntegration = sentryClient.getIntegrationByName<ReplayCanvasIntegration>('ReplayCanvas');

Actual Result

Method snapshot is not defined in replay canvas integration, can't use it in a type safe way.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Package: reactIssues related to the Sentry React SDK

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions