Skip to content

Support before_send hook like JS/Py/Ruby SDK #135

@MunifTanjim

Description

@MunifTanjim

Something like this:

	client, err := posthog.NewWithConfig(
		config.Posthog.APIKey,
		posthog.Config{},
	)

	if err != nil {
		log.Fatal("failed to initialize", "error", err)
	}

	client.BeforeSend(func(msg posthog.Message) posthog.Message {
		switch m := msg.(type) {
		case posthog.Exception:
			// would be nice if we can access the actual exception here,
			// instead of just the already transformed data
			return m
		default:
			return m
		}
	})
	client.BeforeSend(func(msg posthog.Message) posthog.Message {
		// is not sent if `nil` is returned
		return nil
	})
	client.BeforeSend(func(msg posthog.Message) posthog.Message {
		// never runs
	})

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions