Skip to content

Commit

Permalink
chore(Cross): [IOAPPX-282] Move Mixpanel URL into env file (pagopa#5691)
Browse files Browse the repository at this point in the history
## Short description
This PR moves the Mixpanel URL into our env file.

## List of changes proposed in this pull request
- Adds the URL in `.env.local` and `.env.production`;
- Adds the constant in `config.ts`; 
- Remove the hardcoded URL from `mixpanel.ts`.

## How to test
Test if Mixpanel events are tracked properly.

Co-authored-by: Cristiano Tofani <[email protected]>
  • Loading branch information
LazyAfternoons and CrisTofani authored Apr 15, 2024
1 parent d5669d8 commit 02a1a83
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .env.local
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ CONTENT_REPO_URL='http://127.0.0.1:3000/static_contents'
PRIVACY_URL='https://io.italia.it/app-content/tos_privacy.html'
# Privacy url for Zendesk usage
ZENDESK_PRIVACY_URL='https://www.pagopa.it/it/privacy-policy-assistenza/'
# Mixpanel
MIXPANEL_URL='https://api-eu.mixpanel.com'
MIXPANEL_TOKEN='0cb505dace6f4b3ceb9e17c7fcd7c66f'
# Test overlay caption, if the string is nonempty will be displayed in the TestOverlay
# TEST_OVERLAY_CAPTION='Functionality name here!'
Expand Down
2 changes: 2 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ CONTENT_REPO_URL='https://assets.cdn.io.pagopa.it'
PRIVACY_URL='https://io.italia.it/app-content/tos_privacy.html'
# Privacy url for Zendesk usage
ZENDESK_PRIVACY_URL='https://www.pagopa.it/it/privacy-policy-assistenza/'
# Mixpanel
MIXPANEL_URL='https://api-eu.mixpanel.com'
MIXPANEL_TOKEN='0cb505dace6f4b3ceb9e17c7fcd7c66f'
# Test overlay caption, if the string is nonempty will be displayed in the TestOverlay
# TEST_OVERLAY_CAPTION='Functionality name here!'
Expand Down
8 changes: 8 additions & 0 deletions ts/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,18 @@ const DEFAULT_TOT_SERVICE_FETCH_WORKERS = 5;
// https://pagopa.atlassian.net/browse/IA-474
const DEFAULT_PAGE_SIZE = 12;

// Default mixpanel EU url
const DEFAULT_MIXPANEL_URL = "https://api-eu.mixpanel.com";

export const environment: string = Config.ENVIRONMENT;
export const apiUrlPrefix: string = Config.API_URL_PREFIX;
export const pagoPaApiUrlPrefix: string = Config.PAGOPA_API_URL_PREFIX;
export const pagoPaApiUrlPrefixTest: string = Config.PAGOPA_API_URL_PREFIX_TEST;
export const mixpanelUrl = pipe(
Config.MIXPANEL_URL,
NonEmptyString.decode,
E.getOrElse(() => DEFAULT_MIXPANEL_URL)
);
export const mixpanelToken: string = Config.MIXPANEL_TOKEN;
export const isDebugBiometricIdentificationEnabled =
Config.DEBUG_BIOMETRIC_IDENTIFICATION === "YES";
Expand Down
8 changes: 2 additions & 6 deletions ts/mixpanel.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Mixpanel } from "mixpanel-react-native";
import { mixpanelToken } from "./config";
import { mixpanelToken, mixpanelUrl } from "./config";
import { getDeviceId } from "./utils/device";
import { GlobalState } from "./store/reducers/types";
import { updateMixpanelSuperProperties } from "./mixpanelConfig/superProperties";
Expand All @@ -17,11 +17,7 @@ export const initializeMixPanel = async (state: GlobalState) => {
}
const trackAutomaticEvents = true;
const privateInstance = new Mixpanel(mixpanelToken, trackAutomaticEvents);
await privateInstance.init(
undefined,
undefined,
"https://api-eu.mixpanel.com"
);
await privateInstance.init(undefined, undefined, mixpanelUrl);
mixpanel = privateInstance;
// On app first open
// On profile page, when user opt-in
Expand Down

0 comments on commit 02a1a83

Please sign in to comment.