Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EMBR-3910] IOS - Allow the Embrace RN Sdk to be configured with a custom exporter #192

Draft
wants to merge 53 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
277d87d
iOS 6.0 Migration (#56)
TheMutsi Jul 29, 2024
a27a2bb
EMBR-4343 get basic test passing (#57)
jpmunz Jul 29, 2024
74e2b92
EMBR-4422 native module interface for spans (#59)
jpmunz Jul 29, 2024
2c6be4a
flush spans after adding attributes or events
jpmunz Aug 1, 2024
009ee6e
Update iOS initialization to configure from code instead of plist (#62)
jpmunz Aug 1, 2024
cb392ce
EMBR-4619 fix swift tests (#65)
jpmunz Aug 7, 2024
6f353cc
EMBR-4612 use nulls for timestamps on android instead of 0 (#64)
jpmunz Aug 7, 2024
1b42a9b
EMBR-4627 fix flaky tests (#67)
jpmunz Aug 8, 2024
0748517
EMBR-4625 handle removing session properties for all lifespans (#66)
jpmunz Aug 8, 2024
521b29e
EMBR-4634 update to ios 6.3.0 (#68)
jpmunz Aug 9, 2024
4a38ef5
[EMBR-4461] Implement logNetworkRequest/logNetworkClientError (#70)
facostaembrace Aug 14, 2024
363f001
iOS 6 - addBreadcrumb - logRNAction (#61)
TheMutsi Aug 14, 2024
38d73e8
bump package version to 5.0.0-alpha.0 for QA
jpmunz Aug 14, 2024
681c792
Native start end view to track JS Screens (#69)
TheMutsi Aug 14, 2024
a163e0b
misc cleanup to 5.0 branch (#71)
jpmunz Aug 15, 2024
57da81b
EMBR-4337 update the install/uninstall scripts for iOS 6 (#63)
jpmunz Aug 15, 2024
97ab747
fix Java syntax error
jpmunz Aug 15, 2024
d88fffd
EMBR-4336 port over docs changes to readme
jpmunz Aug 19, 2024
41c58fa
[EMBR-4462] Implement logHandlEderror (#77)
facostaembrace Aug 22, 2024
5f04e98
EMBR-4778 fix logging api (#76)
jpmunz Aug 22, 2024
a4390d6
EMBR-4795 use addBreadcrumb (#80)
jpmunz Aug 23, 2024
763c2d5
Jpmunz/embr 4790 pass js stacktrace to ios (#79)
jpmunz Aug 26, 2024
4500408
EMBR-4796 string returned from getLastRunEndState needs to match enum…
jpmunz Aug 26, 2024
712f6e0
(integration-test): local embrace script fixes (#78)
facostaembrace Aug 26, 2024
d8c4c7c
EMBR-4804 fix android start view (#85)
jpmunz Aug 28, 2024
86bb2ce
EMBR-4821 fix path for bridging header (#86)
jpmunz Aug 29, 2024
890ed6d
EMBR-4636 calculate react native bundle id (#72)
jpmunz Sep 4, 2024
72cc4dc
[EMBR-4464] Hook Swift tests up to CI (#84)
facostaembrace Sep 4, 2024
5579424
EMBR-4935 unit tests passing on 6.4.0 (#119)
jpmunz Sep 10, 2024
3e99b07
[EMBR-4462] Implement Log Unhandled JS Exceptions (#88)
facostaembrace Sep 12, 2024
37dfea8
(fix): Removing Embrace-Info.plist reference + tweak for ts type (Pro…
facostaembrace Sep 13, 2024
4bbac7f
updating to ios 6.4.0 (#127)
jpmunz Sep 13, 2024
e10fd91
[EMBR-3910] Allow the Embrace RN SDK to be configured with a custom e…
facostaembrace Sep 6, 2024
3921968
Android package
facostaembrace Sep 12, 2024
1502c9b
ios WIP
facostaembrace Sep 12, 2024
33e9cc3
adding ios native module/tweaks for documentation
facostaembrace Sep 13, 2024
fcbe1e2
android/ios projects
facostaembrace Sep 16, 2024
0296ce1
ios setting
facostaembrace Sep 17, 2024
8fe3573
wip
facostaembrace Sep 19, 2024
2c28879
wip
facostaembrace Sep 19, 2024
05a21fe
progress on ios
facostaembrace Sep 26, 2024
ecb3ae5
reintroducing files
facostaembrace Sep 26, 2024
92094bc
updating Podfile.lock
facostaembrace Sep 26, 2024
a3d6f31
Merge branch 'main' into facosta/EMBR-3910_Allow-the-embrace-rn-sdk-t…
facostaembrace Sep 26, 2024
7a4937d
progress
facostaembrace Sep 27, 2024
8046c43
merge from main
facostaembrace Oct 7, 2024
e47721c
progressing on dependencies
facostaembrace Oct 9, 2024
20f97a9
merging main branch into current
facostaembrace Oct 9, 2024
0324595
Merge branch 'main' into facosta/EMBR-3910_Allow-the-embrace-rn-sdk-t…
facostaembrace Oct 10, 2024
2977309
building app
facostaembrace Oct 10, 2024
1e38f9c
updating approach: ios to init from otlp package
facostaembrace Oct 14, 2024
c74716e
merge main into current
facostaembrace Oct 15, 2024
2dd3f61
Merge branch 'main' into facosta/EMBR-3910_Allow-the-embrace-rn-sdk-t…
facostaembrace Oct 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ local.properties
android/.classpath
android/.settings
android/.project

# Node
node_modules
*.log
Expand Down Expand Up @@ -87,3 +88,7 @@ RNTester/build

# VS Code
.vscode/

# Lerna
.nx/
nx.json
117 changes: 116 additions & 1 deletion DEVELOPING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ Any new package under ./packages/ will get automatically picked up as a new Yarn
- `package.json` with name, description, main, typings (other fields will be filled by yarn constraints, version is supplied by Lerna)
- `tsconfig.json` that extends from the one at the root
- `README.md`
- `src/` and `__tests__/` folders to contain the code for the package
- `src/` and `__tests__/` folders to contain the code for the package.

If an item from the previous list is missing, the package won't compile.

## Adding dependencies

Expand All @@ -25,6 +27,119 @@ are shared between multiple packages then they should be added to the Yarn const
This is also where we define common peerDependencies and enforce a common version. These are packages such as React Native
that our packages require but that we leave to the customer to have defined as explicit dependencies.

## Adding new Native Modules
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has some similar information to packages/react-native-tracer-provider/DEVELOPING.md but is more comprehensive, I added a note to https://www.notion.so/embraceio/Strategy-Template-for-new-packages-that-have-native-code-10a7e3c99852800faf13cc70fe783f25?pvs=4 that after merging we can delete packages/react-native-tracer-provider/DEVELOPING.md and move any extra information from there into this file


If new packages needs to connect with native code there are few things to have in mind.
The folder structure should be something like the following:

```
packages/
└── my-new-package/
├── ios/ # containing an Xcode workspace/project
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

were you able to get ios + android building using this structure without requiring a separate native-src/ folder to wrap the package inside a test react native app?

├── android/ # containing an Android workspace/project
├── src/
│ ├── __tests__/
│ └── index.ts
├── tsconfig.json
├── package.json
├── .eslintrc.js
├── README.md
└── MyNewPackage.podspec
```

> Make sure the new `package.json` file list all files/folders we want to get packed during the build and pack process. Example:

```json
{
"files": [
"lib",
"android",
"ios",
"NewPackageModule.podspec"
],
}
```

This example is configured to pack lib/, android/, ios/ and NewPackageModule.podspec into the package we will publish in the future. All folders/files that should be packed and published should be listed here. If they are not there, the pack/publish process will ignore them.

## iOS Native Module

References are very important when developing a new iOS Standalone Native Module, we encourage developers to create new modules through Xcode to avoid any issue related to this.

### Recommended steps

- Open Xcode and create a new workspace.
- Create a new target with the same name
- Create the proper files following the [iOS Native Modules for React Native](https://reactnative.dev/docs/native-modules-ios) official documentation.

This repository already contains classes using Swift. We highly recommend to keep this approach. More information about how to do it can be found in the (official documentation)[https://reactnative.dev/docs/native-modules-ios#exporting-swift].

At the end of this process the ios folder structure should contain something like the following:

```
ios/
└── MyNewModule.xcworkspace
└── MyNewModule/
├── MyNewModule.xcodeproj
├── MyNewModule-Bridging-Header.h
├── MyNewModule.m
└── MyNewModule.swift
```

This is the bare minimum we need to create a new iOS Native Module.

> Do not forget to properly create the .podspec file outside the ios folder listing all dependencies. Also it's a good idea to check in that this file is in place after run the build and pack the new package. Without this file the new iOS Native Module won't be recognized by the application and won't be installed.

## Android Native Module

Also for Android Standalone Native Modules we highly recommend to start the development process using Android Studio.

### Recommended steps

- Open Android Studio and create a new project using Empty Activity template.
- Provide a proper Project and Package Name (i.e MyNewPiece and io.embrace.mynewpiece respectively)
- Choose a location to save the new project (under android/ folder), select the languaje for the project and the build configuration and finish the process.

This process is going to create several folders/files with an structure like

```
android/
├── src/
│ └── main/
│ ├── java/
│ │ └── io/
│ │ └── embrace/
│ │ └── mynewpiece/
│ │ └── MyNewPiece.java # we will tweak this file name in following steps
│ ├── res/
│ └── AndroidManifest.xml
├── gradlew.bat
├── gradlew
├── gradle/
│ └── wrapper/
│ ├── gradle-wrapper.properties
│ └── gradle-wrapper.jar
├── local.properties
├── gradle.properties
├── settings.gradle (or settings.gradle.kts)
└── build.gradle (or build.gradle.kts)
```

In order to create an (Android React Native Module)[https://reactnative.dev/docs/native-modules-android] it's also recommended to follow the official documentation

Once this is done files should be the following inside `io.embrace.mynewpiece`:

```
src/
└── main/
└── java/
└── io/
└── embrace/
└── myapplication/
├── MyNewPieceModule.java
└── MyNewPiecePackage.java
```

## Testing changes during development

From the root of the project you can lint and test all packages with:
Expand Down
18 changes: 17 additions & 1 deletion integration-tests/basic-test-app/app/(tabs)/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const HomeScreen = () => {
"custom.property.test": "hey",
"another.property": "ho",
"yet.another": "hum",
"rn.sdk.test": 1234567,
"rn.sdk.test": "1234567",
});
}, []);

Expand Down Expand Up @@ -84,6 +84,22 @@ const HomeScreen = () => {
title="CRASH (not anonymous)"
/>
</ThemedView>

<ThemedView style={styles.stepContainer}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks to be duplicated from above

<ThemedText type="subtitle">Logs</ThemedText>
<Button onPress={sendLogs} title="LOGs (war/info/error)" />
<Button onPress={sendMessage} title="Custom Message (also a log)" />
<Button onPress={handleErrorLog} title="Handled JS Exception" />
</ThemedView>

<ThemedView style={styles.stepContainer}>
<ThemedText type="subtitle">Crashes (Unhandled Exceptions)</ThemedText>
<Button onPress={handleLogUnhandledError} title="CRASH" />
<Button
onPress={handleLogUnhandledErrorNotAnonymous}
title="CRASH (not anonymous)"
/>
</ThemedView>
</ParallaxScrollView>
);
};
Expand Down
21 changes: 21 additions & 0 deletions integration-tests/basic-test-app/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,33 @@ import * as SplashScreen from "expo-splash-screen";
import {useEffect} from "react";
import "react-native-reanimated";
import {initialize as initEmbrace} from "@embrace-io/react-native";
import {initialize as initEmbraceWithCustomExporters} from "@embrace-io/react-native-otlp";

import {useColorScheme} from "@/hooks/useColorScheme";

// Prevent the splash screen from auto-hiding before asset loading is complete.
SplashScreen.preventAutoHideAsync();

export default function RootLayout() {
const initWithCustomExporters = initEmbraceWithCustomExporters({
// logExporter: {
// endpoint: "http://localhost:4317/v1/logs",
// header: {
// key: "a-key",
// token: "a-token",
// },
// timeout: 30000,
// },
traceExporter: {
endpoint: "http://localhost:8080/otlp-http/v1/traces",
// header: {
// key: "a-key",
// token: "a-token",
// },
timeout: 30000,
},
});

useEffect(() => {
const init = async () => {
await initEmbrace({
Expand All @@ -20,6 +40,7 @@ export default function RootLayout() {
appId: "abcdf",
// endpointBaseUrl: "http://localhost:8877",
},
replaceInit: initWithCustomExporters,
},
});
};
Expand Down
2 changes: 2 additions & 0 deletions integration-tests/basic-test-app/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ install! 'cocoapods',
:deterministic_uuids => false

prepare_react_native_project!
# include the following when using 'EmbraceInternalGrpcSwift'
# use_modular_headers!

target 'basictestapp' do
use_expo_modules!
Expand Down
Loading
Loading