Skip to content
Merged
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
48 changes: 14 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ Real-time device performance monitoring and telemetry for React Native. Collect
### Android

- **minSdkVersion**: 24
- **compileSdkVersion**: 35+

This library depends on a native Android SDK published to **Maven Central**. No additional repository configuration is needed.
- **compileSdkVersion**: 35+

---

Expand All @@ -48,29 +46,13 @@ npm install @lokal-dev/react-native-device-metrics
yarn add @lokal-dev/react-native-device-metrics
```

Linking is automatic. The native Android dependency resolves from **Maven Central** — no additional repository configuration needed.

### React Native CLI

No additional setup required.

### Expo

Add the config plugin in `app.json`:

```json
{
"expo": {
"plugins": ["@lokal-dev/react-native-device-metrics"]
}
}
```

Then create a **development build** (Expo Go is not supported):

```bash
npx expo run:android
```
No additional setup required. Expo Go is not supported — use a development build.

---

Expand Down Expand Up @@ -260,10 +242,6 @@ await DeviceMetrics.init(customThresholds);

## Troubleshooting

### Build

- **AGP / Kotlin version errors** — Align Android Gradle Plugin and Kotlin versions with React Native 0.73+ (e.g. Kotlin 1.8.0+).

### Runtime

- **`Cannot read property 'init' of undefined`** — Clean build and Metro cache:
Expand All @@ -278,22 +256,24 @@ await DeviceMetrics.init(customThresholds);

## Publishing

### Manual release
Publishing is automated via GitHub Actions. The `publish.yml` workflow triggers on any `v*` tag push, runs validation, and publishes to npm with provenance attestation.

### Stable release

```bash
git checkout main && git pull origin main
yarn release # select the next stable version e.g. 1.0.1
```

1. Ensure you're logged in to npm: `npm login`
2. Commit all changes, clean working tree.
3. Build: `yarn prepare`
4. Bump: `npm version patch` (or `minor` / `major`)
5. Publish: `npm publish --access public`
6. Push: `git push && git push --tags`
release-it bumps `package.json`, generates `CHANGELOG.md`, commits, tags `v1.0.1`, and pushes. The tag push triggers the publish pipeline which publishes under the `latest` dist-tag.

### Automated (release-it)
### Beta / pre-release

```bash
yarn release
yarn release --preRelease=beta # produces 1.0.1-beta.0, 1.0.1-beta.1, etc.
```

This bumps version, tags, publishes to npm, and can create a GitHub release (if configured).
Published under the `beta` dist-tag — `latest` is not affected.

---

Expand Down
70 changes: 3 additions & 67 deletions app.plugin.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,5 @@
const {
withProjectBuildGradle,
createRunOncePlugin,
} = require('@expo/config-plugins');
const { createRunOncePlugin } = require('@expo/config-plugins');
const pkg = require('./package.json');

const MAVEN_REPO_BLOCK = `
maven {
url = uri("https://maven.pkg.github.com/lokal-app/device-telemetry-toolkit")
credentials {
username = System.getenv("GITHUB_USERNAME") ?: "lokal-app"
password = System.getenv("GITHUB_TOKEN") ?: ""
}
}`;

const ALLPROJECTS_BLOCK = `
allprojects {
repositories {${MAVEN_REPO_BLOCK}
}
}
`;

function addDeviceTelemetryGithubPackageRepo(config) {
return withProjectBuildGradle(config, (gradleConfig) => {
const { contents } = gradleConfig.modResults;

if (
contents.includes(
'maven.pkg.github.com/lokal-app/device-telemetry-toolkit'
)
) {
return gradleConfig;
}

const allprojectsMatch = contents.match(/\ballprojects\s*\{/);

if (allprojectsMatch) {
const blockStart = allprojectsMatch.index + allprojectsMatch[0].length;
const repoMatch = contents
.slice(blockStart)
.match(/^\s*repositories\s*\{/);

if (repoMatch) {
const repoOpenBraceIndex =
blockStart + repoMatch.index + repoMatch[0].length - 1;
gradleConfig.modResults.contents =
contents.slice(0, repoOpenBraceIndex + 1) +
MAVEN_REPO_BLOCK +
contents.slice(repoOpenBraceIndex + 1);
} else {
const repoBlock = `\n repositories {${MAVEN_REPO_BLOCK}\n }`;
gradleConfig.modResults.contents =
contents.slice(0, blockStart) +
repoBlock +
contents.slice(blockStart);
}
} else {
gradleConfig.modResults.contents = contents + '\n' + ALLPROJECTS_BLOCK;
}

return gradleConfig;
});
}

module.exports = createRunOncePlugin(
addDeviceTelemetryGithubPackageRepo,
pkg.name,
pkg.version
);
// Placeholder for future Expo config plugin functionality.
module.exports = createRunOncePlugin((config) => config, pkg.name, pkg.version);
Loading