Skip to content

Commit 5c9a6c1

Browse files
committed
docs(react): Add withProfiler docs
1 parent 998a97c commit 5c9a6c1

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed

packages/react/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"dependencies": {
1919
"@sentry/browser": "5.16.0-beta.5",
2020
"@sentry/types": "5.16.0-beta.5",
21+
"@sentry/utils": "^5.15.5",
2122
"tslib": "^1.9.3"
2223
},
2324
"peerDependencies": {

packages/react/src/profiler.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { getCurrentHub } from '@sentry/browser';
22
import { Integration, IntegrationClass } from '@sentry/types';
3+
import { logger } from '@sentry/utils';
34
import * as React from 'react';
45

56
/** The Props Injected by the HOC */
@@ -32,10 +33,16 @@ const getInitActivity = (componentDisplayName: string, timeout = DEFAULT_DURATIO
3233
);
3334
}
3435

36+
logger.warn(`Unable to profile component ${componentDisplayName} due to invalid Tracing Integration`);
3537
return null;
3638
};
3739

38-
// tslint:disable-next-line: variable-name
40+
/**
41+
* withProfiler() is a HOC that leverages the Sentry AM tracing integration to
42+
* send transactions about a React component.
43+
* @param WrappedComponent The component profiled
44+
* @param timeout A maximum timeout for the component render
45+
*/
3946
export const withProfiler = <P extends object>(WrappedComponent: React.ComponentType<P>, timeout?: number) => {
4047
const componentDisplayName = WrappedComponent.displayName || WrappedComponent.name || 'Component';
4148

yarn.lock

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,19 @@
11171117
universal-user-agent "^2.0.0"
11181118
url-template "^2.0.8"
11191119

1120+
1121+
version "5.15.5"
1122+
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-5.15.5.tgz#16c97e464cf09bbd1d2e8ce90d130e781709076e"
1123+
integrity sha512-F9A5W7ucgQLJUG4LXw1ZIy4iLevrYZzbeZ7GJ09aMlmXH9PqGThm1t5LSZlVpZvUfQ2rYA8NU6BdKJSt7B5LPw==
1124+
1125+
"@sentry/utils@^5.15.5":
1126+
version "5.15.5"
1127+
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-5.15.5.tgz#dec1d4c79037c4da08b386f5d34409234dcbfb15"
1128+
integrity sha512-Nl9gl/MGnzSkuKeo3QaefoD/OJrFLB8HmwQ7HUbTXb6E7yyEzNKAQMHXGkwNAjbdYyYbd42iABP6Y5F/h39NtA==
1129+
dependencies:
1130+
"@sentry/types" "5.15.5"
1131+
tslib "^1.9.3"
1132+
11201133
"@sinonjs/commons@^1", "@sinonjs/commons@^1.4.0":
11211134
version "1.4.0"
11221135
resolved "https://registry.yarnpkg.com/@sinonjs/commons/-/commons-1.4.0.tgz#7b3ec2d96af481d7a0321252e7b1c94724ec5a78"

0 commit comments

Comments
 (0)