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

Two different Amplitude instances send event to the same project #45

Closed
hurlenko opened this issue Apr 3, 2023 · 1 comment · Fixed by #48
Closed

Two different Amplitude instances send event to the same project #45

hurlenko opened this issue Apr 3, 2023 · 1 comment · Fixed by #48
Labels
bug Something isn't working

Comments

@hurlenko
Copy link

hurlenko commented Apr 3, 2023

Consider this sample code:

client_a = Amplitude(PROJECT_A)
client_b = Amplitude(PROJECT_B)

client_a.track(...)  # sends event to PROJECT_B

Expected Behavior

client_a.track(...) sends the event to PROJECT_A

Current Behavior

client_a.track(...) sends the event to PROJECT_B

Possible Solution

Don't use mutable defaults in function arguments as they are shared across all class instances:

def __init__(self, api_key: str, configuration: Config = Config()):

self.configuration: Config = configuration
self.configuration.api_key = api_key

Can be replaced with something like:

def __init__(self, api_key: str, configuration: Optional[Config] = None):
    self.configuration = configuration or Config()

Possible workaround for now is to specify different config instances explicitly:

client_a = Amplitude(PROJECT_A, configuration=Config())
client_b = Amplitude(PROJECT_B, configuration=Config())

Another possible bug with this scenario might be here (didn't check):

storage_provider: StorageProvider = InMemoryStorageProvider(),

Environment

  • SDK Version: amplitude-analytics==1.1.0
  • Python Version: 3.9.16
  • OS Info: macOS 13.2
@hurlenko hurlenko added the bug Something isn't working label Apr 3, 2023
@Mercy811
Copy link
Contributor

Mercy811 commented Aug 4, 2023

Hi @hurlenko, thanks for creating this issue. It should be fixed in 1.1.2. Please upgrade to the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants