i have been following implementation guide to use firebase in our react-native application.
According to documentation: https://rnfirebase.io/reference/analytics#logPurchase expects PurchaseEventParameters https://rnfirebase.io/reference/analytics/purchaseeventparameters
which include value, currency as well as items which is a list of Item with mentioned parameters:
https://rnfirebase.io/reference/analytics/item
When using these parameters
const parameters = {
"value": 64.55,
"currency": "eur",
"items": [
{
"item_category": "special_offer",
"quantity": 1,
"item_price": 64.55
}
]
}
try {
await analytics().logPurchase(parameters)
} catch (error) {
console.log('🚀 ~ error', error)
}
we are getting an error Error: firebase.analytics().logPurchaseEvent(*): unknown property 'items'.
Now we are wondering, if documentation is outdated, or am i overseeing something important here?
react-native 0.67.4
#react-native-firebase 14.11.0
Thanks for any hint on this!
Related
i have added "additionalProperties": false to schema scripts in postman. The "additionalProperties": false, worked fine and im getting error message when new fields are newly added to the json response and not covered by schema. But is there a script to specify what fields are added in the json?
No, I think you cannot.
I have tried using itv4 directly instead of using it through pm...
like below... The best I have obtained is the number of fields that are exceeding... but not the name.
const schema = {
"type": "object",
"properties": {
"code": { "type": "string" }
},
"additionalProperties": false
};
console.log(tv4.validate(body, schema))
console.log(tv4.validateResult(body, schema))
console.log(tv4.validateMultiple(body, schema));
pm.test("Explicitly ", function () {
let Ajv = require('ajv');
let ajv = Ajv()
let result = ajv.validate(schema, jsonData);
pm.expect(result, JSON.stringify(ajv.errors)).to.be.true;
});
this will show the additional property there is a bug for this already :
https://github.com/postmanlabs/postman-app-support/issues/9276
I am able to fetch the record from dynamo db and view the response successfully. I need to modify the fetched 'ACCOUNTNAME' attribute in the 'items' array and update the json and also update in dynamo db. Now when I try to update the fetched records I end up with the Invalid attribute value type exception.
I was trying to update it using the key with Array of Strings which is provided with code snippet also tried to update inside for loop using the individual string but both failed with same exception as
"statusCode": 400,
"body": {
"message": "Invalid attribute value type",
"error": {
"errorMessage": "ValidationException"
}
}
I tried to create params and update the call inside the for loop by setting the key as below,
Key: {
"UUID": {
"S": usersOfAccountFromDB.body.Items[key].UUID
}
,
"TYPE": {
"S": user
}
}
but also failed with the same exception.
Fetched Json from dynamo db
[
{
"DEFINITION": "914ba44a-8c26-4b60-af0f-96b6aa37efe6",
"UUID": "830a49cb-4ed3-41ae-b111-56714a71ab98",
"TYPE": "USER",
"RELATION": "01efd131-6a5d-4068-889e-9dba44262da5",
"ACCOUNTNAME": "Wolff LLC"
},
{
"DEFINITION": "1f60fded-323d-40e1-a7f8-e2d053b0bed0",
"UUID": "47db3bbe-53ac-4e58-a378-f42331141997",
"TYPE": "USER",
"RELATION": "01efd131-6a5d-4068-889e-9dba44262da5",
"ACCOUNTNAME": "Wolff LLC"
},
{
"DEFINITION": "05ddccba-2b6d-46bd-9db4-7b897ebe16ca",
"UUID": "e7290457-db77-48fc-bd1a-7056bfce8fab",
"TYPE": "USER",
"RELATION": "01efd131-6a5d-4068-889e-9dba44262da5",
"ACCOUNTNAME": "Wolff LLC"
},
.
.
.
.]
Now I tried to iterate the Json and setup UUID which is the key as the String array as below,
var userUUIDArray : string[] = [];
for (let key in usersOfAccountFromDB.body.Items) {
userUUIDArray.push(usersOfAccountFromDB.body.Items[key].UUID);
}
for (var uuid of userUUIDArray) {
console.log("UUID : " +uuid); // prints all the uuid
}
// Creating a parameter for the update dynamo db
var params = {
TableName: <tableName>,
Key: {
"UUID": {
"SS": userUUIDArray
}
,
"TYPE": {
"S": user
}
},
UpdateExpression: 'SET #ACCOUNTNAME = :val1',
ExpressionAttributeNames: {
'#ACCOUNTNAME': 'ACCOUNTNAME' //COLUMN NAME
},
ExpressionAttributeValues: {
':val1': newAccountName
},
ReturnValues: 'UPDATED_NEW',
};
//call the update of dynamodb
const result = await this.getDocClient().update(param).promise();
I get the error as below,
"body": {
"message": "Invalid attribute value type",
"error": {
"errorMessage": "ValidationException"
}
}
All the approaches failed with same above exception
The update operation which your code currently uses only allow a single item to be updated.
IIUC, you want to update multiple items with one API call. For this you need to use batchWrite operation. Keep in mind that you cannot update more than 25 items per invocation.
The origin of the error you are getting
Your code fails due to the use of "SS" in the UUID field. This field is of type string so you must use "S". Note however that since you're using the document client API you do not need to pass values using this notation. See this answer for further details.
I have resolved the issue now by running the update statement one by one using loop
for (let key in usersOfAccountFromDB.body.Items) {
var updateParam = {
TableName: process.env.AWS_DYNAMO_TABLE,
Key: {
UUID: usersOfAccountFromDB.body.Items[key].UUID,
TYPE: user
},
UpdateExpression: "SET #ACCOUNTNAME = :val1",
ExpressionAttributeNames: {
'#ACCOUNTNAME': 'ACCOUNTNAME'
},
ExpressionAttributeValues: {
":val1": newAccountName
},
ReturnValues: "UPDATED_NEW",
};
const result = await this.getDocClient().update(updateParam).promise();
}
I've got an account page in my SPA that i'm currently trying to populate with information from my database.
I've used Postman to see that the property I am trying to access is available. As well as I'm able to access another property from the same element.
JSON from Postman
{
"newsSubscription": {
"SubscriptionID": "1",
"ObjectID": "00000000-0000-0000-0000-000000000000",
"OrganizationNumber": null,
"CompanyName": null,
"Active": true,
"SubscriptionType": 1,
"ObjectType": 1
},
"Subscriptions": [],
"Email": "email#email.com"
}
I'm accessing the API using axios. I'm able to get the email address, but can't seem to access the true/false of "Active", which will determine if the checkbox is checked or not.
class Example extends React.Component {
state = {
emailAddress: [],
}
componentDidMount() {
axios.get(
'http://api',
{ withCredentials: true }
)
.then(res => {
const emailAddress = res.data;
this.setState({ emailAddress });
})
//error handling
}
render() {
return (
// Removed for simplicity
<Typography>The registered e-mail address for your account is <b>{this.state.emailAddress.Email}</b></Typography>
<Checkbox
checked={this.state.emailAddress.newsSubscription.Active}
value="email_notifications"
color="primary"
/>
);
}
}
I would like the API property "Active" to check or uncheck the checkbox based on a true/false response from the API call.
state = {
emailAddress: [],
}
Your state is quite confusing. Your state.emailAddress semms to be an array, but you use it like an object: this.state.emailAddress.newsSubscription.
Your API give you an object, or an array ? I think your issue is here.
Please add in the render section
console.log(this.state.emailAddress);
to see what is coming. Maybe there is an issue on how the data is arriving and that is why it fails.
I am having an issue getting results back from my AppSync API via AWSAppSyncClient. I can run the query in the AWS AppSync console and get the complete results, however when I run the query from my client the portion of the results I am looking for returns an empty array.
I have tried slimming down the query to return less results, as I read at one point that dynamo will run a filter on the results being returned if you do not provide your own. I have also read this could have something to do with the partition keys used in the dynamoDB table, however AppSync provisioned that resource for me and handled the initial config. I am new to working with AppSync so I am sort of drawing a blank on where to even start looking for the issue because there is not even an error message.
The Query I am running
export const getUserConversations = `query getUser($id: ID!) {
getUser(id: $id) {
id
conversations {
items {
conversation{
id
associated{
items{
convoLinkUserId
}
}
}
}
}
}
}
`;
Call being made in a redux actions file
export const getUserConvos = (id) => async dispatch => {
AppSyncClient.query({
query: gql(getUserConversations),
variables: {
id: id
}
}).then(res => {
console.log("RES FROM CONVO QUERY", res)
})
}
This is the response I am getting in the browser
Notice conversations.items returns an empty array.
getUser:
conversations:
items: []
__typename: "ModelConvoLinkConnection"
__proto__: Object
id: "HIDDEN_ID"
__typename: "User"
__proto__: Object
__proto__: Object
However if i run the exact same query in the playground on the AppSync console I get this...
{
"data": {
"getUser": {
"id": "HIDDEN_ID",
"conversations": {
"items": [
{
"conversation": {
"id": "HIDDEN_ID",
"associated": {
"items": [
{
"convoLinkUserId": "HIDDEN_ID"
},
{
"convoLinkUserId": "HIDDEN_ID"
}
]
}
}
},
{
"conversation": {
"id": "HIDDEN_ID",
"associated": {
"items": [
{
"convoLinkUserId": "HIDDEN_ID"
},
{
"convoLinkUserId": "HIDDEN_ID"
}
]
}
}
}
]
}
}
}
}
*HIDDEN_ID is a placeholder
I know that the objects are in my DB, however if i run the query via my react application I get nothing, and if I run it in the console on AWS I get another. I need to be able to have access to these conversations via the client. What could be causing this?
I'm stuck with querying Firestore REST API. I can figure out how to filter by a regular key but I can't figure out how to query by nested object key.
Basically, in the browser client, I can do
firestore.collection("channels")
.where("members.[memberID]", "==", true)
.get()
However, when I try to do the same in the REST API, it said Invalid Argument. I was trying to do
{
"structuredQuery": {
"where": {
"fieldFilter": {
"field": {
"fieldPath": "members.[memberID]"
},
"op": "EQUAL",
"value": {
booleanValue: "true"
}
}
},
"from": [
{
"collectionId": "channels"
}
]
}
}
but it gives me "Invalid Argument" error on fieldPath. Does anybody know how to query Firestore REST API based on nested object?
Thank you!
I asked for Firebase support and they said special characters in fieldPath such as "-" in my case can be escaped using back tick or back slash. It is mentioned in the documentation. In my case, I'll need to do
members.`[memberID]`
I hope this is helpful for you guys.