Question

Best Practice to separate environments using Ampli Wrapper

  • 24 November 2023
  • 4 replies
  • 174 views

Hi, I’m quite new to Amplitude. I’m intalling Amplitude to my Saas web application made by react and typescript. I have several envrionments of this application. ex) local, dev(qa), staging, production.

 

First, I thought having project per environment was the right way( I’m ok to use dev project for local,dev,staging and prod project for production enviornment). But, seeing generated code by Ampli Wrapper, I got confused.  This is the fragment of  generated code. 

export type Environment = 'projectname';

export const ApiKey: Record<Environment, string> = {
projectname: 'xxxxxxxxx'
};

This shows environment = project. However, ampli.json seems not to be configurable for multiple project. Do I need to create source per enviornment and project per app?

 

What is the best way to setup Amplitude project in multi environment scenario for Ampli wrapper user? What I want is simple, I need an environment to test if my implementation is OK before releasing code to production. Plus, I want to keep data clean in Amplitude project. 

 

 


4 replies

Did you ever figure this out? I am facing the same confusion

@Andy Meagher 

Yes. I’ve talked with support team. Is your plan Enterprise or Growth? If not, you can’t use environment with Ampli wrapper.

In my case, I have two projects on amplitude data, dev and prod. ampli.json is connected to production project. I make tracking plans in prod project and generate typescript code. I set different API_KEY per application environments. ex) local/stg => dev, prod=>prod

Amplitude data can ingest undefined events, so I can see new events as status=unexpected in dev project at development phase. 

 

 

Oh we are not Enterprise or Growth, that explains a lot Thank you for the response / tip! 

I set different API_KEY per application environments. ex) local/stg => dev, prod=>prod


How did you achieve that?

 

Reply