How to setup Sentry-cli source maps with react-native - react-native

Introduction
Hi, I'm trying to get Sentry to recognise our sourcemaps in a react-native project, but I can't get it working.
The artifacts are uploading - I can see them in the WebUI, but the events lack context/mapping:
Question
Can anyone see any problems in my setup?
Thanks!
 Background
Assumptions
uploading release artifacts, then deleting artifacts from web ui, then re-uploading new artifacts is valid
"abs_path": "app:///index.bundle", requires the bundled js needs to be renamed to index.bundle
That fact that all events have a processing error: Discarded invalid parameter 'dist' should not effect sourcemaps
Once everything lines up, all my historical events for the release will benefit from the uploaded files/sourcemaps
Xcode build phase
During the XCode build phase we already bundle the DSym.
In this script, I'm trying to pull out the bundled js and sourcemap, and uploading it.
Script
#!/bin/bash
# WARNING: Run directly from Xcode
# For testing of Xcode bundling/sentry locally, set to "true"
DEBUG_FORCE_BUNDLING="true"
printf "Xcode: Bundle react-native and upload to Sentry"
source ../scripts/xcode/utils/node_activate.sh
# Create bundle and sourcemap
export NODE_BINARY=node
export SENTRY_PROPERTIES=sentry.properties
DEST=$CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH
export EXTRA_PACKAGER_ARGS="--sourcemap-output $DEST/main.bundle.map.js";
if [ "${CONFIGURATION}" = "Release" ]; then
FORCE_BUNDLING="$DEBUG_FORCE_BUNDLING" \
../node_modules/#sentry/cli/sentry-cli react-native xcode \
../node_modules/react-native/scripts/react-native-xcode.sh
else
FORCE_BUNDLING="$DEBUG_FORCE_BUNDLING" \
../node_modules/#sentry/cli/sentry-cli react-native xcode \
../node_modules/react-native/scripts/react-native-xcode.sh
fi
# Copy bundle & sourcemap
mkdir -p ../.xcodebuild
cp $DEST/main.jsbundle ../.xcodebuild/index.bundle # rename?
cp $DEST/main.bundle.map.js ../.xcodebuild
echo "Size of file $(wc -c ../.xcodebuild/index.bundle)" # RENAME!?
echo "Size of sourcemap $(wc -c ../.xcodebuild/main.bundle.map.js)"
# Upload sentry release
# https://docs.sentry.io/cli/releases/#creating-releases
APP_IDENTIFIER="com.mycompany.app"
VERSION="1.4.21"
RELEASE_NAME="$APP_IDENTIFIER-$VERSION"
DISTRIBUTION_NAME="2400"
function sentry_release {
npx sentry-cli releases \
files $RELEASE_NAME \
$1 $2 $3
--dist $DISTRIBUTION_NAME \
--strip-prefix ".build" \
--ignore node_modules \
--rewrite "$(pwd)"
}
sentry_release upload ../.xcodebuild/index.bundle '~/index.bundle'
echo "sentry_release upload"
sentry_release upload-sourcemaps ../.xcodebuild/main.bundle.map.js
echo "sentry_release upload-sourcemaps"
echo `date`
echo "DONE"
Note: The important bit of node_modules/react-native/scripts/react-native-xcode.sh is:
BUNDLE_FILE="$DEST/main.jsbundle"
echo "BUNDLE_FILE: $BUNDLE_FILE" > ~/bh/react-native-native/bundle.log
"$NODE_BINARY" $NODE_ARGS "$CLI_PATH" $BUNDLE_COMMAND \
$CONFIG_ARG \
--entry-file "$ENTRY_FILE" \
--platform ios \
--dev $DEV \
--reset-cache \
--bundle-output "$BUNDLE_FILE" \
--assets-dest "$DEST" \
$EXTRA_PACKAGER_ARGS
Script output
Xcode: Upload Debug Symbols to SentryNow using node v11.11.0 (npm v6.7.0)
FORCE_BUNDLING enabled; continuing to bundle.
warning: the transform cache was reset.
Loading dependency graph, done.
info Writing bundle output to:, /Users/me/Library/Developer/Xcode/DerivedData/TheApp-cvfhlrosjrphnjdcngyqxnlmjjbb/Build/Products/Debug-iphonesimulator/TheApp.app/main.jsbundle
info Writing sourcemap output to:, /Users/me/Library/Developer/Xcode/DerivedData/TheApp-cvfhlrosjrphnjdcngyqxnlmjjbb/Build/Products/Debug-iphonesimulator/TheApp.app/main.bundle.map.js
info Done writing bundle output
info Done writing sourcemap output
info Copying 109 asset files
info Done copying assets
Size of file 8477623 ../.xcodebuild/index.bundle
Size of sourcemap 15378754 ../.xcodebuild/main.bundle.map.js
A 560eaee15f0c1ccb5a57b68b5dc1b4944cff84d2 (8477623 bytes)
sentry_release upload
> Analyzing 1 sources
> Adding source map references
> Uploading source maps for release com.mycompany.app-1.4.21
Source Map Upload Report
Source Maps
~/main.bundle.map.js
sentry_release upload-sourcemaps
Fri May 3 15:50:26 BST 2019
DONE
Sentry event JSON
Trimmed some breadcrumbs/callstack:
// 20190503154011
// https://sentry.mycompany.com/mycompany/react-native-app/issues/4205/events/396945/json/
{
"id": "1c754ed7d651445eb48ed79c995073e2",
"project": 11,
"release": "com.mycompany.app-1.4.21",
"platform": "cocoa",
"culprit": "crash(app:///index.bundle)",
"message": "Error Sentry: TEST crash crash(app:///index.bundle)",
"datetime": "2019-05-03T14:32:25.000000Z",
"time_spent": null,
"tags": [
[
"logger",
"javascript"
],
[
"sentry:user",
"id:b5f212b4-9112-4253-86cc-11583ac1945a"
],
[
"sentry:release",
"com.mycompany.app-1.4.21"
],
[
"level",
"fatal"
],
[
"device",
"iPhone9,1"
],
[
"device.family",
"iOS"
],
[
"os",
"iOS 12.1"
],
[
"os.name",
"iOS"
],
[
"os.rooted",
"no"
]
],
"contexts": {
"device": {
"model_id": "simulator",
"family": "iOS",
"simulator": true,
"type": "device",
"storage_size": 499963170816,
"free_memory": 274915328,
"memory_size": 17179869184,
"boot_time": "2019-04-29T07:53:06Z",
"timezone": "GMT+1",
"model": "iPhone9,1",
"usable_memory": 16463810560,
"arch": "x86"
},
"app": {
"app_version": "1.4.21",
"app_name": "MyApp",
"device_app_hash": "<device_app_hash>",
"app_id": "<app_id>",
"app_build": "2400",
"app_start_time": "2019-05-03T14:31:33Z",
"app_identifier": "com.mycompany.app",
"type": "default",
"build_type": "simulator"
},
"os": {
"rooted": false,
"kernel_version": "Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64",
"version": "12.1",
"build": "17G65",
"type": "os",
"name": "iOS"
}
},
"errors": [
{
"type": "invalid_attribute",
"name": "dist"
}
],
"extra": {
"session:duration": 52129
},
"fingerprint": [
"{{ default }}"
],
"metadata": {
"type": "Error",
"value": "Sentry: TEST crash"
},
"received": 1556893946.0,
"sdk": {
"client_ip": "109.69.86.251",
"version": "0.42.0",
"name": "sentry.javascript.react-native"
},
"sentry.interfaces.Breadcrumbs": {
"values": [
{
"category": "console",
"timestamp": 1556893700.0,
"message": "%c prev state color: #9E9E9E; font-weight: bold [object Object]",
"type": "default"
},
{
"category": "console",
"timestamp": 1556893941.0,
"message": "%c prev state color: #9E9E9E; font-weight: bold [object Object]",
"type": "default"
},
{
"category": "console",
"timestamp": 1556893941.0,
"message": "%c next state color: #4CAF50; font-weight: bold [object Object]",
"type": "default"
},
{
"category": "sentry",
"timestamp": 1556893945.0,
"message": "Error: Sentry: TEST crash",
"type": "default",
"level": "fatal"
}
]
},
"sentry.interfaces.Exception": {
"exc_omitted": null,
"values": [
{
"stacktrace": {
"frames": [
{
"function": "callFunctionReturnFlushedQueue",
"platform": "javascript",
"abs_path": "app:///[native code]",
"in_app": false,
"filename": "app:///[native code]"
},
{
"function": "touchableHandlePress",
"abs_path": "app:///index.bundle",
"in_app": false,
"platform": "javascript",
"lineno": 64988,
"colno": 47,
"filename": "app:///index.bundle"
},
{
"function": "crash",
"abs_path": "app:///index.bundle",
"in_app": false,
"platform": "javascript",
"lineno": 93710,
"colno": 22,
"filename": "app:///index.bundle"
}
],
"has_system_frames": false,
"frames_omitted": null
},
"mechanism": null,
"raw_stacktrace": null,
"value": "Sentry: TEST crash",
"thread_id": 99,
"module": null,
"type": "Error"
}
]
},
"sentry.interfaces.User": {
"id": "b5f212b4-9112-4253-86cc-11583ac1945a"
},
"type": "error",
"version": "7"
}
Artifacts
Web UI
Cut and pasted from Release artifacts page:
Release com.mycompany.app-1.4.21
Artifacts
NAME SIZE
~/index.bundle 8.1 MB
~/main.bundle.map.js 14.7 MB
sourceMappingURL
$ tail -c 50 .xcodebuild/main.jsbundle
//# sourceMappingURL=main.bundle.map.js

