@datadog/mobile-react-native 1.0.0-rc9 → 1.0.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.
@@ -0,0 +1,137 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+
7
+ import org.apache.tools.ant.taskdefs.condition.Os
8
+
9
+ def reactConfig = project.hasProperty("react") ? project.react : [:]
10
+ def reactRoot = file(reactConfig.root ?: "../../")
11
+
12
+ afterEvaluate {
13
+
14
+ def androidExtension = extensions.findByName("android")
15
+
16
+ if (androidExtension == null || android.applicationVariants == null) {
17
+ throw new GradleException("Android extension is missing or running not in the application" +
18
+ " module. Make sure you've applied datadog-sourcemaps.gradle in the" +
19
+ " application module (usually it is located in the android/app/build.gradle file).")
20
+ }
21
+
22
+ androidExtension.applicationVariants.all { variant ->
23
+
24
+ def releaseVersion = variant.versionName
25
+ def buildVersion = variant.versionCode
26
+
27
+ if (releaseVersion == null) {
28
+ throw new GradleException("Cannot determine application version. Make sure to" +
29
+ " define versionName property in the application/variant config.")
30
+ }
31
+
32
+ // locations and names are defined in "../../node_modules/react-native/react.gradle"
33
+ def targetName = variant.name.capitalize()
34
+ def targetPath = variant.dirName
35
+
36
+ def bundleTask = tasks.findByName("bundle${targetName}JsAndAssets")
37
+
38
+ if (bundleTask == null) {
39
+ logger.info("Cannot find JS bundle task for variant=${targetName}.")
40
+ return
41
+ }
42
+ if (!bundleTask.enabled) {
43
+ logger.info("JS bundle task for variant=${targetName} is not enabled.")
44
+ return
45
+ }
46
+
47
+ def serviceName = getServiceName(variant)
48
+ logger.info("Service name used for the upload of variant=${targetName} is ${serviceName}.")
49
+
50
+ def bundleAssetName = reactConfig.bundleAssetName ?: "index.android.bundle"
51
+
52
+ def jsBundleDir = file("$buildDir/generated/assets/react/${targetPath}")
53
+ def jsBundleFile = file("$jsBundleDir/$bundleAssetName")
54
+
55
+ def jsSourceMapsDir = file("$buildDir/generated/sourcemaps/react/${targetPath}")
56
+ def jsOutputSourceMapFile = file("$jsSourceMapsDir/${bundleAssetName}.map")
57
+
58
+ def uploadTask = tasks.create("upload${targetName}Sourcemaps") {
59
+ group = "datadog"
60
+ description = "Uploads sourcemaps to Datadog."
61
+
62
+ def execCommand = [
63
+ "yarn",
64
+ "datadog-ci",
65
+ "react-native",
66
+ "upload",
67
+ "--platform",
68
+ "android",
69
+ "--service",
70
+ serviceName,
71
+ "--bundle",
72
+ jsBundleFile.absolutePath,
73
+ "--sourcemap",
74
+ jsOutputSourceMapFile.absolutePath,
75
+ "--release-version",
76
+ releaseVersion,
77
+ "--build-version",
78
+ buildVersion
79
+ ]
80
+
81
+ doFirst {
82
+ if (!jsBundleFile.exists()) {
83
+ throw new GradleException("JS bundle file doesn't exist, aborting upload.")
84
+ }
85
+
86
+ if (!jsOutputSourceMapFile.exists()) {
87
+ throw new GradleException("JS sourcemap file doesn't exist, aborting upload.")
88
+ }
89
+
90
+ runShellCommand(execCommand, reactRoot)
91
+
92
+ }
93
+ }
94
+
95
+ uploadTask.dependsOn bundleTask
96
+ bundleTask.finalizedBy uploadTask
97
+
98
+ }
99
+ }
100
+
101
+ private def runShellCommand(
102
+ List<String> command,
103
+ File workingDirectory
104
+ ) {
105
+ def outputStream = new ByteArrayOutputStream()
106
+ def errorStream = new ByteArrayOutputStream()
107
+
108
+ try {
109
+ def result = exec {
110
+ workingDir = workingDirectory
111
+ standardOutput = outputStream
112
+ errorOutput = errorStream
113
+ if (Os.isFamily(Os.FAMILY_WINDOWS)) {
114
+ commandLine("cmd", "/c", *command)
115
+ } else {
116
+ commandLine(*command)
117
+ }
118
+ }
119
+
120
+ if (result.exitValue != 0) {
121
+ logger.error(errorStream.toString("UTF-8"))
122
+ result.rethrowFailure()
123
+ } else {
124
+ logger.lifecycle(outputStream.toString("UTF-8"))
125
+ }
126
+ } catch (Exception e) {
127
+ def errorStreamContent = errorStream.toString("UTF-8")
128
+ def standardStreamContent = outputStream.toString("UTF-8")
129
+ logger.error("Exception raised during command execution," +
130
+ " stderr=${errorStreamContent}, stdout=${standardStreamContent}")
131
+ throw e
132
+ }
133
+ }
134
+
135
+ private static def getServiceName(variant) {
136
+ return variant.applicationId
137
+ }
@@ -15,9 +15,14 @@ var _SdkVerbosity = require("../../../../SdkVerbosity");
15
15
  * Copyright 2016-Present Datadog, Inc.
