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

feat: add library context field #76

Merged
merged 1 commit into from
Aug 19, 2022
Merged

Conversation

liuyang1520
Copy link
Contributor

Summary

  • feat: add library context field

Add this option in the configuration, which can be used in the library wrapper/code generation/dynamic loading cases, for setting the library_context information.

Checklist

  • Does your PR title have the correct title format?
  • Does your PR have a breaking change?: No

@@ -24,6 +24,7 @@ public class Amplitude {
private Object eventQueueLock = new Object();
private Plan plan;
private long flushTimeout;
private String libraryContext;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found that adding a new middleware to this repo might be a little overkilled, e.g.:

public class ContextMiddleware implements Middleware {
    public String libraryContext;

    public ContextMiddleware(String libraryContext) {
        this.libraryContext = libraryContext;
    }

    @Override
    public void run(MiddlewarePayload payload, MiddlewareNext next) {
        if (payload.event != null) {
            payload.event.libraryContext = this.libraryContext;
        }
        next.run(payload);
    }
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What'll be your suggestion?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, my preference would be the change in this PR.

  • The property can be globally set (like plan), doesn't need to be applied per event
  • Lightweight and minimum changes, adding a new middleware and exporting it in package only for this case seems overkill to me

For the Python (new generation SDk) change: https://github.com/amplitude/Amplitude-Python/pull/33/files. Similarly, exposing a way to set it globally, as Python puts the library in ContextPlugin, we can put in the similar place, while keeping the changes minimum and lightweight.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it! Thanks

@liuyang1520 liuyang1520 merged commit c874396 into main Aug 19, 2022
@liuyang1520 liuyang1520 deleted the add-library-context-field branch August 19, 2022 04:03
liuyang1520 added a commit that referenced this pull request Aug 25, 2022
liuyang1520 added a commit that referenced this pull request Aug 25, 2022
justin-fiedler pushed a commit that referenced this pull request Jun 20, 2023
# [1.11.0](v1.10.0...v1.11.0) (2023-06-20)

### Bug Fixes

* fix failed unit tests due to async methods ([#74](#74)) ([026c3cc](026c3cc))
* handle non-json response bodies and retry on 5xx errors. ([#85](#85)) ([1d4567e](1d4567e))

### Features

* add ingestion_metadata field ([#78](#78)) ([727bb51](727bb51))
* add library context field ([#76](#76)) ([c874396](c874396))

### Reverts

* Revert "feat: add library context field (#76)" (#77) ([7d9e474](7d9e474)), closes [#76](#76) [#77](#77)
@github-actions
Copy link

🎉 This PR is included in version 1.11.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

5 participants