Skip to content

feat(analytics): added trace debug mode and enhanced daily analytics#8

Open
simon-accoil wants to merge 1 commit intoanalyticsfrom
trace-mode-new-analytics
Open

feat(analytics): added trace debug mode and enhanced daily analytics#8
simon-accoil wants to merge 1 commit intoanalyticsfrom
trace-mode-new-analytics

Conversation

@simon-accoil
Copy link
Copy Markdown
Collaborator

Added a new trace debug mode (ANALYTICS_TRACE_DEBUG) for the analytics system, which makes real HTTP requests to Accoil APIs while logging detailed request and response information. This is helpful for debugging API integration issues.

Enhanced the daily analytics job to include more information from the app context, including app version, environment type, and all available license attributes. This information is collected using the Forge API's getAppContext function.

These changes provide more detailed analytics and debugging capabilities, assisting in the monitoring of request performance and the validation of successful data transmission.

Added a new trace debug mode (`ANALYTICS_TRACE_DEBUG`) for the analytics system, which makes real HTTP requests to Accoil APIs while logging detailed request and response information. This is helpful for debugging API integration issues.

Enhanced the daily analytics job to include more information from the app context, including app version, environment type, and all available license attributes. This information is collected using the Forge API's `getAppContext` function.

These changes provide more detailed analytics and debugging capabilities, assisting in the monitoring of request performance and the validation of successful data transmission.
@simon-accoil simon-accoil requested a review from accoilmj August 29, 2025 04:13

if (isTraceDebugMode) {
console.log(`TRACE DEBUG: Making HTTP request to ${url}`);
console.log(`TRACE DEBUG: Request headers:`, JSON.stringify({"Content-Type": "application/json"}, null, 2));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to either pre-emptively construct the fetch params object or move headers out somewhere so it's not statically redefined each time here and in the call to fetch below.

Comment thread src/analytics/schedule.js
totalTodoCount: `${await getTodoCount()}`,

// App Context API - App Version
appVersion: appContext.appVersion,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing appContext is always defined? This code intermixes use of null safe access ?. with direct access.

Comment thread src/analytics/schedule.js

// Filter out undefined values to keep payload clean
const filteredTraits = Object.fromEntries(
Object.entries(traits).filter(([_, value]) => value !== undefined)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably overkill I think as the eventual JSON.stringify should drop these from the payload:

JSON.stringify({"test": undefined, "test2": {"test": undefined, "foo": "bar"}})
'{"test2":{"foo":"bar"}}' 

If they're null though they will show up so maybe you want to remove those? I don't think it will break anything though:

JSON.stringify({"test": null})
'{"test":null}' 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants