Background: I have a managed package that is actively being used by other organizations. The end goal is to be able to appropriately pull app analytics from Salesforce so that I can better understand how folks are using my app.
I opened a case with Salesforce to appropriately enable app analytics. The case was reported to be appropriately worked about a week ago, so app analytics should be working now, and there should be data to query.
What I have tried so far:
After reviewing the documentation on AppAnalyticsQueryRequest: https://developer.salesforce.com/docs/atlas.en-us.220.0.object_reference.meta/object_reference/sforce_api_objects_appanalyticsqueryrequest.htm,
I tried to query the Salesforce SOAP API like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:enterprise.soap.sforce.com"> <soapenv:Header> <urn:PackageVersionHeader> </urn:PackageVersionHeader> <urn:QueryOptions> </urn:QueryOptions> <urn:SessionHeader> <urn:sessionId>[session id goes here]</urn:sessionId> </urn:SessionHeader> </soapenv:Header> <soapenv:Body> <urn:query> <urn:queryString>SELECT DataType, DownloadExpirationTime, DownloadUrl, EndTime, ErrorMessage, LastReferencedDate, LastViewedDate, Name, OrganizationIds, PackageIds, RequestState, StartTime FROM AppAnalyticsQueryRequest</urn:queryString> </urn:query> </soapenv:Body> </soapenv:Envelope>
...but my query response is blank.
<queryResponse> <result> <done>true</done> <queryLocator xsi:nil="true"/> <size>0</size> </result> </queryResponse>
My Question: What are the correct steps to get analytics data back?
Now that I got it working, here are some troubleshooting lessons learned that I wish I had known:
- If you don’t specify an EndTime, the StartTime must be 7 days or fewer from today to avoid a limits error.
- You must specify values for either PackageIds or OrganizationIds. Both can’t be wildcard/blank.
- Values provided to OrganizationIds or PackageIds must use the 15-digit RecordID format.
- You can only run so many App Analytics queries per day against the same LMO (based on your license and such)
CustomObjectUsageSummarydoesn't work. Use