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

feat(useCookie): skip anonymous userToken if useCookie is false #236

Merged
merged 12 commits into from
Dec 22, 2020

Conversation

eunjae-lee
Copy link
Contributor

@eunjae-lee eunjae-lee commented Dec 15, 2020

This PR adds an option useCookie to init method.
Its default value is true, but it needs to be false in the next major version to avoid the situation where our customers set cookies in end-users' browsers without knowing it.

hasUserOptedOut vs useCookie

If user denies to be tracked, for example, by clicking "deny" button on a cookie popup, then userHasOptedOut should be true, and search-insights won't send any event from the user. So this is per-user setting.

On the other hand, if a website decides not to use anonymous user token in cookie at all, then they can set useCookie: false. It means search-insights will not generate/store any anonymous user token in the cookie. So aa will not have any user token initially. setUserToken must be called explicitly. Once a userToken is set, it will send events.

@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 15, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit fa4e239:

Sandbox Source
Vanilla Configuration

lib/init.ts Show resolved Hide resolved
lib/_tokenUtils.ts Outdated Show resolved Hide resolved
@eunjae-lee eunjae-lee requested a review from a team December 15, 2020 13:38
@ghost ghost requested review from francoischalifour and Haroenv and removed request for a team December 15, 2020 13:38
README.md Outdated
@@ -65,6 +65,7 @@ aa('setUserToken', 'USER_ID');
| **`apiKey`** | `string` | None (required) | The search API key of your Algolia application |
| `userHasOptedOut` | `boolean` | `false` | Whether to exclude users from analytics |
| `region` | `'de' \| 'us'` | Automatic | The DNS server to target |
| `useCookie` | `boolean` | `true` | Whether to use cookie in browser environment. The anonymous user token will not be set if `false`. |
Copy link
Contributor

Choose a reason for hiding this comment

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

after this, I think we should release a version with useCookie as true

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean false as a breaking change? It's true by default.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, sorry I meant false in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah it should be false in the next major version.

lib/_tokenUtils.ts Show resolved Hide resolved
@eunjae-lee eunjae-lee requested a review from Haroenv December 22, 2020 09:48
Copy link
Contributor

@Haroenv Haroenv left a comment

Choose a reason for hiding this comment

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

good to go!

@eunjae-lee eunjae-lee changed the title skip anonymous userToken if useCookie is false feat(useCookie): skip anonymous userToken if useCookie is false Dec 22, 2020
@eunjae-lee eunjae-lee merged commit db09c7e into master Dec 22, 2020
@eunjae-lee eunjae-lee deleted the feat/use-cookie branch December 22, 2020 10:21
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.

3 participants