16
16
  */
17
17
  // This regex does not match anything
18
- const NO_MATCH_REGEX = new RegExp('a^');
18
+ const NO_MATCH_REGEX = new RegExp('a^'); // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
19
+
19
20
  exports.NO_MATCH_REGEX = NO_MATCH_REGEX;
20
21
 
22
+ const escapeRegExp = string => {
23
+ return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
24
+ };
25
+
21
26
  const firstPartyHostsRegexBuilder = firstPartyHosts => {
22
27
  if (firstPartyHosts.length === 0) {
23
28
  return NO_MATCH_REGEX;
@@ -26,7 +31,7 @@ const firstPartyHostsRegexBuilder = firstPartyHosts => {
26
31
  try {
27
32
  // A regexp for matching hosts, e.g. when `hosts` is "example.com", it will match
28
33
  // "example.com", "api.example.com", but not "foo.com".
29
- const firstPartyHostsRegex = new RegExp(`^(.*\\.)*(${firstPartyHosts.map(host => `${host}$`).join('|')})`);
34
+ const firstPartyHostsRegex = new RegExp(`^(.*\\.)*(${firstPartyHosts.map(host => `${escapeRegExp(host)}$`).join('|')})`);
30
35
  firstPartyHostsRegex.test('test_the_regex_is_valid');
31
36
  return firstPartyHostsRegex;
32
37
  } catch (e) {
@@ -1 +1 @@
1
- {"version":3,"sources":["firstPartyHosts.ts"],"names":["NO_MATCH_REGEX","RegExp","firstPartyHostsRegexBuilder","firstPartyHosts","length","firstPartyHostsRegex","map","host","join","test","e","InternalLog","log","JSON","stringify","SdkVerbosity","WARN","isHostFirstParty","hostname"],"mappings":";;;;;;;AAMA;;AACA;;AAPA;AACA;AACA;AACA;AACA;AAOA;AACO,MAAMA,cAAc,GAAG,IAAIC,MAAJ,CAAW,IAAX,CAAvB;;;AAEA,MAAMC,2BAA2B,GACpCC,eADuC,IAE9B;AACT,MAAIA,eAAe,CAACC,MAAhB,KAA2B,CAA/B,EAAkC;AAC9B,WAAOJ,cAAP;AACH;;AACD,MAAI;AACA;AACA;AACA,UAAMK,oBAAoB,GAAG,IAAIJ,MAAJ,CACxB,aAAYE,eAAe,CAACG,GAAhB,CAAoBC,IAAI,IAAK,GAAEA,IAAK,GAApC,EAAwCC,IAAxC,CAA6C,GAA7C,CAAkD,GADtC,CAA7B;AAGAH,IAAAA,oBAAoB,CAACI,IAArB,CAA0B,yBAA1B;AACA,WAAOJ,oBAAP;AACH,GARD,CAQE,OAAOK,CAAP,EAAU;AACRC,6BAAYC,GAAZ,CACK,kCAAiCC,IAAI,CAACC,SAAL,CAC9BX,eAD8B,CAEhC,wCAHN,EAIIY,2BAAaC,IAJjB;;AAMA,WAAOhB,cAAP;AACH;AACJ,CAvBM;;;;AAyBA,MAAMiB,gBAAgB,GAAG,CAC5BC,QAD4B,EAE5Bb,oBAF4B,KAGlB;AACV,SAAOA,oBAAoB,CAACI,IAArB,CAA0BS,QAA1B,CAAP;AACH,CALM","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { InternalLog } from '../../../../InternalLog';\nimport { SdkVerbosity } from '../../../../SdkVerbosity';\n\nexport type Hostname = { _type: 'Hostname' } & string;\n\n// This regex does not match anything\nexport const NO_MATCH_REGEX = new RegExp('a^');\n\nexport const firstPartyHostsRegexBuilder = (\n firstPartyHosts: string[]\n): RegExp => {\n if (firstPartyHosts.length === 0) {\n return NO_MATCH_REGEX;\n }\n try {\n // A regexp for matching hosts, e.g. when `hosts` is \"example.com\", it will match\n // \"example.com\", \"api.example.com\", but not \"foo.com\".\n const firstPartyHostsRegex = new RegExp(\n `^(.*\\\\.)*(${firstPartyHosts.map(host => `${host}$`).join('|')})`\n );\n firstPartyHostsRegex.test('test_the_regex_is_valid');\n return firstPartyHostsRegex;\n } catch (e) {\n InternalLog.log(\n `Invalid first party hosts list ${JSON.stringify(\n firstPartyHosts\n )}. Regular expressions are not allowed.`,\n SdkVerbosity.WARN\n );\n return NO_MATCH_REGEX;\n }\n};\n\nexport const isHostFirstParty = (\n hostname: Hostname,\n firstPartyHostsRegex: RegExp\n): boolean => {\n return firstPartyHostsRegex.test(hostname);\n};\n"]}
1
+ {"version":3,"sources":["firstPartyHosts.ts"],"names":["NO_MATCH_REGEX","RegExp","escapeRegExp","string","replace","firstPartyHostsRegexBuilder","firstPartyHosts","length","firstPartyHostsRegex","map","host","join","test","e","InternalLog","log","JSON","stringify","SdkVerbosity","WARN","isHostFirstParty","hostname"],"mappings":";;;;;;;AAMA;;AACA;;AAPA;AACA;AACA;AACA;AACA;AAOA;AACO,MAAMA,cAAc,GAAG,IAAIC,MAAJ,CAAW,IAAX,CAAvB,C,CAEP;;;;AACA,MAAMC,YAAY,GAAIC,MAAD,IAAoB;AACrC,SAAOA,MAAM,CAACC,OAAP,CAAe,qBAAf,EAAsC,MAAtC,CAAP,CADqC,CACiB;AACzD,CAFD;;AAIO,MAAMC,2BAA2B,GACpCC,eADuC,IAE9B;AACT,MAAIA,eAAe,CAACC,MAAhB,KAA2B,CAA/B,EAAkC;AAC9B,WAAOP,cAAP;AACH;;AACD,MAAI;AACA;AACA;AACA,UAAMQ,oBAAoB,GAAG,IAAIP,MAAJ,CACxB,aAAYK,eAAe,CACvBG,GADQ,CACJC,IAAI,IAAK,GAAER,YAAY,CAACQ,IAAD,CAAO,GAD1B,EAERC,IAFQ,CAEH,GAFG,CAEE,GAHU,CAA7B;AAKAH,IAAAA,oBAAoB,CAACI,IAArB,CAA0B,yBAA1B;AACA,WAAOJ,oBAAP;AACH,GAVD,CAUE,OAAOK,CAAP,EAAU;AACRC,6BAAYC,GAAZ,CACK,kCAAiCC,IAAI,CAACC,SAAL,CAC9BX,eAD8B,CAEhC,wCAHN,EAIIY,2BAAaC,IAJjB;;AAMA,WAAOnB,cAAP;AACH;AACJ,CAzBM;;;;AA2BA,MAAMoB,gBAAgB,GAAG,CAC5BC,QAD4B,EAE5Bb,oBAF4B,KAGlB;AACV,SAAOA,oBAAoB,CAACI,IAArB,CAA0BS,QAA1B,CAAP;AACH,CALM","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { InternalLog } from '../../../../InternalLog';\nimport { SdkVerbosity } from '../../../../SdkVerbosity';\n\nexport type Hostname = { _type: 'Hostname' } & string;\n\n// This regex does not match anything\nexport const NO_MATCH_REGEX = new RegExp('a^');\n\n// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\nconst escapeRegExp = (string: string) => {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'); // $& means the whole matched string\n};\n\nexport const firstPartyHostsRegexBuilder = (\n firstPartyHosts: string[]\n): RegExp => {\n if (firstPartyHosts.length === 0) {\n return NO_MATCH_REGEX;\n }\n try {\n // A regexp for matching hosts, e.g. when `hosts` is \"example.com\", it will match\n // \"example.com\", \"api.example.com\", but not \"foo.com\".\n const firstPartyHostsRegex = new RegExp(\n `^(.*\\\\.)*(${firstPartyHosts\n .map(host => `${escapeRegExp(host)}$`)\n .join('|')})`\n );\n firstPartyHostsRegex.test('test_the_regex_is_valid');\n return firstPartyHostsRegex;\n } catch (e) {\n InternalLog.log(\n `Invalid first party hosts list ${JSON.stringify(\n firstPartyHosts\n )}. Regular expressions are not allowed.`,\n SdkVerbosity.WARN\n );\n return NO_MATCH_REGEX;\n }\n};\n\nexport const isHostFirstParty = (\n hostname: Hostname,\n firstPartyHostsRegex: RegExp\n): boolean => {\n return firstPartyHostsRegex.test(hostname);\n};\n"]}
@@ -5,6 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = void 0;
7
7
  // generated by genversion
8
- const version = '1.0.0-rc9';
8
+ const version = '1.0.0';
9
9
  exports.version = version;
10
10
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,WAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.0.0-rc9';\n"]}
1
+ {"version":3,"sources":["version.ts"],"names":["version"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.0.0';\n"]}
@@ -6,7 +6,12 @@
6
6
  import { InternalLog } from '../../../../InternalLog';
7
7
  import { SdkVerbosity } from '../../../../SdkVerbosity';
8
8
  // This regex does not match anything
9
- export const NO_MATCH_REGEX = new RegExp('a^');
9
+ export const NO_MATCH_REGEX = new RegExp('a^'); // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
10
+
11
+ const escapeRegExp = string => {
12
+ return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
13
+ };
14
+
10
15
  export const firstPartyHostsRegexBuilder = firstPartyHosts => {
11
16
  if (firstPartyHosts.length === 0) {
12
17
  return NO_MATCH_REGEX;
@@ -15,7 +20,7 @@ export const firstPartyHostsRegexBuilder = firstPartyHosts => {
15
20
  try {
16
21
  // A regexp for matching hosts, e.g. when `hosts` is "example.com", it will match
17
22
  // "example.com", "api.example.com", but not "foo.com".
18
- const firstPartyHostsRegex = new RegExp(`^(.*\\.)*(${firstPartyHosts.map(host => `${host}$`).join('|')})`);
23
+ const firstPartyHostsRegex = new RegExp(`^(.*\\.)*(${firstPartyHosts.map(host => `${escapeRegExp(host)}$`).join('|')})`);
19
24
  firstPartyHostsRegex.test('test_the_regex_is_valid');
20
25
  return firstPartyHostsRegex;
21
26
  } catch (e) {
@@ -1 +1 @@
1
- {"version":3,"sources":["firstPartyHosts.ts"],"names":["InternalLog","SdkVerbosity","NO_MATCH_REGEX","RegExp","firstPartyHostsRegexBuilder","firstPartyHosts","length","firstPartyHostsRegex","map","host","join","test","e","log","JSON","stringify","WARN","isHostFirstParty","hostname"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,WAAT,QAA4B,yBAA5B;AACA,SAASC,YAAT,QAA6B,0BAA7B;AAIA;AACA,OAAO,MAAMC,cAAc,GAAG,IAAIC,MAAJ,CAAW,IAAX,CAAvB;AAEP,OAAO,MAAMC,2BAA2B,GACpCC,eADuC,IAE9B;AACT,MAAIA,eAAe,CAACC,MAAhB,KAA2B,CAA/B,EAAkC;AAC9B,WAAOJ,cAAP;AACH;;AACD,MAAI;AACA;AACA;AACA,UAAMK,oBAAoB,GAAG,IAAIJ,MAAJ,CACxB,aAAYE,eAAe,CAACG,GAAhB,CAAoBC,IAAI,IAAK,GAAEA,IAAK,GAApC,EAAwCC,IAAxC,CAA6C,GAA7C,CAAkD,GADtC,CAA7B;AAGAH,IAAAA,oBAAoB,CAACI,IAArB,CAA0B,yBAA1B;AACA,WAAOJ,oBAAP;AACH,GARD,CAQE,OAAOK,CAAP,EAAU;AACRZ,IAAAA,WAAW,CAACa,GAAZ,CACK,kCAAiCC,IAAI,CAACC,SAAL,CAC9BV,eAD8B,CAEhC,wCAHN,EAIIJ,YAAY,CAACe,IAJjB;AAMA,WAAOd,cAAP;AACH;AACJ,CAvBM;AAyBP,OAAO,MAAMe,gBAAgB,GAAG,CAC5BC,QAD4B,EAE5BX,oBAF4B,KAGlB;AACV,SAAOA,oBAAoB,CAACI,IAArB,CAA0BO,QAA1B,CAAP;AACH,CALM","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { InternalLog } from '../../../../InternalLog';\nimport { SdkVerbosity } from '../../../../SdkVerbosity';\n\nexport type Hostname = { _type: 'Hostname' } & string;\n\n// This regex does not match anything\nexport const NO_MATCH_REGEX = new RegExp('a^');\n\nexport const firstPartyHostsRegexBuilder = (\n firstPartyHosts: string[]\n): RegExp => {\n if (firstPartyHosts.length === 0) {\n return NO_MATCH_REGEX;\n }\n try {\n // A regexp for matching hosts, e.g. when `hosts` is \"example.com\", it will match\n // \"example.com\", \"api.example.com\", but not \"foo.com\".\n const firstPartyHostsRegex = new RegExp(\n `^(.*\\\\.)*(${firstPartyHosts.map(host => `${host}$`).join('|')})`\n );\n firstPartyHostsRegex.test('test_the_regex_is_valid');\n return firstPartyHostsRegex;\n } catch (e) {\n InternalLog.log(\n `Invalid first party hosts list ${JSON.stringify(\n firstPartyHosts\n )}. Regular expressions are not allowed.`,\n SdkVerbosity.WARN\n );\n return NO_MATCH_REGEX;\n }\n};\n\nexport const isHostFirstParty = (\n hostname: Hostname,\n firstPartyHostsRegex: RegExp\n): boolean => {\n return firstPartyHostsRegex.test(hostname);\n};\n"]}
1
+ {"version":3,"sources":["firstPartyHosts.ts"],"names":["InternalLog","SdkVerbosity","NO_MATCH_REGEX","RegExp","escapeRegExp","string","replace","firstPartyHostsRegexBuilder","firstPartyHosts","length","firstPartyHostsRegex","map","host","join","test","e","log","JSON","stringify","WARN","isHostFirstParty","hostname"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AAEA,SAASA,WAAT,QAA4B,yBAA5B;AACA,SAASC,YAAT,QAA6B,0BAA7B;AAIA;AACA,OAAO,MAAMC,cAAc,GAAG,IAAIC,MAAJ,CAAW,IAAX,CAAvB,C,CAEP;;AACA,MAAMC,YAAY,GAAIC,MAAD,IAAoB;AACrC,SAAOA,MAAM,CAACC,OAAP,CAAe,qBAAf,EAAsC,MAAtC,CAAP,CADqC,CACiB;AACzD,CAFD;;AAIA,OAAO,MAAMC,2BAA2B,GACpCC,eADuC,IAE9B;AACT,MAAIA,eAAe,CAACC,MAAhB,KAA2B,CAA/B,EAAkC;AAC9B,WAAOP,cAAP;AACH;;AACD,MAAI;AACA;AACA;AACA,UAAMQ,oBAAoB,GAAG,IAAIP,MAAJ,CACxB,aAAYK,eAAe,CACvBG,GADQ,CACJC,IAAI,IAAK,GAAER,YAAY,CAACQ,IAAD,CAAO,GAD1B,EAERC,IAFQ,CAEH,GAFG,CAEE,GAHU,CAA7B;AAKAH,IAAAA,oBAAoB,CAACI,IAArB,CAA0B,yBAA1B;AACA,WAAOJ,oBAAP;AACH,GAVD,CAUE,OAAOK,CAAP,EAAU;AACRf,IAAAA,WAAW,CAACgB,GAAZ,CACK,kCAAiCC,IAAI,CAACC,SAAL,CAC9BV,eAD8B,CAEhC,wCAHN,EAIIP,YAAY,CAACkB,IAJjB;AAMA,WAAOjB,cAAP;AACH;AACJ,CAzBM;AA2BP,OAAO,MAAMkB,gBAAgB,GAAG,CAC5BC,QAD4B,EAE5BX,oBAF4B,KAGlB;AACV,SAAOA,oBAAoB,CAACI,IAArB,CAA0BO,QAA1B,CAAP;AACH,CALM","sourcesContent":["/*\n * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.\n * This product includes software developed at Datadog (https://www.datadoghq.com/).\n * Copyright 2016-Present Datadog, Inc.\n */\n\nimport { InternalLog } from '../../../../InternalLog';\nimport { SdkVerbosity } from '../../../../SdkVerbosity';\n\nexport type Hostname = { _type: 'Hostname' } & string;\n\n// This regex does not match anything\nexport const NO_MATCH_REGEX = new RegExp('a^');\n\n// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions\nconst escapeRegExp = (string: string) => {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&'); // $& means the whole matched string\n};\n\nexport const firstPartyHostsRegexBuilder = (\n firstPartyHosts: string[]\n): RegExp => {\n if (firstPartyHosts.length === 0) {\n return NO_MATCH_REGEX;\n }\n try {\n // A regexp for matching hosts, e.g. when `hosts` is \"example.com\", it will match\n // \"example.com\", \"api.example.com\", but not \"foo.com\".\n const firstPartyHostsRegex = new RegExp(\n `^(.*\\\\.)*(${firstPartyHosts\n .map(host => `${escapeRegExp(host)}$`)\n .join('|')})`\n );\n firstPartyHostsRegex.test('test_the_regex_is_valid');\n return firstPartyHostsRegex;\n } catch (e) {\n InternalLog.log(\n `Invalid first party hosts list ${JSON.stringify(\n firstPartyHosts\n )}. Regular expressions are not allowed.`,\n SdkVerbosity.WARN\n );\n return NO_MATCH_REGEX;\n }\n};\n\nexport const isHostFirstParty = (\n hostname: Hostname,\n firstPartyHostsRegex: RegExp\n): boolean => {\n return firstPartyHostsRegex.test(hostname);\n};\n"]}
@@ -1,3 +1,3 @@
1
1
  // generated by genversion
2
- export const version = '1.0.0-rc9';
2
+ export const version = '1.0.0';
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,WAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.0.0-rc9';\n"]}
1
+ {"version":3,"sources":["version.ts"],"names":["version"],"mappings":"AAAA;AACA,OAAO,MAAMA,OAAO,GAAG,OAAhB","sourcesContent":["// generated by genversion\nexport const version = '1.0.0';\n"]}
@@ -1 +1 @@
1
- export declare const version = "1.0.0-rc9";
1
+ export declare const version = "1.0.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datadog/mobile-react-native",
3
- "version": "1.0.0-rc9",
3
+ "version": "1.0.0",
4
4
  "description": "A client-side React Native module to interact with Datadog",
5
5
  "keywords": [
6
6
  "datadog",
@@ -26,7 +26,8 @@
26
26
  "ios/DdSdkReactNative.xcodeproj/project.xcworkspace/xcsharedata",
27
27
  "ios/DdSdkReactNative.xcodeproj/project.xcworkspace/*.xcworkspacedata",
28
28
  "ios/DdSdkReactNative.xcodeproj/*.pbxproj",
29
- "DatadogSDKReactNative.podspec"
29
+ "DatadogSDKReactNative.podspec",
30
+ "datadog-sourcemaps.gradle"
30
31
  ],
31
32
  "types": "lib/typescript/index.d.ts",
32
33
  "react-native": "src/index",
@@ -72,5 +73,5 @@
72
73
  ]
73
74
  ]
74
75
  },
75
- "gitHead": "552457ced3fc826cb42120402eb9e98f80228890"
76
+ "gitHead": "c5d5168d03f8a18062e1d6169fe1ab54b147baa7"
76
77
  }
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
3
+ * This product includes software developed at Datadog (https://www.datadoghq.com/).
4
+ * Copyright 2016-Present Datadog, Inc.
5
+ */
6
+
7
+ import { firstPartyHostsRegexBuilder } from '../firstPartyHosts';
8
+
9
+ describe('firstPartyHosts', () => {
10
+ describe('firstPartyHostsRegexBuilder', () => {
11
+ it('returns a RegExp that matches hosts', () => {
12
+ const regex = firstPartyHostsRegexBuilder(['api.example.com']);
13
+ expect(regex.test('api.example.com')).toBe(true);
14
+ expect(regex.test('api.myapi.com')).toBe(false);
15
+ });
16
+
17
+ it('escapes special characters in hosts', () => {
18
+ const regex = firstPartyHostsRegexBuilder(['api.example.com']);
19
+ expect(regex.test('apiiexample.com')).toBe(false);
20
+ });
21
+ });
22
+ });
@@ -12,6 +12,11 @@ export type Hostname = { _type: 'Hostname' } & string;
12
12
  // This regex does not match anything
13
13
  export const NO_MATCH_REGEX = new RegExp('a^');
14
14
 
15
+ // From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
16
+ const escapeRegExp = (string: string) => {
17
+ return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
18
+ };
19
+
15
20
  export const firstPartyHostsRegexBuilder = (
16
21
  firstPartyHosts: string[]
17
22
  ): RegExp => {
@@ -22,7 +27,9 @@ export const firstPartyHostsRegexBuilder = (
22
27
  // A regexp for matching hosts, e.g. when `hosts` is "example.com", it will match
23
28
  // "example.com", "api.example.com", but not "foo.com".
24
29
  const firstPartyHostsRegex = new RegExp(
25
- `^(.*\\.)*(${firstPartyHosts.map(host => `${host}$`).join('|')})`
30
+ `^(.*\\.)*(${firstPartyHosts
31
+ .map(host => `${escapeRegExp(host)}$`)
32
+ .join('|')})`
26
33
  );
27
34
  firstPartyHostsRegex.test('test_the_regex_is_valid');
28
35
  return firstPartyHostsRegex;
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // generated by genversion
2
- export const version = '1.0.0-rc9';
2
+ export const version = '1.0.0';