@amplitude/analytics-react-native 0.3.0 → 0.3.3
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/storage/cookie.js +1 -1
- package/lib/commonjs/storage/cookie.js.map +1 -1
- package/lib/commonjs/utils/query-params.js +1 -1
- package/lib/commonjs/utils/query-params.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/storage/cookie.js +1 -1
- package/lib/module/storage/cookie.js.map +1 -1
- package/lib/module/utils/query-params.js +1 -1
- package/lib/module/utils/query-params.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +4 -4
- package/src/storage/cookie.ts +1 -1
- package/src/utils/query-params.ts +1 -1
- package/src/version.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["CookieStorage","constructor","options","isEnabled","isNative","window","random","String","Date","now","testStrorage","testKey","set","value","get","remove","key","getRaw","undefined","decodeURIComponent","atob","JSON","parse","cookie","document","split","match","find","c","indexOf","substring","length","expirationDays","expires","expireDate","date","setTime","getTime","str","btoa","encodeURIComponent","stringify","toUTCString","domain","secure","sameSite","reset"],"sources":["cookie.ts"],"sourcesContent":["import { Storage, CookieStorageOptions } from '@amplitude/analytics-types';\nimport { isNative } from '../utils/platform';\n\nexport class CookieStorage<T> implements Storage<T> {\n options: CookieStorageOptions;\n\n constructor(options?: CookieStorageOptions) {\n this.options = { ...options };\n }\n\n async isEnabled(): Promise<boolean> {\n /* istanbul ignore if */\n if (isNative() || typeof window === 'undefined') {\n return false;\n }\n\n const random = String(Date.now());\n const testStrorage = new CookieStorage<string>();\n const testKey = 'AMP_TEST';\n try {\n await testStrorage.set(testKey, random);\n const value = await testStrorage.get(testKey);\n return value === random;\n } catch {\n /* istanbul ignore next */\n return false;\n } finally {\n await testStrorage.remove(testKey);\n }\n }\n\n async get(key: string): Promise<T | undefined> {\n let value = await this.getRaw(key);\n if (!value) {\n return undefined;\n }\n try {\n try {\n value = decodeURIComponent(atob(value));\n } catch {\n // value not encoded\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(value);\n } catch {\n /* istanbul ignore next */\n return undefined;\n }\n }\n\n async getRaw(key: string): Promise<string | undefined> {\n const cookie = window.document.cookie.split('; ');\n const match = cookie.find((c) => c.indexOf(key + '=') === 0);\n if (!match) {\n return undefined;\n }\n return match.substring(key.length + 1);\n }\n\n async set(key: string, value: T | null): Promise<void> {\n try {\n const expirationDays = this.options.expirationDays ?? 0;\n const expires = value !== null ? expirationDays : -1;\n let expireDate: Date | undefined = undefined;\n if (expires) {\n const date = new Date();\n date.setTime(date.getTime() + expires * 24 * 60 * 60 * 1000);\n expireDate = date;\n }\n let str = `${key}=${btoa(encodeURIComponent(JSON.stringify(value)))}`;\n if (expireDate) {\n str += `; expires=${expireDate.toUTCString()}`;\n }\n str += '; path=/';\n if (this.options.domain) {\n str += `; domain=${this.options.domain}`;\n }\n if (this.options.secure) {\n str += '; Secure';\n }\n if (this.options.sameSite) {\n str += `; SameSite=${this.options.sameSite}`;\n }\n window.document.cookie = str;\n } catch {\n //\n }\n }\n\n async remove(key: string): Promise<void> {\n await this.set(key, null);\n }\n\n async reset(): Promise<void> {\n return;\n }\n}\n"],"mappings":";;;;;;;AACA;;;;AAEO,MAAMA,aAAN,CAA6C;EAGlDC,WAAW,CAACC,OAAD,EAAiC;IAAA;;IAC1C,KAAKA,OAAL,GAAe,EAAE,GAAGA;IAAL,CAAf;EACD;;EAEc,MAATC,SAAS,GAAqB;IAClC;IACA,IAAI,IAAAC,kBAAA,OAAc,OAAOC,MAAP,KAAkB,WAApC,EAAiD;MAC/C,OAAO,KAAP;IACD;;IAED,MAAMC,MAAM,GAAGC,MAAM,CAACC,IAAI,CAACC,GAAL,EAAD,CAArB;IACA,MAAMC,YAAY,GAAG,IAAIV,aAAJ,
|
|
1
|
+
{"version":3,"names":["CookieStorage","constructor","options","isEnabled","isNative","window","random","String","Date","now","testStrorage","testKey","set","value","get","remove","key","getRaw","undefined","decodeURIComponent","atob","JSON","parse","cookie","document","split","match","find","c","indexOf","substring","length","expirationDays","expires","expireDate","date","setTime","getTime","str","btoa","encodeURIComponent","stringify","toUTCString","domain","secure","sameSite","reset"],"sources":["cookie.ts"],"sourcesContent":["import { Storage, CookieStorageOptions } from '@amplitude/analytics-types';\nimport { isNative } from '../utils/platform';\n\nexport class CookieStorage<T> implements Storage<T> {\n options: CookieStorageOptions;\n\n constructor(options?: CookieStorageOptions) {\n this.options = { ...options };\n }\n\n async isEnabled(): Promise<boolean> {\n /* istanbul ignore if */\n if (isNative() || typeof window === 'undefined') {\n return false;\n }\n\n const random = String(Date.now());\n const testStrorage = new CookieStorage<string>(this.options);\n const testKey = 'AMP_TEST';\n try {\n await testStrorage.set(testKey, random);\n const value = await testStrorage.get(testKey);\n return value === random;\n } catch {\n /* istanbul ignore next */\n return false;\n } finally {\n await testStrorage.remove(testKey);\n }\n }\n\n async get(key: string): Promise<T | undefined> {\n let value = await this.getRaw(key);\n if (!value) {\n return undefined;\n }\n try {\n try {\n value = decodeURIComponent(atob(value));\n } catch {\n // value not encoded\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(value);\n } catch {\n /* istanbul ignore next */\n return undefined;\n }\n }\n\n async getRaw(key: string): Promise<string | undefined> {\n const cookie = window.document.cookie.split('; ');\n const match = cookie.find((c) => c.indexOf(key + '=') === 0);\n if (!match) {\n return undefined;\n }\n return match.substring(key.length + 1);\n }\n\n async set(key: string, value: T | null): Promise<void> {\n try {\n const expirationDays = this.options.expirationDays ?? 0;\n const expires = value !== null ? expirationDays : -1;\n let expireDate: Date | undefined = undefined;\n if (expires) {\n const date = new Date();\n date.setTime(date.getTime() + expires * 24 * 60 * 60 * 1000);\n expireDate = date;\n }\n let str = `${key}=${btoa(encodeURIComponent(JSON.stringify(value)))}`;\n if (expireDate) {\n str += `; expires=${expireDate.toUTCString()}`;\n }\n str += '; path=/';\n if (this.options.domain) {\n str += `; domain=${this.options.domain}`;\n }\n if (this.options.secure) {\n str += '; Secure';\n }\n if (this.options.sameSite) {\n str += `; SameSite=${this.options.sameSite}`;\n }\n window.document.cookie = str;\n } catch {\n //\n }\n }\n\n async remove(key: string): Promise<void> {\n await this.set(key, null);\n }\n\n async reset(): Promise<void> {\n return;\n }\n}\n"],"mappings":";;;;;;;AACA;;;;AAEO,MAAMA,aAAN,CAA6C;EAGlDC,WAAW,CAACC,OAAD,EAAiC;IAAA;;IAC1C,KAAKA,OAAL,GAAe,EAAE,GAAGA;IAAL,CAAf;EACD;;EAEc,MAATC,SAAS,GAAqB;IAClC;IACA,IAAI,IAAAC,kBAAA,OAAc,OAAOC,MAAP,KAAkB,WAApC,EAAiD;MAC/C,OAAO,KAAP;IACD;;IAED,MAAMC,MAAM,GAAGC,MAAM,CAACC,IAAI,CAACC,GAAL,EAAD,CAArB;IACA,MAAMC,YAAY,GAAG,IAAIV,aAAJ,CAA0B,KAAKE,OAA/B,CAArB;IACA,MAAMS,OAAO,GAAG,UAAhB;;IACA,IAAI;MACF,MAAMD,YAAY,CAACE,GAAb,CAAiBD,OAAjB,EAA0BL,MAA1B,CAAN;MACA,MAAMO,KAAK,GAAG,MAAMH,YAAY,CAACI,GAAb,CAAiBH,OAAjB,CAApB;MACA,OAAOE,KAAK,KAAKP,MAAjB;IACD,CAJD,CAIE,MAAM;MACN;MACA,OAAO,KAAP;IACD,CAPD,SAOU;MACR,MAAMI,YAAY,CAACK,MAAb,CAAoBJ,OAApB,CAAN;IACD;EACF;;EAEQ,MAAHG,GAAG,CAACE,GAAD,EAAsC;IAC7C,IAAIH,KAAK,GAAG,MAAM,KAAKI,MAAL,CAAYD,GAAZ,CAAlB;;IACA,IAAI,CAACH,KAAL,EAAY;MACV,OAA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,CAAe5B,KAAf,CAAD,CAAnB,CAA4C,EAApE;;MACA,IAAIqB,UAAJ,EAAgB;QACdI,GAAG,IAAK,aAAYJ,UAAU,CAACQ,WAAX,EAAyB,EAA7C;MACD;;MACDJ,GAAG,IAAI,UAAP;;MACA,IAAI,KAAKpC,OAAL,CAAayC,MAAjB,EAAyB;QACvBL,GAAG,IAAK,YAAW,KAAKpC,OAAL,CAAayC,MAAO,EAAvC;MACD;;MACD,IAAI,KAAKzC,OAAL,CAAa0C,MAAjB,EAAyB;QACvBN,GAAG,IAAI,UAAP;MACD;;MACD,IAAI,KAAKpC,OAAL,CAAa2C,QAAjB,EAA2B;QACzBP,GAAG,IAAK,cAAa,KAAKpC,OAAL,CAAa2C,QAAS,EAA3C;MACD;;MACDxC,MAAM,CAACmB,QAAP,CAAgBD,MAAhB,GAAyBe,GAAzB;IACD,CAxBD,CAwBE,MAAM,CACN;IACD;EACF;;EAEW,MAANvB,MAAM,CAACC,GAAD,EAA6B;IACvC,MAAM,KAAKJ,GAAL,CAASI,GAAT,EAAc,IAAd,CAAN;EACD;;EAEU,MAAL8B,KAAK,GAAkB;IAC3B;EACD;;AA5FiD"}
|
|
@@ -7,7 +7,7 @@ exports.tryDecodeURIComponent = exports.getQueryParams = void 0;
|
|
|
7
7
|
|
|
8
8
|
const getQueryParams = () => {
|
|
9
9
|
/* istanbul ignore if */
|
|
10
|
-
if (typeof window === 'undefined') {
|
|
10
|
+
if (typeof window === 'undefined' || !window.location || !window.location.search) {
|
|
11
11
|
return {};
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getQueryParams","window","
|
|
1
|
+
{"version":3,"names":["getQueryParams","window","location","search","pairs","substring","split","filter","Boolean","params","reduce","acc","curr","query","key","tryDecodeURIComponent","value","decodeURIComponent"],"sources":["query-params.ts"],"sourcesContent":["export const getQueryParams = (): Record<string, string | undefined> => {\n /* istanbul ignore if */\n if (typeof window === 'undefined' || !window.location || !window.location.search) {\n return {};\n }\n const pairs = window.location.search.substring(1).split('&').filter(Boolean);\n const params = pairs.reduce<Record<string, string | undefined>>((acc, curr) => {\n const query = curr.split('=', 2);\n const key = tryDecodeURIComponent(query[0]);\n const value = tryDecodeURIComponent(query[1]);\n if (!value) {\n return acc;\n }\n acc[key] = value;\n return acc;\n }, {});\n return params;\n};\n\nexport const tryDecodeURIComponent = (value = '') => {\n try {\n return decodeURIComponent(value);\n } catch {\n return '';\n }\n};\n"],"mappings":";;;;;;;AAAO,MAAMA,cAAc,GAAG,MAA0C;EACtE;EACA,IAAI,OAAOC,MAAP,KAAkB,WAAlB,IAAiC,CAACA,MAAM,CAACC,QAAzC,IAAqD,CAACD,MAAM,CAACC,QAAP,CAAgBC,MAA1E,EAAkF;IAChF,OAAO,EAAP;EACD;;EACD,MAAMC,KAAK,GAAGH,MAAM,CAACC,QAAP,CAAgBC,MAAhB,CAAuBE,SAAvB,CAAiC,CAAjC,EAAoCC,KAApC,CAA0C,GAA1C,EAA+CC,MAA/C,CAAsDC,OAAtD,CAAd;EACA,MAAMC,MAAM,GAAGL,KAAK,CAACM,MAAN,CAAiD,CAACC,GAAD,EAAMC,IAAN,KAAe;IAC7E,MAAMC,KAAK,GAAGD,IAAI,CAACN,KAAL,CAAW,GAAX,EAAgB,CAAhB,CAAd;IACA,MAAMQ,GAAG,GAAGC,qBAAqB,CAACF,KAAK,CAAC,CAAD,CAAN,CAAjC;IACA,MAAMG,KAAK,GAAGD,qBAAqB,CAACF,KAAK,CAAC,CAAD,CAAN,CAAnC;;IACA,IAAI,CAACG,KAAL,EAAY;MACV,OAAOL,GAAP;IACD;;IACDA,GAAG,CAACG,GAAD,CAAH,GAAWE,KAAX;IACA,OAAOL,GAAP;EACD,CATc,EASZ,EATY,CAAf;EAUA,OAAOF,MAAP;AACD,CAjBM;;;;AAmBA,MAAMM,qBAAqB,GAAG,YAAgB;EAAA,IAAfC,KAAe,uEAAP,EAAO;;EACnD,IAAI;IACF,OAAOC,kBAAkB,CAACD,KAAD,CAAzB;EACD,CAFD,CAEE,MAAM;IACN,OAAO,EAAP;EACD;AACF,CANM"}
|
package/lib/commonjs/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["VERSION"],"sources":["version.ts"],"sourcesContent":["export const VERSION = '0.3.
|
|
1
|
+
{"version":3,"names":["VERSION"],"sources":["version.ts"],"sourcesContent":["export const VERSION = '0.3.3';\n"],"mappings":";;;;;;AAAO,MAAMA,OAAO,GAAG,OAAhB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["isNative","CookieStorage","constructor","options","isEnabled","window","random","String","Date","now","testStrorage","testKey","set","value","get","remove","key","getRaw","undefined","decodeURIComponent","atob","JSON","parse","cookie","document","split","match","find","c","indexOf","substring","length","expirationDays","expires","expireDate","date","setTime","getTime","str","btoa","encodeURIComponent","stringify","toUTCString","domain","secure","sameSite","reset"],"sources":["cookie.ts"],"sourcesContent":["import { Storage, CookieStorageOptions } from '@amplitude/analytics-types';\nimport { isNative } from '../utils/platform';\n\nexport class CookieStorage<T> implements Storage<T> {\n options: CookieStorageOptions;\n\n constructor(options?: CookieStorageOptions) {\n this.options = { ...options };\n }\n\n async isEnabled(): Promise<boolean> {\n /* istanbul ignore if */\n if (isNative() || typeof window === 'undefined') {\n return false;\n }\n\n const random = String(Date.now());\n const testStrorage = new CookieStorage<string>();\n const testKey = 'AMP_TEST';\n try {\n await testStrorage.set(testKey, random);\n const value = await testStrorage.get(testKey);\n return value === random;\n } catch {\n /* istanbul ignore next */\n return false;\n } finally {\n await testStrorage.remove(testKey);\n }\n }\n\n async get(key: string): Promise<T | undefined> {\n let value = await this.getRaw(key);\n if (!value) {\n return undefined;\n }\n try {\n try {\n value = decodeURIComponent(atob(value));\n } catch {\n // value not encoded\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(value);\n } catch {\n /* istanbul ignore next */\n return undefined;\n }\n }\n\n async getRaw(key: string): Promise<string | undefined> {\n const cookie = window.document.cookie.split('; ');\n const match = cookie.find((c) => c.indexOf(key + '=') === 0);\n if (!match) {\n return undefined;\n }\n return match.substring(key.length + 1);\n }\n\n async set(key: string, value: T | null): Promise<void> {\n try {\n const expirationDays = this.options.expirationDays ?? 0;\n const expires = value !== null ? expirationDays : -1;\n let expireDate: Date | undefined = undefined;\n if (expires) {\n const date = new Date();\n date.setTime(date.getTime() + expires * 24 * 60 * 60 * 1000);\n expireDate = date;\n }\n let str = `${key}=${btoa(encodeURIComponent(JSON.stringify(value)))}`;\n if (expireDate) {\n str += `; expires=${expireDate.toUTCString()}`;\n }\n str += '; path=/';\n if (this.options.domain) {\n str += `; domain=${this.options.domain}`;\n }\n if (this.options.secure) {\n str += '; Secure';\n }\n if (this.options.sameSite) {\n str += `; SameSite=${this.options.sameSite}`;\n }\n window.document.cookie = str;\n } catch {\n //\n }\n }\n\n async remove(key: string): Promise<void> {\n await this.set(key, null);\n }\n\n async reset(): Promise<void> {\n return;\n }\n}\n"],"mappings":";;AACA,SAASA,QAAT,QAAyB,mBAAzB;AAEA,OAAO,MAAMC,aAAN,CAA6C;EAGlDC,WAAW,CAACC,OAAD,EAAiC;IAAA;;IAC1C,KAAKA,OAAL,GAAe,EAAE,GAAGA;IAAL,CAAf;EACD;;EAEc,MAATC,SAAS,GAAqB;IAClC;IACA,IAAIJ,QAAQ,MAAM,OAAOK,MAAP,KAAkB,WAApC,EAAiD;MAC/C,OAAO,KAAP;IACD;;IAED,MAAMC,MAAM,GAAGC,MAAM,CAACC,IAAI,CAACC,GAAL,EAAD,CAArB;IACA,MAAMC,YAAY,GAAG,IAAIT,aAAJ,
|
|
1
|
+
{"version":3,"names":["isNative","CookieStorage","constructor","options","isEnabled","window","random","String","Date","now","testStrorage","testKey","set","value","get","remove","key","getRaw","undefined","decodeURIComponent","atob","JSON","parse","cookie","document","split","match","find","c","indexOf","substring","length","expirationDays","expires","expireDate","date","setTime","getTime","str","btoa","encodeURIComponent","stringify","toUTCString","domain","secure","sameSite","reset"],"sources":["cookie.ts"],"sourcesContent":["import { Storage, CookieStorageOptions } from '@amplitude/analytics-types';\nimport { isNative } from '../utils/platform';\n\nexport class CookieStorage<T> implements Storage<T> {\n options: CookieStorageOptions;\n\n constructor(options?: CookieStorageOptions) {\n this.options = { ...options };\n }\n\n async isEnabled(): Promise<boolean> {\n /* istanbul ignore if */\n if (isNative() || typeof window === 'undefined') {\n return false;\n }\n\n const random = String(Date.now());\n const testStrorage = new CookieStorage<string>(this.options);\n const testKey = 'AMP_TEST';\n try {\n await testStrorage.set(testKey, random);\n const value = await testStrorage.get(testKey);\n return value === random;\n } catch {\n /* istanbul ignore next */\n return false;\n } finally {\n await testStrorage.remove(testKey);\n }\n }\n\n async get(key: string): Promise<T | undefined> {\n let value = await this.getRaw(key);\n if (!value) {\n return undefined;\n }\n try {\n try {\n value = decodeURIComponent(atob(value));\n } catch {\n // value not encoded\n }\n // eslint-disable-next-line @typescript-eslint/no-unsafe-return\n return JSON.parse(value);\n } catch {\n /* istanbul ignore next */\n return undefined;\n }\n }\n\n async getRaw(key: string): Promise<string | undefined> {\n const cookie = window.document.cookie.split('; ');\n const match = cookie.find((c) => c.indexOf(key + '=') === 0);\n if (!match) {\n return undefined;\n }\n return match.substring(key.length + 1);\n }\n\n async set(key: string, value: T | null): Promise<void> {\n try {\n const expirationDays = this.options.expirationDays ?? 0;\n const expires = value !== null ? expirationDays : -1;\n let expireDate: Date | undefined = undefined;\n if (expires) {\n const date = new Date();\n date.setTime(date.getTime() + expires * 24 * 60 * 60 * 1000);\n expireDate = date;\n }\n let str = `${key}=${btoa(encodeURIComponent(JSON.stringify(value)))}`;\n if (expireDate) {\n str += `; expires=${expireDate.toUTCString()}`;\n }\n str += '; path=/';\n if (this.options.domain) {\n str += `; domain=${this.options.domain}`;\n }\n if (this.options.secure) {\n str += '; Secure';\n }\n if (this.options.sameSite) {\n str += `; SameSite=${this.options.sameSite}`;\n }\n window.document.cookie = str;\n } catch {\n //\n }\n }\n\n async remove(key: string): Promise<void> {\n await this.set(key, null);\n }\n\n async reset(): Promise<void> {\n return;\n }\n}\n"],"mappings":";;AACA,SAASA,QAAT,QAAyB,mBAAzB;AAEA,OAAO,MAAMC,aAAN,CAA6C;EAGlDC,WAAW,CAACC,OAAD,EAAiC;IAAA;;IAC1C,KAAKA,OAAL,GAAe,EAAE,GAAGA;IAAL,CAAf;EACD;;EAEc,MAATC,SAAS,GAAqB;IAClC;IACA,IAAIJ,QAAQ,MAAM,OAAOK,MAAP,KAAkB,WAApC,EAAiD;MAC/C,OAAO,KAAP;IACD;;IAED,MAAMC,MAAM,GAAGC,MAAM,CAACC,IAAI,CAACC,GAAL,EAAD,CAArB;IACA,MAAMC,YAAY,GAAG,IAAIT,aAAJ,CAA0B,KAAKE,OAA/B,CAArB;IACA,MAAMQ,OAAO,GAAG,UAAhB;;IACA,IAAI;MACF,MAAMD,YAAY,CAACE,GAAb,CAAiBD,OAAjB,EAA0BL,MAA1B,CAAN;MACA,MAAMO,KAAK,GAAG,MAAMH,YAAY,CAACI,GAAb,CAAiBH,OAAjB,CAApB;MACA,OAAOE,KAAK,KAAKP,MAAjB;IACD,CAJD,CAIE,MAAM;MACN;MACA,OAAO,KAAP;IACD,CAPD,SAOU;MACR,MAAMI,YAAY,CAACK,MAAb,CAAoBJ,OAApB,CAAN;IACD;EACF;;EAEQ,MAAHG,GAAG,CAACE,GAAD,EAAsC;IAC7C,IAAIH,KAAK,GAAG,MAAM,KAAKI,MAAL,CAAYD,GAAZ,CAAlB;;IACA,IAAI,CAACH,KAAL,EAAY;MACV,OAAOK,SAAP;IACD;;IACD,IAAI;MACF,IAAI;QACFL,KAAK,GAAGM,kBAAkB,CAACC,IAAI,CAACP,KAAD,CAAL,CAA1B;MACD,CAFD,CAEE,MAAM,CACN;MACD,CALC,CAMF;;;MACA,OAAOQ,IAAI,CAACC,KAAL,CAAWT,KAAX,CAAP;IACD,CARD,CAQE,MAAM;MACN;MACA,OAAOK,SA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KnC,OAAL,CAAawC,MAAO,EAAvC;MACD;;MACD,IAAI,KAAKxC,OAAL,CAAayC,MAAjB,EAAyB;QACvBN,GAAG,IAAI,UAAP;MACD;;MACD,IAAI,KAAKnC,OAAL,CAAa0C,QAAjB,EAA2B;QACzBP,GAAG,IAAK,cAAa,KAAKnC,OAAL,CAAa0C,QAAS,EAA3C;MACD;;MACDxC,MAAM,CAACmB,QAAP,CAAgBD,MAAhB,GAAyBe,GAAzB;IACD,CAxBD,CAwBE,MAAM,CACN;IACD;EACF;;EAEW,MAANvB,MAAM,CAACC,GAAD,EAA6B;IACvC,MAAM,KAAKJ,GAAL,CAASI,GAAT,EAAc,IAAd,CAAN;EACD;;EAEU,MAAL8B,KAAK,GAAkB;IAC3B;EACD;;AA5FiD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getQueryParams","window","
|
|
1
|
+
{"version":3,"names":["getQueryParams","window","location","search","pairs","substring","split","filter","Boolean","params","reduce","acc","curr","query","key","tryDecodeURIComponent","value","decodeURIComponent"],"sources":["query-params.ts"],"sourcesContent":["export const getQueryParams = (): Record<string, string | undefined> => {\n /* istanbul ignore if */\n if (typeof window === 'undefined' || !window.location || !window.location.search) {\n return {};\n }\n const pairs = window.location.search.substring(1).split('&').filter(Boolean);\n const params = pairs.reduce<Record<string, string | undefined>>((acc, curr) => {\n const query = curr.split('=', 2);\n const key = tryDecodeURIComponent(query[0]);\n const value = tryDecodeURIComponent(query[1]);\n if (!value) {\n return acc;\n }\n acc[key] = value;\n return acc;\n }, {});\n return params;\n};\n\nexport const tryDecodeURIComponent = (value = '') => {\n try {\n return decodeURIComponent(value);\n } catch {\n return '';\n }\n};\n"],"mappings":"AAAA,OAAO,MAAMA,cAAc,GAAG,MAA0C;EACtE;EACA,IAAI,OAAOC,MAAP,KAAkB,WAAlB,IAAiC,CAACA,MAAM,CAACC,QAAzC,IAAqD,CAACD,MAAM,CAACC,QAAP,CAAgBC,MAA1E,EAAkF;IAChF,OAAO,EAAP;EACD;;EACD,MAAMC,KAAK,GAAGH,MAAM,CAACC,QAAP,CAAgBC,MAAhB,CAAuBE,SAAvB,CAAiC,CAAjC,EAAoCC,KAApC,CAA0C,GAA1C,EAA+CC,MAA/C,CAAsDC,OAAtD,CAAd;EACA,MAAMC,MAAM,GAAGL,KAAK,CAACM,MAAN,CAAiD,CAACC,GAAD,EAAMC,IAAN,KAAe;IAC7E,MAAMC,KAAK,GAAGD,IAAI,CAACN,KAAL,CAAW,GAAX,EAAgB,CAAhB,CAAd;IACA,MAAMQ,GAAG,GAAGC,qBAAqB,CAACF,KAAK,CAAC,CAAD,CAAN,CAAjC;IACA,MAAMG,KAAK,GAAGD,qBAAqB,CAACF,KAAK,CAAC,CAAD,CAAN,CAAnC;;IACA,IAAI,CAACG,KAAL,EAAY;MACV,OAAOL,GAAP;IACD;;IACDA,GAAG,CAACG,GAAD,CAAH,GAAWE,KAAX;IACA,OAAOL,GAAP;EACD,CATc,EASZ,EATY,CAAf;EAUA,OAAOF,MAAP;AACD,CAjBM;AAmBP,OAAO,MAAMM,qBAAqB,GAAG,YAAgB;EAAA,IAAfC,KAAe,uEAAP,EAAO;;EACnD,IAAI;IACF,OAAOC,kBAAkB,CAACD,KAAD,CAAzB;EACD,CAFD,CAEE,MAAM;IACN,OAAO,EAAP;EACD;AACF,CANM"}
|
package/lib/module/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const VERSION = '0.3.
|
|
1
|
+
export const VERSION = '0.3.3';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["VERSION"],"sources":["version.ts"],"sourcesContent":["export const VERSION = '0.3.
|
|
1
|
+
{"version":3,"names":["VERSION"],"sources":["version.ts"],"sourcesContent":["export const VERSION = '0.3.3';\n"],"mappings":"AAAA,OAAO,MAAMA,OAAO,GAAG,OAAhB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { createInstance } from './react-native-client';
|
|
2
|
-
export declare const add: (plugin: Types.Plugin) => Types.AmplitudeReturn<void>, flush: () => Types.AmplitudeReturn<void>, getDeviceId: () => string | undefined, getSessionId: () => number | undefined, getUserId: () => string | undefined, groupIdentify: (groupType: string, groupName: string | string[], identify: Types.Identify, eventOptions?: Types.EventOptions | undefined) => Types.AmplitudeReturn<Types.Result>, identify: (identify: Types.Identify, eventOptions?: Types.EventOptions | undefined) => Types.AmplitudeReturn<Types.Result>, init: (apiKey: string, userId?: string | undefined, options?: Types.ReactNativeOptions | undefined) => Types.AmplitudeReturn<void>, logEvent: (eventInput: string | Types.BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: Types.EventOptions | undefined) => Types.AmplitudeReturn<Types.Result>, remove: (pluginName: string) => Types.AmplitudeReturn<void>, reset: () => void, revenue: (revenue: Types.Revenue, eventOptions?: Types.EventOptions | undefined) => Types.AmplitudeReturn<Types.Result>, setDeviceId: (deviceId: string) => void, setGroup: (groupType: string, groupName: string | string[], eventOptions?: Types.EventOptions | undefined) => Types.AmplitudeReturn<Types.Result>, setOptOut: (optOut: boolean) => void, setSessionId: (sessionId: number) => void, setUserId: (userId: string) => void, track: (eventInput: string | Types.BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: Types.EventOptions | undefined) => Types.AmplitudeReturn<Types.Result>;
|
|
2
|
+
export declare const add: (plugin: Types.Plugin) => Types.AmplitudeReturn<void>, flush: () => Types.AmplitudeReturn<void>, getDeviceId: () => string | undefined, getSessionId: () => number | undefined, getUserId: () => string | undefined, groupIdentify: (groupType: string, groupName: string | string[], identify: Types.Identify, eventOptions?: Types.EventOptions | undefined) => Types.AmplitudeReturn<Types.Result>, identify: (identify: Types.Identify, eventOptions?: Types.EventOptions | undefined) => Types.AmplitudeReturn<Types.Result>, init: (apiKey: string, userId?: string | undefined, options?: (Types.ReactNativeOptions & Types.AdditionalReactNativeOptions) | undefined) => Types.AmplitudeReturn<void>, logEvent: (eventInput: string | Types.BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: Types.EventOptions | undefined) => Types.AmplitudeReturn<Types.Result>, remove: (pluginName: string) => Types.AmplitudeReturn<void>, reset: () => void, revenue: (revenue: Types.Revenue, eventOptions?: Types.EventOptions | undefined) => Types.AmplitudeReturn<Types.Result>, setDeviceId: (deviceId: string) => void, setGroup: (groupType: string, groupName: string | string[], eventOptions?: Types.EventOptions | undefined) => Types.AmplitudeReturn<Types.Result>, setOptOut: (optOut: boolean) => void, setSessionId: (sessionId: number) => void, setUserId: (userId: string) => void, track: (eventInput: string | Types.BaseEvent, eventProperties?: Record<string, any> | undefined, eventOptions?: Types.EventOptions | undefined) => Types.AmplitudeReturn<Types.Result>;
|
|
3
3
|
export { Revenue, Identify } from '@amplitude/analytics-core';
|
|
4
4
|
import * as Types from '@amplitude/analytics-types';
|
|
5
5
|
export { Types };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,eAAO,MACL,GAAG,yDACH,KAAK,qCACL,WAAW,4BACX,YAAY,4BACZ,SAAS,4BACT,aAAa,qKACb,QAAQ,oHACR,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,eAAO,MACL,GAAG,yDACH,KAAK,qCACL,WAAW,4BACX,YAAY,4BACZ,SAAS,4BACT,aAAa,qKACb,QAAQ,oHACR,IAAI,uKACJ,QAAQ,mLACR,MAAM,uDACN,KAAK,cACL,OAAO,kHACP,WAAW,8BACX,QAAQ,2IACR,SAAS,6BACT,YAAY,+BACZ,SAAS,4BACT,KAAK,iLACG,CAAC;AACX,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAG9D,OAAO,KAAK,KAAK,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.3.
|
|
1
|
+
export declare const VERSION = "0.3.3";
|
|
2
2
|
//# sourceMappingURL=version.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amplitude/analytics-react-native",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Official React Native SDK",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"analytics",
|
|
@@ -58,8 +58,8 @@
|
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"@amplitude/analytics-connector": "1.4.5",
|
|
61
|
-
"@amplitude/analytics-core": "^0.8.
|
|
62
|
-
"@amplitude/analytics-types": "^0.8.
|
|
61
|
+
"@amplitude/analytics-core": "^0.8.1",
|
|
62
|
+
"@amplitude/analytics-types": "^0.8.1",
|
|
63
63
|
"@amplitude/ua-parser-js": "^0.7.31",
|
|
64
64
|
"@react-native-async-storage/async-storage": "^1.17.7",
|
|
65
65
|
"tslib": "^2.3.1"
|
|
@@ -89,5 +89,5 @@
|
|
|
89
89
|
]
|
|
90
90
|
]
|
|
91
91
|
},
|
|
92
|
-
"gitHead": "
|
|
92
|
+
"gitHead": "404f81a1cdcf1cce9bd35d04561016a65dab635a"
|
|
93
93
|
}
|
package/src/storage/cookie.ts
CHANGED
|
@@ -15,7 +15,7 @@ export class CookieStorage<T> implements Storage<T> {
|
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const random = String(Date.now());
|
|
18
|
-
const testStrorage = new CookieStorage<string>();
|
|
18
|
+
const testStrorage = new CookieStorage<string>(this.options);
|
|
19
19
|
const testKey = 'AMP_TEST';
|
|
20
20
|
try {
|
|
21
21
|
await testStrorage.set(testKey, random);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const getQueryParams = (): Record<string, string | undefined> => {
|
|
2
2
|
/* istanbul ignore if */
|
|
3
|
-
if (typeof window === 'undefined') {
|
|
3
|
+
if (typeof window === 'undefined' || !window.location || !window.location.search) {
|
|
4
4
|
return {};
|
|
5
5
|
}
|
|
6
6
|
const pairs = window.location.search.substring(1).split('&').filter(Boolean);
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = '0.3.
|
|
1
|
+
export const VERSION = '0.3.3';
|