Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] WithAITracking cannot wrap around functional components #1274

Closed
Ishraque99 opened this issue May 28, 2020 · 2 comments · Fixed by #1275
Closed

[BUG] WithAITracking cannot wrap around functional components #1274

Ishraque99 opened this issue May 28, 2020 · 2 comments · Fixed by #1275
Labels
Milestone

Comments

@Ishraque99
Copy link
Contributor

Ishraque99 commented May 28, 2020

Description/Screenshot
image
Functional components (ala ES6) have undefined prototype and no constructor name. While we can provide a name parameter to WithAITracking I don't think it makes sense as these components are meant to be anonymous/nameless.

Steps to Reproduce

  • create a functional component as such and wrap it withAITracking()
const Test = (props: Props) => {
    return (<div>
        <p>This is a test component</p>
    </div>);
}
...
export default withAITracking(reactPlugin, Test)
  • OS/Browser: Ubuntu 20.04/Firefox
  • applicationinsights-react-js version: ^2.5.4
  • How you initialized the SDK: following the basic usage guideline in the README for applicationinsights-react-js

Expected behavior
Component should load as normal

Possible fix
Edit: Added PR #1275 :)
I think it's a simple fix. Update WithAITracking as such.

  if (componentName === undefined || componentName === null || typeof componentName !== 'string') {
    componentName = Component.prototype && 
          Component.prototype.constructor && 
          Component.prototype.constructor.name ||
          'Anonymous component';
  }

instead of "Anonymous component" it could also be an empty string, just like the default for className.

@MSNev MSNev added fixed - waiting release PR Committed and waiting deployment bug labels May 29, 2020
@MSNev MSNev added this to the 2.5.5 milestone Jun 2, 2020
@MSNev MSNev linked a pull request Jun 2, 2020 that will close this issue
@MSNev MSNev removed the fixed - waiting release PR Committed and waiting deployment label Jun 4, 2020
@MSNev
Copy link
Collaborator

MSNev commented Jun 4, 2020

Included in v 2.5.5 which is now fully deployed

@MSNev MSNev closed this as completed Jun 4, 2020
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants