Skip to content

Commit

Permalink
moving logic to web file
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldoglas committed Apr 24, 2024
1 parent e423af1 commit bd6e492
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
14 changes: 4 additions & 10 deletions src/libs/fullstory/index.native.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import FullStory, {FSPage} from '@fullstory/react-native';
import type {OnyxEntry} from 'react-native-onyx';
import CONST from '@src/CONST';
import * as Environment from '@src/libs/Environment/Environment';
import type {UserMetadata} from '@src/types/onyx';

/**
Expand All @@ -24,14 +22,10 @@ const FS = {
*/
consentAndIdentify: (value: OnyxEntry<UserMetadata>) => {
try {
Environment.getEnvironment().then((envName: string) => {
if (CONST.ENVIRONMENT.PRODUCTION !== envName) {
return;
}
// We only use FullStory in production environment
FullStory.consent(true);
FS.fsIdentify(value);
});
// We only use FullStory in production environment
FullStory.consent(true);
FS.fsIdentify(value);

} catch (e) {
// error handler
}
Expand Down
30 changes: 21 additions & 9 deletions src/libs/fullstory/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import {FullStory, init, isInitialized} from '@fullstory/browser';
import type {OnyxEntry} from 'react-native-onyx';
import CONST from '@src/CONST';
import * as Environment from '@src/libs/Environment/Environment';
import type {UserMetadata} from '@src/types/onyx';
import type NavigationProperties from './types';

Expand Down Expand Up @@ -27,12 +29,17 @@ const FS = {
*/
onReady: () =>
new Promise((resolve) => {
// Initialised via HEAD snippet
if (isInitialized()) {
init({orgId: ''}, resolve);
} else {
FullStory('observe', {type: 'start', callback: resolve});
}
Environment.getEnvironment().then((envName: string) => {
if (CONST.ENVIRONMENT.PRODUCTION !== envName) {
return;
}
// Initialised via HEAD snippet
if (isInitialized()) {
init({orgId: ''}, resolve);
} else {
FullStory('observe', {type: 'start', callback: resolve});
}
});
}),

/**
Expand All @@ -50,9 +57,14 @@ const FS = {
*/
consentAndIdentify: (value: OnyxEntry<UserMetadata>) => {
try {
FS.onReady().then(() => {
FS.consent(true);
FS.fsIdentify(value);
Environment.getEnvironment().then((envName: string) => {
if (CONST.ENVIRONMENT.PRODUCTION !== envName) {
return;
}
FS.onReady().then(() => {
FS.consent(true);
FS.fsIdentify(value);
});
});
} catch (e) {
// error handler
Expand Down

0 comments on commit bd6e492

Please sign in to comment.