Skip to content

[#149390457] Add support for source maps in Error Analytics - #33

Merged
cloudify merged 5 commits into
masterfrom
149390457-source-maps
Aug 9, 2017
Merged

[#149390457] Add support for source maps in Error Analytics#33
cloudify merged 5 commits into
masterfrom
149390457-source-maps

Conversation

@gesposito

@gesposito gesposito commented Jul 30, 2017

Copy link
Copy Markdown
Contributor

Adds

  • react-native-device-info, in order to retrieve the readable app version (${package.version}.${build.version} i.e. 0.1.22)

  • react-native-fs needed by react-native-source-maps

  • a custom script to patch node_modules/react-native/scripts/react-native-xcode.sh in order to append --sourcemap-output "$BUNDLE_FILE.map for source map generation

  • customized version of react-native-source-maps that will create a readable stack trace from source maps

Upgrades

  • react-native to 0.46.4 in order to improve the app's build

Demo

screen shot 2017-07-30 at 21 19 13

Comment thread add-ios-source-maps.sh Outdated
@@ -0,0 +1,16 @@
#!/bin/bash

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.

Does the script needs bash, can it run with sh?

Also, better to move it under a bin directory to avoid polluting the project root

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread add-ios-source-maps.sh Outdated
@@ -0,0 +1,16 @@
#!/bin/bash

script=./node_modules/react-native/scripts/react-native-xcode.sh

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.

please add a comment describing what this script does and how to use it

Comment thread add-ios-source-maps.sh Outdated
@@ -0,0 +1,16 @@
#!/bin/bash

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.

need set -eo pipefail, also see here

Comment thread add-ios-source-maps.sh Outdated
@@ -0,0 +1,16 @@
#!/bin/bash

script=./node_modules/react-native/scripts/react-native-xcode.sh

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.

is there a variable name more descriptive than script ? :)

Comment thread add-ios-source-maps.sh Outdated
#!/bin/bash

script=./node_modules/react-native/scripts/react-native-xcode.sh
backup=./node_modules/react-native/scripts/react-native-xcode.back.sh

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.

not sure if you should backup into node_modules, that directory is supposed to be transient

another option could be to backup into project root and have that file in .gitignore ?

@gesposito gesposito Jul 31, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I gave this more than one thought, having our own version of the script /node_modules/react-native/scripts/react-native-xcode.sh would require a customization of our native projects, possibly causing errors in migrations, it might also soon end up being up out of sync with the repo, resulting in wrong builds or errors in builds without us not even knowing why.

The current patch script at bin/add-ios-source-maps.sh is ran as npm postinstall script. On each new install of the node_modules the patch is meant to be executed again.

Comment thread add-ios-source-maps.sh Outdated
# append ` --sourcemap-output "$BUNDLE_FILE.map"` to the `bundle` after `--bundle-output "$BUNDLE_FILE" \`
replace=$(awk '1;/bundle-output /{ print " --sourcemap-output \"$BUNDLE_FILE.map\" \\"}' "$script")
echo "$replace" > "$script"

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.

you should print something in the else, like "backup file already exist, skipping backup"

Comment thread js/react-native-source-maps/index.js Outdated
/*
Imported from
https://github.com/philipshurpik/react-native-source-maps/blob/master/index.js
due to dependecies' errors

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.

what happened?

@gesposito gesposito Jul 31, 2017

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The native dependency react-native-fs was throwing some errors on invocations when installed from the original npm module. This could be due to a API breaking version.

Also I ended up customizing the source code in order to allow Android support.
https://github.com/teamdigitale/ItaliaApp/pull/33/files/5cf0f6cb242961f26d249ad2909912ff9e7934b3#diff-7652556149ff20e100d57fa7df5beadfR60

We could send a PR or fork the repo/module once we're positive about the solution. Right now the original committer is not responsive
philipshurpik/react-native-source-maps#2

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.

ok, thanks, please add this explanation to the comment above, for future reference

`
We have reported this to our team! Please close the app and start again!
`
'We have reported this to our team! Please close the app and start again!'

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.

can you please create a story on Pivotal for translating this string?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@cloudify

Copy link
Copy Markdown
Contributor

How is the upgrade of react handled? do I need to run something after git pull?

@gesposito

Copy link
Copy Markdown
Contributor Author

This is a minor upgrade (from 0.46.1 to 0.46.4) so we don't need to run any migration.

$ rm -rf node_modules/
$ yarn install

should do the job.

@@ -0,0 +1,23 @@
#!/bin/bash

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.

Need a comment on what this script purpose is, e.g: This script configures... It gets executed by ... after ...

Comment thread js/react-native-source-maps/index.js Outdated
/*
Imported from
https://github.com/philipshurpik/react-native-source-maps/blob/master/index.js
due to dependecies' errors

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.

ok, thanks, please add this explanation to the comment above, for future reference

@cloudify cloudify 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.

LGTM

@cloudify
cloudify merged commit 9da158b into master Aug 9, 2017
@cloudify
cloudify deleted the 149390457-source-maps branch August 9, 2017 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants