Skip to content

Commit

Permalink
Merge branch 'feat/example-apm-screen' into feat/combo-support-app-fl…
Browse files Browse the repository at this point in the history
…ows-with-apm-example

# Conflicts:
#	CHANGELOG.md
  • Loading branch information
abdelhamid-f-nasser committed Mar 4, 2024
2 parents 450c63c + e41b986 commit 421d8dc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
4 changes: 3 additions & 1 deletion examples/default/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
"graphql": "^16.8.1",
"graphql-request": "^6.1.0",
"instabug-reactnative": "link:../..",
"instabug-reactnative-ndk": "github:https://github.com/Instabug/Instabug-React-Native-NDK",
"native-base": "^3.4.28",
"react": "18.2.0",
"react-native": "0.72.3",
"react-native-background-timer": "^2.4.1",
"react-native-config": "^1.5.1",
"react-native-gesture-handler": "^2.13.4",
"react-native-maps": "^1.10.3",
Expand All @@ -29,7 +31,6 @@
"react-native-screens": "^3.20.0",
"react-native-svg": "^13.9.0",
"react-native-vector-icons": "^10.0.0",
"instabug-reactnative-ndk": "github:https://github.com/Instabug/Instabug-React-Native-NDK",
"react-query": "^3.39.3"
},
"devDependencies": {
Expand All @@ -39,6 +40,7 @@
"@react-native/metro-config": "^0.73.1",
"@types/jest": "^29.2.1",
"@types/react": "^18.0.24",
"@types/react-native-background-timer": "^2.0.2",
"@types/react-native-vector-icons": "^6.4.13",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.2.1",
Expand Down
8 changes: 8 additions & 0 deletions examples/default/src/screens/apm/FlowsScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Screen } from '../../components/Screen';
import { VStack } from 'native-base';
import { InputField } from '../../components/InputField';
import { CustomButton } from '../../components/CustomButton';
import BackgroundTimer from 'react-native-background-timer';

export const FlowsScreen: React.FC = () => {
const [flowName, setFlowName] = useState<string>('');
Expand All @@ -16,6 +17,12 @@ export const FlowsScreen: React.FC = () => {
return APM.startFlow(flowName);
}

async function startDelayedFlow() {
return BackgroundTimer.setTimeout(() => {
APM.startFlow(flowName);
}, 5000);
}

function setFlowAttribute() {
return APM.setFlowAttribute(flowName, flowAttributeKey, flowAttributeValue);
}
Expand All @@ -35,6 +42,7 @@ export const FlowsScreen: React.FC = () => {
value={flowName}
/>
<CustomButton title="Start Flow" onPress={startFlow} />
<CustomButton title="Start 5s Delayed Flow" onPress={startDelayedFlow} />
<InputField
placeholder="Flows Attribute Key"
onChangeText={(text) => setFlowAttributeKey(text)}
Expand Down
8 changes: 8 additions & 0 deletions examples/default/src/screens/apm/TracesScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Screen } from '../../components/Screen';
import { VStack } from 'native-base';
import { InputField } from '../../components/InputField';
import { CustomButton } from '../../components/CustomButton';
import BackgroundTimer from 'react-native-background-timer';

export const TracesScreen: React.FC = () => {
const [traceName, setTraceName] = useState<string>('');
Expand All @@ -17,6 +18,12 @@ export const TracesScreen: React.FC = () => {
executionTrace = await APM.startExecutionTrace(traceName ?? '');
}

async function startDelayedTrace() {
return BackgroundTimer.setTimeout(async () => {
executionTrace = await APM.startExecutionTrace(traceName ?? '');
}, 5000);
}

function setTraceAttribute() {
if (!executionTrace) {
console.log('Please, start a trace before setting attributes.');
Expand All @@ -42,6 +49,7 @@ export const TracesScreen: React.FC = () => {
value={traceName}
/>
<CustomButton title="Start Trace" onPress={startTrace} />
<CustomButton title="Start 5s Delayed Trace" onPress={startDelayedTrace} />
<InputField
placeholder="Trace Key Attribute"
onChangeText={(text) => setTraceAttributeKey(text)}
Expand Down
10 changes: 10 additions & 0 deletions examples/default/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2920,6 +2920,11 @@
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.5.tgz#5f19d2b85a98e9558036f6a3cacc8819420f05cf"
integrity sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==

"@types/react-native-background-timer@^2.0.2":
version "2.0.2"
resolved "https://registry.npmjs.org/@types/react-native-background-timer/-/react-native-background-timer-2.0.2.tgz#22f9126124068a0ee6a812e16f98e270c2b9b2c7"
integrity sha512-cMAep0M5yqUHjiiRPvGiviqiJYdI45KSjbI5ufsIFSQGFwHwrHJC/8yawNhy0G3Gix6fufWLsEj6jC5niUNHiQ==

"@types/react-native-vector-icons@^6.4.13":
version "6.4.13"
resolved "https://registry.yarnpkg.com/@types/react-native-vector-icons/-/react-native-vector-icons-6.4.13.tgz#28b34d15094e040718beefb67cb3eff0c4994cb6"
Expand Down Expand Up @@ -6610,6 +6615,11 @@ react-is@^17.0.1:
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==

react-native-background-timer@^2.4.1:
version "2.4.1"
resolved "https://registry.npmjs.org/react-native-background-timer/-/react-native-background-timer-2.4.1.tgz#a3bc1cafa8c1e3aeefd0611de120298b67978a0f"
integrity sha512-TE4Kiy7jUyv+hugxDxitzu38sW1NqjCk4uE5IgU2WevLv7sZacaBc6PZKOShNRPGirLl1NWkaG3LDEkdb9Um5g==

react-native-config@^1.5.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/react-native-config/-/react-native-config-1.5.1.tgz#73c94f511493e9b7ff9350cdf351d203a1b05acc"
Expand Down

0 comments on commit 421d8dc

Please sign in to comment.