After MONTHS, we realised we had to write client code to knit in the Distribution and Release....
const configureSentry = () => {
Sentry.config(config.sentry.dsn).install();
Sentry.setDist(DeviceInfo.getBuildNumber());
Sentry.setRelease(DeviceInfo.getBundleId() + '-' + DeviceInfo.getVersion());
};

Related

Azure Devops API Release definitions expand recursively (I need workflowTasksfrom deployPhases from environments)

Does the Azure Devops REST API allow me to expand multiple levels? When using the release definitions I specifically need the workflowtasks, which are buried a couple of lists deep.
More context:
I'm optimizing an Azure Devops extension that scans pipelines for compliancy. Right now there's a rule that scans the workflowtasks. To get the information required on all relevant pipelines, we do the following call to the Azdo API for each release definition:
https://vsrm.dev.azure.com/{Organization}/{Project}/_apis/release/definitions/{definitionID}?api-version=6.0
This returns a completely decked-out release definition including environments like this:
"environments": [{
"id": 10,
"name": "Stage 1",
... etc
"deployPhases": [{
"deploymentInput": {
"parallelExecution": {
"parallelExecutionType": "none"
},
...etc
"rank": 1,
...etc
"workflowTasks": [{
"environment": {},
"taskId": "obfuscated",
"version": "2.*",
"name": "obfuscated",
"refName": "",
"enabled": true,
"alwaysRun": false,
"continueOnError": false,
"timeoutInMinutes": 0,
"retryCountOnTaskFailure": 0,
"definitionType": "task",
"overrideInputs": {},
"condition": "succeeded()",
"inputs": {
"template": "obfuscated",
"assets": "obfuscated",
"duration": "60",
"title": "",
"description": "",
"implementationPlan": "obfuscated"
}
}, {
"environment": {},
"taskId": "obfuscated",
"version": "2.*",
"name": "obfuscated",
"refName": "",
"enabled": true,
"alwaysRun": false,
"continueOnError": false,
"timeoutInMinutes": 0,
"retryCountOnTaskFailure": 0,
"definitionType": "task",
"overrideInputs": {},
"condition": "succeeded()",
"inputs": {
"changeClosureCode": "1",
"changeClosureComments": "Successful implementation",
"changeId": ""
}
}
]
}
],
...etc
}
],
But when I try and get the list as a whole, using the following URL:
https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/definitions?$expand=environments&api-version=6.0
My Environments arrays (there is one for each definition obviously) looks nothing like the previous one. It doesn't include deployPhases (not even as an empty array).
Since we have 2300 release definitions, you can Imagine how inconvenient it is to call the release/definitions/{definitionID} endpoint instead of the release/definitions one that fetches all of them at the same time.
Is there a way to expand the release/definitions call to fetch all environments including workflowTasks and maybe other stuff? Is there a syntax that allows for this? Something like $expand=environments>deployPhases>workflowTasks?
Is there a way to expand the release/definitions call to fetch all environments including workflowTasks and maybe other stuff? Is there a syntax that allows for this? Something like $expand=environments>deployPhases>workflowTasks?
I am afraid there is no such syntax allow you to fetch all environments including workflowTasks.
You could use the REST API with some powershell scripts to fetch all environments including workflowTasks:
The sample powershell scripts:
$url = "https://vsrm.dev.azure.com/{Organization}/{Project}/_apis/release/definitions/{definitionID}?api-version=6.0"
Write-Host "URL: $url"
$pipeline = Invoke-RestMethod -Uri $url -Method Get -Headers #{
Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"
}
Write-Host "workflowTasks = $($pipeline.environments.deployPhases.workflowTasks | ConvertTo-Json -Depth 100)"
The output is:

