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

Moved configuring to service provider. #1

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

dkulyk
Copy link

@dkulyk dkulyk commented Apr 30, 2021

GA4MeasurementProtocol required configuration for using. This is a problem for using it manually without package configuring.

Also need to send additional user parameters with events like user_id.

Comment on lines +28 to +32
if (config('google-analytics-4-measurement-protocol.measurement_id') === null
|| config('google-analytics-4-measurement-protocol.api_secret') === null
) {
throw new Exception('Please set .env variables for Google Analytics 4 Measurement Protocol as per the readme file first.');
}
Copy link
Member

Choose a reason for hiding this comment

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

Does this mean that someone will face this exception for any request just after installing the package until they set the .env vars?

Copy link
Author

Choose a reason for hiding this comment

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

This called only on resolving 'ga4'. Same as in the constructor.

Comment on lines +37 to +44
function () {
$clientId = session(config('google-analytics-4-measurement-protocol.client_id_session_key'));
if (empty($clientId)) {
throw new Exception('Please use the package provided blade directive or set client_id manually before posting an event.');
}

return $clientId;
}
Copy link
Member

Choose a reason for hiding this comment

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

What is the benefit of passing the closure from here instead of keeping the login inside the facade?

Copy link
Author

Choose a reason for hiding this comment

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

Service class should not know about configuration. But provider must configuring service.

@gauravmak
Copy link
Member

Thanks for the PR Dmytro.

Also need to send additional user parameters with events like user_id.

Maybe we can have a separate PR for this to keep things simple?

@dkulyk
Copy link
Author

dkulyk commented May 1, 2021

Reverted "Also need to send additional user parameters with events like user_id."

Simplified using only clientId for allow Closure for dynamic resolver for clientId

@dkulyk dkulyk requested a review from gauravmak May 1, 2021 14:27
@dkulyk dkulyk changed the title Moved configuring to service provider. Added post() method for raw payload. Moved configuring to service provider. May 1, 2021
@gauravmak
Copy link
Member

A bit occupied these days. Will revert after 17th May, thanks.

@gauravmak
Copy link
Member

@dkulyk I haven't added any tests in the package yet. Reason - I wasn't sure how to.

Do you have any ideas?

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