@amplitude/analytics-react-native 0.3.3 → 0.4.1

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.
Files changed (119) hide show
  1. package/lib/commonjs/config.js +10 -18
  2. package/lib/commonjs/config.js.map +1 -1
  3. package/lib/commonjs/cookie-migration/index.js +3 -5
  4. package/lib/commonjs/cookie-migration/index.js.map +1 -1
  5. package/lib/commonjs/plugins/context.js +8 -2
  6. package/lib/commonjs/plugins/context.js.map +1 -1
  7. package/lib/commonjs/react-native-client.js +7 -11
  8. package/lib/commonjs/react-native-client.js.map +1 -1
  9. package/lib/commonjs/version.js +1 -1
  10. package/lib/commonjs/version.js.map +1 -1
  11. package/lib/module/config.js +1 -5
  12. package/lib/module/config.js.map +1 -1
  13. package/lib/module/cookie-migration/index.js +1 -2
  14. package/lib/module/cookie-migration/index.js.map +1 -1
  15. package/lib/module/plugins/context.js +7 -1
  16. package/lib/module/plugins/context.js.map +1 -1
  17. package/lib/module/react-native-client.js +1 -3
  18. package/lib/module/react-native-client.js.map +1 -1
  19. package/lib/module/version.js +1 -1
  20. package/lib/module/version.js.map +1 -1
  21. package/lib/typescript/config.d.ts +1 -2
  22. package/lib/typescript/config.d.ts.map +1 -1
  23. package/lib/typescript/cookie-migration/index.d.ts.map +1 -1
  24. package/lib/typescript/index.d.ts +1 -1
  25. package/lib/typescript/index.d.ts.map +1 -1
  26. package/lib/typescript/plugins/context.d.ts.map +1 -1
  27. package/lib/typescript/react-native-client.d.ts +3 -3
  28. package/lib/typescript/react-native-client.d.ts.map +1 -1
  29. package/lib/typescript/version.d.ts +1 -1
  30. package/package.json +5 -4
  31. package/src/config.ts +7 -5
  32. package/src/cookie-migration/index.ts +1 -2
  33. package/src/plugins/context.ts +7 -1
  34. package/src/react-native-client.ts +4 -7
  35. package/src/version.ts +1 -1
  36. package/lib/commonjs/attribution/campaign-parser.js +0 -74
  37. package/lib/commonjs/attribution/campaign-parser.js.map +0 -1
  38. package/lib/commonjs/attribution/campaign-tracker.js +0 -133
  39. package/lib/commonjs/attribution/campaign-tracker.js.map +0 -1
  40. package/lib/commonjs/attribution/constants.js +0 -47
  41. package/lib/commonjs/attribution/constants.js.map +0 -1
  42. package/lib/commonjs/plugins/identity.js +0 -40
  43. package/lib/commonjs/plugins/identity.js.map +0 -1
  44. package/lib/commonjs/session-manager.js +0 -114
  45. package/lib/commonjs/session-manager.js.map +0 -1
  46. package/lib/commonjs/storage/cookie.js +0 -124
  47. package/lib/commonjs/storage/cookie.js.map +0 -1
  48. package/lib/commonjs/storage/utm-cookie.js +0 -42
  49. package/lib/commonjs/storage/utm-cookie.js.map +0 -1
  50. package/lib/commonjs/transports/fetch.js +0 -34
  51. package/lib/commonjs/transports/fetch.js.map +0 -1
  52. package/lib/commonjs/utils/analytics-connector.js +0 -15
  53. package/lib/commonjs/utils/analytics-connector.js.map +0 -1
  54. package/lib/commonjs/utils/cookie-name.js +0 -23
  55. package/lib/commonjs/utils/cookie-name.js.map +0 -1
  56. package/lib/commonjs/utils/language.js +0 -18
  57. package/lib/commonjs/utils/language.js.map +0 -1
  58. package/lib/commonjs/utils/query-params.js +0 -43
  59. package/lib/commonjs/utils/query-params.js.map +0 -1
  60. package/lib/module/attribution/campaign-parser.js +0 -62
  61. package/lib/module/attribution/campaign-parser.js.map +0 -1
  62. package/lib/module/attribution/campaign-tracker.js +0 -120
  63. package/lib/module/attribution/campaign-tracker.js.map +0 -1
  64. package/lib/module/attribution/constants.js +0 -26
  65. package/lib/module/attribution/constants.js.map +0 -1
  66. package/lib/module/plugins/identity.js +0 -29
  67. package/lib/module/plugins/identity.js.map +0 -1
  68. package/lib/module/session-manager.js +0 -104
  69. package/lib/module/session-manager.js.map +0 -1
  70. package/lib/module/storage/cookie.js +0 -114
  71. package/lib/module/storage/cookie.js.map +0 -1
  72. package/lib/module/storage/utm-cookie.js +0 -32
  73. package/lib/module/storage/utm-cookie.js.map +0 -1
  74. package/lib/module/transports/fetch.js +0 -24
  75. package/lib/module/transports/fetch.js.map +0 -1
  76. package/lib/module/utils/analytics-connector.js +0 -5
  77. package/lib/module/utils/analytics-connector.js.map +0 -1
  78. package/lib/module/utils/cookie-name.js +0 -10
  79. package/lib/module/utils/cookie-name.js.map +0 -1
  80. package/lib/module/utils/language.js +0 -9
  81. package/lib/module/utils/language.js.map +0 -1
  82. package/lib/module/utils/query-params.js +0 -31
  83. package/lib/module/utils/query-params.js.map +0 -1
  84. package/lib/typescript/attribution/campaign-parser.d.ts +0 -10
  85. package/lib/typescript/attribution/campaign-parser.d.ts.map +0 -1
  86. package/lib/typescript/attribution/campaign-tracker.d.ts +0 -74
  87. package/lib/typescript/attribution/campaign-tracker.d.ts.map +0 -1
  88. package/lib/typescript/attribution/constants.d.ts +0 -17
  89. package/lib/typescript/attribution/constants.d.ts.map +0 -1
  90. package/lib/typescript/plugins/identity.d.ts +0 -9
  91. package/lib/typescript/plugins/identity.d.ts.map +0 -1
  92. package/lib/typescript/session-manager.d.ts +0 -28
  93. package/lib/typescript/session-manager.d.ts.map +0 -1
  94. package/lib/typescript/storage/cookie.d.ts +0 -12
  95. package/lib/typescript/storage/cookie.d.ts.map +0 -1
  96. package/lib/typescript/storage/utm-cookie.d.ts +0 -6
  97. package/lib/typescript/storage/utm-cookie.d.ts.map +0 -1
  98. package/lib/typescript/transports/fetch.d.ts +0 -6
  99. package/lib/typescript/transports/fetch.d.ts.map +0 -1
  100. package/lib/typescript/utils/analytics-connector.d.ts +0 -3
  101. package/lib/typescript/utils/analytics-connector.d.ts.map +0 -1
  102. package/lib/typescript/utils/cookie-name.d.ts +0 -3
  103. package/lib/typescript/utils/cookie-name.d.ts.map +0 -1
  104. package/lib/typescript/utils/language.d.ts +0 -2
  105. package/lib/typescript/utils/language.d.ts.map +0 -1
  106. package/lib/typescript/utils/query-params.d.ts +0 -3
  107. package/lib/typescript/utils/query-params.d.ts.map +0 -1
  108. package/src/attribution/campaign-parser.ts +0 -78
  109. package/src/attribution/campaign-tracker.ts +0 -112
  110. package/src/attribution/constants.ts +0 -32
  111. package/src/plugins/identity.ts +0 -21
  112. package/src/session-manager.ts +0 -81
  113. package/src/storage/cookie.ts +0 -97
  114. package/src/storage/utm-cookie.ts +0 -27
  115. package/src/transports/fetch.ts +0 -23
  116. package/src/utils/analytics-connector.ts +0 -5
  117. package/src/utils/cookie-name.ts +0 -9
  118. package/src/utils/language.ts +0 -7
  119. 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
- }
@@ -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
- }
@@ -1,5 +0,0 @@
1
- import { AnalyticsConnector } from '@amplitude/analytics-connector';
2
-
3
- export const getAnalyticsConnector = (): AnalyticsConnector => {
4
- return AnalyticsConnector.getInstance('$default_instance');
5
- };
@@ -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
- };
@@ -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' || !window.location || !window.location.search) {
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
- };