Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hackathon: sdk plugins #2248

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft

Hackathon: sdk plugins #2248

wants to merge 5 commits into from

Conversation

bcaudan
Copy link
Contributor

@bcaudan bcaudan commented May 16, 2023

Motivation

More flexibility for prototyping, integration with third parties

Changes

Rum plugin interface (similar for logs):

interface RumPlugin {
  name: string
  version: string
  onRegistered?: (datadogRum: RumPublicApi) => void
  beforeSend?: RumInitConfiguration['beforeSend']
}

Registering API:

DD_RUM.registerPlugins: (...RumPlugin[]) => void

Dummy example:

class CurrentViewUpdateLogger {
  name: 'dummy_plugin'
  version: '0.0.0'
  datadogRum

  onRegistered(datadogRum) {
    this.datadogRum = datadogRum
  }

  beforeSend(event) {
    if (event.type === "view" && event.view.id === this.datadogRum?.getInternalContext()?.view?.id) {
      console.log("current view updated", event)
    }
  }
}

DD_RUM.registerPlugins(new CurrentViewUpdateLogger());

Features:

  • beforeSend hook for plugins
  • pass the global to plugins to allow them to call public APIs
  • monitor individual plugin call to allow plugin failure without bothering the SDK execution
  • add plugin name and version to plugin telemetry errors
  • LaunchDarkly integration example without using the addFeatureFlagEvaluation API

Ideas:

  • dedicated plugins context in event schema to allow external plugins to provide data
  • provide monitor function for plugins to use on their own functions
  • monitor plugins usage (with monitoring for all SDK APIs)
  • rework sdk internals to also use plugins internally (product VS platform)
  • provide more specific hooks to allow precise tweaks on SDK behaviour (new frustration type, change session storage)

Testing

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant