How Should I Plan My App Analytics Query Strategy?
| Available in: both Salesforce Classic and Lightning Experience |
| Available in: Enterprise, Performance, Unlimited, and Developer Editions |
All partners can take advantage of these query strategies.
- Choose a data results FileType value, and select a corresponding FileCompression. With this query strategy, you can choose gzip compression for csv files or snappy column compression for parquet files.
- Create regularly scheduled, automated queries.
- To sweep in late-arriving data, create catch-up queries using the AvailableSince field.
Compress Your Results Files
Your App Analytics query plan starts with your results file type and file compression. Data can eat up time and space, so do more with less by specifying the type of file you download. Reduce your data download time by specifying how your results file is compressed.
If you don’t specify file type or file compression, your results file defaults to csv with no compression for backwards compatibility reasons. If you choose the parquet file type, your results file includes data type information for each column.
We recommend that you always compress your results files. Choose from these SOAP API AppAnalyticsQueryRequest FileType and FileCompression value combinations.
| FileType | FileCompression |
|---|---|
| csv (default) |
|
| parquet |
|
Schedule and Automate Your Queries
After you determine what queries to run and how often to run them, you want to schedule those queries. The easiest way is via automation.
What do we mean by automation? Write code that creates query request records on your schedule, monitors them, retrieves the data, and stores your AppExchange App Analytics data somewhere. For example, you can store the data in a custom object in your License Management Org.
Your automation options include, but aren’t limited to:
- Custom API integrations using REST or SOAP API calls
- Salesforce DX automation using the CLI
- Salesforce flows
- Apex triggers
For example, automate the retrieval of package usage summaries using Apex triggers.
If you want to also automate the retrieval of package usage log data, look to a different storage solution that scales with the data volume the logs contain.
Create Catch-Up Queries
A catch-up query is like a broom, sweeping for data newly added to our data lake. Catch-up queries rely on you already having regular queries in place.
For example, on March 2, 2021 18:00 UTC you run this regular query that retrieves package usage log data for March 1, 2021:
1sf data create record
2--sobjecttype AppAnalyticsQueryRequest
3--values "StartTime=2021-03-01T00:00:00Z
4EndTime=2021-03-02T00:00:00Z
5DataType=PackageUsageLog
6FileType=csv
7FileCompression=gzip"Rerun that exact same query on March 3, 2021 18:00 UTC, but add the AvailableSince field set to the day and time you ran your original query: 2021-03-02T18:00:00Z. This query is your ad hoc catch-up query. It retrieves any data newly added to the data lake for March 2 since you ran your regular query:
1sf data create record
2--sobjecttype AppAnalyticsQueryRequest
3--values "StartTime=2021-03-01T00:00:00Z
4EndTime=2021-03-02T00:00:00Z
5DataType=PackageUsageLog
6FileType=csv
7FileCompression=gzip
8AvailableSince=2021-03-02T18:00:00Z"You can use catch-up queries in many different ways, which we discuss in more detail in the Recommendations section.
When creating catch-up queries, keep these considerations in mind.
- If StartTime is specified, the AvailableSince date must be later.
- If EndTime is specified, the AvailableSince date must be later.
- All queries must include StartTime or AvailableSince or both.
- AvailableSince must be earlier than now.