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 the Event Specifications plugin #1300

Merged
merged 1 commit into from
Mar 27, 2024

Conversation

igneel64
Copy link
Contributor

No description provided.

@igneel64 igneel64 force-pushed the feature/event-specifications-plugin branch from 3a9e2e2 to 618442e Compare March 25, 2024 10:49
Copy link

bundlemon bot commented Mar 25, 2024

BundleMon

Files added (6)
Status Path Size Limits
libraries/browser-tracker-core/dist/index.mod
ule.js
+26.51KB 27KB / +10%
trackers/javascript-tracker/dist/sp.js
+25.1KB 25.5KB / +10%
trackers/javascript-tracker/dist/sp.lite.js
+15.4KB 16KB / +10%
trackers/browser-tracker/dist/index.umd.min.j
s
+15.29KB 15.5KB / +10%
libraries/tracker-core/dist/index.module.js
+13.36KB 15KB / +10%
trackers/browser-tracker/dist/index.module.js
+3.51KB 5KB / +10%

Total files change +99.17KB 0%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history

@igneel64 igneel64 force-pushed the feature/event-specifications-plugin branch from 618442e to 639abcc Compare March 25, 2024 10:55
Copy link
Contributor

@matus-tomlein matus-tomlein left a comment

Choose a reason for hiding this comment

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

I like this, seems like a nice solution!

Just one question, did you consider having a typed interface for the EventSpecificationsPluginOptions constructor parameter? Currently users can pass Record<string, string> for the specific plugin events, which opens room for typos (e.g., play_evnt) and doesn't show the users what are the available options. It is more flexible for us this way, so it's a trade-off, just wanted to hear your thoughts on that.

activateBrowserPlugin: (tracker) => {
trackerId = tracker.id;
_trackers[trackerId] = tracker;
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: extra return

@igneel64
Copy link
Contributor Author

igneel64 commented Mar 27, 2024

Just one question, did you consider having a typed interface for the EventSpecificationsPluginOptions constructor parameter? Currently users can pass Record<string, string> for the specific plugin events, which opens room for typos (e.g., play_evnt) and doesn't show the users what are the available options. It is more flexible for us this way, so it's a trade-off, just wanted to hear your thoughts on that.

Good call!
The thinking is that this plugin input will never be typed by the user. It will be retrieved directly from the console like the following:
image

This is also mentioned in the README and will be added in the documentation page as well.

This configuration should be retrieved directly from your Data Product in the Snowplow BDP Console.

Does it make sense?

Copy link
Contributor

@matus-tomlein matus-tomlein left a comment

Choose a reason for hiding this comment

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

That makes sense! If it's going to be primarily used by copying from Console, then it should be fine this way.

Except for the one potential problem that I commented, this LGTM!

if (!matchedEvent) {
return;
}
const matchingPluginEventMap = Object.values(options).find(
Copy link
Contributor

@matus-tomlein matus-tomlein Mar 27, 2024

Choose a reason for hiding this comment

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

Why do we consider all integrations here? For instance if the user configured the plugin like this:

EventSpecificationPlugin({
  OtherPlugin: { play_event: "wrong" },
  SnowplowMediaPlugin: { play_event: "correct" },
})

And the current event was matched against the media plugin, wouldn't this code result in the wrong ES ID being taken?

This can't happen now since we only have one integration, but if there is such a problem, it would be good to solve it before we add more integrations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeap, fixed:

const matchingPluginEventMap = options[integrationKey as AvailablePlugins];
const matchingEventSpecificationId = matchingPluginEventMap && matchingPluginEventMap[matchedEvent];
if (!matchingEventSpecificationId) {
    return;
}

Plus both integrations and options can only have AvailablePlugins as keys

Copy link
Contributor

Choose a reason for hiding this comment

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

looks good!

@igneel64 igneel64 force-pushed the feature/event-specifications-plugin branch from b9c45bd to 5d531a6 Compare March 27, 2024 15:20
@matus-tomlein matus-tomlein changed the base branch from master to release/3.23.0 March 27, 2024 15:25
@igneel64 igneel64 merged commit b79b189 into release/3.23.0 Mar 27, 2024
2 of 3 checks passed
@igneel64 igneel64 deleted the feature/event-specifications-plugin branch March 27, 2024 15:41
@igneel64 igneel64 mentioned this pull request Mar 27, 2024
igneel64 added a commit that referenced this pull request Mar 28, 2024
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.

None yet

2 participants