Error assert(): assert(sizeof($failures) == 1) failed stops Codeception Test

At some point, while adding assertions for my test, I got the following error message during a test run which stops the execution of the test
Testing started at 14:28 ...
C:\xampp\php\php.exe C:/Users/georg/AppData/Local/Temp/ide-codeception.php run --report -o "reporters: report: PhpStorm_Codeception_ReportPrinter" --no-interaction -c C:/Users/georg/Documents/CMS_Automation_Tests/codeception.yml "tests\regression\features\ArticleTests.feature:Create a new article and fill out all available fields"
Codeception PHP Testing Framework v4.1.7
Powered by PHPUnit 9.3.8 by Sebastian Bergmann and contributors.
Running with seed:
In ErrorHandler.php line 83:
assert(): assert(sizeof($failures) == 1) failed
run [-o|--override OVERRIDE] [-e|--ext EXT] [--report] [--html [HTML]] [--xml [XML]] [--phpunit-xml [PHPUNIT-XML]] [--tap [TAP]] [--json [JSON]] [--colors] [--no-colors] [--silent] [--steps] [-d|--debug] [--bootstrap [BOOTSTRAP]] [--no-redirect] [--coverage [COVERAGE]] [--coverage-html [COVERAGE-HTML]] [--coverage-xml [COVERAGE-XML]] [--coverage-text [COVERAGE-TEXT]] [--coverage-crap4j [COVERAGE-CRAP4J]] [--coverage-phpunit [COVERAGE-PHPUNIT]] [--no-exit] [-g|--group GROUP] [-s|--skip SKIP] [-x|--skip-group SKIP-GROUP] [--env ENV] [-f|--fail-fast] [--no-rebuild] [--seed SEED] [--no-artifacts] [--] [<suite> [<test>]]
I didn't find any information about this error. It doesn't seem to be related to any specific error in my code.
My composer.json is below:
{
"name": "cms/automation",
"type": "project",
"require": {
"php": "^7.2",
"ext-json": "*",
"fzaninotto/faker": "^1.7",
"php-webdriver/webdriver": "^1.8#dev",
"ext-curl": "*",
"ext-zip": "*",
"ext-mb$ vendor/bin/behat -V\nstring": "*",
"facebook/webdriver": "1.7"
},
"require-dev": {
"phpunit/phpunit": "^6.5",
"mockery/mockery": "~0.9",
"codeception/codeception": "^4.1",
"codeception/base": "^2.4",
"symfony/var-dumper": "^4.1",
"behat/behat": "^3.6"
},
"autoload": {
"psr-4": {
"App\\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/"
]
},
"minimum-stability": "dev",
"prefer-stable": true
}

