Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ It is configured to use the local version of the library, so any changes you mak

If you want to use Android Studio or Xcode to edit the native code, you can open the `apps/example-react-native/android` or `apps/example-react-native/ios` directories respectively in those editors. To edit the Objective-C or Swift files, run `yarn example ios:setup`, then open `apps/example-react-native/ios/MargeloAnalyticsSdkExample.xcodeproj` in Xcode and select the SDK under Package Dependencies.

To edit the Java or Kotlin files, open `apps/example-react-native/android` in Android studio and find the source files in the `callstack_performance-analytics-react-native` Gradle project under `Android`.
To edit the Java or Kotlin files, open `apps/example-react-native/android` in Android studio and find the source files in the `callstack_react-native-performance-analytics` Gradle project under `Android`.

You can use various commands from the root directory to work with the project.

Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
# Callstack Performance Analytics SDK

Performance analytics SDK suite for React Native, React Nitro, native Android, and native iOS apps.
Performance analytics SDK suite for React Native, Nitro UI, native Android, and native iOS apps.

## Monorepo Layout

- `packages/react-native-sdk`: React Native adapter package (`@callstack/performance-analytics-react-native`)
- `packages/react-native-sdk`: React Native adapter package (`@callstack/react-native-performance-analytics`)
- `packages/android-native-sdk`: Native Android SDK sources (Maven artifact: `com.callstack:performance-analytics-android`)
- `packages/react-native-sdk/apple`: Native iOS SDK sources (CocoaPod/SPM product: `CallstackPerformanceAnalytics`, podspec at `packages/react-native-sdk/apple/CallstackPerformanceAnalytics.podspec`)
- `packages/core-cpp`: Shared C++ components (Android Prefab provider: `com.callstack:performance-analytics-core-cpp`)
- `apps/example-react-native`: Example React Native app
- `apps/example-expo`: Example Expo development app
- `packages/react-nitro-sdk`: React Nitro adapter (`@callstack/performance-analytics-react-nitro`)
- `apps/example-react-nitro`: React Nitro example for iOS and Android
- `packages/nitro-sdk`: Nitro UI adapter (`@callstack/nitro-performance-analytics`)
- `apps/example-nitro-ui`: Nitro UI example for iOS and Android

## React Nitro example
## Nitro UI example

With Bun and the iOS or Android toolchain installed, run the following from the repository root.

```sh
corepack yarn install
cd apps/example-react-nitro
cd apps/example-nitro-ui
bun run prepare:nitro
bun run start
```

Press `i` or `a` in the dev server to open the example on iOS or Android.
Enter an instance URL and project ingest key, then tap **Start recording**.
**Flush samples** persists the active session and asks the SDK to upload completed sessions.
See the [React Nitro package guide](packages/react-nitro-sdk/README.md) to integrate another app.
See the [Nitro UI package guide](packages/nitro-sdk/README.md) to integrate another app.

## React Native Usage

```sh
npm install @callstack/performance-analytics-react-native
npm install @callstack/react-native-performance-analytics
```

```ts
import { PerformanceAnalytics } from '@callstack/performance-analytics-react-native';
import { PerformanceAnalytics } from '@callstack/react-native-performance-analytics';

PerformanceAnalytics.init({
host: 'https://perf.example.com',
Expand Down Expand Up @@ -99,7 +99,7 @@ import {
MeasurementView,
PerformanceAnalytics,
type FirstDrawnFinishedEvent,
} from '@callstack/performance-analytics-react-native';
} from '@callstack/react-native-performance-analytics';

PerformanceAnalytics.init({ host, apiKey, autoInjectFCP: true });

Expand Down Expand Up @@ -168,7 +168,7 @@ For a custom navigator, call the public markers from its transition callbacks. U
names such as `ProductDetails` across visits. Keep the handle for the individual transition.

```ts
import { screenNavigation } from '@callstack/performance-analytics-react-native';
import { screenNavigation } from '@callstack/react-native-performance-analytics';

