@amplitude/analytics-react-native 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/config.js +10 -18
- package/lib/commonjs/config.js.map +1 -1
- package/lib/commonjs/cookie-migration/index.js +3 -5
- package/lib/commonjs/cookie-migration/index.js.map +1 -1
- package/lib/commonjs/plugins/context.js +8 -2
- package/lib/commonjs/plugins/context.js.map +1 -1
- package/lib/commonjs/react-native-client.js +7 -11
- package/lib/commonjs/react-native-client.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/config.js +1 -5
- package/lib/module/config.js.map +1 -1
- package/lib/module/cookie-migration/index.js +1 -2
- package/lib/module/cookie-migration/index.js.map +1 -1
- package/lib/module/plugins/context.js +7 -1
- package/lib/module/plugins/context.js.map +1 -1
- package/lib/module/react-native-client.js +1 -3
- package/lib/module/react-native-client.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/config.d.ts +1 -2
- package/lib/typescript/config.d.ts.map +1 -1
- package/lib/typescript/cookie-migration/index.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/plugins/context.d.ts.map +1 -1
- package/lib/typescript/react-native-client.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +5 -4
- package/src/config.ts +7 -5
- package/src/cookie-migration/index.ts +1 -2
- package/src/plugins/context.ts +7 -1
- package/src/react-native-client.ts +1 -3
- package/src/version.ts +1 -1
- package/lib/commonjs/attribution/campaign-parser.js +0 -74
- package/lib/commonjs/attribution/campaign-parser.js.map +0 -1
- package/lib/commonjs/attribution/campaign-tracker.js +0 -133
- package/lib/commonjs/attribution/campaign-tracker.js.map +0 -1
- package/lib/commonjs/attribution/constants.js +0 -47
- package/lib/commonjs/attribution/constants.js.map +0 -1
- package/lib/commonjs/plugins/identity.js +0 -40
- package/lib/commonjs/plugins/identity.js.map +0 -1
- package/lib/commonjs/session-manager.js +0 -114
- package/lib/commonjs/session-manager.js.map +0 -1
- package/lib/commonjs/storage/cookie.js +0 -124
- package/lib/commonjs/storage/cookie.js.map +0 -1
- package/lib/commonjs/storage/utm-cookie.js +0 -42
- package/lib/commonjs/storage/utm-cookie.js.map +0 -1
- package/lib/commonjs/transports/fetch.js +0 -34
- package/lib/commonjs/transports/fetch.js.map +0 -1
- package/lib/commonjs/utils/analytics-connector.js +0 -15
- package/lib/commonjs/utils/analytics-connector.js.map +0 -1
- package/lib/commonjs/utils/cookie-name.js +0 -23
- package/lib/commonjs/utils/cookie-name.js.map +0 -1
- package/lib/commonjs/utils/language.js +0 -18
- package/lib/commonjs/utils/language.js.map +0 -1
- package/lib/commonjs/utils/query-params.js +0 -43
- package/lib/commonjs/utils/query-params.js.map +0 -1
- package/lib/module/attribution/campaign-parser.js +0 -62
- package/lib/module/attribution/campaign-parser.js.map +0 -1
- package/lib/module/attribution/campaign-tracker.js +0 -120
- package/lib/module/attribution/campaign-tracker.js.map +0 -1
- package/lib/module/attribution/constants.js +0 -26
- package/lib/module/attribution/constants.js.map +0 -1
- package/lib/module/plugins/identity.js +0 -29
- package/lib/module/plugins/identity.js.map +0 -1
- package/lib/module/session-manager.js +0 -104
- package/lib/module/session-manager.js.map +0 -1
- package/lib/module/storage/cookie.js +0 -114
- package/lib/module/storage/cookie.js.map +0 -1
- package/lib/module/storage/utm-cookie.js +0 -32
- package/lib/module/storage/utm-cookie.js.map +0 -1
- package/lib/module/transports/fetch.js +0 -24
- package/lib/module/transports/fetch.js.map +0 -1
- package/lib/module/utils/analytics-connector.js +0 -5
- package/lib/module/utils/analytics-connector.js.map +0 -1
- package/lib/module/utils/cookie-name.js +0 -10
- package/lib/module/utils/cookie-name.js.map +0 -1
- package/lib/module/utils/language.js +0 -9
- package/lib/module/utils/language.js.map +0 -1
- package/lib/module/utils/query-params.js +0 -31
- package/lib/module/utils/query-params.js.map +0 -1
- package/lib/typescript/attribution/campaign-parser.d.ts +0 -10
- package/lib/typescript/attribution/campaign-parser.d.ts.map +0 -1
- package/lib/typescript/attribution/campaign-tracker.d.ts +0 -74
- package/lib/typescript/attribution/campaign-tracker.d.ts.map +0 -1
- package/lib/typescript/attribution/constants.d.ts +0 -17
- package/lib/typescript/attribution/constants.d.ts.map +0 -1
- package/lib/typescript/plugins/identity.d.ts +0 -9
- package/lib/typescript/plugins/identity.d.ts.map +0 -1
- package/lib/typescript/session-manager.d.ts +0 -28
- package/lib/typescript/session-manager.d.ts.map +0 -1
- package/lib/typescript/storage/cookie.d.ts +0 -12
- package/lib/typescript/storage/cookie.d.ts.map +0 -1
- package/lib/typescript/storage/utm-cookie.d.ts +0 -6
- package/lib/typescript/storage/utm-cookie.d.ts.map +0 -1
- package/lib/typescript/transports/fetch.d.ts +0 -6
- package/lib/typescript/transports/fetch.d.ts.map +0 -1
- package/lib/typescript/utils/analytics-connector.d.ts +0 -3
- package/lib/typescript/utils/analytics-connector.d.ts.map +0 -1
- package/lib/typescript/utils/cookie-name.d.ts +0 -3
- package/lib/typescript/utils/cookie-name.d.ts.map +0 -1
- package/lib/typescript/utils/language.d.ts +0 -2
- package/lib/typescript/utils/language.d.ts.map +0 -1
- package/lib/typescript/utils/query-params.d.ts +0 -3
- package/lib/typescript/utils/query-params.d.ts.map +0 -1
- package/src/attribution/campaign-parser.ts +0 -78
- package/src/attribution/campaign-tracker.ts +0 -112
- package/src/attribution/constants.ts +0 -32
- package/src/plugins/identity.ts +0 -21
- package/src/session-manager.ts +0 -81
- package/src/storage/cookie.ts +0 -97
- package/src/storage/utm-cookie.ts +0 -27
- package/src/transports/fetch.ts +0 -23
- package/src/utils/analytics-connector.ts +0 -5
- package/src/utils/cookie-name.ts +0 -9
- package/src/utils/language.ts +0 -7
- package/src/utils/query-params.ts +0 -26
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { CookieStorage } from './cookie';
|
|
2
|
-
|
|
3
|
-
export class UTMCookie extends CookieStorage<Record<string, string | undefined>> {
|
|
4
|
-
async get(key: string): Promise<Record<string, string | undefined> | undefined> {
|
|
5
|
-
try {
|
|
6
|
-
const value = await this.getRaw(key);
|
|
7
|
-
if (!value) {
|
|
8
|
-
return undefined;
|
|
9
|
-
}
|
|
10
|
-
const entries = value.split('.').splice(-1)[0].split('|');
|
|
11
|
-
return entries.reduce<Record<string, string | undefined>>((acc, curr) => {
|
|
12
|
-
const [key, value = ''] = curr.split('=', 2);
|
|
13
|
-
if (!value) {
|
|
14
|
-
return acc;
|
|
15
|
-
}
|
|
16
|
-
acc[key] = decodeURIComponent(value);
|
|
17
|
-
return acc;
|
|
18
|
-
}, {});
|
|
19
|
-
} catch {
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
async set(): Promise<void> {
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
}
|
package/src/transports/fetch.ts
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { BaseTransport } from '@amplitude/analytics-core';
|
|
2
|
-
import { Payload, Response, Transport } from '@amplitude/analytics-types';
|
|
3
|
-
|
|
4
|
-
export class FetchTransport extends BaseTransport implements Transport {
|
|
5
|
-
async send(serverUrl: string, payload: Payload): Promise<Response | null> {
|
|
6
|
-
/* istanbul ignore if */
|
|
7
|
-
if (typeof fetch === 'undefined') {
|
|
8
|
-
throw new Error('FetchTransport is not supported');
|
|
9
|
-
}
|
|
10
|
-
const options: RequestInit = {
|
|
11
|
-
headers: {
|
|
12
|
-
'Content-Type': 'application/json',
|
|
13
|
-
Accept: '*/*',
|
|
14
|
-
},
|
|
15
|
-
body: JSON.stringify(payload),
|
|
16
|
-
method: 'POST',
|
|
17
|
-
};
|
|
18
|
-
const response = await fetch(serverUrl, options);
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
20
|
-
const responsePayload: Record<string, any> = await response.json();
|
|
21
|
-
return this.buildResponse(responsePayload);
|
|
22
|
-
}
|
|
23
|
-
}
|
package/src/utils/cookie-name.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AMPLITUDE_PREFIX } from '@amplitude/analytics-core';
|
|
2
|
-
|
|
3
|
-
export const getCookieName = (apiKey: string, postKey = '', limit = 10) => {
|
|
4
|
-
return [AMPLITUDE_PREFIX, postKey, apiKey.substring(0, limit)].filter(Boolean).join('_');
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export const getOldCookieName = (apiKey: string) => {
|
|
8
|
-
return `${AMPLITUDE_PREFIX.toLowerCase()}_${apiKey.substring(0, 6)}`;
|
|
9
|
-
};
|
package/src/utils/language.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export const getLanguage = (): string => {
|
|
2
|
-
if (typeof navigator === 'undefined') return '';
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
4
|
-
const userLanguage = (navigator as any).userLanguage as string | undefined;
|
|
5
|
-
|
|
6
|
-
return navigator.languages?.[0] ?? navigator.language ?? userLanguage ?? '';
|
|
7
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export const getQueryParams = (): Record<string, string | undefined> => {
|
|
2
|
-
/* istanbul ignore if */
|
|
3
|
-
if (typeof window === 'undefined') {
|
|
4
|
-
return {};
|
|
5
|
-
}
|
|
6
|
-
const pairs = window.location.search.substring(1).split('&').filter(Boolean);
|
|
7
|
-
const params = pairs.reduce<Record<string, string | undefined>>((acc, curr) => {
|
|
8
|
-
const query = curr.split('=', 2);
|
|
9
|
-
const key = tryDecodeURIComponent(query[0]);
|
|
10
|
-
const value = tryDecodeURIComponent(query[1]);
|
|
11
|
-
if (!value) {
|
|
12
|
-
return acc;
|
|
13
|
-
}
|
|
14
|
-
acc[key] = value;
|
|
15
|
-
return acc;
|
|
16
|
-
}, {});
|
|
17
|
-
return params;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const tryDecodeURIComponent = (value = '') => {
|
|
21
|
-
try {
|
|
22
|
-
return decodeURIComponent(value);
|
|
23
|
-
} catch {
|
|
24
|
-
return '';
|
|
25
|
-
}
|
|
26
|
-
};
|