Sentry cannot find my source code - expo

I cannot display my original code in sentry dashboard.
i get the following errors
Discarded invalid parameter 'type'
Source code was not found for app:///crna-entry.delta?
platform=ios&dev=true&minify=false`
I've configured the app.json as indicated in the docs.
"hooks": {
"postPublish": [
{
"file": "sentry-expo/upload-sourcemaps",
"config": {
"organization": "xxxxx",
"project": "xxxxxxx",
"authToken": "xxxxxxxxxx"
}
}
]
}

I answered this question here
First way
If you are using expo. You should use sentry-expo package which you can find here: sentry-expo
Put this hook to your expo json (app.json) file
{
"expo": {
"hooks": {
"postPublish": [
{
"file": "sentry-expo/upload-sourcemaps",
"config": {
"organization": "<your organization name>",
"project": "<your project name>",
"authToken": "<your auth token here>"
}
}
]
}
}
organization you can find on here https://sentry.io/settings/ which named "Organization Name"
project enter your project name, you can find here: https://sentry.io/organizations/ORGANIZATION_NAME/projects/
authToken create a authToken with this url https://sentry.io/api/
Then run expo publish, it upload the source maps automatically.
Testing Locally
Make sure that you enabled expo development.
add lines;
Sentry.enableInExpoDevelopment = true;
Sentry.config(publicDsn, options).install();
As a Result
On sentry, for only ios, you can able to see the source code where error occured.
BUT: unable to see the source code for ANDROID
https://github.com/getsentry/react-native-sentry/issues/372
Second way (manual upload)
Using the api https://docs.sentry.io/platforms/javascript/sourcemaps/
curl -X POST \
https://sentry.io/api/0/organizations/ORG_NAME/releases/VERSION/files/ \
-H 'Authorization: Bearer AUTH_TOKEN' \
-H 'content-type: multipart/form-data' \
-F file=#script.min.js.map \
-F 'name=~/scripts/script.min.js.map'

Related

How to create a new Workbench Managed Notebook using REST API?

How can I create a new Managed Notebook programmatically?
I want to use Notebooks API REST but has not found an example.
Reference Link
To create a new Managed notebook you can use the following example:
BASE_ADDRESS=notebooks.googleapis.com
LOCATION=us-central1
PROJECT_ID=gogasca-sandbox
AUTH_TOKEN=$(gcloud auth application-default print-access-token)
RUNTIME_BODY="{
'access_config': {
'access_type': 'SINGLE_USER',
'runtime_owner': 'gogasca#google.com'
},
'virtual_machine': {
'virtual_machine_config': {
'data_disk': {
'initialize_params': {
'disk_size_gb': 200,
'disk_type': 'PD_SSD',
}
},
'container_images': [{
'repository': 'gcr.io/deeplearning-platform-release/pytorch-gpu', 'tag': 'latest'
}],
'metadata': {
'file_to_load_1':'https://test.google.com/v2/models/versions/trainable_v1.0/zip',
},
'machine_type':'n1-standard-4',
'accelerator_config': {
'type': 'NVIDIA_TESLA_T4',
'core_count': '1'
}
}
},
'software_config':{
'post_startup_script':'gs://gcp-scripts/step01.sh'
}
}"
RUNTIME_NAME=gogasca-managed-notebook
curl -X POST https://${BASE_ADDRESS}/v1/projects/$PROJECT_ID/locations/$LOCATION/runtimes?runtime_id=$RUNTIME_NAME -d "${RUNTIME_BODY}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $AUTH_TOKEN" -v
Google Cloud SDK is in progress.
Terraform module just got released.

Required field is invalid error when trying to create new dataset in GCP AutoML object detection

I am following the quickstart for AutoML object detection. Unfortunately I run into an error I cannot figure out. At the very first curl command
curl -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
"https://automl.googleapis.com/v1beta1/projects/$PROJECT_ID/locations/us-central1/datasets" -d '{
"display_name": "dataset_name",
"image_object_detection_dataset_metadata": {
}
}'
I get this error:
{
"error": {
"code": 400,
"message": "List of found errors:\t1.Field: parent; Message: Required field is invalid\t",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "parent",
"description": "Required field is invalid"
}
]
}
]
}
}
It seems to be some kind of schema validation error, so perhaps they changed the request body format but I cannot figure out how to change it.
Doh, It turns out the PROJECT_ID variable was not actually set.
It's somewhat typical of GCP that you get very cryptic errors sometimes when working through their APIs.

Accessing Google Cloud speech-to-text response

I am a total beginner with this and I hope someone can point me into the right direction: I used the Google Cloud Speech-to-text API, in particular the longrunningrecognize method. Now everything works out and I get the expected results:
{
"name": "4983661747957213554",
"metadata": {
"#type":
"type.googleapis.com/google.cloud.speech.v1.LongRunningRecognizeMetadata",
"progressPercent": 100,
"startTime": "2019-04-07T10:22:26.018723Z",
"lastUpdateTime": "2019-04-07T10:23:17.659732Z"
},
"done": true
}
After this have been stuck for a full day though. The transcription is done, but how do I access it? Which variable can I call to see the result? How can I save it to a file?
On top, I am wondering what´s the best way to run Python scripts in GCP.
I have seen this answer: Google cloud speech API response : Parsing iOS
but it brings me to a very fundamental problem that I am experiencing: How and where is the best way to execute that code?
I have also tried to create *.py files and chmod them, but is there any easier way to run simple scripts?
My expected result is the final text file or even just access to a string that is behind the operations: that I get returned.
Google has examples in documentation:
In shell, you can run
curl -H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
"https://speech.googleapis.com/v1/operations/4983661747957213554"
Where 4983661747957213554 is the name of your operation returned above. And it will print you the results:
{
"name": "7612202767953098924",
"metadata": {
"#type": "type.googleapis.com/google.cloud.speech.v1.LongRunningRecognizeMetadata",
"progressPercent": 100,
"startTime": "2017-07-20T16:36:55.033650Z",
"lastUpdateTime": "2017-07-20T16:37:17.158630Z"
},
"done": true,
"response": {
"#type": "type.googleapis.com/google.cloud.speech.v1.LongRunningRecognizeResponse",
"results": [
{
"alternatives": [
{
"transcript": "okay so what am I doing here...(etc)...",
"confidence": 0.96096134,
}
]
},
{
In Python you can run the demo script.

Keystone v3 auth error

I am following keystone ocata installation guide https://docs.openstack.org/ocata/install-guide-ubuntu/keystone-install.html
Post installation, I am able to get the user list using openstack user list command.
openstack --os-auth-url="[keystone_url]" --os-identity-api-version="3" --os-password="mypwd123" --os-project-domain-name="Default" --os-project-name="admin" --os-username="admin" --os-user-domain-name="Default" user list
Outputs the User list properly.
But when I take auth token with below command :
curl -si -d '{"auth": {"identity": {"methods": ["password" ],"password": {"user": {"domain": {"id": "default" },"name": "admin","password": "mypwd123" }}}}}' -H "Content-type: application/json" [keystone_url]/v3/auth/tokens
and then use the token from the output of above command in below command to list the users:
curl -s -H "X-Auth-Token: gAAAAABZlAN0NPibgBLcUW3aAcgNYIGaRH98M7w6b4tRliXC4LQB4dr5cGxTJmF5-iKvY2U_AU3c71uJUqgaQJP-iyURCBzBqYHlHtTGqofzzVndVncBRU5z4iLbArBdbJCI2Wd-1No9C0cq4iWB6RBNa9wqXWm-Gw" "[keystone_url]/v3/users" | python -mjson.tool
Returns :
{
"error": {
"code": 403,
"message": "You are not authorized to perform the requested action: identity:list_users.",
"title": "Forbidden"
}
}
Any help would be appreciated.
Thanks,
Viral
because list users need token with scope, you should add scope for query, like this:
curl -i http://ip:5000/v3/auth/tokens -H "Content-
Type: application/json" -d '
{
"auth": {
"identity": {
"methods": [
"password"
],
"password": {
"user": {
"name": "admin",
"domain": {
"name": "Default"
},
"password": "secret"
}
}
},
"scope": {
"domain": {
"id": "default"
}
}
}
}'
then use X-Subject-Token to query users.
See the official documentation for details.https://docs.openstack.org/keystone/pike/api_curl_examples.html#tokens

number of instances the cloud foundry app is running

my app needs to get the number of instances in which its running, (in runtime my app uses this info in my program logic).
(VCAP_APPLICATION env variables cannot provide this info. )
Calling API directly and using "instances" attribute is an option, but I dont know how to call apps API directly in my app. Please let me know how to call it.
Below is the link I got for app API:
http://apidocs.cloudfoundry.org/218/apps/retrieve_a_particular_app.html
In order to use the API, you first need to authenticate. In order to authenticate, you need to retrieve the authorization endpoint.
To retrieve the authorization endpoint, issue the following curl request (I am using pivotal web services in this example, but you would replace https://api.run.pivotal.io with the cloud foundry api endpoint you are using.
curl -H 'content-type: application/x-www-form-urlencoded;charset=utf-8' \
-H 'accept: application/json;charset=utf-8' \
https://api.run.pivotal.io/v2/info
You'll get back something that looks like this:
{
"name": "vcap",
"build": "2222",
"support": "http://support.cloudfoundry.com",
"version": 2,
"description": "Cloud Foundry sponsored by Pivotal",
"authorization_endpoint": "https://login.run.pivotal.io",
"token_endpoint": "https://uaa.run.pivotal.io",
"min_cli_version": null,
"min_recommended_cli_version": null,
"api_version": "2.36.0",
"app_ssh_endpoint": "ssh.run.pivotal.io:2222",
"app_ssh_host_key_fingerprint": "e7:13:4e:32:ee:39:62:df:54:41:d7:f7:8b:b2:a7:6b",
"logging_endpoint": "wss://loggregator.run.pivotal.io:443",
"doppler_logging_endpoint": "wss://doppler.run.pivotal.io:443"
}
Grab the authorization_endpoint value, in this case it is:
https://login.run.pivotal.io
You now need to grab an authentication token. Issue the following curl command replacing the [my user name] and [my password] and [my authorization endpoint] with your values. Please note that you should url encode your password.
curl -H 'content-type: application/x-www-form-urlencoded;charset=utf-8' \
-H 'accept: application/json;charset=utf-8' \
-H 'authorization: Basic Y2Y6' \
-d "username=[my user name]&password=[my password]&grant_type=password" \
[my authorization endpoint]/oauth/token
You will get a response that looks like this:
{
"access_token": "very_long_token.very_long_token.very_long_token",
"token_type": "bearer",
"refresh_token": "very_long_token.very_long_token.very_long_token",
"expires_in": 599,
"scope": "cloud_controller.read password.write cloud_controller.write openid",
"jti": "shorter_value"
}
You are interested in the access_token value (access_token, refresh_token, and jti have been changed from the actual values in this example)
Now we are finally at the point where we can use the api to get the information about our app. You could use the link you provided above, but to use that api endpoint, you need the guid of your app. Instead I would recommend using the List all Apps endpoint and use a query filter on it to get your app information. Here is the curl command (replace [my authorization token] with your auth token from the previous step, replace [my api endpoint] with the api endpoint you use for cloud foundry, replace [my app name] with the name of your app:
curl -H "authorization: bearer [my authorization token]" \
[my api endpoint]/v2/apps?q=name:[my app name] -X GET
You'll receive a message that looks like this:
{
"total_results": 1,
"total_pages": 1,
"prev_url": null,
"next_url": null,
"resources": [
{
"metadata": {
"guid": "blah-blah",
"url": "/v2/apps/blah-blah",
"created_at": "time_stamp",
"updated_at": null
},
"entity": {
"name": "my-app",
"production": false,
"space_guid": "blah-blah",
"stack_guid": "blah-blah",
"buildpack": null,
"detected_buildpack": null,
"environment_json": {
},
"memory": 1024,
"instances": 3,
"disk_quota": 1024,
"state": "STOPPED",
"version": "blah-blah",
"command": null,
"console": false,
"debug": null,
"staging_task_id": null,
"package_state": "STAGED",
"health_check_type": "port",
"health_check_timeout": null,
"staging_failed_reason": null,
"staging_failed_description": null,
"diego": false,
"docker_image": null,
"package_updated_at": "time stamp",
"detected_start_command": "",
"enable_ssh": true,
"docker_credentials_json": {
"redacted_message": "[PRIVATE DATA HIDDEN]"
},
"space_url": "/v2/spaces/blah-blah",
"stack_url": "/v2/stacks/blah-blah",
"events_url": "/v2/apps/blah-blah/events",
"service_bindings_url": "/v2/apps/blah-blah/service_bindings",
"routes_url": "/v2/apps/blah-blah/routes"
}
}
]
}
You can grab the instances from the message. If you want to use the api in your original link, you can grab the metadata.guid for use in that call.
Hope that helps!
I was looking for something similar but using cf cli, to get the instance count of my app in a shell script. I came up with this and it works.
cf app my_app_name|grep instances|cut -d'/' -f2
I understand this post might not be related, but i would be happy if it helps someone.
Though it is late now to reply - an alternate solution would be to have a service discovery component like Eureka and let your application register to it. From the discovery client, you can get the number of instances for this application.
Be aware though, the state of instances would be eventually consistent on Eureka. We are using this pattern for a cluster broadcast use case.
create a container to container link with the name myapp.apps.internal. Then count the IP's returned by a DNS lookup of myapp.apps.internal.