How to check whether any window is open in i3

How could I find out whether any window is opened in i3 or not? Like, check if any workspace contains any window.
You can check if any 'visible' window is open in i3 by using xdotool:
You can install xdotool with sudo pacman -S xdotool
WINDOWS=$(xdotool search --all --onlyvisible --desktop $(xprop -notype -root _NET_CURRENT_DESKTOP | cut -c 24-) "" 2>/dev/null)
NUM=$(echo "$WINDOWS" | wc -l)
if [ $NUM -eq 0 ]; then
echo "No windows open."
fi
maybe try i3-save-tree. You must install perl-anyevent-i3 and perl-json-xs first.
https://i3wm.org/docs/layout-saving.html
Example:
$ i3-save-tree --workspace 10
// vim:ts=4:sw=4:et
{
"border": "pixel",
"current_border_width": 1,
"floating": "auto_off",
"geometry": {
"height": 720,
"width": 1366,
"x": 0,
"y": 0
},
"name": "Waterfox Start Page - Waterfox",
"percent": 1,
"swallows": [
{
// "class": "^Waterfox$",
// "instance": "^Navigator$",
// "title": "^Waterfox\\ Start\\ Page\\ \\-\\ Waterfox$",
// "transient_for": "^$",
// "window_role": "^browser$"
}
],
"type": "con"
}

