@amplitude/analytics-react-native 0.0.1-dev.6 → 0.0.1-dev.7

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 (107) hide show
  1. package/README.md +150 -0
  2. package/android/src/main/java/com/amplitude/reactnative/AmplitudeReactNativeModule.kt +5 -5
  3. package/ios/AmplitudeReactNative.swift +4 -4
  4. package/lib/commonjs/attribution/campaign-tracker.js +1 -1
  5. package/lib/commonjs/attribution/campaign-tracker.js.map +1 -1
  6. package/lib/commonjs/config.js +2 -22
  7. package/lib/commonjs/config.js.map +1 -1
  8. package/lib/commonjs/index.js +2 -16
  9. package/lib/commonjs/index.js.map +1 -1
  10. package/lib/commonjs/plugins/context.js +4 -4
  11. package/lib/commonjs/plugins/context.js.map +1 -1
  12. package/lib/commonjs/plugins/identity.js +40 -0
  13. package/lib/commonjs/plugins/identity.js.map +1 -0
  14. package/lib/commonjs/react-native-client.js +23 -57
  15. package/lib/commonjs/react-native-client.js.map +1 -1
  16. package/lib/commonjs/storage/cookie.js +1 -6
  17. package/lib/commonjs/storage/cookie.js.map +1 -1
  18. package/lib/commonjs/utils/analytics-connector.js +15 -0
  19. package/lib/commonjs/utils/analytics-connector.js.map +1 -0
  20. package/lib/commonjs/utils/query-params.js +1 -6
  21. package/lib/commonjs/utils/query-params.js.map +1 -1
  22. package/lib/commonjs/version.js +1 -1
  23. package/lib/commonjs/version.js.map +1 -1
  24. package/lib/module/attribution/campaign-tracker.js +1 -1
  25. package/lib/module/attribution/campaign-tracker.js.map +1 -1
  26. package/lib/module/config.js +1 -15
  27. package/lib/module/config.js.map +1 -1
  28. package/lib/module/index.js +3 -4
  29. package/lib/module/index.js.map +1 -1
  30. package/lib/module/plugins/context.js +4 -4
  31. package/lib/module/plugins/context.js.map +1 -1
  32. package/lib/module/plugins/identity.js +29 -0
  33. package/lib/module/plugins/identity.js.map +1 -0
  34. package/lib/module/react-native-client.js +21 -55
  35. package/lib/module/react-native-client.js.map +1 -1
  36. package/lib/module/storage/cookie.js +1 -6
  37. package/lib/module/storage/cookie.js.map +1 -1
  38. package/lib/module/utils/analytics-connector.js +5 -0
  39. package/lib/module/utils/analytics-connector.js.map +1 -0
  40. package/lib/module/utils/query-params.js +1 -6
  41. package/lib/module/utils/query-params.js.map +1 -1
  42. package/lib/module/version.js +1 -1
  43. package/lib/module/version.js.map +1 -1
  44. package/lib/typescript/config.d.ts +1 -4
  45. package/lib/typescript/config.d.ts.map +1 -1
  46. package/lib/typescript/index.d.ts +2 -4
  47. package/lib/typescript/index.d.ts.map +1 -1
  48. package/lib/typescript/plugins/context.d.ts +5 -5
  49. package/lib/typescript/plugins/context.d.ts.map +1 -1
  50. package/lib/typescript/plugins/identity.d.ts +9 -0
  51. package/lib/typescript/plugins/identity.d.ts.map +1 -0
  52. package/lib/typescript/react-native-client.d.ts +7 -26
  53. package/lib/typescript/react-native-client.d.ts.map +1 -1
  54. package/lib/typescript/storage/cookie.d.ts.map +1 -1
  55. package/lib/typescript/utils/analytics-connector.d.ts +3 -0
  56. package/lib/typescript/utils/analytics-connector.d.ts.map +1 -0
  57. package/lib/typescript/utils/query-params.d.ts.map +1 -1
  58. package/lib/typescript/version.d.ts +1 -1
  59. package/package.json +1 -2
  60. package/lib/commonjs/constants.js +0 -31
  61. package/lib/commonjs/constants.js.map +0 -1
  62. package/lib/commonjs/transports/send-beacon.js +0 -43
  63. package/lib/commonjs/transports/send-beacon.js.map +0 -1
  64. package/lib/commonjs/transports/xhr.js +0 -54
  65. package/lib/commonjs/transports/xhr.js.map +0 -1
  66. package/lib/commonjs/utils/snippet-helper.js +0 -56
  67. package/lib/commonjs/utils/snippet-helper.js.map +0 -1
  68. package/lib/module/constants.js +0 -13
  69. package/lib/module/constants.js.map +0 -1
  70. package/lib/module/transports/send-beacon.js +0 -33
  71. package/lib/module/transports/send-beacon.js.map +0 -1
  72. package/lib/module/transports/xhr.js +0 -44
  73. package/lib/module/transports/xhr.js.map +0 -1
  74. package/lib/module/utils/snippet-helper.js +0 -41
  75. package/lib/module/utils/snippet-helper.js.map +0 -1
  76. package/lib/typescript/constants.d.ts +0 -13
  77. package/lib/typescript/constants.d.ts.map +0 -1
  78. package/lib/typescript/transports/send-beacon.d.ts +0 -6
  79. package/lib/typescript/transports/send-beacon.d.ts.map +0 -1
  80. package/lib/typescript/transports/xhr.d.ts +0 -7
  81. package/lib/typescript/transports/xhr.d.ts.map +0 -1
  82. package/lib/typescript/utils/snippet-helper.d.ts +0 -16
  83. package/lib/typescript/utils/snippet-helper.d.ts.map +0 -1
  84. package/src/attribution/campaign-parser.ts +0 -78
  85. package/src/attribution/campaign-tracker.ts +0 -112
  86. package/src/attribution/constants.ts +0 -32
  87. package/src/config.ts +0 -240
  88. package/src/constants.ts +0 -14
  89. package/src/cookie-migration/index.ts +0 -54
  90. package/src/index.ts +0 -24
  91. package/src/plugins/context.ts +0 -106
  92. package/src/react-native-client.ts +0 -366
  93. package/src/session-manager.ts +0 -81
  94. package/src/storage/cookie.ts +0 -100
  95. package/src/storage/local-storage.ts +0 -67
  96. package/src/storage/utm-cookie.ts +0 -27
  97. package/src/transports/fetch.ts +0 -23
  98. package/src/transports/send-beacon.ts +0 -34
  99. package/src/transports/xhr.ts +0 -36
  100. package/src/typings/browser-snippet.d.ts +0 -7
  101. package/src/typings/ua-parser.d.ts +0 -4
  102. package/src/utils/cookie-name.ts +0 -9
  103. package/src/utils/language.ts +0 -7
  104. package/src/utils/platform.ts +0 -9
  105. package/src/utils/query-params.ts +0 -21
  106. package/src/utils/snippet-helper.ts +0 -35
  107. package/src/version.ts +0 -1
