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