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

Add feature usage observer. #1919

Merged
merged 17 commits into from
Nov 14, 2023
Merged

Add feature usage observer. #1919

merged 17 commits into from
Nov 14, 2023

Conversation

Soare-Robert-Daniel
Copy link
Contributor

@Soare-Robert-Daniel Soare-Robert-Daniel commented Oct 10, 2023

Closes #.

Summary

Add a system to observer the features used in the plugin.

Screenshots


Test instructions


Checklist before the final review

  • Included E2E or unit tests for the changes in this PR.
  • Visual elements are not affected by independent changes.
  • It is at least compatible with the minimum WordPress version.
  • It loads additional script in frontend only if it is required.
  • Does not impact the Core Web Vitals.
  • In case of deprecation, old blocks are safely migrated.
  • It is usable in Widgets and FSE.
  • Copy/Paste is working if the attributes are modified.
  • PR is following the best practices

@Soare-Robert-Daniel Soare-Robert-Daniel self-assigned this Oct 10, 2023
@Soare-Robert-Daniel
Copy link
Contributor Author

How to set up the dummy server.

ℹ️ You will need Node/Bun with MongoDB (preferably with Docker)

Server script: https://pastebin.com/1VVwEE9i | package.json script: https://pastebin.com/nAdydQHQ

Install with npm ci and run with node server.js or bun server.js

For mongo, open docker and run this command:

docker run -d --name tracking-db-mongo -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=admin mongo

You will need to create a database with name otter and a collection with name tracking. If you use the Mongo Compass app this can be done by pressing the plus button in the top-left area near the Databases label.

Other info

JS tracking script: https://github.com/Codeinwp/otter-blocks/blob/03d57579444ea0dc4f997399a14c6c0d20fa5ac7/src/blocks/helpers/tracking.js

PHP tracking script: https://github.com/Codeinwp/otter-blocks/blob/03d57579444ea0dc4f997399a14c6c0d20fa5ac7/inc/Tracker.php

JS Script usage.

Use set function to set an event and a key that allows you to change it. Use this when you want the event to have the last values.

Use add function for things that do not change frequently or to register unique events. This function uses the set function, and the key is the hash of the object.

ℹ️ Consult the source code to see different options for those functions.

Use start, stop, refresh to start an interval for sending an event once in 5 minutes. This is not usually necessary since events are sent automatically when the user exits the page or saves the post in Post Editor.

@Soare-Robert-Daniel Soare-Robert-Daniel marked this pull request as ready for review October 12, 2023 08:59
@pirate-bot
Copy link
Contributor

pirate-bot commented Oct 12, 2023

Bundle Size Diff

Package Old Size New Size Diff
Animations 275.01 KB 275.01 KB 0 B (0.00%)
Blocks 1.48 MB 1.48 MB 1.7 KB (0.11%)
CSS 89.3 KB 89.37 KB 66 B (0.07%)
Dashboard 132.27 KB 132.62 KB 354 B (0.26%)
Export Import 87.21 KB 87.21 KB 0 B (0.00%)
Pro 346.65 KB 348.97 KB 2.32 KB (0.67%)

@pirate-bot
Copy link
Contributor

pirate-bot commented Oct 12, 2023

Plugin build for fa0295a is ready 🛎️!

@pirate-bot pirate-bot added the pr-checklist-incomplete The Pull Request checklist is incomplete. (automatic label) label Oct 12, 2023
@Soare-Robert-Daniel Soare-Robert-Daniel added the pr-checklist-skip Allow this Pull Request to skip checklist. label Oct 12, 2023
@pirate-bot pirate-bot added pr-checklist-complete The Pull Request checklist is complete. (automatic label) and removed pr-checklist-incomplete The Pull Request checklist is incomplete. (automatic label) labels Oct 12, 2023
@HardeepAsrani
Copy link
Member

@Soare-Robert-Daniel Can you fix the PHPStan errors?

@pirate-bot
Copy link
Contributor

pirate-bot commented Oct 13, 2023

E2E Summary

Typing

Test Average Time (ms) Standard Deviation (ms) Median Time (ms) Quantile for soft limit (%) Quantile for hard limit (%)
Typing 85.02 12.29 87.12 5.26 (60ms) 21.05 (80ms)
Values above 60ms "0 - 61.73, 2 - 65.14, 3 - 77.28, 4 - 87.12, 5 - 81.44, 6 - 93.46, 7 - 88.37, 8 - 85.07, 9 - 98.34, 10 - 98.93, 11 - 98.89, 12 - 98.58, 13 - 85.30, 14 - 92.53, 15 - 85.98, 16 - 88.08, 17 - 85.42, 18 - 89.38"

inc/Tracker.php Outdated Show resolved Hide resolved
@HardeepAsrani HardeepAsrani changed the base branch from development to next November 14, 2023 13:20
@HardeepAsrani HardeepAsrani merged commit 0a550c8 into next Nov 14, 2023
@HardeepAsrani HardeepAsrani deleted the feat/tracking branch November 14, 2023 19:42
@pirate-bot
Copy link
Contributor

🎉 This PR is included in version 2.5.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@pirate-bot pirate-bot added the released Indicate that an issue has been resolved and released in a particular version of the product. label Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-checklist-complete The Pull Request checklist is complete. (automatic label) pr-checklist-skip Allow this Pull Request to skip checklist. released Indicate that an issue has been resolved and released in a particular version of the product.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants