Skip to content

Commit 449a803

Browse files
committed
Merge branch 'antonis/3859-newCaptureFeedbackAPI-Form' into antonis/3859-newCaptureFeedbackAPI-Form-logo
2 parents 727a423 + 0588552 commit 449a803

File tree

12 files changed

+152
-134
lines changed

12 files changed

+152
-134
lines changed

.github/workflows/codeql-analysis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444

4545
# Initializes the CodeQL tools for scanning.
4646
- name: Initialize CodeQL
47-
uses: github/codeql-action/init@aa578102511db1f4524ed59b8cc2bae4f6e88195 # [email protected].6
47+
uses: github/codeql-action/init@df409f7d9260372bd5f19e5b04e83cb3c43714ae # [email protected].9
4848
with:
4949
languages: ${{ matrix.language }}
5050
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -55,7 +55,7 @@ jobs:
5555
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
5656
# If this step fails, then you should remove it and run the build manually (see below)
5757
- name: Autobuild
58-
uses: github/codeql-action/autobuild@aa578102511db1f4524ed59b8cc2bae4f6e88195 # [email protected].6
58+
uses: github/codeql-action/autobuild@df409f7d9260372bd5f19e5b04e83cb3c43714ae # [email protected].9
5959

6060
# ℹ️ Command-line programs to run using the OS shell.
6161
# 📚 https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions
@@ -66,4 +66,4 @@ jobs:
6666
# make bootstrap
6767
# make release
6868
- name: Perform CodeQL Analysis
69-
uses: github/codeql-action/analyze@aa578102511db1f4524ed59b8cc2bae4f6e88195 # [email protected].6
69+
uses: github/codeql-action/analyze@df409f7d9260372bd5f19e5b04e83cb3c43714ae # [email protected].9

CHANGELOG.md

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,14 @@
2222
2323
message: "Hello World!",
2424
associatedEventId: eventId, // optional
25-
}, {
26-
captureContext: {
27-
tags: { "tag-key": "tag-value" },
28-
},
29-
attachments: [
30-
{
31-
filename: 'hello.txt',
32-
data: 'Hello, World!',
33-
},
34-
],
3525
});
3626
```
3727

38-
- User Feedback From Component Beta ([#4320](https://github.com/getsentry/sentry-react-native/pull/4328))
28+
To learn how to attach context data to the feedback visit [the documentation](https://docs.sentry.io/platforms/react-native/user-feedback/).
29+
30+
- User Feedback Form Component Beta ([#4320](https://github.com/getsentry/sentry-react-native/pull/4328))
3931

40-
To collect user feedback from inside your application add the `FeedbackFrom` component.
32+
To collect user feedback from inside your application add the `FeedbackForm` component.
4133

4234
```jsx
4335
import { FeedbackForm } from "@sentry/react-native";
@@ -46,6 +38,7 @@
4638
```
4739

4840
- Export `Span` type from `@sentry/types` ([#4345](https://github.com/getsentry/sentry-react-native/pull/4345))
41+
- Add RN SDK package to `sdk.packages` on Android ([#4380](https://github.com/getsentry/sentry-react-native/pull/4380))
4942

5043
### Fixes
5144

@@ -66,9 +59,9 @@
6659
- Bump Android SDK from v7.18.0 to v7.19.0 ([#4329](https://github.com/getsentry/sentry-react-native/pull/4329), [#4365](https://github.com/getsentry/sentry-react-native/pull/4365))
6760
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#7190)
6861
- [diff](https://github.com/getsentry/sentry-java/compare/7.18.0...7.19.0)
69-
- Bump JavaScript SDK from v8.40.0 to v8.44.0 ([#4351](https://github.com/getsentry/sentry-react-native/pull/4351), [#4325](https://github.com/getsentry/sentry-react-native/pull/4325))
70-
- [changelog](https://github.com/getsentry/sentry-javascript/blob/develop/CHANGELOG.md#8440)
71-
- [diff](https://github.com/getsentry/sentry-javascript/compare/8.40.0...8.44.0)
62+
- Bump JavaScript SDK from v8.40.0 to v8.45.1 ([#4351](https://github.com/getsentry/sentry-react-native/pull/4351), [#4325](https://github.com/getsentry/sentry-react-native/pull/4325), [#4371](https://github.com/getsentry/sentry-react-native/pull/4371), [#4382](https://github.com/getsentry/sentry-react-native/pull/4382))
63+
- [changelog](https://github.com/getsentry/sentry-javascript/blob/develop/CHANGELOG.md#8451)
64+
- [diff](https://github.com/getsentry/sentry-javascript/compare/8.40.0...8.45.1)
7265

7366
## 6.4.0
7467

dev-packages/e2e-tests/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"devDependencies": {
1414
"@babel/preset-env": "^7.25.3",
1515
"@babel/preset-typescript": "^7.18.6",
16-
"@sentry/core": "8.44.0",
16+
"@sentry/core": "8.45.1",
1717
"@sentry/react-native": "6.4.0",
1818
"@types/node": "^20.9.3",
1919
"@types/react": "^18.2.64",

packages/core/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ public class RNSentryModuleImpl {
9393

9494
public static final String NAME = "RNSentry";
9595

96-
private static final String NATIVE_SDK_NAME = "sentry.native.android.react-native";
97-
private static final String ANDROID_SDK_NAME = "sentry.java.android.react-native";
9896
private static final ILogger logger = new AndroidLogger(NAME);
9997
private static final BuildInfoProvider buildInfo = new BuildInfoProvider(logger);
10098
private static final String modulesPath = "modules.json";
@@ -191,13 +189,16 @@ protected void getSentryAndroidOptions(
191189
@NotNull SentryAndroidOptions options, @NotNull ReadableMap rnOptions, ILogger logger) {
192190
@Nullable SdkVersion sdkVersion = options.getSdkVersion();
193191
if (sdkVersion == null) {
194-
sdkVersion = new SdkVersion(ANDROID_SDK_NAME, BuildConfig.VERSION_NAME);
192+
sdkVersion = new SdkVersion(RNSentryVersion.ANDROID_SDK_NAME, BuildConfig.VERSION_NAME);
195193
} else {
196-
sdkVersion.setName(ANDROID_SDK_NAME);
194+
sdkVersion.setName(RNSentryVersion.ANDROID_SDK_NAME);
197195
}
196+
sdkVersion.addPackage(
197+
RNSentryVersion.REACT_NATIVE_SDK_PACKAGE_NAME,
198+
RNSentryVersion.REACT_NATIVE_SDK_PACKAGE_VERSION);
198199

199200
options.setSentryClientName(sdkVersion.getName() + "/" + sdkVersion.getVersion());
200-
options.setNativeSdkName(NATIVE_SDK_NAME);
201+
options.setNativeSdkName(RNSentryVersion.NATIVE_SDK_NAME);
201202
options.setSdkVersion(sdkVersion);
202203

203204
if (rnOptions.hasKey("debug") && rnOptions.getBoolean("debug")) {
@@ -970,10 +971,10 @@ private void setEventOriginTag(SentryEvent event) {
970971
SdkVersion sdk = event.getSdk();
971972
if (sdk != null) {
972973
switch (sdk.getName()) {
973-
case NATIVE_SDK_NAME:
974+
case RNSentryVersion.NATIVE_SDK_NAME:
974975
setEventEnvironmentTag(event, "native");
975976
break;
976-
case ANDROID_SDK_NAME:
977+
case RNSentryVersion.ANDROID_SDK_NAME:
977978
setEventEnvironmentTag(event, "java");
978979
break;
979980
default:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package io.sentry.react;
2+
3+
class RNSentryVersion {
4+
static final String REACT_NATIVE_SDK_PACKAGE_NAME = "npm:@sentry/react-native";
5+
static final String REACT_NATIVE_SDK_PACKAGE_VERSION = "6.4.0";
6+
static final String NATIVE_SDK_NAME = "sentry.native.android.react-native";
7+
static final String ANDROID_SDK_NAME = "sentry.java.android.react-native";
8+
}

packages/core/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,21 @@
6666
},
6767
"dependencies": {
6868
"@sentry/babel-plugin-component-annotate": "2.20.1",
69-
"@sentry/browser": "8.44.0",
69+
"@sentry/browser": "8.45.1",
7070
"@sentry/cli": "2.39.1",
71-
"@sentry/core": "8.44.0",
72-
"@sentry/react": "8.44.0",
73-
"@sentry/types": "8.44.0",
74-
"@sentry/utils": "8.44.0"
71+
"@sentry/core": "8.45.1",
72+
"@sentry/react": "8.45.1",
73+
"@sentry/types": "8.45.1",
74+
"@sentry/utils": "8.45.1"
7575
},
7676
"devDependencies": {
7777
"@babel/core": "^7.25.2",
7878
"@expo/metro-config": "0.19.5",
7979
"@mswjs/interceptors": "^0.25.15",
8080
"@react-native/babel-preset": "0.76.3",
81-
"@sentry-internal/eslint-config-sdk": "8.44.0",
82-
"@sentry-internal/eslint-plugin-sdk": "8.44.0",
83-
"@sentry-internal/typescript": "8.44.0",
81+
"@sentry-internal/eslint-config-sdk": "8.45.1",
82+
"@sentry-internal/eslint-plugin-sdk": "8.45.1",
83+
"@sentry-internal/typescript": "8.45.1",
8484
"@sentry/wizard": "3.36.0",
8585
"@testing-library/react-native": "^12.7.2",
8686
"@types/jest": "^29.5.3",

packages/core/src/js/feedback/FeedbackForm.styles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { FeedbackFormStyles } from './FeedbackForm.types';
22

33
const PURPLE = 'rgba(88, 74, 192, 1)';
44
const FORGROUND_COLOR = '#2b2233';
5-
const BACKROUND_COLOR = '#fff';
5+
const BACKROUND_COLOR = '#ffffff';
66
const BORDER_COLOR = 'rgba(41, 35, 47, 0.13)';
77

88
const defaultStyles: FeedbackFormStyles = {

packages/core/src/js/feedback/FeedbackForm.tsx

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import type { SendFeedbackParams } from '@sentry/core';
12
import { captureFeedback, getCurrentScope, lastEventId } from '@sentry/core';
2-
import type { SendFeedbackParams } from '@sentry/types';
33
import * as React from 'react';
44
import type { KeyboardTypeOptions } from 'react-native';
55
import {
@@ -26,42 +26,43 @@ import type { FeedbackFormProps, FeedbackFormState, FeedbackFormStyles,FeedbackG
2626
* Implements a feedback form screen that sends feedback to Sentry using Sentry.captureFeedback.
2727
*/
2828
export class FeedbackForm extends React.Component<FeedbackFormProps, FeedbackFormState> {
29-
private _config: FeedbackFormProps;
29+
public static defaultProps: Partial<FeedbackFormProps> = {
30+
...defaultConfiguration
31+
}
3032

3133
public constructor(props: FeedbackFormProps) {
3234
super(props);
3335

3436
const currentUser = {
3537
useSentryUser: {
36-
email: getCurrentScope().getUser().email || '',
37-
name: getCurrentScope().getUser().name || '',
38+
email: this.props?.useSentryUser?.email || getCurrentScope()?.getUser()?.email || '',
39+
name: this.props?.useSentryUser?.name || getCurrentScope()?.getUser()?.name || '',
3840
}
3941
}
4042

41-
this._config = { ...defaultConfiguration, ...currentUser, ...props };
4243
this.state = {
4344
isVisible: true,
44-
name: this._config.useSentryUser.name,
45-
email: this._config.useSentryUser.email,
45+
name: currentUser.useSentryUser.name,
46+
email: currentUser.useSentryUser.email,
4647
description: '',
4748
};
4849
}
4950

5051
public handleFeedbackSubmit: () => void = () => {
5152
const { name, email, description } = this.state;
52-
const { onFormClose } = this._config;
53-
const text: FeedbackTextConfiguration = this._config;
53+
const { onFormClose } = this.props;
54+
const text: FeedbackTextConfiguration = this.props;
5455

5556
const trimmedName = name?.trim();
5657
const trimmedEmail = email?.trim();
5758
const trimmedDescription = description?.trim();
5859

59-
if ((this._config.isNameRequired && !trimmedName) || (this._config.isEmailRequired && !trimmedEmail) || !trimmedDescription) {
60+
if ((this.props.isNameRequired && !trimmedName) || (this.props.isEmailRequired && !trimmedEmail) || !trimmedDescription) {
6061
Alert.alert(text.errorTitle, text.formError);
6162
return;
6263
}
6364

64-
if (this._config.shouldValidateEmail && (this._config.isEmailRequired || trimmedEmail.length > 0) && !this._isValidEmail(trimmedEmail)) {
65+
if (this.props.shouldValidateEmail && (this.props.isEmailRequired || trimmedEmail.length > 0) && !this._isValidEmail(trimmedEmail)) {
6566
Alert.alert(text.errorTitle, text.emailError);
6667
return;
6768
}
@@ -86,9 +87,9 @@ export class FeedbackForm extends React.Component<FeedbackFormProps, FeedbackFor
8687
*/
8788
public render(): React.ReactNode {
8889
const { name, email, description } = this.state;
89-
const { onFormClose } = this._config;
90-
const config: FeedbackGeneralConfiguration = this._config;
91-
const text: FeedbackTextConfiguration = this._config;
90+
const { onFormClose } = this.props;
91+
const config: FeedbackGeneralConfiguration = this.props;
92+
const text: FeedbackTextConfiguration = this.props;
9293
const styles: FeedbackFormStyles = { ...defaultStyles, ...this.props.styles };
9394
const onCancel = (): void => {
9495
onFormClose();

packages/core/test/feedback/FeedbackForm.test.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ import { FeedbackForm } from '../../src/js/feedback/FeedbackForm';
77
import type { FeedbackFormProps } from '../../src/js/feedback/FeedbackForm.types';
88

99
const mockOnFormClose = jest.fn();
10+
const mockGetUser = jest.fn(() => ({
11+
12+
name: 'Test User',
13+
}));
1014

1115
jest.spyOn(Alert, 'alert');
1216

1317
jest.mock('@sentry/core', () => ({
1418
captureFeedback: jest.fn(),
1519
getCurrentScope: jest.fn(() => ({
16-
getUser: jest.fn(() => ({
17-
18-
name: 'Test User',
19-
})),
20+
getUser: mockGetUser,
2021
})),
2122
lastEventId: jest.fn(),
2223
}));
@@ -75,6 +76,17 @@ describe('FeedbackForm', () => {
7576
expect(emailInput.props.value).toBe('[email protected]');
7677
});
7778

79+
it('ensure getUser is called only after the component is rendered', () => {
80+
// Ensure getUser is not called before render
81+
expect(mockGetUser).not.toHaveBeenCalled();
82+
83+
// Render the component
84+
render(<FeedbackForm />);
85+
86+
// After rendering, check that getUser was called twice (email and name)
87+
expect(mockGetUser).toHaveBeenCalledTimes(2);
88+
});
89+
7890
it('shows an error message if required fields are empty', async () => {
7991
const { getByText } = render(<FeedbackForm {...defaultProps} />);
8092

samples/react-native-macos/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
"@react-navigation/bottom-tabs": "^6.5.12",
1717
"@react-navigation/native": "^6.1.9",
1818
"@react-navigation/stack": "^6.3.20",
19-
"@sentry/core": "8.44.0",
20-
"@sentry/react": "8.44.0",
19+
"@sentry/core": "8.45.1",
20+
"@sentry/react": "8.45.1",
2121
"@sentry/react-native": "6.4.0",
22-
"@sentry/types": "8.44.0",
22+
"@sentry/types": "8.45.1",
2323
"delay": "^6.0.0",
2424
"react": "18.2.0",
2525
"react-native": "0.73.9",

scripts/version-bump.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ const replace = require('replace-in-file');
44
const pjson = require('../packages/core/package.json');
55

66
replace({
7-
files: ['packages/core/src/js/version.ts'],
7+
files: [
8+
'packages/core/src/js/version.ts',
9+
'packages/core/android/src/main/java/io/sentry/react/RNSentryVersion.java',
10+
],
811
from: /\d+\.\d+.\d+(?:-\w+(?:\.\w+)?)?/g,
912
to: pjson.version,
1013
})

0 commit comments

Comments
 (0)