screenNavigation.screen('Feed'); // Feed is visible and settled.
const opening = screenNavigation.beginTransition('Feed', 'ProductDetails');
Expand Down Expand Up @@ -203,7 +203,7 @@ In a CocoaPods app, add the bundled native pod inside your app target before run
`pod install` (the path below assumes a Podfile under `ios/`):

```ruby
pod 'CallstackPerformanceAnalytics', :path => '../node_modules/@callstack/performance-analytics-react-native/apple'
pod 'CallstackPerformanceAnalytics', :path => '../node_modules/@callstack/react-native-performance-analytics/apple'
```

## Native SDK installation
Expand All @@ -216,7 +216,7 @@ product to the app target. Xcode and CI need read access to the private reposito

### Android with Gradle

For native Android, React Native, and React Nitro apps, add the GitHub Packages
For native Android, React Native, and Nitro UI apps, add the GitHub Packages
repository to the app's Gradle dependency repositories. In `settings.gradle.kts`:

```kotlin
Expand Down Expand Up @@ -269,7 +269,7 @@ acknowledging them and deduplicates retries by project and session ID.

### Thread benchmarks

React Native and React Nitro export `ThreadBenchmark` on Android and iOS.
React Native and Nitro UI export `ThreadBenchmark` on Android and iOS.
Import it from the adapter your app uses. Swift apps can construct
`try ThreadBenchmark(name:)` from `CallstackPerformanceAnalytics`. Kotlin apps
use `com.callstack.performanceanalytics.ThreadBenchmark` on any app thread.
Expand Down Expand Up @@ -308,7 +308,7 @@ collect CPU metrics for a performance-test block on its calling thread.
[Apple’s XCTCPUMetric](https://developer.apple.com/documentation/xctest/xctcpumetric)

[React Native Release example](apps/example-react-native/benchmarks) ·
[Android instrumentation and CI invocation](apps/example-react-nitro/benchmarks/README.md)
[Android instrumentation and CI invocation](apps/example-nitro-ui/benchmarks/README.md)

## Development

Expand Down
2 changes: 1 addition & 1 deletion apps/example-expo/app/(tabs)/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
type ExpoRouterLogger,
type ExpoRouterSanitizeContext,
wrapExpoRouter,
} from '@callstack/performance-analytics-react-native';
} from '@callstack/react-native-performance-analytics';

import { Text, View } from '@/components/Themed';

Expand Down
2 changes: 1 addition & 1 deletion apps/example-expo/app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { useEffect } from 'react';
import 'react-native-reanimated';
import {
PerformanceAnalytics,
} from '@callstack/performance-analytics-react-native';
} from '@callstack/react-native-performance-analytics';

import { navigationIntegration } from '@/integrations/navigation';
import { useColorScheme } from '@/components/useColorScheme';
Expand Down
2 changes: 1 addition & 1 deletion apps/example-expo/integrations/navigation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { reactNavigationIntegration } from '@callstack/performance-analytics-react-native';
import { reactNavigationIntegration } from '@callstack/react-native-performance-analytics';

export const navigationIntegration = reactNavigationIntegration({
logger(message, context) {
Expand Down
2 changes: 1 addition & 1 deletion apps/example-expo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"web": "expo start --web"
},
"dependencies": {
"@callstack/performance-analytics-react-native": "workspace:*",
"@callstack/react-native-performance-analytics": "workspace:*",
"@expo/vector-icons": "^15.0.2",
"@react-navigation/native": "^7.1.8",
"expo": "~58.0.23",
Expand Down
2 changes: 1 addition & 1 deletion apps/example-expo/plugins/with-local-analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ project(':performance-analytics-android').projectDir = new File(rootProject.proj
}
mod.modResults.contents = mod.modResults.contents.replace(
/target '([^']+)' do\n/,
"$& pod 'CallstackPerformanceAnalytics', :path => '../node_modules/@callstack/performance-analytics-react-native/apple'\n"
"$& pod 'CallstackPerformanceAnalytics', :path => '../node_modules/@callstack/react-native-performance-analytics/apple'\n"
);
return mod;
});
Expand Down
2 changes: 1 addition & 1 deletion apps/example-expo/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"compilerOptions": {
"strict": true,
"paths": {
"@callstack/performance-analytics-react-native": [
"@callstack/react-native-performance-analytics": [
"../../packages/react-native-sdk/src/index"
],
"@/*": [
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("com.margelo.reactnitro")
id("com.margelo.nitroui")
}

val benchmarkAssets = layout.buildDirectory.dir("benchmark/assets")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import android.os.Process
import android.os.SystemClock
import android.util.Base64
import com.callstack.performanceanalytics.ThreadBenchmark
import com.margelo.reactnitro.runtime.JSRuntime
import com.margelo.nitroui.runtime.JSRuntime
import org.json.JSONObject
import java.security.MessageDigest
import java.util.concurrent.Callable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.INTERNET" />
<application android:label="@string/app_name" android:theme="@style/ReactNitroTheme">
<application android:label="@string/app_name" android:theme="@style/NitroUITheme">
<activity android:name=".MainActivity" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package com.example.perfkitexample

import com.margelo.reactnitro.runtime.NitroActivity
import com.margelo.nitroui.runtime.NitroActivity

class MainActivity : NitroActivity()
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<resources>
<style name="ReactNitroTheme" parent="Theme.Material3.DayNight.NoActionBar">
<style name="NitroUITheme" parent="Theme.Material3.DayNight.NoActionBar">
<item name="android:windowLightStatusBar">false</item>
<item name="android:windowLightNavigationBar">false</item>
</style>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<resources>
<style name="ReactNitroTheme" parent="Theme.Material3.DayNight.NoActionBar">
<style name="NitroUITheme" parent="Theme.Material3.DayNight.NoActionBar">
<item name="android:windowLightStatusBar">true</item>
<item name="android:windowLightNavigationBar">true</item>
</style>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
id("org.jetbrains.kotlin.android") version "2.2.0" apply false
}

// Compile the workspace SDK projects with the same NDK as the React Nitro runtime.
// Compile the workspace SDK projects with the same NDK as the Nitro UI runtime.
subprojects {
plugins.withId("com.android.library") {
extensions.configure<com.android.build.gradle.LibraryExtension> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ val runtimeDirectory = file(runtimePath)
project(":runtime").projectDir = runtimeDirectory
val configDirectory = nitro.getProperty("configDirectory")
gradle.beforeProject {
extensions.extraProperties.set("reactNitroConfigDirectory", configDirectory)
extensions.extraProperties.set("nitroUIConfigDirectory", configDirectory)
}

include(":performance-analytics-core-cpp", ":performance-analytics-android")
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ Android SDK, JDK 17, Python 3 and Bun available:

```sh
corepack yarn install --immutable
cd apps/example-react-nitro
cd apps/example-nitro-ui
bun run prepare:nitro
cd android
./gradlew :app:assembleRelease :app:assembleReleaseAndroidTest -PreactNitroAbis=arm64-v8a -PreactNativeArchitectures=arm64-v8a
./gradlew :app:assembleRelease :app:assembleReleaseAndroidTest -PnitroUIAbis=arm64-v8a -PreactNativeArchitectures=arm64-v8a
adb install -r app/build/outputs/apk/release/app-release.apk
adb install -r app/build/outputs/apk/androidTest/release/app-release-androidTest.apk
adb shell am instrument -w -r -e workerBlocks 32 \
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { mkdir, writeFile } from 'node:fs/promises';
import { join } from 'node:path';
import { bundle } from 'react-nitro-bundler';
import { hermescPath } from 'react-nitro-hermes';
import { bundle } from 'nitro-ui-bundler';
import { hermescPath } from 'nitro-hermes';

const directory = process.argv[2];
await mkdir(directory, { recursive: true });
Expand Down
Loading
Loading