Retrieve the traffic variable in RankedReport of Adobe Sitecatalyst - api

Is it possible to fetch a traffic variable sProp1 along with PageName and Url when issuing a GetReport request of a Ranked report?
Let us say I have the following passed to SiteCatalyst (Omniture) via Java Script.
s.pageName = o_title; // Page Name
s.channel = o_structure; // SiteSection
s.prop1 = o_inode // Traffic variable also the Primary Key Id of the PageName
Now, if I run a RankedReport, I will get the following
PageName
PageViews
Url
Along with this info, I will also be interested in fetching the s.prop1 value. I will need the s.prop1 value to use it on my db to query the first sentence of the article from db (and other metadata) and show the results on the results page that shows the most popular pages. Can this be achieved? I mean is it possible to get the traffic variable associated with the pageName?
Thanks,
Rag

OK. I think I if I add another element (prop1) I get the breakdown. {
"reportDescription":{
"reportSuiteID":"*",
"dateFrom":"2013-03-06",
"dateTo":"2013-03-15",
"metrics":[
{
"id":"pageviews",
"name":"Page Views",
"type":"number"
}
],
"sortBy":"pageviews",
"elements":[
{
"id":"siteSection"
},
{
"id":"page"
},
{
"id":"prop1"
}
],
"locale":"en_US"
},
"validate":"false"
}

Related

Vue: Setting Data by matching route query

I'm attempting to set data fields provided by an array based on the Vue Router query. For example, when someone lands on my website using example.com/?location=texas, I want to set the location data by an array.
An example the array:
locations {
{
slug: "texas",
tagline: "Welcome to Texas",
}, {
slug: "california",
tagline: "Welcome to California",
}
}
I know this should be done using a computed property, however I am unable to get anything functioning. I've tried simple tests like if (this.slug.location === "texas"), and I cannot get the location data to populate. I would also like to provide default data in case there are no route matches.
Any help is extremely appreciated!
Edit:
I can accomplish this in a very manual way. Right now, I'm setting the query in data by the following:
slug: this.$route.query.location
I can display specific text by doing something like:
h3(v-if="slug === 'texas'") This will show for texas
h3(v-else-if="slug === 'california'") This will show for California
h3(v-else) This is default
The issue with this approach is there are various elements I need to customize depending on the slug. Is there any way I can create an array, and move whichever array matches a key in an array to the data??
You should be able to access a query param using the following (link to Vue Router documentation):
this.$route.query.location
So based on what you listed I would do something like...
export default {
computed: {
displayBasedOnLocationQueryParam() {
switch(this.$route.query.location) {
case 'texas':
return 'Welcome to Texas'
default:
return 'hello there, generic person'
}
}
}
}
Note that I'm not using your array explicitly there. The switch statement can be the sole source of that logic, if need be.

VueJS Apollo graphql store/cache data collision between queries

I have the following data flow scenario:
UI has 3 sections: Enrolled Services, Enrolling Services, and
Search Services
User will search for existing services (upon the User
entering searchServiceText, searchResultServices gets called)
The user selects a service from the search result and enrolls in a
service. If the User's enrollment not complete (ex: no payment, not
accepted, etc), UI will show the data in the Enrolling section.
Otherwise, it will be in the Enrolled section
I have the following queries:
enrolledServices: {
query: gql(listServices),
variables() {
let idFilter = this.idFilter(this.userData.enrolledServiceIds);
return {
filter: {
or: idFilter
}
};
},
update: data => {
return _.compact(data.listServices.items);
}
},
enrollingServices: {
query: gql(listServices),
variables() {
let idFilter = this.idFilter(this.userData.enrollingServiceIds);
return {
filter: {
or: idFilter
}
};
},
update: data => {
return _.compact(data.listServices.items);
}
},
searchResultServices: {
query: gql(listServices),
variables() {
console.log('before search - enrolledServices:', this.enrolledServices); //Data Collision!!
console.log('before search - enrollingServices:', this.enrollingServices);
return {
filter: {
or: [
{ name: { contains: this.searchServiceText } }
],
and: [
{ status: { eq: 'Active' } }
]
}
};
},
skip() {
return !this.searchServiceText;
},
update(data) {
return _.compact(data.listServices.items);
}
}
enrolledServices: and enrollingServices: gets called on page load, hence UI will have 2 sections for enrolled services and enrolling services.
searchResultServices: will not be called on page load because of skip() condition. It is gets called reactively when user enters value to searchServiceText field in the UI
Getting to my issue now:
On page load as expected Service_enrolled, Service_enrolling is shown in Enrolled, Enrolling sections respectively (see below).
Enrolled Section:
Service_enrolled
Enrolling Section:
Service_enrolling
If the user sets search word in searchServiceText and clicks search, Enrolled section shows Service_enrolling (see below). User is just searching at time and he/she has not acted on the search results as yet
Enrolled Section:
Service_enrolling (enrolled service replaced with enrolling
service)
Enrolling Section:
Service_enrolling
The expected behavior in step2: I should see step 1 behavior (Service_enrolled should be in Enrolled section, Service_enrolling should be in Enrolling section) because the user has not acted on search results as yet.
Not sure why in step 2 above, there is a data collision. I have console.log to print enrolled and enrolling list in the memory/cache before hitting the search query. It shows data collision right there before hitting the search query. so search query is not contributing to the issue and there are no traces of enrolledServices, enrollingServices query execution in step 2 above. I am not sure how enrolled and enrolling data gets messed up.
Note: both enrolledServices, enrollingServices has same search query except 'idFilter' data will be different as they have different service Ids. That means, as per my understanding cache key is unique for these two queries, right?
I am absolutely sure something is missing in my approach or code but not able to figure out. Any help is much appreciated and you will save a lot of time plus for others who may have a similar issue.

