Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a transformer to enforce current terminology in reportEvent without breaking Mixpanel events #8774

Merged
merged 19 commits into from
Jul 9, 2024

Conversation

grahamlangford
Copy link
Collaborator

What does this PR do?

  • Adds a type check to event payloads in reportEvent banning certain deprecated terms
  • Uses a transformer to send the new terms and the deprecated terms to Mixpanel

Discussion

  • We've been unable to remove outdated terms like blueprintId from reportEvent payloads because it breaks Mixpanel reports
  • By adding a transformer, we can force sending blueprintId && recipeId && modId for backwards compatibility
  • Once we've been doing this for long enough, we can remove the transformer and convert reports to rely on the new terms

For more information on our expectations for the PR process, see the
code review principles doc

*/
export async function clearExtensionDebugLogs(
extensionId: UUID,
export async function clearModComponentDebugLogs(
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not sure of the safety of changing the indexes for the database.

Since this is for debug and trace only it may be safe? Otherwise I can revert this change

Copy link
Contributor

Choose a reason for hiding this comment

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

Since this is for debug and trace only it may be safe?

I suspect we'd need to write some sort of migration. But I don't have enough experience with IDB to know

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's what I was wondering. I can look into it if we want to move forward with this concept

Copy link
Collaborator

@mnholtz mnholtz Jul 8, 2024

Choose a reason for hiding this comment

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

There's this comment here suggesting we don't really need the logs anyways?

// For now, just clear local logs whenever we need to upgrade the log database structure. There's no real use
// cases for looking at historic local logs
db.deleteObjectStore(ENTRY_OBJECT_STORE);
console.warn(
"Deleting object store %s for upgrade",
ENTRY_OBJECT_STORE,
);

But if we were to do it properly we'd bump the database version number and properly implement that upgrade function

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Per the comment, I'm just going to bump the version number

event: Event,
data: UnknownObject = {},
data: TData extends ReservedKeys ? never : TData = {} as never,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This type is a bit of a hack to prevent us from passing outdated terminology to reportEvent. The resulting ts error looks like:

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There might be a better type that explicitly states which key(s) is the problem, but this works as a POC

Copy link
Collaborator

Choose a reason for hiding this comment

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

What about never on the types of the individual offending properties? I'm sure we could get fancy with that somehow but it would obviously be nice to have a more specific type error

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually there's a much simpler solution that I didn't catch my first time around

Copy link
Collaborator

Choose a reason for hiding this comment

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

Did you make that change? I noticed you marked this ready for review

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i did

Copy link

github-actions bot commented Jul 8, 2024

Playwright test results

passed  84 passed
flaky  2 flaky
skipped  2 skipped

Details

report  Open report ↗︎
stats  88 tests across 31 suites
duration  14 minutes, 36 seconds
commit  545e1c7

Flaky tests

edge › tests/extensionConsole/modsPage.spec.ts › can open mod in the workshop
chrome › tests/regressions/welcomeStarterBricks.spec.ts › #8740: can view the starter mods on the pixiebrix.com/welcome page

Skipped tests

chrome › tests/runtime/googleSheetsIntegration.spec.ts › can activate a google spreadsheet mod with config options
edge › tests/runtime/googleSheetsIntegration.spec.ts › can activate a google spreadsheet mod with config options

Copy link

codecov bot commented Jul 8, 2024

Codecov Report

Attention: Patch coverage is 36.23188% with 44 lines in your changes missing coverage. Please review.

Project coverage is 74.19%. Comparing base (8318d74) to head (bddeca3).
Report is 35 commits behind head on main.

Files Patch % Lines
src/telemetry/telemetryHelpers.ts 0.00% 26 Missing ⚠️
src/data/service/errorService.ts 0.00% 4 Missing ⚠️
...ensionConsole/pages/packageEditor/useLogContext.ts 0.00% 4 Missing ⚠️
src/telemetry/logging.ts 20.00% 4 Missing ⚠️
...ionConsole/pages/mods/hooks/useReactivateAction.ts 0.00% 2 Missing ⚠️
src/telemetry/reportEvent.ts 0.00% 2 Missing ⚠️
src/bricks/renderers/customForm.tsx 66.66% 1 Missing ⚠️
src/telemetry/telemetryTypes.ts 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8774      +/-   ##
==========================================
- Coverage   74.24%   74.19%   -0.06%     
==========================================
  Files        1332     1333       +1     
  Lines       40817    40892      +75     
  Branches     7634     7651      +17     
==========================================
+ Hits        30306    30340      +34     
- Misses      10511    10552      +41     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@grahamlangford grahamlangford marked this pull request as ready for review July 9, 2024 14:39
Copy link

github-actions bot commented Jul 9, 2024

No loom links were found in the first post. Please add one there if you'd like to it to appear on Slack.

Do not edit this comment manually.

@grahamlangford grahamlangford merged commit 6c441b8 into main Jul 9, 2024
18 checks passed
@grahamlangford grahamlangford deleted the report-event-tranformer branch July 9, 2024 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants