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

fix: make cajs less painful with nextjs #457

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/client/analyticsFetchClient.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {AnalyticsRequestClient, IAnalyticsRequestOptions, IAnalyticsClientOptions} from './analyticsRequestClient';
import {AnyEventResponse, EventType, IRequestPayload} from '../events';
import {fetch} from 'cross-fetch';
import {crossFetch} from 'cross-fetch';

const isoFetch = fetch ?? crossFetch;
export class AnalyticsFetchClient implements AnalyticsRequestClient {
constructor(private opts: IAnalyticsClientOptions) {}

Expand All @@ -25,7 +26,7 @@ export class AnalyticsFetchClient implements AnalyticsRequestClient {
let response: Response;

try {
response = await fetch(url, fetchData);
response = await isoFetch(url, fetchData);
} catch (error) {
console.error('An error has occured when sending the event.', error);
return;
Expand Down
4 changes: 2 additions & 2 deletions src/donottrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
// gathering data of actions of an user as long as it is not associated to the
// identity of that user, doNotTrack is not enabled here.

import {hasNavigator} from './detector';
import {hasNavigator, hasWindow} from './detector';

const doNotTrackValues = ['1', 1, 'yes', true];

export function doNotTrack(): boolean {
return (
hasNavigator() &&
hasNavigator() && hasWindow() &&
[
(<any>navigator).globalPrivacyControl,
(<any>navigator).doNotTrack,
Expand Down
Loading