@@ -1,36 +0,0 @@
1
- import { BaseTransport } from '@amplitude/analytics-core';
2
- import { Payload, Response, Transport } from '@amplitude/analytics-types';
3
-
4
- export class XHRTransport extends BaseTransport implements Transport {
5
- private state = {
6
- done: 4,
7
- };
8
-
9
- async send(serverUrl: string, payload: Payload): Promise<Response | null> {
10
- return new Promise((resolve, reject) => {
11
- /* istanbul ignore if */
12
- if (typeof XMLHttpRequest === 'undefined') {
13
- reject(new Error('XHRTransport is not supported.'));
14
- }
15
-
16
- const xhr = new XMLHttpRequest();
17
- xhr.open('POST', serverUrl, true);
18
- xhr.onreadystatechange = () => {
19
- if (xhr.readyState === this.state.done) {
20
- try {
21
- const responsePayload = xhr.responseText;
22
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
23
- const parsedResponsePayload: Record<string, any> = JSON.parse(responsePayload);
24
- const result = this.buildResponse(parsedResponsePayload);
25
- resolve(result);
26
- } catch (e) {
27
- reject(e);
28
- }
29
- }
30
- };
31
- xhr.setRequestHeader('Content-Type', 'application/json');
32
- xhr.setRequestHeader('Accept', '*/*');
33
- xhr.send(JSON.stringify(payload));
34
- });
35
- }
36
- }
@@ -1,7 +0,0 @@
1
- import { InstanceProxy } from '@amplitude/analytics-types';
2
-
3
- declare global {
4
- // globalThis only includes `var` declarations
5
- // eslint-disable-next-line no-var
6
- var amplitude: InstanceProxy & { invoked: boolean };
7
- }
@@ -1,4 +0,0 @@
1
- declare module '@amplitude/ua-parser-js' {
2
- import UAParser from 'ua-parser-js';
3
- export = UAParser;
4
- }
@@ -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,9 +0,0 @@
1
- import { Platform } from 'react-native';
2
-
3
- export const isWeb = (): boolean => {
4
- return Platform.OS === 'web';
5
- };
6
-
7
- export const isNative = (): boolean => {
8
- return !isWeb();
9
- };
@@ -1,21 +0,0 @@
1
- import { isNative } from './platform';
2
-
3
- export const getQueryParams = (): Record<string, string | undefined> => {
4
- if (isNative()) {
5
- return {};
6
- }
7
- /* istanbul ignore if */
8
- if (typeof window === 'undefined') {
9
- return {};
10
- }
11
- const pairs = window.location.search.substring(1).split('&').filter(Boolean);
12
- const params = pairs.reduce<Record<string, string | undefined>>((acc, curr) => {
13
- const [key, value = ''] = curr.split('=', 2);
14
- if (!value) {
15
- return acc;
16
- }
17
- acc[decodeURIComponent(key)] = decodeURIComponent(value);
18
- return acc;
19
- }, {});
20
- return params;
21
- };
@@ -1,35 +0,0 @@
1
- import { AmplitudeReturn, InstanceProxy, QueueProxy, Result } from '@amplitude/analytics-types';
2
-
3
- /**
4
- * Applies the proxied functions on the proxied amplitude snippet to an instance of the real object.
5
- * @ignore
6
- */
7
- export const runQueuedFunctions = (instance: object, queue: QueueProxy) => {
8
- convertProxyObjectToRealObject(instance, queue);
9
- };
10
-
11
- /**
12
- * Applies the proxied functions on the proxied object to an instance of the real object.
13
- * Used to convert proxied Identify and Revenue objects.
14
- */
15
- export const convertProxyObjectToRealObject = <T>(instance: T, queue: QueueProxy): T => {
16
- for (let i = 0; i < queue.length; i++) {
17
- const { name, args, resolve } = queue[i];
18
- const fn = instance && instance[name as keyof T];
19
- if (typeof fn === 'function') {
20
- const result = fn.apply(instance, args) as AmplitudeReturn<Promise<Result>>;
21
- if (typeof resolve === 'function') {
22
- resolve(result?.promise);
23
- }
24
- }
25
- }
26
- return instance;
27
- };
28
-
29
- /**
30
- * Check if the param is snippet proxy
31
- */
32
- export const isInstanceProxy = (instance: unknown): instance is InstanceProxy => {
33
- const instanceProxy = instance as InstanceProxy;
34
- return instanceProxy && instanceProxy._q !== undefined;
35
- };
package/src/version.ts DELETED
@@ -1 +0,0 @@
1
- export const VERSION = '0.0.1-dev.6';