Skip to content

Make expo-crypto an optional dependency - #292

Merged
jaredmixpanel merged 1 commit into
masterfrom
jared-expo-crypto-optional
Jun 2, 2025
Merged

Make expo-crypto an optional dependency#292
jaredmixpanel merged 1 commit into
masterfrom
jared-expo-crypto-optional

Conversation

@jaredmixpanel

Copy link
Copy Markdown
Collaborator

Fix for #291

@jaredmixpanel
jaredmixpanel requested review from Copilot and micaww June 2, 2025 16:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR makes the expo-crypto dependency optional to address issue #291 by shifting its management in package.json and adjusting the device ID generation logic accordingly.

  • Moves expo-crypto from mandatory to optionalDependencies in package.json.
  • Modifies mixpanel-persistent.js to dynamically require expo-crypto with a fallback to uuid.v4() when generating a device ID.
  • Removes .vscode/settings.json.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
package.json Moves expo-crypto into the optionalDependencies block.
javascript/mixpanel-persistent.js Changes device ID generation to use expo-crypto if available, with fallback.
.vscode/settings.json Removes VSCode settings; confirm if this is an intentional cleanup.
Comment thread javascript/mixpanel-persistent.js
@jaredmixpanel jaredmixpanel changed the title Make expo-crypto optional Jun 2, 2025

@micaww micaww left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

looks great thanks!

@jaredmixpanel
jaredmixpanel merged commit d127a85 into master Jun 2, 2025
@jaredmixpanel jaredmixpanel added the bug Something isn't working label Jun 2, 2025
@sseppola

sseppola commented Jun 4, 2025

Copy link
Copy Markdown

Leaving this here in case this helps anyone else.

On react-native 0.76 and expo 52 I got the following error, solved by downgrading to mixpanel-react-native@3.0.9 to avoid the expo-crypto module.

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file '/path/to/project/node_modules/expo-crypto/android/build.gradle' line: 3

* What went wrong:
Plugin [id: 'expo-module-gradle-plugin'] was not found in any of the following sources:

- Gradle Core Plugins (not a core plugin. For more available plugins, please refer to https://docs.gradle.org/8.10.2/userguide/plugin_reference.html in the Gradle documentation.)
- Included Builds (No included builds contain this plugin)
- Plugin Repositories (plugin dependency must include a version number for this source)

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
==============================================================================

2: Task failed with an exception.
-----------
* Where:
Script '/path/to/project/node_modules/expo-modules-core/android/ExpoModulesCorePlugin.gradle' line: 95

* What went wrong:
A problem occurred configuring project ':expo'.
> Could not get unknown property 'release' for SoftwareComponent container of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.
@jaredmixpanel

Copy link
Copy Markdown
Collaborator Author

@sseppola v3.1.2 is released which removes expo-crypto and adds react-native-get-random-values which should fix the original problem in Expo apps without creating a dependency on any Expo modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

4 participants