Testing API via newman

Hi there I am testing an API via postman, I want to automate my tests and have downloaded newman. Now the request I use in postman has been exported as a collection and is giving me a 404 via newman.... Any pointers much appreciated. IP address has been changed for obvious reasons.
{
"id": "11f345f7-9f12-58fb-099d-27f11233cee7",
"name": "GC",
"description": "",
"order": [
"f7fe3f94-0dd2-6dba-05b9-29ae7e571ed9"
],
"folders": [],
"timestamp": 1446559540652,
"owner": "195242",
"remoteLink": "",
"public": false,
"requests": [
{
"id": "f7fe3f94-0dd2-6dba-05b9-29ae7e571ed9",
"headers": "",
"url": "http://218.24.201.144/cb/mobile/v1/residences/568288d0-71b6-11e5-ad9f-0242ac110908/lastAirQuality/rooms",
"pathVariables": {},
"preRequestScript": "",
"method": "GET",
"collectionId": "11f345f7-9f12-58fb-099d-27f11233cee7",
"data": [],
"dataMode": "params",
"name": "http://218.24.201.144/cb/mobile/v1/residences/568288d0-71b6-11e5-ad9f-0242ac110908/lastAirQuality/rooms",
"description": "",
"descriptionFormat": "html",
"time": 1446559548262,
"version": 2,
"responses": [],
"tests": "",
"currentHelper": "normal",
"helperAttributes": {}
}
]
}
this is the output I get in newman
$ newman -c GC.json.postman_collection
Iteration 1 of 1
404 218ms http://218.24.201.144/cb/mobile/v1/residences/568288d0-71b6-11e5-ad9f-0242ac110908/lastAirQuality/rooms http://218.24.201.144/cb/mobile/v1/residences/568288d0-71b6-11e5-ad9f-0242ac110908/lastAirQuality/rooms
Summary:
Parent Pass Count FailCount
-------------------------------------------------------------
Collection GC 0 0
Total
0 0
Do you have tests set?
var data = JSON.parse(responseBody);
tests["Pass this case"] = data.id === 11f345f7-9f12-58fb-099d-27f11233cee7;
Create Tests and don't forgot to update your json collection before testing.
Check this #298
404 is means the resource you are looking in is not exist, or the system is unable to find the requested data, you can try using
$ newman run <path of you collection>
npm install postman
npm install newman
npm install newman-reporter-html
https://github.com/shahing/api-automation-tests
run command in your directory : newman run test.js

Sencha SDK Tools does not Minified app-all.js

I'm using Sencha SDK Tools 2 Beta 3 and ExtJS 4.0.7 in Windows 7 64bit.
After I build my project, the app-all.js file is not minified.
This is the .JSB3 file (that was generated by Sencha):
{
"projectName": "Project Name",
"licenseText": "Copyright(c) 2012 Company Name",
"builds": [
{
"name": "All Classes",
"target": "all-classes.js",
"options": {
"debug": true
},
"files": [
// All Classes
]
},
{
"name": "Application - Production",
"target": "app-all.js",
"compress": true,
"files": [
{
"path": "",
"name": "all-classes.js"
},
{
"path": "",
"name": "app.js"
}
]
}
],
"resources": []
}
And Sencha result in command prompt: (Without Errors)
Loaded 2 Builds
Creating the "All Classes" target as "all-classes.js"
- 256 file(s) included in this target.
+ // All Classes
* Parse all-classes.js with options:
- debug: true
- debugLevel: 1
Creating the "Application - Production" target as "app-all.js"
- 2 file(s) included in this target.
+ all-classes.js
+ app.js
* Parse app-all.js with options:
- debug: false
- debugLevel: 1
* Compress and obfuscate app-all.js...
Copy resources...
Done building!
FUI: My file has Unicode characters.
Thank you in Advance.
Update: (Folder Structure, Simplified)
MyApp
- app
-- controller
--- mycontroller.js
-- model
--- mymodel.js
-- store
--- mystore.js
-- view
--- myview.js
- ext
- app.js
- index.html
(Folders don't have file extensions)
It was about an internal error.
I've replaced float with 'float' in my JS File and now it works.