error generating storefront id in shopify buy js sdk

I am super confused with the documentation on Shopify. I wanted to use their Javascript Buy SDK. To follow their simple product fetch example, in the docs, it says that "Before you can retrieve a product or collection, you need to query for a Storefront ID. After you've obtained either a product ID or collection ID, you can fetch the product or collection using the SDK."
So using the Shopify Graphiql app and from the example to get a storefront ID, the request looks like this.
{
shop {
productByHandle(handle: "my-own-product-handle") {
id
}
}
}
the expected return id is somewhat like
"id": "Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzczNDE0OTkzOTk=" in some sort of encoded value. But however the ID I am getting is like a URL. Here is what I got in return.
{
"data": {
"shop": {
"productByHandle": {
"id": "gid://shopify/Product/1349634097238"
}
}
},
"extensions": {
"cost": {
"requestedQueryCost": 2,
"actualQueryCost": 2,
"throttleStatus": {
"maximumAvailable": 1000,
"currentlyAvailable": 998,
"restoreRate": 50
}
}
}
}
When I use this URL to do a request as shown in JS SDK example
// Fetch a single product by ID
const productId = 'gid://shopify/Product/13496340972223';
client.product.fetch(productId).then((product) => {
// Do something with the product
console.log(product);
});
I get the error in the console that Variable id of type ID! was provided invalid value.
I am not able to figure out where I am missing the dots.
Please help!
Thanks.
Think I have cracked it.... or at least found a work around. This should be clearer I feel, which makes me think I'm wrong.... anyway, here's what I found out.
When using the Shopify graphiQl app you can ask for the id. (just as you have shown above). Take the result and encode it into base64 here..
https://www.base64encode.org/
That will give you the result - 'Z2lkOi8vc2hvcGlmeS9Qcm9kdWN0LzEzNDk2MzQwOTcyMjIz'.
Stick that in your productId variable and you should get a response.

Not getting results field after querying task by ID in Lookback API

I'm trying to query tasks by ObjectID to get their most recent snapshots. I'm trying the API out, and am not getting the expected results that I was hoping for after reading the docs. I don't get a results field in the response object. Here's my code:
_loadTaskSnapshot: function() {
let snapshot = Ext.create('Rally.data.lookback.SnapshotStore', {
context: {
workspace: '/workspace/2290039850'
},
"find": {
"ObjectID": 34858774310,
"_ValidFrom": {
"$gte": "2016",
"$lt": "2017"
}
},
"fields": ["Name", "Estimate", "ToDo", "TimeSpent"],
});
return snapshot.load();
}
This is the store with 18 snapshots for the specified task. The first snapshot is opened. You can see there is no results field where I could find the Name, Estimate, ToDo, and TimeSpent:
Alejandro, you are asking for the changes in the fields, not the values of the fields. This is a common misconception with the lookback api. There is a special way to get the current values shown in the help pages available inside Agile Central.
Any information returned is actually held within the object underneath 'raw' and 'data'. Each of those may not contain any values if there has been no 'changes' to those fields at the time the snapshot was taken.

Generate Url from virtual field or from value of another field

I would like to generate a Url in a list in keystoneJS. I prefer that the url not be stored in mongo.
Attempted:
Virtual field: works, but will not generate raw HTML for the href.
Types.Url: I get the href format, but I need a value from another field in my model, so it generates the url with undefined.. Example:
{ type: Types.Url, label: "Link", default: "[http://www.stackoverflow.com/ask?id=][1]" + this._id }
Any help on how to pull this off would be much appreciated.
For your second point, this._id is not available when adding fields to the model, hence why you're getting undefined.
Instead, try using a pre-save hook on your model:
yourModel.pre('save', function(next) {
this.link = "[http://www.stackoverflow.com/ask?id=][1]" + this._id;
next();
}
I'm not quite sure if you're trying to just generate a link in this way every time, or if the user should also be able to add their own link. If the later, you'll need to check if the link has been filled in in the pre-save hook.
I hope that helps and sorry it took so long to get an answer on this!