Skip to content

Commit

Permalink
Merge pull request Expensify#44821 from Expensify/dsilva_fixFullStory…
Browse files Browse the repository at this point in the history
…StartOnStaging

Only initialize FullStory after we confirm if this is production
  • Loading branch information
puneetlath authored Jul 12, 2024
2 parents 6b04fb2 + ad58f78 commit ec19663
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ fullstory {
org 'o-1WN56P-na1'
enabledVariants 'all'
logcatLevel 'debug'
recordOnStart false
}

react {
Expand Down
2 changes: 2 additions & 0 deletions ios/NewExpensify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
<dict>
<key>OrgId</key>
<string>o-1WN56P-na1</string>
<key>RecordOnStart</key>
<false/>
</dict>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
Expand Down
4 changes: 4 additions & 0 deletions src/Expensify.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import * as Report from './libs/actions/Report';
import * as User from './libs/actions/User';
import * as ActiveClientManager from './libs/ActiveClientManager';
import BootSplash from './libs/BootSplash';
import FS from './libs/Fullstory';
import * as Growl from './libs/Growl';
import Log from './libs/Log';
import migrateOnyx from './libs/migrateOnyx';
Expand Down Expand Up @@ -147,6 +148,9 @@ function Expensify({
// Initialize this client as being an active client
ActiveClientManager.init();

// Initialize Fullstory lib
FS.init();

// Used for the offline indicator appearing when someone is offline
const unsubscribeNetInfo = NetworkConnection.subscribeToNetInfo();

Expand Down
18 changes: 18 additions & 0 deletions src/libs/Fullstory/index.native.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,31 @@
import FullStory, {FSPage} from '@fullstory/react-native';
import type {OnyxEntry} from 'react-native-onyx';
import {useOnyx} from 'react-native-onyx';
import CONST from '@src/CONST';
import * as Environment from '@src/libs/Environment/Environment';
import ONYXKEYS from '@src/ONYXKEYS';
import type {UserMetadata} from '@src/types/onyx';

/**
* Fullstory React-Native lib adapter
* Proxy function calls to React-Native lib
* */
const FS = {
/**
* Initializes FullStory
*/
init: () => {
Environment.getEnvironment().then((envName: string) => {
// We only want to start fullstory if the app is running in production
if (envName !== CONST.ENVIRONMENT.PRODUCTION) {
return;
}
FullStory.restart();
const [session] = useOnyx(ONYXKEYS.USER_METADATA);
FS.fsIdentify(session);
});
},

/**
* Sets the identity as anonymous using the FullStory library.
*/
Expand Down
5 changes: 5 additions & 0 deletions src/libs/Fullstory/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ const FS = {
});
}
},

/**
* Init function, created so we're consistent with the native file
*/
init: () => {},
};

export default FS;
Expand Down
4 changes: 2 additions & 2 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,15 @@
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, interactive-widget=resizes-content">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<link rel="shortcut icon" id="favicon" href="/favicon.png">
<% if (htmlWebpackPlugin.options.isWeb && (htmlWebpackPlugin.options.isProduction || htmlWebpackPlugin.options.isStaging)) { %>
<% if (htmlWebpackPlugin.options.isWeb && htmlWebpackPlugin.options.isProduction) { %>
<!-- Third party scripts -->
<script async="" src="thirdPartyScripts.js"></script>
<!-- End Third party scripts -->
<% } %>
<link rel="manifest" href="/manifest.json" />
</head>
<body>
<% if (htmlWebpackPlugin.options.isWeb && (htmlWebpackPlugin.options.isProduction || htmlWebpackPlugin.options.isStaging)) { %>
<% if (htmlWebpackPlugin.options.isWeb && htmlWebpackPlugin.options.isProduction) { %>
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-N4M3FLJZ" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
Expand Down

0 comments on commit ec19663

Please sign in to comment.